From dccdd865c7a823535b2db425571e9451c9c0cf1c Mon Sep 17 00:00:00 2001 From: Chad El Kurdi <162061136+Chad-Mufasax@users.noreply.github.com> Date: Thu, 23 Jul 2026 15:11:34 +0200 Subject: [PATCH] =?UTF-8?q?lint:=20frontmatter-aware=20verdict=20insertion?= =?UTF-8?q?=20=E2=80=94=20naive=20line-2=20insert=20corrupted=20YAML=20fro?= =?UTF-8?q?ntmatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found in the field: on a memory/dashboard page that already carries YAML frontmatter, the first-run insertion landed inside the frontmatter block and broke its parse. Insert after the closing --- instead. Claude-Session: https://claude.ai/code/session_013ERfM4utJGsw4McARGJt6a --- engine/nightly/gbrain-lint.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/engine/nightly/gbrain-lint.sh b/engine/nightly/gbrain-lint.sh index 5deed92..115942b 100644 --- a/engine/nightly/gbrain-lint.sh +++ b/engine/nightly/gbrain-lint.sh @@ -167,9 +167,12 @@ mem = mem_path.read_text() if mem_path.exists() else "# Memory\n" if "" in mem: mem = re.sub(r".*?", block, mem, flags=re.S) else: - lines = mem.splitlines(keepends=True) - lines.insert(min(2, len(lines)), "\n" + block + "\n") - mem = "".join(lines) + # Frontmatter-aware insertion: NEVER inside the YAML block. A naive + # line-2 insert lands inside the frontmatter of any page that has one + # and corrupts it (found in the field on a dashboard page). + fm = re.match(r"^---\n.*?\n---\n", mem, re.S) + at = fm.end() if fm else 0 + mem = mem[:at] + "\n" + block + "\n" + mem[at:] mem_path.write_text(mem) print(f"lint {verdict} — {summary}")