diff --git a/scripts/run_monthly_report_bundle.py b/scripts/run_monthly_report_bundle.py index bddf760..812e3c5 100644 --- a/scripts/run_monthly_report_bundle.py +++ b/scripts/run_monthly_report_bundle.py @@ -113,7 +113,19 @@ def render_job_summary(bundle: dict[str, Any], release_status: dict[str, Any], m """ +def strip_wrapped_h1(markdown: str, heading: str) -> str: + text = markdown.strip() + first_line, separator, rest = text.partition("\n") + if separator and first_line.strip() == f"# {heading}": + return rest.lstrip("\n") + if not separator and first_line.strip() == f"# {heading}": + return "" + return text + + def render_ai_review_input(bundle: dict[str, Any], release_status_md: str, monthly_review_md: str, telegram_text: str) -> str: + release_status_body = strip_wrapped_h1(release_status_md, "Release Status Summary") + monthly_review_body = strip_wrapped_h1(monthly_review_md, "Monthly Review") return f"""# Monthly Report Review Input Use this file as the primary review input for the monthly upstream release package. @@ -143,11 +155,11 @@ def render_ai_review_input(bundle: dict[str, Any], release_status_md: str, month ## Release Status Summary -{release_status_md} +{release_status_body} ## Monthly Review -{monthly_review_md} +{monthly_review_body} ## Telegram Preview diff --git a/tests/test_monthly_report_bundle.py b/tests/test_monthly_report_bundle.py index c4f3276..4838869 100644 --- a/tests/test_monthly_report_bundle.py +++ b/tests/test_monthly_report_bundle.py @@ -35,12 +35,18 @@ def write_fixture_files(self, root: Path) -> Path: ), encoding="utf-8", ) - (output_dir / "release_status_summary.md").write_text("# Release Status Summary\n", encoding="utf-8") + (output_dir / "release_status_summary.md").write_text( + "# Release Status Summary\n\nGenerated: fixture\n", + encoding="utf-8", + ) (output_dir / "monthly_review.json").write_text( json.dumps({"as_of_date": "2026-03-13", "warnings": [], "status": "ok"}), encoding="utf-8", ) - (output_dir / "monthly_review.md").write_text("# Monthly Review\n", encoding="utf-8") + (output_dir / "monthly_review.md").write_text( + "# Monthly Review\n\n## Current release status\n", + encoding="utf-8", + ) (output_dir / "monthly_review_prompt.md").write_text("Monthly release review prompt\n", encoding="utf-8") (output_dir / "monthly_telegram.txt").write_text("CryptoSnapshotPipelines monthly release\n", encoding="utf-8") return output_dir @@ -61,6 +67,10 @@ def test_write_bundle_copies_files_and_writes_manifest(self) -> None: self.assertIn("upstream selector review", ai_review_input) self.assertIn("Shadow / challenger coverage", ai_review_input) self.assertIn("Strategy review questions", ai_review_input) + self.assertIn("## Release Status Summary\n\nGenerated: fixture", ai_review_input) + self.assertIn("## Monthly Review\n\n## Current release status", ai_review_input) + self.assertNotIn("## Release Status Summary\n\n# Release Status Summary", ai_review_input) + self.assertNotIn("## Monthly Review\n\n# Monthly Review", ai_review_input) if __name__ == "__main__":