Repository navigation
Description
Problem
A read_only stage on Codex is recorded as read_only_mode = enforced, and nothing checks afterwards that the tree is unchanged (executors.dispatch: artifacts.setdefault("read_only_mode", "enforced")). The only guarantee is codex exec -s read-only.
That sandbox governs the commands the agent runs. Tools that the host exposes through MCP servers run as separate processes that the host launches, so the argument doesn't necessarily confine them. Semantic editing servers are one example: Serena offers replace_symbol_body, insert_after_symbol, rename_symbol, and safe_delete_symbol. When such a server is configured globally for the host, a reviewer can edit the implementer's tree without any shell command.
The Claude path already handles this class of problem: _isolated_review_dispatch (merged in #74) fingerprints HEAD and git status --porcelain before and after, and turns a change into a failed stage. The Codex path trusts the flag alone.
Current behavior
- Claude
read_only: disposable clone, before/after fingerprint of the implementer checkout,read_only_mode = detected. - Codex
read_only: sandbox flag only,read_only_mode = enforced, no after-check. - Orca
read_only: explicit isolated workspace (OrcaReviewWorkspace).
Existing architecture involved
scripts/executors.py:dispatch,_isolated_review_dispatchand its fingerprint helpers,CodexAdapter.argvscripts/cycle.py:ROLE_CONTRACTSscripts/telemetry.py:read_only_mode(enforced,detected)docs/role-workspace-policy.md,docs/routing.mdWorkspace policy
Proposed behavior
The contract being protected is:
role workspace policy == read_only → mutation of the assigned workspace == forbidden
It holds whatever the source of the write: the agent's shell, an MCP server, a plugin, a host hook, an editor tool, or a subprocess any of them spawns. The check therefore observes the result (the repository state) and never the cause. It has no tool, product, or provider branches: no "if Serena…", no MCP allow-list, no per-executor exception. An executor's sandbox is defence in depth and never a reason to skip the check.
- Verify first. Confirm with a scripted MCP server whether
codex exec -s read-onlyconfines a configured MCP server's file writes. Record the result in the PR. - Either way, check after the fact. Every
read_onlydispatch on every executor (Codex, Claude, Orca, and any future adapter), reuses the existing fingerprint helpers:HEAD,git status --porcelain --untracked-files=all, and the branch ref, taken before and after on the checkout the stage was given. A difference iscontract_violationand the cycle stops, which is the existing behaviour for Claude. read_only_mode = enforcedis recorded only when the sandbox was used and the after-check found no change. A failed check drops the token, as the Claude path already does on cleanup failure.
Scope
executors.dispatch for the non-isolated read_only path, tests, and two doc paragraphs.
Non-goals
- No per-tool allow or deny lists and no detection of which MCP servers exist. The check is product-neutral.
- No change to Claude's isolated path or Orca's workspace contract.
- No change to publication, which stays behavioural (Publish through gh when it is authenticated, not through a host connector #76, Harness-side publication for credential-free Claude review stages #79).
Design constraints
- Fail closed: an unreadable fingerprint is a failed stage, not a skipped check.
- The fingerprint must ignore nothing the implementer would commit, and must not capture file contents.
- A read-only stage must not require a clean checkout just because the check exists. Compare before and after; don't demand clean.
Acceptance criteria
- A scripted Codex read-only stage that modifies a tracked file (simulating an MCP write) →
contract_violation, noenforcedtoken, the cycle stops. - A scripted Codex read-only stage that changes nothing →
enforced, unchanged behaviour. - The same mutation test passes for every adapter through one shared helper: a write by the fake agent's shell, and a write by a separate child process the fake starts (standing in for an MCP server or hook), both fail the stage.
- A code-level check: the helper takes no executor, tool, or product argument.
- An argv test still asserts
-s read-onlyand no bypass flag.
Tests / verification
tests/test_executors.py with a fake Codex binary that writes during the stage, tests/test_run_cycle.py for the stop, and the manual MCP probe from step 1.
Dependencies
None (#74 is merged).
Documentation impact
docs/role-workspace-policy.md: "enforced" means sandboxed and verified unchanged. docs/routing.md: host-configured tools are outside the sandbox guarantee.
Backwards compatibility
A stage that didn't mutate is unaffected. A stage that did will now fail; that is intended.
Suggested implementation areas
scripts/executors.py, tests/test_executors.py, tests/test_run_cycle.py, docs/role-workspace-policy.md, docs/routing.md.
Activity
[-]Verify non-mutation after every read-only dispatch, not only Claude's[/-][+]Read-only means no mutation: verify after every read-only dispatch, whatever the executor or tool[/+]fix(executors): keep asynchronous read-only checks pending and record…
fix(executors): verify a read-only stage only when it succeeded and f…
Read-only means no mutation: verify after every read-only dispatch (#91…