Skip to content

Read-only means no mutation: verify after every read-only dispatch, whatever the executor or tool #91

Closed

Description

@datacas

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_dispatch and its fingerprint helpers, CodexAdapter.argv
  • scripts/cycle.py: ROLE_CONTRACTS
  • scripts/telemetry.py: read_only_mode (enforced, detected)
  • docs/role-workspace-policy.md, docs/routing.md Workspace 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.

  1. Verify first. Confirm with a scripted MCP server whether codex exec -s read-only confines a configured MCP server's file writes. Record the result in the PR.
  2. Either way, check after the fact. Every read_only dispatch 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 is contract_violation and the cycle stops, which is the existing behaviour for Claude.
  3. read_only_mode = enforced is 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

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, no enforced token, 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-only and 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

  1. changed the title [-]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[/+] on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions