Repository navigation
Merged
Conversation
…validated #469: scripts/lib-env-cache.sh keyed its cache file on the raw CLAUDE_PROJECT_DIR, which Codex and Gemini CLI never set -- resolve-paths.sh exports the RESOLVED value only after a full slow-path run, so a cache was written on every invocation on those hosts and never found by a fresh process reading it before that export exists. _remember_env_cache_path now falls back to REMEMBER_HOOK_CWD (the same fallback #411/#444 already gave every hook), and the load-side identity check and publish-side guard/record now compare against that same fallback-aware key. #471: scripts/resolve-paths.sh accepted PLUGIN_ROOT/CLAUDE_PLUGIN_ROOT with only [ -d ], four lines above a sibling branch that already checks for pipeline/haiku.py. An unrelated directory merely named by the generic PLUGIN_ROOT var could become this plugin's execution root. Now validated the same way, with a fallthrough to CLAUDE_PLUGIN_ROOT on a PLUGIN_ROOT collision. tests/test_host_shell_parity_407.py's alias test, which used to pin an empty directory as accepted, is updated deliberately to build a real plugin install. Three pre-existing test fixtures (test_post_tool_hook_stdin_size.py, test_staging_growth_warning_349.py, test_staging_lock_missing_log_dependency_394.py) built a fake CLAUDE_PLUGIN_ROOT with no pipeline/haiku.py; given a stub/symlink so the new #471 validation does not break them. Co-Authored-By: Max <noreply>
Self-review finding on the #469/#471 commit: _remember_env_cache_path was recomputed on every call, so a publish call made after resolve-paths.sh had already normalised and exported CLAUDE_PROJECT_DIR (Windows/Git-Bash drive-letter rewriting) would key the cache under that normalised string -- a different one than the raw REMEMBER_HOOK_CWD an earlier _remember_env_cache_load call in the same process had already keyed on. Write and read would still never agree, just relocated to Windows instead of Codex/Gemini's absent CLAUDE_PROJECT_DIR. The key is now pinned once per process (resolve-paths.sh only resolves once per hook invocation, so this is safe): once _REMEMBER_ENV_CACHE_KEY is set, later calls in the same process reuse it instead of asking the environment again. Reproduced and verified genuinely red on the pre-pin code by forcing OSTYPE=msys, which runs the real drive-letter-rewriting branch of _remember_normalize_win_path regardless of host OS -- the same technique tests/test_windows_native_hook_cwd_448.py already uses. Co-Authored-By: Max <noreply>
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 #469
Closes #471
Two non-blocking findings from the v0.24.0 round-1 release audit.
#469 -- the #227 env-cache fast path was permanently dead on Codex and Gemini CLI.
scripts/lib-env-cache.sh's_remember_env_cache_pathkeyed the cache file on the rawCLAUDE_PROJECT_DIR, which neither host ever sets:resolve-paths.sh:270exports theresolved value only after a full slow-path run, so on those hosts a cache was written on
every invocation and never found by
_remember_env_cache_load, which runs in a freshprocess before that export exists. Written every time, hit never -- so every prompt and
every tool call took the full
resolve-paths.sh->bootstrap-dirs.sh->log.shchain,on a hook whose own header says a non-zero exit blocks the prompt and erases what the user
typed.
The key now falls back to
REMEMBER_HOOK_CWD(the same fallback #411/#444 already gaveevery hook from its own stdin
cwd) whenCLAUDE_PROJECT_DIRis unset, and the load-sideidentity cross-check and publish-side guard compare against that same fallback-aware key.
A self-review pass found a second half: the key was recomputed per call, so a publish made
after
resolve-paths.shhad normalised and exportedCLAUDE_PROJECT_DIR(Windows/Git-Bashdrive-letter rewriting) keyed under the normalised string while an earlier load in the same
process had keyed on the raw one -- the same never-agree bug relocated to Windows. The key
is pinned once per process in the second commit. Reproduced genuinely red on the pre-pin
code by forcing
OSTYPE=msys, the techniquetests/test_windows_native_hook_cwd_448.pyalready uses.
#471 --
PLUGIN_ROOTwas accepted with only a directory-exists check. Four lines belowa sibling branch that already checks for a specific marker file. An unrelated directory that
merely happens to be named by that generic, unnamespaced variable became the directory this
plugin loads and executes from --
PIPELINE_DIRis thepython3 -m pipeline.shellimportroot, the source of
scripts/log.sh, the executablescripts/save-session.shand thehooks.ddispatch root. Now validated with the samepipeline/haiku.pymarker check,falling through to
CLAUDE_PLUGIN_ROOTon failure, which turns a name collision into afallback rather than a wrong execution root. #407's precedence order is unchanged.
Tests.
tests/test_env_cache_hook_cwd_key_469.py(274 lines) andtests/test_plugin_root_validated_471.py(135 lines), both written against the old code andwatched fail first.
tests/test_host_shell_parity_407.py's alias test used to pin an emptyCLAUDE_PLUGIN_ROOTas accepted -- exactly the gap #471 closes -- so it now builds adirectory that actually looks like a plugin install. Three pre-existing fixtures built a fake
plugin root with no
pipeline/haiku.py; each is given a stub so the new validation does notbreak them.
Platform. The #469 Windows half is reasoned, plus a forced-
OSTYPEreproduction onmacOS; it is not observed on a real Windows box. The CI matrix is what will observe it.