Context
A 2026-06-14 identity-drift incident showed that Codex-authored GitHub review/comment operations can stamp the wrong GitHub account when a fresh process inherits another harness environment. We verified .codex/CODEX.md is loaded into Codex turn context through .codex/hooks.json -> .codex/hooks/codex-context.mjs, and that /Users/tobiasuhlig/.zshenv selects per-agent .env files by PWD.
Live latest-open sweep: checked latest 20 open issues immediately before filing on 2026-06-14; no equivalent Codex worktree-placement rule ticket found. A2A in-flight sweep: checked latest 30 messages immediately before filing; no competing claim on this exact scope found. Local/KB sweep: exact repository search found no existing identity-sensitive Codex worktree rule, and KB surfaced .codex/CODEX.md but no worktree/.zshenv guidance.
Release classification: boardless (Codex harness hardening follow-up; not a v13 release blocker).
The Problem
Codex currently has diagnostics for GitHub identity checks, sandboxed gh behavior, and harness restarts, but it does not instruct future Codex turns where to create review/feature worktrees. Generic scratch locations such as /private/tmp/neo-* do not match the existing .zshenv per-clone cases. If a process starts there, it may keep a stale parent environment instead of re-sourcing the Codex .env.
That creates a discipline gap: an otherwise correct Codex session can inspect or operate on a Codex worktree while a fresh child process uses another agent's GH_TOKEN / NEO_AGENT_IDENTITY.
The Architectural Reality
.codex/CODEX.md is a Codex-only turn-loaded substrate file.
.codex/hooks.json registers the UserPromptSubmit hook.
.codex/hooks/codex-context.mjs reads .codex/CODEX.md and writes it into turn context.
/Users/tobiasuhlig/.zshenv maps /Users/Shared/codex/neomjs/neo/* to the Codex .env and maps other agent clone roots to their own .env files.
- Generic
/private/tmp/neo-* worktrees sit outside that mapping.
The Fix
Add a compact Runtime Notes rule to .codex/CODEX.md that:
- Directs Codex to create identity-sensitive worktrees under
/Users/Shared/codex/neomjs/neo/.codex/worktrees/ or another path beneath /Users/Shared/codex/neomjs/neo/.
- Warns against generic
/private/tmp/neo-* for work that may run gh, MCP setup, PR review/comment tools, or commits.
- Requires a cheap identity preflight after worktree/thread switches before state-changing GitHub actions:
NEO_AGENT_IDENTITY=@neo-gpt and gh api user --jq .login == neo-gpt.
Contract Ledger Matrix
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback |
Docs |
Evidence |
| Codex turn-loaded runtime notes |
.codex/CODEX.md via .codex/hooks/codex-context.mjs |
Future Codex turns use identity-mapped worktree roots for identity-sensitive work and verify identity before state-changing GitHub calls after switches. |
If a scratch path is already outside the mapped root, treat it as inspect-only until identity is verified; move/create a new mapped worktree for mutations. |
.codex/CODEX.md |
Static hook/load-path verification + shell identity check. |
Decision Record impact
none
Acceptance Criteria
Out of Scope
- No
.zshenv change in this ticket.
- No GitHub Workflow MCP fail-closed implementation.
- No rewrite of the broader incident runbook owned by
#13239.
- No cleanup of existing
/private/tmp worktrees.
Avoided Traps
- Do not map all
/private/tmp/neo-* paths to Codex; that path family is shared-looking and can contaminate other agents.
- Do not put this in global
AGENTS.md; the rule is Codex-harness-local and belongs in .codex/CODEX.md.
- Do not rely only on PR body self-identification; GitHub API author identity still comes from the token used by the posting process.
Related
Related: #13239
Origin Session ID: 4ed21ddf-b92f-45ce-8689-bb3ebb563dd9
Handoff Retrieval Hints: Codex CODEX.md worktree GH_TOKEN identity drift .zshenv private tmp; identity-sensitive worktrees; 2026-06-14 agent identity drift.
Context
A 2026-06-14 identity-drift incident showed that Codex-authored GitHub review/comment operations can stamp the wrong GitHub account when a fresh process inherits another harness environment. We verified
.codex/CODEX.mdis loaded into Codex turn context through.codex/hooks.json->.codex/hooks/codex-context.mjs, and that/Users/tobiasuhlig/.zshenvselects per-agent.envfiles byPWD.Live latest-open sweep: checked latest 20 open issues immediately before filing on 2026-06-14; no equivalent Codex worktree-placement rule ticket found. A2A in-flight sweep: checked latest 30 messages immediately before filing; no competing claim on this exact scope found. Local/KB sweep: exact repository search found no existing identity-sensitive Codex worktree rule, and KB surfaced
.codex/CODEX.mdbut no worktree/.zshenvguidance.Release classification: boardless (Codex harness hardening follow-up; not a v13 release blocker).
The Problem
Codex currently has diagnostics for GitHub identity checks, sandboxed
ghbehavior, and harness restarts, but it does not instruct future Codex turns where to create review/feature worktrees. Generic scratch locations such as/private/tmp/neo-*do not match the existing.zshenvper-clone cases. If a process starts there, it may keep a stale parent environment instead of re-sourcing the Codex.env.That creates a discipline gap: an otherwise correct Codex session can inspect or operate on a Codex worktree while a fresh child process uses another agent's
GH_TOKEN/NEO_AGENT_IDENTITY.The Architectural Reality
.codex/CODEX.mdis a Codex-only turn-loaded substrate file..codex/hooks.jsonregisters theUserPromptSubmithook..codex/hooks/codex-context.mjsreads.codex/CODEX.mdand writes it into turn context./Users/tobiasuhlig/.zshenvmaps/Users/Shared/codex/neomjs/neo/*to the Codex.envand maps other agent clone roots to their own.envfiles./private/tmp/neo-*worktrees sit outside that mapping.The Fix
Add a compact Runtime Notes rule to
.codex/CODEX.mdthat:/Users/Shared/codex/neomjs/neo/.codex/worktrees/or another path beneath/Users/Shared/codex/neomjs/neo/./private/tmp/neo-*for work that may rungh, MCP setup, PR review/comment tools, or commits.NEO_AGENT_IDENTITY=@neo-gptandgh api user --jq .login == neo-gpt.Contract Ledger Matrix
.codex/CODEX.mdvia.codex/hooks/codex-context.mjs.codex/CODEX.mdDecision Record impact
none
Acceptance Criteria
.codex/CODEX.mdcontains a concise Runtime Notes rule for identity-sensitive Codex worktree placement./private/tmp/neo-*for state-changing work.NEO_AGENT_IDENTITYandgh api user --jq .loginbefore state-changing GitHub actions after a worktree/thread switch.turn-memory-pre-flight.neo-gptGitHub identity.Out of Scope
.zshenvchange in this ticket.#13239./private/tmpworktrees.Avoided Traps
/private/tmp/neo-*paths to Codex; that path family is shared-looking and can contaminate other agents.AGENTS.md; the rule is Codex-harness-local and belongs in.codex/CODEX.md.Related
Related: #13239
Origin Session ID: 4ed21ddf-b92f-45ce-8689-bb3ebb563dd9
Handoff Retrieval Hints:
Codex CODEX.md worktree GH_TOKEN identity drift .zshenv private tmp;identity-sensitive worktrees;2026-06-14 agent identity drift.