fix(claude-memory): count heading-shaped lines a pseudo-frontmatter block would swallow - #1962
Conversation
…lock would swallow A markdown heading is a comment to YAML but loaded content to markdown, so admitting it to the frontmatter grammar let a MEMORY.md opening with a thematic break, carrying up to twenty heading lines, and reaching any later break strip the whole span: a 5-line index reported one loaded line, disarming the FAIL-severity M1 size gate that a low count always passes. The grammar now accepts only blank lines and key mapping entries, so that shape counts every line. The cost is that a real YAML comment inside frontmatter ends the block, and ending it strips nothing at all, so the delimiters and every entry held so far count too. That is an over-count in the direction M1 already guesses toward, and a rare one, since Claude Code writes only the modified scalar and never authors comments. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
…belongs to The entry read as if a hand-authored YAML comment were a new over-count shape. Any frontmatter the grammar cannot parse already ended the block before this change, and a block sequence under tags still does, so comments join that class rather than opening one. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Claude finished @kyle-sexton's task in 58s —— View job Security review complete
ScopeReviewed all 5 files changed in this PR (
No GitHub Actions workflow files are touched by this PR. FindingsNone. This is a narrow, local, read-only bugfix:
No CRITICAL, IMPORTANT, or SUGGESTION items to report. |
|
Claude finished @kyle-sexton's task in 2m 30s —— View job Code review complete
Scope note: this is the code-review lane; security concerns are left to the dedicated security-review lane per CorrectnessTraced the awk state machine in
The core fix (dropping Test coverageThe new cases in Hygiene
No blocking findings. This is a narrowly-scoped, well-justified fix with the reasoning traceable across code comment, test, doc, and changelog. |
|
Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count. |
Follow-up to #1933 (work-items row 127, campaign ledger #1941). #1933 shipped the M1 index-size measurement fixes for
memory-dir-stats.sh; this closes the last under-count residual that surfaced during its gate review, after the PR had already merged.No linked issue — the residual was found by #1933's own gate review rather than filed as an issue, and the campaign ledger it belongs to stays open past this PR.
The bug
memory-dir-stats.shadmitted#lines to its frontmatter grammar. AMEMORY.mdthat opens with a---thematic break, carries heading lines, and reaches any later---therefore had the whole span stripped as frontmatter:Raw 5 lines / 41 bytes, reported 1 line / 5 bytes.
M1 is a
[FAIL]-severity size gate, and a low count always passes it, so the shape disarmed the gate outright rather than merely mismeasuring it. This is the same failure species #1933 exists to eliminate — silent under-count on the gate — reached through the frontmatter grammar instead of the comment strip.A
#line is a comment to YAML but a heading to markdown, and headings are loaded content. The grammar now accepts only blank lines andkey:mapping entries.Evidence
Measured against
origin/main's script and this branch's, same fixtures:---(23 lines)key:-only frontmatter# noteThe bound is capped at
fmcap(20) lines, so the worst case was ~22 content lines — 11% of the 200-line budget — never a full disarm of the line limb, but enough to make a five-line index report one.The cost, stated plainly
A real YAML comment inside frontmatter now ends the block, and ending it strips nothing at all: the opening
---, every entry held so far, and the rest of the block through its close all count. That is an over-count, the direction M1's readings already guess toward — it can make the gate fire early, never fail to fire. It takes a hand-edited index to reach, since Claude Code only stamps amodifiedscalar into frontmatter a file already has. Comments join an existing class rather than opening a new one: frontmatter this grammar cannot parse already ended the block before this change, and a block sequence undertags:still does.criteria.mdM1 reading 1 records both halves.Verification
main.key:-only frontmatter still strips; comment/fence behavior unregressed; no#alternation left in the executed awk; version + changelog hygiene). It derived every expectation from the awk before looking at output, and added its own mutation check — runningorigin/main's pre-fix script side by side to confirm the fix is load-bearing and the numbers above reproduce.Versions
claude-memory0.5.6 → 0.5.7 (0.5.5 → 0.5.6 landed via #1947);criteria.md1.5.1 → 1.5.2; CHANGELOG entry under[0.5.7].Related
claude-memory0.5.5 → 0.5.6, the version this PR bumps from. Reference only.