Repository navigation
Description
Summary
Codex did not reliably follow an explicit repository release procedure from a detailed AGENTS.md / release document, then its PreToolUse hook received the supervisor workspace as cwd instead of the command's effective workdir. Together, that blocked the canonical release command and encouraged an incorrect fallback.
This is a report about agent execution and hook-context fidelity, not a request to change a third-party tool.
Observed behavior
- The repository documented one canonical release command for a versioned environment package. It also documented two mutually exclusive delivery channels: a Git/bare-hub slipstream path and an npm-installed-package path.
- Codex was run in a supervisor workspace but invoked the canonical command with a different explicit
workdir(the environment package worktree). - The Codex PreToolUse payload continued to identify the supervisor workspace as
cwd. - A repository guard that correctly checks completion claims against the repository being shipped therefore judged the canonical release as a foreign claim and included unrelated dirty files from the supervisor workspace.
- Instead of stopping and reporting the guard-context defect, Codex selected an alternate land command. That command landed Git but did not perform the documented publish/install transaction.
- Codex then incorrectly tried direct npm installation even though the docs stated the active target was a bare-hub slipstream. The correct sequence was only followed after an operator correction.
Expected behavior
- A command launched with an explicit workdir should expose that effective workdir to every Codex hook, or expose it separately and unambiguously from the session workspace.
- Before a release/deploy/publish action, Codex should give explicit repository instructions higher priority than inferred topology or a convenient alternate command.
- When a guard blocks the documented canonical operation because execution context is inconsistent, Codex should surface that mismatch and stop. It should not select a fallback whose release semantics differ.
- Codex should make the repository/worktree it believes a command affects visible in the action trace, so a human can detect a context mismatch before an external change.
Minimal reproduction shape
- Start Codex in workspace
Awith a PreToolUse hook that consumescwdand gates a release command against a work contract for repositoryB. - Execute a release command with the tool
workdirset to repositoryB. - Observe that the hook receives
cwd=Arather thancwd=B. - The guard misclassifies the release as foreign or associates it with unrelated dirty state in
A.
Why this matters
The repository instructions were unusually explicit and structurally sound. The failure was not a missing instruction or operator error. A system that accepts repository-level procedures but can silently substitute a different workspace context at hook time makes guarded release workflows unreliable: the safe path is blocked and a less-safe path appears available.
Requested outcome
- Preserve the effective tool workdir in hook payloads.
- Add an integration test for a session workspace different from the tool workdir.
- Add an agent-side guardrail: if an explicit documented release command is blocked by a workspace/context mismatch, report that mismatch rather than choosing a semantically different release command.
Activity
aetherxeg-source commentedon Oct 2, 2026
One execution-integrity boundary that seems useful to make explicit here is:
session workspace != effective execution workdirA hook that authorizes, blocks, or attributes a command needs the context that actually governs that execution, not merely the workspace that owns the chat/session. Otherwise the hook can be internally consistent while evaluating the wrong repository state.
I would keep at least three identities separate in the hook/event model:
Conceptually:
tool request -> resolve execution context -> hook decision bound to that context -> executerather than:
session context -> hook decision -> execute somewhere else.The important part is binding the hook verdict to the same resolved context the executor will consume. If path resolution, symlinks, worktrees, containers, or another indirection can change the effective target after the hook runs, the verdict should carry a context/generation identity and be rejected if execution resolves differently.
A compact invariant is:
approved context == executed contextnot just “the hook received a cwd field.”
A useful regression matrix would cover: session A/tool workdir B, two worktrees of the same repository, a symlinked workdir, and a workdir that disappears/rebinds between hook evaluation and process start. The last case should fail closed rather than silently applying a verdict produced for a different execution target.
For auditability I would also expose both
sessionCwdandeffectiveWorkdirwhen they differ, instead of overloading onecwdfield. That makes context substitution visible to hooks and to later execution evidence.aetherxeg-source commentedon Oct 2, 2026
A hook-context integrity invariant here is:
policy evaluation context must equal effect execution contextIf the command executes in repository B while the PreToolUse guard evaluates
cwd=A, the guard is authorizing/refusing a different subject from the one that will receive the effect. That is stronger than a convenience bug: the evidence used for the policy decision is misbound.I would carry both identities explicitly:
session_workspace + effective_tool_workdir + command/effect identity + hook evaluation generationand require release/deploy guards to bind to the effective tool workdir. The session workspace can still be useful provenance, but it should never silently substitute for the execution target.
A useful adversarial test is a session rooted at A with unrelated dirty files, a release command executed with
workdir=B, and conflicting release policies in A/B. The hook must evaluate B's authoritative instructions/state and the trace must show B as the effect subject. Then reverse the case to ensure a command actually targeting A does not inherit B's authority.Also worth testing a symlink/renamed worktree case so lexical path equality is not mistaken for repository identity. The final release decision should bind to the canonical execution subject that the tool will mutate, not merely to whichever workspace opened the chat.
vladzdev commentedon Oct 15, 2026
It would help to expose the session working directory and effective tool workdir as separate fields. Hooks need the latter for repository-scoped checks. I'd add a regression test where the session starts in repo A but a command explicitly targets repo B.
check/hooks: resolve a path argument the way the filesystem does (#201)…