Skip to content

Commit 8b32b77

Browse files
Pigbibiselfhosted-codex-audit[bot]
andauthored
Fix monthly review input duplicate headings
Co-authored-by: selfhosted-codex-audit[bot] <selfhosted-codex-audit[bot]@users.noreply.github.com>
1 parent 63c4adb commit 8b32b77

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

scripts/run_monthly_report_bundle.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,19 @@ def render_job_summary(bundle: dict[str, Any], release_status: dict[str, Any], m
113113
"""
114114

115115

116+
def strip_wrapped_h1(markdown: str, heading: str) -> str:
117+
text = markdown.strip()
118+
first_line, separator, rest = text.partition("\n")
119+
if separator and first_line.strip() == f"# {heading}":
120+
return rest.lstrip("\n")
121+
if not separator and first_line.strip() == f"# {heading}":
122+
return ""
123+
return text
124+
125+
116126
def render_ai_review_input(bundle: dict[str, Any], release_status_md: str, monthly_review_md: str, telegram_text: str) -> str:
127+
release_status_body = strip_wrapped_h1(release_status_md, "Release Status Summary")
128+
monthly_review_body = strip_wrapped_h1(monthly_review_md, "Monthly Review")
117129
return f"""# Monthly Report Review Input
118130
119131
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
143155
144156
## Release Status Summary
145157
146-
{release_status_md}
158+
{release_status_body}
147159
148160
## Monthly Review
149161
150-
{monthly_review_md}
162+
{monthly_review_body}
151163
152164
## Telegram Preview
153165

tests/test_monthly_report_bundle.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ def write_fixture_files(self, root: Path) -> Path:
3535
),
3636
encoding="utf-8",
3737
)
38-
(output_dir / "release_status_summary.md").write_text("# Release Status Summary\n", encoding="utf-8")
38+
(output_dir / "release_status_summary.md").write_text(
39+
"# Release Status Summary\n\nGenerated: fixture\n",
40+
encoding="utf-8",
41+
)
3942
(output_dir / "monthly_review.json").write_text(
4043
json.dumps({"as_of_date": "2026-03-13", "warnings": [], "status": "ok"}),
4144
encoding="utf-8",
4245
)
43-
(output_dir / "monthly_review.md").write_text("# Monthly Review\n", encoding="utf-8")
46+
(output_dir / "monthly_review.md").write_text(
47+
"# Monthly Review\n\n## Current release status\n",
48+
encoding="utf-8",
49+
)
4450
(output_dir / "monthly_review_prompt.md").write_text("Monthly release review prompt\n", encoding="utf-8")
4551
(output_dir / "monthly_telegram.txt").write_text("CryptoSnapshotPipelines monthly release\n", encoding="utf-8")
4652
return output_dir
@@ -61,6 +67,10 @@ def test_write_bundle_copies_files_and_writes_manifest(self) -> None:
6167
self.assertIn("upstream selector review", ai_review_input)
6268
self.assertIn("Shadow / challenger coverage", ai_review_input)
6369
self.assertIn("Strategy review questions", ai_review_input)
70+
self.assertIn("## Release Status Summary\n\nGenerated: fixture", ai_review_input)
71+
self.assertIn("## Monthly Review\n\n## Current release status", ai_review_input)
72+
self.assertNotIn("## Release Status Summary\n\n# Release Status Summary", ai_review_input)
73+
self.assertNotIn("## Monthly Review\n\n# Monthly Review", ai_review_input)
6474

6575

6676
if __name__ == "__main__":

0 commit comments

Comments
 (0)