Repository navigation
fix(#322): the third reader of the same marker, and a freeze guard that outlived its claim - #329
Conversation
…at outlived its claim Co-Authored-By: Max <noreply>
Code reviewNo blocking issues. One non-blocking finding, filed as #330 rather than held against this PR. The byte-identity pin on the per-tool-call path is gone, and the three substring checks that replace it can be walked around — Checked and clean: the two Adjacent, already open: #326 names 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
…he hook reads (#331) #327 asked for one 10# in 50-git-backup.sh. The sweep found six sinks across the two git hooks: the backup cooldown marker, the restore hook's two fetch-state reads, and all four consecutive-failure counters, whose failing increment abandons the branch holding the ERROR log. #327's severity claim does not hold: measured on bash 3.2.57 in the shape the hook has, the failing arithmetic abandons the if body and the hook exits 0, commits, and re-stamps -- misreports, not fails-to-preserve. Its docstring half was already fixed by #329; that note is updated instead. #324's premise that the test asserts nothing is also wrong -- the #261 legacy carry-forward transports the dotted marker into the state dir before the cooldown block. The test now writes through hook_state anyway, because the shim is not the feature. What was genuinely missing is 08/09 and an assertion on stderr.
Bumps .claude-plugin/plugin.json to 0.18.0 and closes the Unreleased section. Also gives #329 its own entry. Its prose had been appended to #322's bullet inside the already-released 0.17.0 section, so the file claimed work that shipped after the 0.17.0 tag; those two paragraphs are moved out and rewritten as a 0.18.0 entry, with the freeze-guard half of #329 documented for the first time.
… budgets (#330) (#380) * test: pin per-tool-call hot path cost with a spawn+read-builtin harness (#330) #329's substring guard in test_case_divergence_298.py checks for three literals; #330 named vectors that reintroduce #298/#299's per-tool-call cost while staying green against it -- a git wrapper spelled through a variable or `command`, and an extra file read or loop that spawns nothing at all. tests/test_hot_path_cost_pin_330.py adds the measured pin the issue asked for: a spawn budget (reusing the existing harness) plus a new bash-builtin-`read` count via `bash -x` tracing, proven non-vacuous against scratch reproductions of each named vector, with the pure-compute boundary neither pin can see stated rather than hidden. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FLHVEH4aeVK93939UYnfFP * test: widen the #330 read pin to mapfile/readarray, cross-reference #298's substring test Self-review findings: the reviewer flagged that #298's substring-test docstring still read as the whole story on hot-path coverage, with no pointer to the new cost pin that closes its gap -- cross-referenced both ways. The auditor flagged that _is_read_builtin only matched the literal word "read", so a rewrite from a `while read` loop to `mapfile`/`readarray` (same file, same cost, zero new spawns) would silently evade the new pin -- widened the match set and named the one vector that remains genuinely unreachable (`x=$(< file)`, invisible to xtrace itself, confirmed locally) in the module docstring instead of leaving it undiscovered. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FLHVEH4aeVK93939UYnfFP * fix: eliminate the same-second cache-tie race in test_hot_path_cost_pin_330.py (#330) CI (macos-latest, 3.11/3.12) went red on the new file's own positive control: "the injected read spawned a process", with a spawn list that was pure cold-path signature (python3 -V, git rev-parse, jq -s, the trap-stripping sed, the temp sweep). ubuntu and windows legs stayed green. Established rather than guessed: the fixture wrote config.json with a plain write_text() instead of tests.env_cache.write_config(), and never verified warmth with EnvCacheProbe. scripts/lib-env-cache.sh refuses its own cache unless it is `-nt` every config layer, and macOS's system bash 3.2.57 -nt compares whole SECONDS (confirmed via tests.env_cache.nt_granularity() == "second" on this platform) -- so a config written in the same wall-clock second as the cache publish TIES rather than loses, the cache is rejected, and every "warm" measurement in this file was silently re-resolving instead. Reproduced deterministically by forcing the tie by hand: identical spawn signature to the CI failure. This is the exact #303 defect class this repo's own tests.env_cache module exists to prevent, already used by the sibling file this one is modeled on (test_post_tool_fast_path_350.py) -- this file simply never adopted it. Fixed with the established pattern rather than a platform skip, since warmth is genuinely reachable everywhere once the race is closed: config.json now goes through write_config() (backdated past any second boundary), and every measured (non-priming) run goes through a new _measure() helper that brackets it with an EnvCacheProbe and fails loudly -- naming which run went cold and why -- instead of silently reporting a cold-path count as the warm one this file claims to pin. Verified stable across repeated local runs on this machine's bash 3.2.57 (matching macOS CI) after the fix; the x=$(< file) boundary this file already names is untouched. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FLHVEH4aeVK93939UYnfFP --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Builds on @jmossie82's #325 (merged). Their patch is unchanged — this is the sweep it opened up.
Part of #322
The third and fourth sites
10#landed insave-session.sh.scripts/post-tool-hook.shreads the sametmp/last-save-tsat:335andtmp/no-transcript-noticeat:192, bothcase-guarded since #230, neither carrying10#. So08/09clear the guard and are read as octal, the body is abandoned, and::335—IN_COOLDOWNstays false, the hook forks a save inside the window:192— worse: the abandoned body swallows its ownexit 0, so the line below thefideletes the notice marker on the assumption a transcript was foundBoth tests assert behaviour (
save-session.pidabsent / the notice marker surviving), not just the diagnostic. That mattered: the first draft assertedproc.stderralone and passed against the broken code, because bash's line goes tohook-errors.lograther than stderr on this path.SAVE_COOLDOWNwas left alone, deliberatelyI briefed this as having the same gap. It does not.
LAST_TSis inside$(( ));SAVE_COOLDOWNis the right-hand operand of[ … -lt … ], thetestbuiltin, which parses base 10 and does not evaluate:10#there would be inert and worse than inert — it would advertise a hazard at a site that has none, and its absence elsewhere would then read as a finding. The measurement is in the code comment so it does not get "fixed" later.The judgment call that needs a second opinion
test_the_per_tool_call_path_is_not_touched(#298/#299) assertedpost-tool-hook.shis byte-identical to origin/main. That blocked a correct one-token fix and would block every future edit to the file. It is also self-cancelling: once the edit it objects to lands on main, it compares against the new main and passes. So what it actually asserts is "nobody has touched this file since main" — a different claim from the one its name makes, "the per-tool-call path is still cheap". A check that reads as evidence about the world when it is evidence about the diff.Replaced the
post-tool-hook.sharm with the three properties #298/#299 care about — the divergence library is not sourced,case_divergenceis not called, nogitis spawned — each with its own message. Stronger than byte-equality after this merges, and cannot go vacuous. Thelib-slug.sh/lib-memory-dir.sharms keep their byte compare untouched.If you would rather that were its own PR against #298, say so — but then the third site cannot land at all, because the guard forbids it.
Verification
Their tests against main's
save-session.sh:9 failed, 3 passed(the 3 are the two whitespace controls and the valid-marker case, by design). Their tests with their patch:12 passed. My two, before my10#: red withvalue too great for baseat:325and:186. Full suite1519 passed, 43 skipped.macOS + bash 3.2.57 only. bash 5 unverified — no bash 5 on this machine. CI is the authority.