Skip to content

fix(claude-memory): bound the frontmatter strip's byte limb in memory-dir-stats - #2042

Merged
kyle-sexton merged 5 commits into
mainfrom
fix/row250-claude-memory-frontmatter-byte-cap
Aug 9, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
fix/row250-claude-memory-frontmatter-byte-cap

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

No linked issue

Summary

memory-dir-stats.sh bounds the frontmatter block it strips from the M1 index-size counts by grammar (blank lines and key: mapping entries only) and by line count (fmcap = 20), but never by weight. Markdown prose opening Note:, Important:, or TODO: is a well-formed mapping entry, so a MEMORY.md that opens with a --- thematic break, carries one long paragraph, and reaches any later --- had that paragraph stripped however much it weighed.

M1 is a [FAIL]-severity size gate that a low count always passes, so the shape disarmed the gate's 25KB limb outright — the same disarming the line cap already prevents on the 200-line limb (memory-dir-stats.test.sh's "a key:-shaped runaway is bounded by length").

Fix shape chosen: (a), a byte cap analogous to fmcap

fmbytecap = 1024 bytes of held block, checked alongside the existing line and grammar bounds. The existing abandon path re-emits the held lines as content and lets the current line fall through to fence/comment handling, so no new branch was needed.

Why (a) over (b), accepting the residual. The motivating case is not a MEMORY.md with genuinely huge YAML frontmatter — for that, reporting the post-strip figure is arguably correct under M1's own post-strip reading, which is the whole of (b)'s argument. The motivating case is that the grammar misparses ordinary markdown prose as frontmatter. That is the identical risk class fmcap already exists to bound; the line limb bounded it and the byte limb did not. (b) would accept an unbounded under-count on a [FAIL] gate whose own documented direction (criteria.md M1 Provenance) is to guess toward counting: "an over-count can only make the gate fire early on a file near its limit, while an under-count stops it firing at all."

Why 1KB. The cap's job is to separate plausible real frontmatter from misparsed prose, so it is calibrated against what real frontmatter weighs, not against 25600. Claude Code stamps only a modified scalar (~40 bytes) and never adds frontmatter to a file that has none; even a generous hand-written twenty-entry block runs to a few hundred bytes. 1KB clears both by a wide margin.

Coherence with the M1 25KB limb. Every bound leaves a residue — a misparsed block still strips up to the cap before the bound ends it. 1024/25600 is 4%, tighter than the line limb's own residue of 20/200 = 10%, so the new bound is strictly no looser than the bound it is modeled on. It is also the same order as the ~1% CRLF discrepancy M1 reading 4 already accepts as immaterial.

LC_ALL=C was deliberately not added: the reported byte count already comes from wc -c on awk's output and is byte-exact regardless of locale. The locale would only affect the new cap, which is a bound rather than a measurement, and changing it would alter index/substr/character-class semantics on every existing path. The cap is measured in characters — byte-exact for the ASCII a memory-index frontmatter is made of, and merely looser (still finite) otherwise. The script comment records that.

The script's direction sentence ("They bound the block by shape and by line count, never by bytes — a short key:-shaped block ... is stripped whatever those entries weigh") became flatly false and was rewritten; criteria.md M1 reading 1 gained the byte limb, and criteria.md bumped 1.5.2 → 1.5.3 alongside.

Test plan

The script has a self-contained regression harness (memory-dir-stats.test.sh), so this matches the plugin's existing bar rather than declaring a coverage gap. Cases were added next to the existing line-bound case, as its byte sibling:

  • a heavy one-line runaway is bounded by weight / ... counts every line — the reproduction fixture, expectations written as the file's own raw_bytes()/raw_lines() so nothing may be stripped.
  • frontmatter under the weight cap still strips — fifteen key: value entries totalling ~709 bytes, proving the fix cannot regress into never stripping.

Before (26,020-byte MEMORY.md: --- / one Note: xxx… line / --- / body):

raw bytes on disk      : 26020
reported --memory-bytes: 5
reported --memory-lines: 1
M1 byte gate (25600)   : does not fire

After:

raw bytes on disk      : 26020
reported --memory-bytes: 26020
reported --memory-lines: 4
M1 byte gate (25600)   : FIRES

Gates run from the worktree, all green:

  • memory-dir-stats.test.sh — 63/63 checks pass (was 60 before the three new assertions)
  • scripts/check-changelog-parity.sh --check — pass
  • scripts/check-changelog-parity.sh --check-bump origin/main — pass
  • scripts/check-changed-skills.sh origin/main — 3 skills checked, 0 failed
  • scripts/check-shell-portability.sh origin/main — no unexcused GNU-only constructs
  • scripts/check-silent-skips.sh — pass
  • markdownlint-cli2 "plugins/claude-memory/**/*.md" — 0 errors
  • shellcheck on both changed shell files — clean

Related

Refs #1989 row 250 — third surfacing of the byte-limb question. The tracking issue carries many rows, so this PR closes no issue on merge. The G4 grammar narrowing (0.5.7) reduced exposure by making fewer shapes parse as frontmatter, but left the byte limb unbounded; this closes it.

Version: plugins/claude-memory 0.5.7 → 0.6.0 (behavior change), centrally allocated. A sibling PR from the same batch claims 0.5.8, so the gap in this plugin's changelog is expected rather than a missing release.

…-dir-stats

The audit skill's M1 index-size check bounded its frontmatter block by
grammar and by line count but never by weight, and markdown prose opening
`Note:` or `Important:` is a well-formed `key:` mapping entry. A MEMORY.md
opening with a `---` thematic break, carrying one long paragraph, and
reaching any later `---` had that paragraph stripped however much it
weighed: a 26,020-byte index reported 5 loaded bytes, disarming a
[FAIL]-severity gate on its 25KB limb exactly as the line cap already
prevented on the 200-line limb.

Bounds the block a third way, by `fmbytecap` bytes of held content. The
1KB cap is calibrated against what real frontmatter weighs — Claude Code
stamps only a `modified` scalar — so a real block still strips whole,
while the residue it leaves is the smaller share of M1's two limits
(1KB of 25KB, against 20 lines of 200).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HbtPzLRe1yBavNpsmv5Tum
@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

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

claude Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 12s —— View job


Security review complete

  • Gather context (PR diff, changed files)
  • Review shell script changes for injection / logic flaws
  • Review docs/changelog/manifest changes
  • Post final findings

Scope reviewed: the 5 files changed in this PR (plugin.json version bump, CHANGELOG.md, criteria.md, memory-dir-stats.sh, memory-dir-stats.test.sh), diffed against origin/main.

Findings: none.

This PR only touches memory-dir-stats.sh's strip_unloaded() awk routine (adds a third bound, fmbytecap = 1024, alongside the existing grammar and line-count bounds when deciding whether a leading --- block is frontmatter) plus matching doc/changelog/test updates. Relevant properties I checked:

  • No new command/injection surface. $index is a fixed path built from resolve-memory-dir.sh's output, not attacker- or network-controlled input reaching a shell. The awk block does pure text processing (index/substr/regex over $0) — no system(), eval, or shell interpolation of file content anywhere in the diff.
  • No ReDoS/resource-exhaustion risk introduced. The new length(pending) + length($0) + 1 <= fmbytecap check is a plain length comparison, not a regex, and it's evaluated before appending to pending — so this change actually bounds pending's growth (previously a single pathological heavy line could grow pending unboundedly until a non-matching line was seen; now it's capped at 1KB). This is a resource-usage improvement, not a regression.
  • No permission/trust-boundary change. No .github/workflows files, .mcp.json, hook contracts, or userConfig schema are touched. plugin.json's only change is the version field bump (0.5.7 → 0.6.0).
  • Direction of the fix is toward stricter counting, not looser. The bug being fixed was a false-negative in a [FAIL]-severity size gate (M1) — heavy pseudo-frontmatter prose was silently undercounted, letting an oversized MEMORY.md slip past the gate. The fix closes that undercount; it doesn't create a new bypass path (the existing 20-line/fmcap bound and grammar bound are unchanged and still apply independently — all three must hold for a line to keep being treated as frontmatter).
  • Test additions (memory-dir-stats.test.sh) exercise the new bound with a synthetic 26KB pseudo-frontmatter line and a normal-sized real frontmatter block; nothing there executes untrusted content either.

No CRITICAL, IMPORTANT, or SUGGESTION-level security findings on this diff.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c9c5a4ac5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@claude

claude Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in progress

  • Gather context (diff, CLAUDE.md, REVIEW.md if present)
  • Understand the request (code review of PR 2042)
  • Review memory-dir-stats.sh changes
  • Review memory-dir-stats.test.sh changes
  • Review criteria.md changes
  • Review CHANGELOG.md / plugin.json version bump
  • Post findings as inline comments + summary

View job run

kyle-sexton and others added 2 commits August 9, 2026 00:42
…characters

awk's length() counts characters under a multibyte locale, so a heavy multibyte
frontmatter line slipped under fmbytecap and resurrected the under-count the cap
exists to stop. LC_ALL=C on the awk pass pins byte semantics; a 900-character /
1800-byte fixture now guards it.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HbtPzLRe1yBavNpsmv5Tum
…ory-frontmatter-byte-cap

# Conflicts:
#	plugins/claude-memory/.claude-plugin/plugin.json
#	plugins/claude-memory/CHANGELOG.md
@kyle-sexton
kyle-sexton enabled auto-merge (squash) August 9, 2026 04:43
@claude

claude Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 3m 42s —— View job


Review complete

  • Gather context (diff, CLAUDE.md, REVIEW.md)
  • Review memory-dir-stats.sh changes
  • Review memory-dir-stats.test.sh changes
  • Review criteria.md changes
  • Review CHANGELOG.md / plugin.json version bump
  • Post findings

Scope: the 5 files changed in this PR, diffed against origin/main at HEAD c148376. Security review is out of scope for this lane per REVIEW.md's split — see the separate security-lane comment on this PR.

The core logic change — a third fmbytecap = 1024 bound on the frontmatter-strip's pending accumulator in memory-dir-stats.sh — reads correctly: the closing --- line is checked before the byte-cap condition (so it never counts against the cap, mirroring how the pre-existing fmcap line bound already excludes it), the cap accounts for the \n that would be appended, and abandonment falls through to the existing fence/comment handling unchanged. The LC_ALL=C locale pin (added in da47232 after the Codex review) correctly scopes to just the awk invocation in the pipe, leaving tr -d '\r' and the wc -c/wc -l byte/line counts unaffected — wc -c was already locale-independent, so that reviewer's undercount reproduction is closed. The three new test cases (heavy one-line runaway, multibyte fixture proving the locale pin is load-bearing, and an under-cap block that still strips) are well-targeted at the actual failure mode rather than incidental coverage. I could not execute memory-dir-stats.test.sh myself in this sandbox (script execution requires approval not available in this lane), so the 63/63-pass claim in the PR description is author-claimed and unverified by me — the static trace above is what I can independently stand behind.

Two maintainability findings, posted inline:

  1. plugins/claude-memory/.claude-plugin/plugin.json:4 — the "version": "0.6.0" line lost its 2-space indent that every sibling key has, violating the repo's own .editorconfig (indent_size = 2 for *.json). Cosmetic but mechanical — one-line fix.
  2. plugins/claude-memory/CHANGELOG.md:11 — the new entry's parenthetical reads (claude-memory 0.5.7 → 0.6.0, ...), but 0.5.7, 0.5.8, and 0.5.9 are all already present as their own entries lower in the same file — 0.5.9 is the actual immediate predecessor, and every other entry in this file cites the immediate predecessor (e.g., the 0.5.9 entry itself says 0.5.8 → 0.5.9). This reads as leftover prose from before the branch merged in origin/main's 0.5.8/0.5.9 history and wasn't reconciled. Should read 0.5.9 → 0.6.0.

No other correctness, architecture, or test-coverage issues found in criteria.md's M1 wording update or the rest of the test file — both are consistent with the shipped behavior.

@claude

claude Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 13s —— View job


Security review complete

  • Gather context (diff, changed files)
  • Review memory-dir-stats.sh changes (awk frontmatter-strip logic)
  • Review memory-dir-stats.test.sh changes
  • Review criteria.md / CHANGELOG.md / plugin.json changes
  • Post findings

Scope reviewed: all 5 files changed in this PR, diffed against origin/main at HEAD c148376 (which includes da47232, the follow-up commit that pins LC_ALL=C on the awk pass).

Findings: none.

What changed

strip_unloaded()'s frontmatter-detection loop in memory-dir-stats.sh gains a third bound (fmbytecap = 1024) alongside the existing grammar and line-count (fmcap = 20) bounds, plus LC_ALL=C on the awk invocation so length() counts bytes rather than locale-dependent characters. Everything else (memory-dir-stats.test.sh, criteria.md, CHANGELOG.md, plugin.json) is tests/docs/version metadata.

Security-relevant properties checked

  • No new input/injection surface. $index is "$memory_dir/MEMORY.md", where memory_dir comes from the sibling resolve-memory-dir.sh — unchanged by this PR, and not attacker- or network-controlled shell input. The new logic is pure awk text processing (length, index, substr, regex over $0); no system(), eval, or shell interpolation of file content is introduced.
  • LC_ALL=C awk '...' is a plain env-var-prefixed command scoped to the awk invocation only (via the pipe from tr -d '\r' <"$index" | LC_ALL=C awk ...) — it does not leak into or affect tr, and there's no quoting/escaping hazard since it's a static assignment, not built from variable data.
  • No resource-exhaustion regression — the opposite. length(pending) + length($0) + 1 <= fmbytecap is a plain numeric comparison evaluated before pending is appended to, so this change bounds pending's growth (previously a single heavy pseudo-frontmatter line could grow it unboundedly until a non-matching line appeared).
  • No trust-boundary or permission change. No workflow files, .mcp.json, hook contracts, or userConfig schema touched. plugin.json's only functional change is the version bump.
  • Direction of the fix is strictly toward stricter/more-conservative counting, consistent with M1 being a [FAIL]-severity gate: the bug was an under-count (false negative) that let an oversized MEMORY.md silently pass; the fix closes that gap without opening a new bypass (grammar and line bounds are unchanged and still apply independently — all three must hold for a line to stay in the frontmatter block).
  • Test additions (memory-dir-stats.test.sh) construct synthetic oversized/multibyte MEMORY.md fixtures purely as local test data consumed by the script under test — no untrusted/external content, no eval of test-generated strings.
  • Codex's earlier review comment (byte-vs-character counting under a multibyte locale) is resolved by commit da47232, which is included in this diff and is exercised by the new "a multibyte heavy line is bounded by weight in bytes" test case.

No CRITICAL, IMPORTANT, or SUGGESTION-level security findings on this diff. (One cosmetic note outside this review's scope: plugin.json line 4's "version" key lost its leading indentation relative to its siblings — not a security issue, flagging only for awareness.)

Comment thread plugins/claude-memory/CHANGELOG.md Resolved
@github-actions

github-actions Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude has reviewed this PR 3 times. The lane skips further automatic reviews after 5; deleting this comment resets the count.

SC2292 on the [ ] test in the WIDE generator; an arithmetic for-loop replaces
it. No behavior change; suite green.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HbtPzLRe1yBavNpsmv5Tum
@claude

claude Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 25s —— View job


Security review complete

  • Gather context (gh pr diff, changed files at HEAD 0dd0243)
  • Review memory-dir-stats.sh changes (awk frontmatter-strip / LC_ALL=C locale pin)
  • Review memory-dir-stats.test.sh changes
  • Review criteria.md / CHANGELOG.md / plugin.json changes
  • Post findings

Scope reviewed: the 5 files changed in this PR, diffed against origin/main at HEAD 0dd0243 (this sync added da47232's LC_ALL=C locale pin and 0dd0243's shellcheck fix on top of what earlier review passes on this PR saw).

Findings: none.

What changed since the prior security pass on this PR

The only new commit since the last full review is 0dd0243, a shellcheck-only cleanup of the multibyte fixture loop in memory-dir-stats.test.sh (rewriting the for ((i=0; i<900; i++)); do printf 'é'; done construct). It's local test-fixture generation with no shell interpolation of untrusted data — no behavior or security surface change from that commit.

Re-verified properties (unchanged from the earlier review, spot-checked directly)

  • No injection surface. memory-dir-stats.sh:87 builds $index from resolve-memory-dir.sh's output — not attacker- or network-controlled. The touched awk block (lines 156–208) is pure text processing (length/index/substr/regex over $0); no system(), eval, or shell interpolation of file content anywhere in the diff.
  • LC_ALL=C scoping is safe. Line 156 is a static env-var prefix on the awk invocation only, scoped by the pipe from tr -d '\r' <"$index" — not built from variable data, no quoting hazard, doesn't affect tr or the wc -c/wc -l calls downstream.
  • New bound tightens resource usage, doesn't loosen it. Line 174's length(pending) + length($0) + 1 <= fmbytecap is evaluated before appending to pending, capping its growth at 1KB — previously a single pathological line could grow it unboundedly. This is a resource-exhaustion improvement, not a regression.
  • No trust-boundary or permission change. No workflow files, .mcp.json, hook contracts, or userConfig schema touched; plugin.json's only change is the version bump.
  • Direction stays conservative. The fix closes a false-negative undercount on a [FAIL]-severity gate (M1); it doesn't open a new bypass — the pre-existing grammar and fmcap line bounds are unchanged and still apply independently.
  • Test additions construct synthetic fixtures consumed only as local input to the script under test (no untrusted/external content, no eval of generated strings).

No CRITICAL, IMPORTANT, or SUGGESTION-level security findings on this diff.

@claude

claude Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 6m 55s —— View job


Review complete

  • Gather context (diff via gh pr diff, current file state, prior review threads)
  • Review memory-dir-stats.sh changes
  • Review memory-dir-stats.test.sh changes
  • Review criteria.md changes
  • Review CHANGELOG.md / plugin.json version bump
  • Post findings

Scope: all 5 files changed in this PR, as of HEAD 0dd0243 (the "satisfy shellcheck in the multibyte fixture loop" commit, which only touches memory-dir-stats.test.sh). Security review is out of scope for this lane per REVIEW.md's split — see the separate security-lane comments on this PR.

Core logic is sound. The third fmbytecap = 1024 bound in strip_unloaded() is checked before appending to pending, correctly accounts for the trailing \n, never applies to the closing --- line (so it can't disqualify a block right at its close), and its abandon path correctly falls through to the pre-existing fence/comment handling. LC_ALL=C is scoped to just the awk invocation in the pipe, leaving tr/wc untouched. I traced this statically; I could not execute memory-dir-stats.test.sh in this sandbox (script execution isn't permitted in this lane), so the PR's 63/63-pass claim is author-claimed and unverified by me.

One correctness finding, verified independently (posted inline on memory-dir-stats.test.sh:184): the new multibyte regression fixture generates printf 'é', which I confirmed via wc -c/wc -m is 4 bytes / 2 codepoints (a double-UTF-8-encoding mojibake artifact), not the intended 2-byte / 1-codepoint é the fixture's own comment describes. At 900 reps that's 1800 characters — already past the 1024 cap even under character-mode counting — so the assertion passes identically with or without the LC_ALL=C fix it's meant to guard. The test doesn't currently prove what the PR description and review-reply claim it proves ("fails without the locale pin").

Two findings carried over from the prior review pass, still unresolved (both re-flagged inline, since the intervening commit only touched the test file):

  1. plugin.json:4 — the "version": "0.6.0" line is still missing its 2-space indent (.editorconfig sets indent_size = 2 for *.json).
  2. CHANGELOG.md:11 — still cites 0.5.7 → 0.6.0 instead of the immediate predecessor 0.5.9 → 0.6.0, inconsistent with every other entry in the file.

No other correctness, architecture, or test-coverage issues found in criteria.md's wording update or the rest of the script/test diff.

Comment thread plugins/claude-memory/CHANGELOG.md Resolved
…ndent, changelog predecessor

The multibyte fixture had been re-encoded to a four-byte mojibake sequence that
exceeded the cap in characters as well as bytes, guarding nothing; it is now
ASCII octal escapes, 600 reps (600 chars under the 1024 cap, 1200 bytes over
it). The version line regains its 2-space indent, and the entry parenthetical
cites the immediate predecessor 0.5.9.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HbtPzLRe1yBavNpsmv5Tum
@claude

claude Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 10s —— View job


Security review complete

  • Gather context (gh pr diff, current HEAD state, prior review threads)
  • Review changes since last security pass (commit db34744)
  • Re-verify core awk/locale logic for injection/resource-exhaustion risk
  • Post findings

Scope reviewed: all 5 files changed in this PR, diffed against origin/main, at HEAD db34744 (the "repair review nits" commit that landed since the prior security pass on 0dd0243).

Findings: none.

What changed since the last security pass

The only new commit, db34744, touches three files and is purely cosmetic/test-fixture — no logic change:

  • plugin.json:4 — restores the dropped 2-space indent on "version".
  • CHANGELOG.md:11 — corrects the predecessor version cited in the entry from 0.5.7 to 0.5.9.
  • memory-dir-stats.test.sh:180-198 — replaces the mojibake printf 'é' fixture with a correct single-codepoint é built from octal escapes (printf '\303\251'), repeated 600 times (1200 bytes / ~606 chars), so the fixture now actually straddles the 1024-byte cap in char-mode vs. byte-mode counting and exercises the LC_ALL=C fix it's meant to guard. This is local test-fixture generation with fixed literals — no shell interpolation of untrusted or variable data, no new injection surface.

memory-dir-stats.sh (the file with the actual awk logic) is unchanged by this commit — it was last touched in da47232/c148376, both already covered by the prior security passes on this PR.

Re-verified properties (unchanged from earlier passes, spot-checked directly against current HEAD)

  • No injection surface. memory-dir-stats.sh:87 builds $index from resolve-memory-dir.sh's output, not attacker- or network-controlled input. The touched awk block (lines 156-179) is pure text processing (length/index/substr/regex over $0) — no system(), eval, or shell interpolation of file content.
  • LC_ALL=C awk '...' (line 156) is a static env-var prefix scoped to just the awk invocation in the pipe — not built from variable data, doesn't affect tr or the downstream wc -c/wc -l calls.
  • Resource-usage direction is tightening, not loosening. length(pending) + length($0) + 1 <= fmbytecap (line 174) is checked before appending to pending, capping its growth at 1KB — previously a single pathological line could grow it unboundedly.
  • No trust-boundary or permission change. No workflow files, .mcp.json, hook contracts, or userConfig schema touched anywhere in this PR; plugin.json's only functional change across the whole PR is the version bump.
  • Direction of the underlying fix stays conservative. Closes a false-negative undercount on a [FAIL]-severity size gate (M1) without opening a new bypass — the pre-existing grammar and fmcap line bounds are unchanged and still apply independently alongside the new byte bound.

No CRITICAL, IMPORTANT, or SUGGESTION-level security findings on this diff.

@claude

claude Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 43s —— View job


Review complete

  • Gather context (diff, prior review threads at HEAD db34744)
  • Verify the three carried-over findings are actually fixed by db34744
  • Review memory-dir-stats.sh for any remaining issues
  • Review memory-dir-stats.test.sh for any remaining issues
  • Review criteria.md / CHANGELOG.md / plugin.json
  • Post findings

Scope: all 5 files changed in this PR, as of HEAD db34744 — the "repair review nits" commit that landed since the last review pass on this PR. Security review is out of scope for this lane per REVIEW.md's split.

All three carried-over findings are now resolved. I independently re-checked each:

  1. plugin.json:4 indentation — the "version": "0.6.0" line now has its 2-space indent matching every sibling key. Confirmed by reading the current file.
  2. CHANGELOG.md:11 predecessor version — now reads (claude-memory 0.5.9 → 0.6.0, ...), matching the file's convention of citing the immediate predecessor (0.5.9 is indeed the entry directly below it).
  3. Multibyte fixture in memory-dir-stats.test.sh — the mojibake printf 'é' (4 bytes/2 codepoints) is replaced with the octal escape printf '\303\251' (0xC3 0xA9, the correct 2-byte UTF-8 encoding of a single é codepoint), repeated 600 times. I traced the arithmetic by hand: under LC_ALL=C (the shipped behavior), pending accumulates "---\n" (4 bytes) then the Note: line at 1206 bytes (600×2 + "Note: " + newline), so 4 + 1206 + 1 > 1024 correctly abandons the block and the whole file counts — matching the assertion against raw_bytes(). In a hypothetical UTF-8-locale run without the pin, length() would count ~606 characters, staying under the 1024 cap and wrongly stripping the block — which is exactly the regression this fixture is meant to guard, and unlike the prior mojibake version, the math now actually demonstrates that gap rather than exceeding the cap in both modes identically.

Core logic (strip_unloaded()'s fmbytecap bound, memory-dir-stats.sh:174) is unchanged since the prior review passes on this PR, which already traced it as correct: the cap check runs before appending to pending, accounts for the trailing \n, never applies to the closing --- line, and the abandon path falls through cleanly to the existing fence/comment handling. I did not find anything to add to that prior analysis on re-reading it.

criteria.md M1 reading 1 accurately documents the new weight bound and its rationale (1KB vs. the 25KB gate, and the #-heading carve-out), consistent with the shipped script behavior. Version bump 1.5.2 → 1.5.3 is correctly reflected at the top of the file.

I was not able to execute memory-dir-stats.test.sh myself in this sandbox (script execution requires approval not available in this lane), so the PR description's 63/63-pass claim remains author-claimed and unverified by me — the hand-traced arithmetic above is what I can independently stand behind.

No new findings. Nothing outstanding from this or prior review passes.

@kyle-sexton
kyle-sexton merged commit 5f59209 into main Aug 9, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the fix/row250-claude-memory-frontmatter-byte-cap branch August 9, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant