From 0bd41b2fb197311f49a6deefb09eb95d378ac9c3 Mon Sep 17 00:00:00 2001 From: beatz174-bit Date: Wed, 13 May 2026 07:36:57 +1000 Subject: [PATCH] Migrate legacy architecture heading during section upsert --- scripts/render_prometheus_docs.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/render_prometheus_docs.py b/scripts/render_prometheus_docs.py index 1ba0733..b158c0d 100755 --- a/scripts/render_prometheus_docs.py +++ b/scripts/render_prometheus_docs.py @@ -429,8 +429,18 @@ def render_architecture_section( def upsert_generated_section(path: Path, section_markdown: str, dry_run: bool, verbose: bool) -> None: existing = path.read_text(encoding="utf-8") if path.exists() else "" section_body = section_markdown + legacy_heading = "## Runtime visibility from Prometheus" + new_heading = "## Runtime and infrastructure inventory" if GENERATED_BEGIN in existing and GENERATED_END in existing: + # Migration: replace legacy heading that exists outside the generated markers. + existing = re.sub( + rf"^{re.escape(legacy_heading)}(?=\n)", + new_heading, + existing, + count=1, + flags=re.MULTILINE, + ) pattern = re.compile( rf"{re.escape(GENERATED_BEGIN)}.*?{re.escape(GENERATED_END)}", re.DOTALL, @@ -438,7 +448,7 @@ def upsert_generated_section(path: Path, section_markdown: str, dry_run: bool, v replacement = "\n".join( line for line in section_body.splitlines() - if line.strip() not in {"## Runtime visibility from Prometheus", "## Runtime and infrastructure inventory"} + if line.strip() not in {legacy_heading, new_heading} ) updated = pattern.sub(replacement.strip(), existing) else: