Skip to content

fix: resolve-paths.sh can now find a project root without CLAUDE_PROJECT_DIR - #414

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/411
Aug 28, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/411

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #411.

Codex never sets CLAUDE_PROJECT_DIR and Gemini CLI documents no hook environment variables at all, so on either host scripts/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 a cwd field on all three hosts. scripts/session-start-hook.sh and scripts/session-end-hook.sh now extract it (validated the same way transcript_path already is, since #407) and export it as REMEMBER_HOOK_CWD. resolve-paths.sh tries, in order: CLAUDE_PROJECT_DIR, then REMEMBER_HOOK_CWD (if it names a directory that exists), then the existing .claude/remember local-install derivation, then the existing loud failure. A stdin cwd disagreeing with a set CLAUDE_PROJECT_DIR never 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_SUMMARIZER guard already lived in FOUR places before this diff -- resolve-paths.sh's own copy, plus a duplicate already carried by post-tool-hook.sh, user-prompt-hook.sh, and session-end-hook.sh (each ahead of their own stdin capture or fast path, for the same reason). session-start-hook.sh was the one hook missing the pattern its three siblings already use. This PR normalizes it to match, rather than introducing a new duplication. The independent oss:auditor review confirmed this by grepping REMEMBER_NESTED_SUMMARIZER across scripts/*.sh and 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 unsetting CLAUDE_PROJECT_DIR and feeding REMEMBER_HOOK_CWD directly); they are not evidence that either host's hook populates that value the way the tests assume.

pipeline/host.py untouched. It already carried an unused CWD_VAR = "REMEMBER_HOOK_CWD" constant from #407. No host-specific table entry was needed: cwd is 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.sh and user-prompt-hook.sh (both out of this PR's scope; the former belongs to a concurrently in-flight lane) source resolve-paths.sh, which now consults REMEMBER_HOOK_CWD, but neither hook sets, unsets, or validates that variable the way session-start-hook.sh/session-end-hook.sh do. 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 file
  • tests/test_hook_cwd_end_to_end_411.py -- full hook subprocess, real stdin payload, .remember/ scaffolding location
  • tests/test_nested_summarizer.py -- all 9 existing cases still pass, including the parametrized "every registered hook" guard test
  • Full suite: 1737 passed, 43 skipped, 0 failures (one run showed a false-positive repo-mutation-guard error caused by this agent committing mid-run against its own worktree while the suite was still executing -- re-ran clean afterward)
  • python3 .oss/assemble_changelog.py --check -- ok

fdaviddpt and others added 2 commits August 28, 2026 23:30
…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]>
@fdaviddpt
fdaviddpt merged commit cc8be9c into main Aug 28, 2026
13 checks passed
@fdaviddpt
fdaviddpt deleted the fix/411 branch August 28, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resolve-paths.sh cannot resolve a project root on any host that does not set CLAUDE_PROJECT_DIR

1 participant