Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions scripts/run_monthly_report_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
14 changes: 12 additions & 2 deletions tests/test_monthly_report_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__":
Expand Down