Skip to content

The first-match stdin extractor now feeds cwd on all four hooks, and #344's top-level-wins pin only ever covered source #447

Closed

Description

@fdaviddpt

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:

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

  1. added
    bug
    priority:low
    cohort-3
    on Aug 29, 2026
  2. added 2 commits that reference this issue on Sep 1, 2026
  3. added a commit that references this issue on Sep 28, 2026
  4. added 5 commits that reference this issue on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcohort-3priority:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions