Repository navigation
Conversation
…EADME (#534) pipeline/host.py's GEMINI host was already corrected (#456) to read CLAUDE_PROJECT_DIR, since gemini-cli 0.57.0's own bundled docs list it as a compatibility alias Gemini sets -- but that correction was narrow and dead-code-only. The much larger "Codex and Gemini CLI never set CLAUDE_PROJECT_DIR" assumption baked into scripts/resolve-paths.sh, scripts/lib-env-cache.sh, scripts/session-end-hook.sh, scripts/post-tool-hook.sh, scripts/user-prompt-hook.sh, and README.md went untouched. The REMEMBER_HOOK_CWD fallback in resolve-paths.sh and the cache-key fallback in lib-env-cache.sh needed only corrected comments: both stay correct as fallbacks for any host that genuinely leaves CLAUDE_PROJECT_DIR unset (Codex, live-confirmed via tests/fixtures/codex-env-463.txt), and Gemini setting the variable just means priority 1 wins and the fallback is never reached on that host. scripts/user-prompt-hook.sh's UserPromptSubmit JSON-envelope branch needed an actual behavioural fix: it used to key on "is CLAUDE_PROJECT_DIR set" as a stand-in for "is this Codex", which would have silently routed a Gemini session through Codex's JSON envelope -- unverified, since Gemini CLI's own BeforeAgent stdout contract has never been observed and #532 blocks a live session. It now keys on Codex's own live-verified signature (CODEX_SESSION_ID/CODEX_THREAD_ID, the same pair pipeline/host.py's CODEX.signature_vars already uses), so the JSON envelope is Codex-only by construction and every other host, Gemini included, gets plain stdout -- a documented, defensible default, not a claim about what Gemini's own contract wants. TDD via tests/test_gemini_stdout_envelope_534.py, red on the pre-fix gate (a host with neither CLAUDE_PROJECT_DIR nor a Codex signature used to get the JSON envelope by default); tests/test_codex_upsubmit_stdout_451.py's own Codex fixture updated to set the same signature, matching a real codex exec process. README corrected everywhere it repeated the old shared-fact claim. Changelog fragment added. Co-Authored-By: Max <noreply>
The auditor spawned in self-review found that the previous commit's UserPromptSubmit JSON-envelope gate change -- keying on CODEX_SESSION_ID/CODEX_THREAD_ID instead of CLAUDE_PROJECT_DIR -- was a real regression, not an improvement: #465 already measured, live, that neither variable survives into a process Codex spawns as a HOOK, only into a Codex TOOL-SHELL command (pipeline/haiku.py's own note, tests/test_codex_signature_463.py's docstring). scripts/user-prompt-hook.sh is registered as exactly such a hook in hooks/hooks.codex.json, so the new gate would have silently disabled the JSON envelope on every real Codex UserPromptSubmit invocation and reopened #451/#452 (every Codex prompt reading Failed again). tests/fixtures/codex-env-463.txt, the fixture that pair is pinned against, was itself captured from a Codex tool-shell command, not from inside a hook. Reverted the gate to CLAUDE_PROJECT_DIR set/unset, unchanged from before this PR. That mechanism was never wrong for the behavioural question #534 was asked to settle: Gemini setting CLAUDE_PROJECT_DIR (per its own docs, unverified live) just moves Gemini into the same plain-stdout branch Claude Code already takes, which was already true before any code change here -- only the comments describing it were stale. Documented the considered-and-rejected Codex-signature alternative in scripts/user-prompt-hook.sh, README.md, and the changelog fragment, so the reasoning survives for a future reader who reaches for the same "obvious" fix. Rewrote tests/test_gemini_stdout_envelope_534.py as a positive/negative control pinning the gate's actual (unchanged) behaviour rather than a red/green story for a gate that no longer changes; reverted the CODEX_SESSION_ID/CODEX_THREAD_ID additions to tests/test_codex_upsubmit_stdout_451.py's Codex fixture, documenting why they were deliberately removed rather than left inert. Also corrected docs/reading-the-transcript-path.md, an adjacent doc the auditor's sibling Explore review found still asserting the same stale "Gemini documents no environment variables at all" claim. Co-Authored-By: Max <noreply>
…534) The auditor spawned in self-review found scripts/session-start-hook.sh:122 still asserting "only Claude Code also publishes it as CLAUDE_PROJECT_DIR" -- the same "Codex and Gemini CLI never set CLAUDE_PROJECT_DIR" shared-fact claim this issue set out to correct everywhere, left in the one hook script not named in the original file list because it was missed rather than excluded. Corrected to name Codex's own live-confirmed non-setting (#463) and Gemini CLI's own claimed compatibility alias (#456, unverified live, #532) separately, matching the sibling comment already fixed in scripts/session-end-hook.sh. 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 #534.
What was wrong
pipeline/host.py'sGEMINIhost was already corrected (#456) to readCLAUDE_PROJECT_DIRas Gemini CLI's own compatibility-alias project-dir variable, per the installed@google/gemini-cli0.57.0 package's own bundled docs -- but that correction was narrow and dead-code-only. The much larger, load-bearing "Codex and Gemini CLI never set CLAUDE_PROJECT_DIR" assumption baked intoscripts/resolve-paths.sh,scripts/lib-env-cache.sh,scripts/session-end-hook.sh,scripts/post-tool-hook.sh,scripts/user-prompt-hook.sh, and README.md went untouched.The two judgment calls
Are the
REMEMBER_HOOK_CWDfallback (resolve-paths.sh) and the cache-key fallback (lib-env-cache.sh) still correct? Yes, unchanged. Both stay correct fallbacks for any host that genuinely leavesCLAUDE_PROJECT_DIRunset -- still true of Codex, live-confirmed viatests/fixtures/codex-env-463.txt-- and Gemini setting the variable just means priority-1 resolution wins and the fallback is never reached on that host. Only the comments describing "which hosts hit this branch" were stale; fixed in every file the issue named plusscripts/session-start-hook.shanddocs/reading-the-transcript-path.md(see below).Does
scripts/user-prompt-hook.sh'sUserPromptSubmitJSON-envelope gate need a host-specific check instead of "isCLAUDE_PROJECT_DIRset"? I tried it, then rejected it during self-review, and I'm recording the rejection because the alternative looks obviously more correct at first glance and I want the next person who reaches for it to see why it isn't. The obvious replacement is Codex's own signature,CODEX_SESSION_ID/CODEX_THREAD_ID(the pairpipeline/host.py'sCODEX.signature_varsalready uses) -- and it is wrong for this call site specifically: Codex detection still fails in the hook process: the route works under an explicit override but auto resolves to claude #465 already measured, live, that neither variable survives into a process Codex spawns as a HOOK, only into a Codex TOOL-SHELL command (pipeline/haiku.py's own note;tests/test_codex_signature_463.py's docstring).scripts/user-prompt-hook.shis registered as exactly such a hook inhooks/hooks.codex.json. Gating it on that pair would have silently disabled the JSON envelope on every real CodexUserPromptSubmitinvocation and reopened Codex reports UserPromptSubmit as Failed once the hook actually produces output, because its stdout contract is not Claude Code's #451/fix: stop Codex reading UserPromptSubmit as Failed on every prompt (#451) #452 (every Codex prompt readingFailedagain) -- a regression my own first commit on this branch introduced and my self-review caught before this PR was opened. The gate stays onCLAUDE_PROJECT_DIR, unchanged: Gemini setting it now simply routes Gemini through the same plain-stdout branch Claude Code already takes, which is REASONED as the safer default (Gemini CLI's ownBeforeAgentstdout contract has never been observed live, and Gemini CLI: no working credentials in this environment -- blocks driving any live session for #456's remaining scope #532 blocks a live session), not a claim about what that contract actually wants.Self-review: one real regression caught and reverted, two adjacent stale-comment findings fixed
My first commit on this branch (now superseded within this PR) changed the JSON-envelope gate to key on
CODEX_SESSION_ID/CODEX_THREAD_ID. The auditor spawned for self-review caught that this reopens #451/#452 on real Codex, for the reason described above. I reverted the gate and rewrote the test file, README paragraphs, and changelog fragment to match. Two other findings, both stale prose in the same "Codex/Gemini never set it" family, both fixed directly (same subsystem, one-sentence blast radius, in scope):docs/reading-the-transcript-path.md:18still said "Gemini CLI documents no environment variables ... at all" inside a historical sentence about pre-resolve-paths.sh cannot resolve a project root on any host that does not set CLAUDE_PROJECT_DIR #411 behavior.scripts/session-start-hook.sh:122still said "only Claude Code also publishes it as CLAUDE_PROJECT_DIR" -- missed because it wasn't in the issue's own named file list.One item is below the bar for a filing: the auditor also flagged, as a tooling-adjacent observation rather than a diff finding, that its sibling
Explorereviewer'sReadtool result carried injected text instructing it to route reads through asupertoolop it was never granted --Explorecorrectly disregarded it and fell back tocatvia Bash. This is a below-bar observation about this loop's own tooling, not about claude-remember's code, and is recorded in the developer report underadjacentrather than as a code finding here.Tests
tests/test_gemini_stdout_envelope_534.py(new) pins both sides of the (unchanged) gate as controls: a Gemini-shaped environment gets plain stdout, and a genuinely signal-less host (noCLAUDE_PROJECT_DIR, no Codex signature) still gets the Codex JSON envelope -- so a future re-narrowing of the gate to Codex's own signature regresses visibly instead of silently.tests/test_codex_upsubmit_stdout_451.py's_env_codexfixture documents, in its own docstring, why it deliberately does not setCODEX_SESSION_ID/CODEX_THREAD_ID.Narrowed pytest run only (per this repo's own CLAUDE.md and this plugin's brief) -- the full
test_commandwas not run; CI is the gate for that.python3 .oss/assemble_changelog.py --checkpasses.