Repository navigation
Conversation
…d fallback (#444) #417 correctly had these two hooks `unset REMEMBER_HOOK_CWD` at entry to close a leak, but left them with no legitimate source for it at all -- only session-start-hook.sh and session-end-hook.sh ever set it, from their own stdin `cwd`. On a host that never sets CLAUDE_PROJECT_DIR (Codex, Gemini CLI), resolve-paths.sh's FATAL then killed per-turn capture silently behind the `|| exit 0` soft-fail contract. Both hooks now read `cwd` off their own stdin payload, after the existing unset. user-prompt-hook.sh reads it only on its slow (once-per-project) path, since the fast path never sources resolve-paths.sh. post-tool-hook.sh already read its full stdin payload unconditionally on every tool call for session_id (#212); this moves that capture earlier and reuses it, rather than reading stdin twice. Co-Authored-By: Max <noreply>
Self-review (Explore reviewer) on the #444 commit caught three comments left behind by that fix, all claiming a state the same commit made false: - scripts/user-prompt-hook.sh and scripts/post-tool-hook.sh's own #417 `unset REMEMBER_HOOK_CWD` blocks still said "this hook has no stdin cwd of its own to offer" -- contradicted 45-90 lines later in the same file, where #444 gives each hook exactly that. - scripts/resolve-paths.sh's own priority/ASSUMPTION doc block (untouched by #444 itself) said the same thing about both hooks, and said REMEMBER_HOOK_CWD was exported only by session-start-hook.sh/session-end-hook.sh. No behavior change; comments only. Co-Authored-By: Max <noreply>
4 tasks done
fdaviddpt
added a commit
that referenced
this pull request
Aug 29, 2026
…sion/description drift (#467, #470) (#472) * fix: re-sanitise a leaked home path in the Codex fixture, and fix the Codex manifest's stale version/description (#467, #470) Two defects the round-1 v0.24.0 release audit found blocking the tag. #467: tests/fixtures/codex-rollout.jsonl carried the maintainer's real home directory and OS username in two nested JSON-string blobs the field-keyed sanitiser never walked. Since .agents/plugins/marketplace.json declares a local install source, tests/ ships into every install, so this would have reached every 0.24.0 user. Re-sanitised to the fixture's own placeholder convention, plus a new guard (tests/test_no_real_home_paths_467.py) that fails the build if any tests/fixtures/* file names an un-sanitised /Users/<x>/ or /home/<x>/ segment, scoped to fixtures (real captures) rather than the whole tree, where /Users/ and /home/ already appear legitimately in hand-authored test data and docs. #470: .codex-plugin/plugin.json was missing from .oss.json's version_sites (so tagging would have shipped it one version behind, correctable only by another release) and its description still claimed the Codex layer was unverified, false since #443/#460/#463/#465. Fixed both; a version-match guard already existed (tests/test_codex_manifest_410.py) and needed no change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix: also correct .codex-plugin/plugin.json's stale #444 claim and its sibling hooks/hooks.codex.json's stale #410 description (#470) Self-review (two independent spawned reviewers) caught two follow-on defects in the previous commit's own #470 fix: - The new .codex-plugin/plugin.json description claimed "per-turn capture is still broken (#444), not fixed yet" -- #444 was already fixed and merged to main (163bc51, PR #446) before this branch was even cut, so the sentence this fix wrote was wrong the moment it landed. Corrected to list #444 among the verified/fixed issues. - hooks/hooks.codex.json carries the exact same "not verified against a running Codex install (#410)" sentence .codex-plugin/plugin.json had, in the same subsystem, and was missed by the original commit. Brought in line with the same corrected wording. changelog.d/470.fixed.md updated to match. Not in the file list the brief named for this lane, but same subsystem, one sentence, and the same misreports defect class #470 was filed for -- fixed rather than filed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix: #467's guard was missing the bare-username shape its own second leaked file shipped The coordinator caught a defect in the previous commit's own #467 guard before pushing, and asked for a second look rather than taking their word for it -- confirmed correct. The guard's docstring argued hand-authored .py literals "can never carry a real person's real credentials by the mechanism that produced #467". That premise is false: #467 shipped in TWO files, and the second, tests/test_codex_upsubmit_stdout_451.py, is exactly a hand-authored .py literal carrying a real credential -- pasted from live probe output. It is also a BARE username, not a /Users/<x>/ or /home/<x>/ path, so the existing path-shaped regex would not have matched it even scoped tree-wide. Two different shapes need two different detectors. The existing fixtures-scoped path check (Detector 1) is unchanged and its scoping argument still holds for PATHS specifically -- /Users/ and /home/ have a flood of legitimate hits in this repo's hand-authored test data that a username search does not. New: Detector 2, tree-wide, keyed on getpass.getuser() -- the account name of whoever runs the suite. Searches every git-tracked file for a verbatim occurrence of the current machine's own OS username. Fires exactly when a contributor has pasted their own identity into the tree, which is when it matters. Explicitly honest about its own limit, in the test's own docstring rather than left implicit: under a CI runner account this is near-vacuous (the runner's login name is not a contributor's real identity) and must not be read as coverage from a green CI leg -- the real guard is a contributor running the suite locally. Short/generic account names (root, admin, runner, ...) are skipped loudly via pytest.skip rather than searched, to avoid false-positive noise across ~300 tracked files. Has its own positive control (a detector keyed on a name that never appears cannot fail) and was watched red (planted an occurrence in README.md, reverted after) then green. changelog.d/467.fixed.md updated to describe both detectors and the username check's honesty clause. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix: #467's username guard skips on CI instead of chasing runner account names (#472) The coordinator caught a real false positive before pushing: PR #472 went red on windows-latest/3.10, tests/test_no_real_home_paths_467.py's new username detector flagging 'runneradmin' (the Windows runner's actual account) inside tests/test_stale_config_sweep_362.py's own deliberate Windows path fixtures. Explicitly declined the easy fix: adding "runneradmin" to _GENERIC_USERNAMES would only fix this one CI image. Every CI image has its own account name, discovered the same way this one was -- a red build on somebody else's release -- and a skiplist that grows one entry per incident costs more than it catches. Read tests/test_case_divergence_298.py's _origin_main_should_be_resolvable (#442) before deciding, per the coordinator's pointer, since it is the same shape of question (should a guard fail or skip on CI) answered the opposite way. The two differ in kind: #442's precondition (origin/main resolvable) is something CI's own checkout step is supposed to guarantee, so its absence is a real infrastructure defect worth failing loudly over. This detector's precondition -- running under a contributor's own account -- is never true on CI by design, not by a setup failure, so there is no defect for a loud failure to surface; asserting against the runner's account name only ever manufactures false positives. Added _username_check_should_run(env), returning False whenever CI or GITHUB_ACTIONS is set, pinned by two tests mirroring #442's own test_origin_main_unavailable_outcome_fails_loudly_on_ci / _skips_locally shape so neither arm (always-run, reintroducing #472; always-skip, a guard nobody runs) can silently regress. The real check skips loudly there, via pytest.skip with the full reasoning in the skip message (visible under pytest -rs, reported distinctly from a pass in pytest's own summary line -- verified: `CI=true pytest ... -rs` shows "1 skipped" naming the reason). Verified the fix directly: with the scanner mocked to see username 'runneradmin', the check still fails locally (no CI signal) and skips loudly under GITHUB_ACTIONS=true -- confirming this is a principled CI/local discriminator, not a disguised skiplist entry for one more name. The fixtures-scoped path guard, the re-sanitisation, and the .oss.json / .codex-plugin work are untouched, as instructed -- git status confirms only this file and its changelog fragment changed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
scripts/user-prompt-hook.shandscripts/post-tool-hook.shcould never resolve the project root on a host that never setsCLAUDE_PROJECT_DIR(Codex, Gemini CLI). #411 gaveresolve-paths.shaREMEMBER_HOOK_CWDfallback, read from each hook's own stdincwd, but only wired it intosession-start-hook.shandsession-end-hook.sh. #417 then had these two other hooksunset REMEMBER_HOOK_CWDat entry -- correctly closing a leak where one hook's exported value could be inherited by a hook that had not validated it -- but left them with no legitimate source for the variable at all. Invisible on Claude Code (CLAUDE_PROJECT_DIRalways set); fatal on Codex/Gemini CLI, where per-turn capture silently no-oped behind the|| exit 0soft-fail contract.Both hooks now read
cwdoff their own stdin payload, after the existingunset-- never instead of it, so the #417 leak stays closed.user-prompt-hook.sh: the read is added only inside the slow (_REMEMBER_FAST=0, once-per-project-per-config-change) path, before it sourcesresolve-paths.sh. This IS a new stdin read for this hook, but it never reaches the hot per-prompt fast path.post-tool-hook.sh: it already read its full stdin payload unconditionally on every tool call (forsession_id, post-tool-hook.sh infers SESSION_ID from the newest .jsonl by mtime, so under concurrent sessions it can vouch for the wrong one #212) -- this diff moves that same capture earlier in the file and generalizes its extractor (_stdin_session_id->_stdin_json_string) so the one read now feeds bothcwdandsession_id. Confirmed viatests/test_post_tool_hook_spawns.py/test_post_tool_fast_path_350.py(both still green) that this adds no new process spawns on the fast path.A follow-up commit (
2054687) fixes three stale comments the self-review caught: two hooks' own#417blocks andresolve-paths.sh's priority/ASSUMPTION doc all still claimed these two hooks had "no stdin cwd of its own to offer" -- true before this fix, false after it.Tests
New file
tests/test_hook_cwd_fallback_444.py, 6 tests covering both hooks: resolves-from-stdin-cwd (red before the fix:FATAL: Cannot resolve project root, green after), a positive control (scaffolds nothing without a usablecwd, still exits 0), andCLAUDE_PROJECT_DIR-wins-over-a-disagreeing-stdin-cwdprecedence. All existing #411/#417/#424 regression controls and post-tool/user-prompt cost-budget tests stay green. Full suite: 1810 passed, 43 skipped, 1 error -- the error is a conftest concurrent-worktree teardown guard tripped by a sibling lane'sgit worktreeactivity during the run, unrelated to this diff (see the guard's own assertion message).Adjacent, reported for filing (not fixed here)
resolve-paths.sh'sREMEMBER_HOOK_CWDdirectory-existence test runs before the Windows backslash/drive-letter normalization block that only fires on the chosenPROJECT_DIR, an asymmetryCLAUDE_PROJECT_DIRdoesn't have. Pre-existing from resolve-paths.sh cannot resolve a project root on any host that does not set CLAUDE_PROJECT_DIR #411, made load-bearing on two more hooks (one of them,post-tool-hook.sh, on every tool call) by this diff. Reasoned, not observed -- no Windows/Git Bash shell available this session.Closes #444.