Repository navigation
Description
Reported out of the #444 lane's self-review and routed here rather than fixed in that diff, which correctly judged it out of its blast radius.
Symptom
_stdin_json_string KEY takes the first textual occurrence of "KEY" in the joined stdin rather than the first top-level one. A payload carrying a nested key ahead of the top-level one extracts the nested value.
Location
scripts/session-start-hook.sh defines the extractor; scripts/session-end-hook.sh, scripts/user-prompt-hook.sh and scripts/post-tool-hook.sh all now call it. #444 renamed _stdin_session_id to _stdin_json_string in post-tool-hook.sh and added cwd reads to the two hooks that previously had none.
Mechanism
#344 filed exactly this heuristic against the source key, judged it not a live bug, and asked for one thing: "a test that plants a nested key and asserts the top-level value wins". #379 delivered that pin — tests/test_stdin_source_top_level_wins_344.py — and #344 closed.
The pin is keyed to source. It is not a property of the extractor. Since #444, the same extractor resolves cwd on all four hooks and session_id on two, and none of those keys carry the guarantee source does:
sourceis whitelisted down to one of five literals or empty, which is what bounded _stdin_json_string takes the FIRST "source" key, so a future nested payload could suppress the recap at a genuine startup #344's impact.cwdis not whitelisted — it is validated for embedded newlines and then tested for directory existence.cwd's downstream use is not a string comparison. It becomesREMEMBER_HOOK_CWD, whichresolve-paths.shresolves intoPROJECT_DIR— the root every subsequent write is relative to.
So the class #344 described is unchanged, but the consequence at the new call sites is not the one #344 measured, and the artifact it left behind does not reach them.
What would settle it
Either the pin generalises to the extractor rather than to one key — plant a nested key, assert the top-level wins, parameterised over source, cwd and session_id — or somebody establishes that no host's payload can carry a nested cwd. The second is a claim about three hosts' schemas, two of which this project does not control.
Do not reach for a JSON parser: #340 avoided that dependency deliberately, and a hook that must survive a broken install is the wrong place to acquire one. #344 says the same thing and the reasoning has not changed.
Not a reopen of #344
#344 is closed, carries cohort-1, and a frozen cohort can only shrink — reopening it to hold a new instance would grow one, which is the one thing the cohort metric forbids. Filed as its own issue for that reason, not because the class is different.
Activity
Generalise the #344 top-level-wins extractor pin across source, cwd a…
Fewer warm-path forks (#511), env-cache key parity on Windows (#504),…
fix(#829): decode JSON backslash escapes in the hook stdin extractors (…
refactor(#898): session start reads stdin fields through the printf -…
test(#900): pin two compiled-hook pin hazards the fix/898 merge expos…
fix(#900): skip pins the compiled build cannot answer, not fail them
Fix #447 tests: follow post-tool-hook.sh's extractor rename to _stdin…
Fix #1029: remove three unconditional subshell forks per post-tool-ho…