Repository navigation
fix(#750,#751,#776): refuse tracked handoff targets; widen Codex child-env allowlist; route subdirectory-project handoffs correctly - #789
Conversation
…d-env allowlist; route subdirectory-project handoffs correctly #750: write-handoff.sh now refuses to overwrite a target the repository's own git index tracks, mirroring the read-side injection guard (#721) so a tracked remember.md is never silently overwritten and reported as success. #751: the nested Codex summarizer's child-env allow-list is widened to include Windows process variables (SYSTEMROOT/USERPROFILE/APPDATA/PATHEXT) and, on every platform, CODEX_API_KEY and the standard proxy/CA variables. #776: write-handoff.sh disambiguates a repository-subdirectory project from a stale-cwd `cd` using this session's own published handoff hint (#738), so a project deliberately started from a repo subdirectory is routed to its own store instead of the enclosing repository's root. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Review: this PR is currently red on Root cause (reasoned from the diff, not just the log): Decision: needs-fix, not merged. The three below-bar self-review findings already in the PR body (composite subdirectory-project routing, trial-resolution failure signalling, incidental log-line side effect) are read and their reasoning holds -- no disagreement with any of those three. |
…g a Windows-only CI failure PR #789's own CI went red on windows-latest only: a new #751 test asserted `env.get("https_proxy")` after also setting `HTTPS_PROXY` in the same run. CPython's os.py folds every os.environ key to uppercase on `nt`, at process-startup time (`_createenviron`'s encodekey = str.upper, applied while building the initial dict from the inherited environment) -- so the two setenv calls collapsed to one real variable there, and the plain, case-sensitive dict `_codex_child_env()` returns never carried a literal "https_proxy" key to begin with. Production was never broken: the already-listed uppercase allow-list entry passed the value through correctly regardless of which case a real Windows host set it under. Only the test's assumption -- that a specific key casing survives a platform that does not preserve it -- was wrong. Fixed by: - matching the codex child-env allow-list case-insensitively against the real os.environ (pipeline/haiku.py), removing the need to enumerate both cases of the proxy names as separate allow-list entries - splitting the proxy/CA test into one that sets uppercase-only names and one that sets lowercase-only names, never both together, checked via a case-insensitive helper against the output -- and a new test that simulates a real Windows-folded os.environ directly, so the shape of the bug is pinned even without a Windows runner Verified: reverting only the matching-logic change reproduces the failure locally (1 failed) without needing Windows; restoring it is green. Full targeted suite (test_summarizer_sandbox_724, test_write_handoff_*, test_handoff_per_session_pointer_738, test_injection_guard_754_755_756, test_locale_ranges_695, test_windows_skip_triage_497): 55 passed. Co-Authored-By: Claude Sonnet 5 <[email protected]>
What each fix does
release-audit: write-handoff.sh writes into the tracked handoff file the #721 guard is meant to protect, and reports success (fails-to-preserve, non-blocking) #750:
scripts/write-handoff.shhad no check against the repository's own git index before writing a handoff note, so it could silently overwrite a tracked file and report success, causing the next SessionStart to falsely refuse to show the operator their own note. Fix: sourcescripts/lib-memory-context.sh(new) and, before writing, call_remember_file_tracked_state_intoon the resolved target, refusing (nonzero exit,REFUSED:on stderr, no write) when the state istrackedorunavailable.release-audit: Codex child-env allowlist has no Windows branch and drops proxy/API-key credentials on every platform (fails-to-preserve, non-blocking, reasoned not observed) #751:
pipeline/haiku.py's_CODEX_CHILD_ENV_ALLOWwas missing Windows process variables (SYSTEMROOT, USERPROFILE, APPDATA, PATHEXT) and, on every platform, CODEX_API_KEY and standard proxy/CA variables. Fix: widen the allowlist unconditionally -- no platform branch needed, since the dict comprehension in_codex_child_env()only passes through a name also set in the realos.environ, so the Windows names are inert on POSIX.write-handoff.sh's git-root fallback (#743) conflicts with subdirectory-project support (#754), sending handoffs to the wrong store #776:
write-handoff.sh's git-toplevel fallback (release-audit: write-handoff.sh roots resolution at stale PWD when CLAUDE_PROJECT_DIR is unset, notes land where SessionStart never reads them (fails-to-preserve, observed in scratch) #743) broke a project deliberately started from a repository subdirectory, always routing writes to the enclosing repo's root store instead of the subdirectory project's own. Fix: when$PWDand the git toplevel disagree and the session's own sanitized id is known, trial-resolve REMEMBER_DIR for both candidates and prefer whichever candidate's store already carries this session's session-keyed handoff hint file; fall back to the old git-toplevel preference, unchanged, when neither or both do.Closes #750, Closes #751, Closes #776
TDD evidence (red then green, separately, for each issue)
#750 (
tests/test_write_handoff_tracked_target_750.py, 2 tests): red (fix reverted viagit stash) --1 failed, 1 passed(script exited 0 and overwrote the tracked file); green --2 passed.#751 (additions to
tests/test_summarizer_sandbox_724.py, 4 new tests): red --3 failed, 9 passed(three new positive-assertion tests failed,env.get(...)wasNone); green --12 passed.#776 (
tests/test_write_handoff_subdirectory_project_776.py, 2 tests): red --1 failed, 1 passed(note landed at the enclosing repo's store, not the subdirectory project's); green --2 passed.Combined targeted run after all fixes restored:
53 passed.Adjacent finding, fixed in this commit
Moving
_WH_SESSION_ID's computation earlier inscripts/write-handoff.sh(for #776) shifted the line number of a pre-existingcasepattern thattests/test_locale_ranges_695.py's allowlist exempts by file+line-number, going stale. Fixed by updating the allowlist entry to its new line in this same commit.Self-review: three below-bar findings (non-blocking, fails-to-preserve)
Two reviewers (Explore, oss:auditor) were spawned against the committed diff. All three findings below are judged below the intake bar -- narrow, reachable only in edge-case compositions, and never regressing behavior below what shipped before this commit.
Composite subdirectory-project + deeper mid-call cd is not disambiguated. The write-handoff.sh's git-root fallback (#743) conflicts with subdirectory-project support (#754), sending handoffs to the wrong store #776 fix only trials exactly two candidates ($PWD and the git toplevel). If a project is genuinely rooted at
repo/pkgbut the model thencds deeper still (e.g.repo/pkg/deeper) before running/remember, neither trial's store carries the session hint, and the code falls through to the pre-write-handoff.sh's git-root fallback (#743) conflicts with subdirectory-project support (#754), sending handoffs to the wrong store #776 default (git toplevel) -- misrouting the note one directory level deeper than write-handoff.sh's git-root fallback (#743) conflicts with subdirectory-project support (#754), sending handoffs to the wrong store #776 itself. Not a regression: pre-write-handoff.sh's git-root fallback (#743) conflicts with subdirectory-project support (#754), sending handoffs to the wrong store #776, this exact composite scenario already always went to the git toplevel, identically. Reasoned, not executed. A full fix would generalize the two-candidate trial into an ancestor walk from $PWD up to the git toplevel, meaningfully widening this diff's scope for a non-blocking gap.Trial-resolution failure is indistinguishable from "no hint" in the write-handoff.sh's git-root fallback (#743) conflicts with subdirectory-project support (#754), sending handoffs to the wrong store #776 disambiguation.
_wh_trial_remember_direxits nonzero and prints nothing both when a candidate's store genuinely lacks the session hint AND when the resolve-paths.sh/lib-memory-dir.sh chain itself fails for that candidate. The caller only tests for a non-empty result, so a transient failure on the$PWDtrial silently reproduces the write-handoff.sh's git-root fallback (#743) conflicts with subdirectory-project support (#754), sending handoffs to the wrong store #776 bug with a success message, never a refusal. Reasoned via code reading. At worst reproduces the pre-fix behavior, never something worse; a real fix needs three-state signalling (present / absent / could-not-tell), which is non-blocking here.Incidental log-line side effect via resolve-paths.sh's failure path.
_resolve_paths_failcan append a line to a.remember/logs/memory-*.logfile when the log directory exists, reachable in principle from inside a trial subshell. The auditor could not construct a scenario where this actually fires, since both trial candidates are always real, existing directories. Effectively a non-finding, included for completeness.Docs
README.mdchecked (grepped for write-handoff, codex, subdirectory): no-change-needed -- none of these three fixes changes documented, user-facing behavior described there.[AI-generated]