Repository navigation
Conversation
…ECT_DIR (#411) Codex never sets CLAUDE_PROJECT_DIR and Gemini CLI documents no hook environment variables at all, so on either host resolve-paths.sh's project-root resolution failed outright and every hook silently no-oped. session-start-hook.sh and session-end-hook.sh now read the `cwd` field already present on the SessionStart/SessionEnd stdin payload on all three hosts and export it as REMEMBER_HOOK_CWD, which resolve-paths.sh consults as a fallback between CLAUDE_PROJECT_DIR and the existing local-install derivation. Reading stdin ahead of resolve-paths.sh in session-start-hook.sh meant duplicating the REMEMBER_NESTED_SUMMARIZER fast-path guard ahead of the capture, matching the copy the other three hooks already carry -- this keeps the nested summarizer's startup cost at ~5-13ms rather than paying up to a second for a stdin read it does not need (measured). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Self-review (Explore) caught the ENVIRONMENT (inputs) doc block at the top of resolve-paths.sh -- the file's own "single source of truth" contract summary -- listing only CLAUDE_PROJECT_DIR/PLUGIN_ROOT/CLAUDE_PLUGIN_ROOT, not the new REMEMBER_HOOK_CWD fallback the precedence chain further down already documents inline. 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.
Closes #411.
Codex never sets
CLAUDE_PROJECT_DIRand Gemini CLI documents no hook environment variables at all, so on either hostscripts/resolve-paths.sh's project-root resolution failed outright and every hook silently no-oped via its|| exit 0.Fix.
SessionStart/SessionEnd's stdin payload already carries acwdfield on all three hosts.scripts/session-start-hook.shandscripts/session-end-hook.shnow extract it (validated the same waytranscript_pathalready is, since #407) and export it asREMEMBER_HOOK_CWD.resolve-paths.shtries, in order:CLAUDE_PROJECT_DIR, thenREMEMBER_HOOK_CWD(if it names a directory that exists), then the existing.claude/rememberlocal-install derivation, then the existing loud failure. A stdincwddisagreeing with a setCLAUDE_PROJECT_DIRnever wins.The judgement call the issue asked for. The issue framed the guard duplication as a cost to weigh ("duplicates a condition that currently lives in exactly one place"). Re-reading the codebase rather than the issue's framing: the
REMEMBER_NESTED_SUMMARIZERguard already lived in FOUR places before this diff --resolve-paths.sh's own copy, plus a duplicate already carried bypost-tool-hook.sh,user-prompt-hook.sh, andsession-end-hook.sh(each ahead of their own stdin capture or fast path, for the same reason).session-start-hook.shwas the one hook missing the pattern its three siblings already use. This PR normalizes it to match, rather than introducing a new duplication. The independentoss:auditorreview confirmed this by greppingREMEMBER_NESTED_SUMMARIZERacrossscripts/*.shand finding the same four pre-existing sites.Measured, not reasoned (per the issue's own instruction): nested-summarizer startup with the new guard in place is ~5-13ms even with stdin held open on a pipe that never closes -- the guard exits before the stdin read is ever reached. A control run with the guard removed (the shape the issue worried about) measured ~1.03s under the same held-open-stdin condition, matching the issue's "up to a second" estimate. The chosen shape does not make the nested summarizer do any new work.
Simulated, not observed: no Codex or Gemini CLI binary exists on the machine this was built on. The precedence-chain tests are a real test of
resolve-paths.sh's own logic (built by unsettingCLAUDE_PROJECT_DIRand feedingREMEMBER_HOOK_CWDdirectly); they are not evidence that either host's hook populates that value the way the tests assume.pipeline/host.pyuntouched. It already carried an unusedCWD_VAR = "REMEMBER_HOOK_CWD"constant from #407. No host-specific table entry was needed:cwdis uniform across all three hosts on the stdin payload (unlike the plugin-root variable name, which does differ per host and IS in that table).Self-review found one adjacent issue, filed rather than fixed here (below the bar for a one-line filing note -- see report):
post-tool-hook.shanduser-prompt-hook.sh(both out of this PR's scope; the former belongs to a concurrently in-flight lane) sourceresolve-paths.sh, which now consultsREMEMBER_HOOK_CWD, but neither hook sets, unsets, or validates that variable the waysession-start-hook.sh/session-end-hook.shdo. Whether this is reachable depends on whether any real host ever reuses a process/environment across hook invocations -- not established here.Test plan
tests/test_project_root_cwd_fallback_411.py-- resolve-paths.sh precedence chain, red-then-green verified against the pre-fix filetests/test_hook_cwd_end_to_end_411.py-- full hook subprocess, real stdin payload,.remember/scaffolding locationtests/test_nested_summarizer.py-- all 9 existing cases still pass, including the parametrized "every registered hook" guard testpython3 .oss/assemble_changelog.py --check-- ok