Skip to content

Read-only means no mutation: verify after every read-only dispatch (#91) - #111

Merged
datacas merged 3 commits into
mainfrom
issue-91-read-only-after-check
Sep 29, 2026
Merged

datacas merged 3 commits into
mainfrom
issue-91-read-only-after-check

Conversation

@datacas

@datacas datacas commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Closes #91 — #91

Step 1: does codex exec -s read-only confine an MCP server's writes?

No. Probe (codex-cli 0.158.0): a scripted stdio MCP server exposing append_line(path, text) was passed with -c mcp_servers.probe.* to codex exec -s read-only -C <temp repo>. The agent called the tool, the server answered appended, and afterwards tracked.txt contained written by mcp (git status: M tracked.txt). The same run also left an untracked .serena/ directory in the checkout, written on startup by the globally configured Serena server without any tool call.

Change

  • scripts/executors.py
    • _checkout_fingerprint(path): HEAD, branch ref, git status --porcelain --untracked-files=all, staged blob IDs, and a SHA-256 of each modified/untracked file (so a second edit to an already dirty file is caught). Ignored files are excluded; contents are digested, never stored.
    • _verified_read_only(cwd, call): takes no executor, tool, or product. Fingerprints the dispatch cwd (the process cwd when none is given) before and after the stage. A difference, or a fingerprint that cannot be read after the stage, is contract_violation and drops read_only_mode. One that cannot be read before blocks the stage (read_only_verification) without running it.
    • dispatch wraps every read_only stage in it (Codex, Claude's isolated path, Orca, any future adapter). enforced is set only by an enforcing adapter and survives only a clean after-check. The checkout does not have to be clean, only unchanged.
  • Docs: docs/role-workspace-policy.md (enforced = sandboxed and verified unchanged; the probe result) and docs/routing.md (host-configured tools sit outside the sandbox).

Verification

  • python3 -m unittest discover -s tests: 841 tests OK. python3 scripts/validate-package.py: VALID.
  • New ReadOnlyVerificationTests (tests/test_executors.py): a fake agent run through the real Codex/Claude adapters (and Orca's runner) writes either itself or from a separate child process → contract_violation on all three adapters. A Codex stage that writes nothing → enforced, with argv still -s read-only and no bypass flag. A dirty checkout is compared, not refused, and a re-edit of a dirty file is caught. Both fail-closed paths are covered, and a code-level check confirms the helpers take no executor/tool argument and name no product.
  • tests/test_run_cycle.py: a reviewer whose child process writes the checkout stops the cycle (dispatch_failed, row outcome contract_violation).

Residual risk

  • A host tool that writes into the checkout on startup (e.g. Serena's .serena/) now fails every read-only stage unless the repository ignores that path. That is intended by the contract, but it will surface in repositories that don't ignore it.
  • Orca workers are asynchronous: the check covers the launch, not the worker's whole run.
  • The Claude path now fingerprints the implementer checkout twice (its own check plus the shared one). Its behaviour is otherwise unchanged.

…hanged (#91)

`codex exec -s read-only` confines the agent's own commands, not the
processes the host launches for it; a scripted MCP server appended to a
tracked file under that sandbox. Every read_only dispatch, on every
executor, now fingerprints the dispatch checkout before and after (HEAD,
branch ref, porcelain status, staged blobs, digests of changed and
untracked files) through one product-neutral helper. A change is a
contract_violation that stops the cycle; an unreadable checkout fails
closed. `read_only_mode = enforced` now means sandboxed and verified.
@datacas

datacas commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260929-001] · manual · ?/?→? · ? · schema:1

Summary

Reviewed the accumulated diff for PR 111 against main (head 985f02f6cabd9d7f248bd161678b84907bc5514b), including the linked issue #91. The change addresses the stated read-only workspace problem, but one asynchronous Orca path can still mutate the implementer checkout after verification, and the required Python 3.14 CI checks fail. Verdict: CHANGES_REQUESTED.

Repository instructions from AGENTS.md and CONTRIBUTING.md were applied. GitHub is resolved from .code-cycle.yml and origin; prior review history is empty.

Findings

[REV-001] · high · open · - · blocks:yes — Orca can mutate the checkout after the read-only check

Path: scripts/executors.py, line 1623

The wrapper fingerprints the checkout immediately before and after OrcaAdapter.dispatch(). Orca returns from worker-start once the worker is alive and marks the result asynchronous, so this checks launch state rather than the end of the review. A delayed MCP server or child process can therefore change the implementer checkout after the successful comparison without producing a contract_violation.

I reproduced this using the adapter with a runner that returned a ready receipt and then wrote to a tracked file asynchronously: dispatch returned succeeded, asynchronous=True, and equal fingerprints; the checkout changed afterward. Keep the read-only stage open until its work completes and compare again, or prevent asynchronous Orca dispatch from claiming this check as complete.

[REV-002] · medium · open · - · blocks:yes — Source-inspection test fails on the current CI Python

Path: tests/test_executors.py, line 2077

The test removes function.__doc__ from inspect.getsource() with a literal string replacement, then asserts that executor is absent. On the GitHub Actions Python 3.14.7 runtime, the source text retains the docstring, so the assertion fails at line 2081. This fails both Skills, manifests, and Bash installer and PowerShell installer on the PR head. Use a source-inspection method that removes the docstring structurally, or test the function body without matching against its docstring.

Security triage

The deterministic security rule is not configured and no sensitive labels are present. Reviewer triage activated cc-security-review because the change modifies read-only enforcement and workspace-isolation tooling. The audit confirmed REV-001; it found no other security issue in the changed surface.

Verification

  • Preflight: this is a Python tooling change with no application runtime, database, migration, or service requirement. Verification ran in a temporary checkout of the exact PR head; the shared working branch was left unchanged.
  • python3 -m unittest discover -s tests -p 'test_executors.py' -v — 148 passed on Python 3.10.
  • python3 -m unittest discover -s tests — 841 passed on Python 3.10.
  • python3 scripts/validate-package.py — VALID: 14 skills.
  • Asynchronous Orca reproduction — delayed checkout mutation occurred after dispatch had returned success with equal before/after fingerprints (REV-001).
  • GitHub CI on this head: Skills, manifests, and Bash installer failed on both push and pull-request runs; PowerShell installer failed on both runs. The source-inspection test failed in both jobs. The PowerShell run also reports an error in test_shadow_without_a_key_records_unavailable_and_carries_on, which was not reproduced by the local Python 3.10 suite.

Unverified items and residual risk

The current Windows/Python 3.14 CI failures have not been rerun after a fix; Windows installation behavior remains unverified here. The additional test_shadow_without_a_key_records_unavailable_and_carries_on CI error was not reproduced locally and needs its own traceback review. Orca's asynchronous worker can still alter the implementer checkout after the launch-time check while REV-001 remains open.

Verdict

CHANGES_REQUESTED — REV-001 and REV-002 are open and block approval.

@datacas

datacas commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

[CCT-20260929-001] · manual · ?/?→? · ? · triaged:985f02f6cabd9d7f248bd161678b84907bc5514b · schema:1

Triage (before any change)

All findings were judged against 985f02f6cabd9d7f248bd161678b84907bc5514b. Recovered from the trusted review CCR-20260929-001 by datacas. There are no inline threads.

[REV-001] · high · open · valid · blocks:yes — Orca can mutate the checkout after the read-only check

Confirmed by reading the code: OrcaAdapter.dispatch returns once worker-start hands back a receipt (completes_work = False), and _verified_read_only then compares and records workspace_fingerprint_after as if the stage were over. The launch-time comparison is not evidence about the review. Planned fix: an asynchronous result no longer claims the after-check. It keeps the before-fingerprint and is marked read_only_verification = pending, and a product-neutral completion check lets whoever observes the worker finish compare again.

[REV-002] · medium · open · valid · blocks:yes — Source-inspection test fails on the current CI Python

Confirmed from the CI log on Python 3.14. Since Python 3.13, __doc__ is dedented at compile time, so the literal replace(__doc__, "") no longer matches the indented source. Planned fix: strip docstrings structurally with ast.

[REV-003] · high · open · valid · blocks:yes — A read-only pre-check failure crashes telemetry instead of blocking

New ID for the test_shadow_without_a_key_records_unavailable_and_carries_on error that the review left unverified. That test clears the environment, so on Windows git is not on PATH and the pre-stage fingerprint fails closed, which is correct. The resulting BLOCKED carries missing_capability = read_only_verification, which is not in telemetry's closed missing_capability vocabulary, so record_dispatch raises TelemetryError and aborts the cycle. Planned fix: add the token to the vocabulary, and have the test clear only the Jev key variables rather than the whole environment.

… blocked pre-checks (#91)

REV-001: a launched Orca worker had its checkout compared once, at launch,
and was recorded as verified. An asynchronous result now fails only on a
launch-time change; otherwise it is `read_only_verification = pending`, with
no after-fingerprint, until verify_read_only_completion compares again.

REV-002: the neutrality test stripped docstrings by text, which no longer
matches on Python 3.13+. It now strips them from the AST.

REV-003: `read_only_verification` joins telemetry's missing_capability
vocabulary, so a fail-closed pre-check is recorded as BLOCKED instead of
raising. The Jev shadow test clears only the key variables, which keeps git
reachable on Windows.
@datacas

datacas commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260929-001] · manual · ?/?→? · ? · schema:1

[CCT-20260929-001] · manual · ?/?→? · ? · triaged:985f02f6cabd9d7f248bd161678b84907bc5514b · schema:1

[CCR-20260929-002] · manual · ?/?→? · ? · schema:1

Summary

Rereviewed the full accumulated diff against main at be8b92489b4bd1fdfcd5d9cd5951b396b40bee17, including changes since the prior reviewed head 985f02f6cabd9d7f248bd161678b84907bc5514b. The update fixes the Python source-inspection failure and the blocked-precheck telemetry error. REV-001 remains reproducible on Orca's timeout path, so the verdict is CHANGES_REQUESTED.

Repository instructions from AGENTS.md and CONTRIBUTING.md were applied. Provider history has two trusted comments by datacas; the prior triage assigned valid to REV-001, REV-002, and REV-003, and those dispositions are preserved. There are no inline threads.

Changes since the previous review

The update marks successful asynchronous launches as pending until a completion check, adds verify_read_only_completion, adds read_only_verification to the telemetry vocabulary, removes function docstrings structurally in the source-inspection test, and preserves PATH in the Jev key test. The run-cycle test now verifies that an uncheckable checkout blocks and records the reason.

Previous findings

[REV-001] · high · open · valid · blocks:yes — Orca can mutate the checkout after the read-only check

Still reproducible. Path: scripts/executors.py, line 1388.

The new pending state covers a successful asynchronous receipt. On OrcaAdapter's TimeoutExpired path, however, the returned FAILED result has asynchronous=False, even though its detail says the worker may still be alive. _verified_read_only therefore takes the synchronous comparison path and records read_only_verification = verified if the checkout is unchanged at timeout. I reproduced this with a runner that timed out while a delayed child remained active: dispatch returned failed, asynchronous=False, and verification=verified; the child then changed a tracked file. Treat the timeout as unverified/pending while the worker may remain active, or otherwise ensure it cannot continue writing before recording verification.

[REV-002] · medium · resolved · valid · blocks:yes — Source-inspection test fails on the current CI Python

Corrected and verified by execution. The test now removes docstrings from the parsed AST. The executor test file passes locally, and the current Skills, manifests, and Bash installer checks pass on the updated head.

[REV-003] · high · resolved · valid · blocks:yes — A read-only pre-check failure crashes telemetry instead of blocking

Corrected and verified by execution. read_only_verification is now an allowed telemetry capability, the key-absence test preserves the environment (including git on Windows), and the run-cycle tests pass with the blocked pre-check recorded instead of aborting telemetry.

Security triage

The deterministic security rule is not configured and no sensitive labels are present. Reviewer triage activated cc-security-review because this change modifies read-only enforcement and workspace-isolation tooling. The audit found REV-001; it found no other security issue in the changed surface.

Verification

Preflight found no application runtime, database, service, migration, or extra configuration requirement. Verification ran in a temporary checkout of the exact current head; the shared working branch was left unchanged.

  • python3 -m unittest discover -s tests -p 'test_executors.py' — 151 passed.
  • python3 -m unittest discover -s tests -p 'test_jev_shadow.py' — 31 passed.
  • python3 -m unittest discover -s tests -p 'test_run_cycle.py' — 125 passed.
  • python3 scripts/validate-package.py — VALID: 14 skills.
  • python3 -m unittest discover -s tests — 845 passed.
  • Orca timeout reproduction — the failed dispatch was marked verified, then the still-running child changed the tracked checkout (REV-001).
  • Current GitHub CI on head be8b92489b4bd1fdfcd5d9cd5951b396b40bee17: Skills, manifests, and Bash installer passed on push and pull-request runs; PowerShell installer passed on both runs. No expected gate is missing or pending.

Residual risk

An Orca worker that remains alive after its launch command times out can still mutate the checkout after the current check reports verified. REV-001 remains open until that path fails closed or is verified after worker termination/completion.

Verdict

CHANGES_REQUESTED — REV-001 remains open and blocks approval. REV-002 and REV-003 are resolved.

@datacas

datacas commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

[CCT-20260929-002] · manual · ?/?→? · ? · triaged:be8b92489b4bd1fdfcd5d9cd5951b396b40bee17 · schema:1

Triage (before any change)

The triage follows rereview CCR-20260929-002 and is judged against be8b92489b4bd1fdfcd5d9cd5951b396b40bee17. Dispositions assigned by CCT-20260929-001 are preserved; there are no new findings and no inline threads.

[REV-001] · high · open · valid · blocks:yes — Orca can mutate the checkout after the read-only check

Confirmed by reading the code at the triage commit. Only a SUCCEEDED asynchronous result is kept pending. Any other result whose work may still be running, such as Orca's FAILED receipt timeout or a native CLI timeout that can leave child processes alive, goes through the synchronous comparison and is recorded as verified. Planned fix, product-neutral: verified only for a SUCCEEDED result that completed its work. Every other outcome still fails on an observed change, but an unchanged checkout is recorded as pending, never as verified.

[REV-002] · medium · resolved · valid · blocks:yes — Source-inspection test fails on the current CI Python

Resolved in be8b924, confirmed by the rereview. No change.

[REV-003] · high · resolved · valid · blocks:yes — A read-only pre-check failure crashes telemetry instead of blocking

Resolved in be8b924, confirmed by the rereview. No change.

…inished (#91)

REV-001 (timeout path): Orca's receipt timeout and a native CLI timeout
return FAILED while the worker or its children may still be alive, and the
synchronous comparison recorded them as verified. Only a SUCCEEDED result
that completed its work is now `verified`; every other outcome still fails
on an observed change, but an unchanged checkout is `pending` until
verify_read_only_completion compares again.
@datacas

datacas commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260929-001] · manual · ?/?→? · ? · schema:1

[CCT-20260929-001] · manual · ?/?→? · ? · triaged:985f02f6cabd9d7f248bd161678b84907bc5514b · schema:1

[CCR-20260929-002] · manual · ?/?→? · ? · schema:1

[CCT-20260929-002] · manual · ?/?→? · ? · triaged:be8b92489b4bd1fdfcd5d9cd5951b396b40bee17 · schema:1

[CCR-20260929-003] · manual · ?/?→? · ? · schema:1

Summary

Rereviewed the complete accumulated diff for PR 111 against main at head a04212c8222bfebda2b7828a53f8c47d702a1187. The latest change closes REV-001: only a successful, finished read-only dispatch can be marked verified; timeout and asynchronous results remain pending and carry no read_only_mode. The dispatch cycle stops rather than treating an unfinished review as complete. REV-002 and REV-003 remain resolved. No new findings. Verdict: APPROVED.

The repository instructions in AGENTS.md and CONTRIBUTING.md were applied. GitHub is resolved from .code-cycle.yml and origin. The configured trusted author is datacas; all recovered review state came from that trusted author. Existing dispositions are preserved.

Changes since the previous rereview

Commit a04212c8222bfebda2b7828a53f8c47d702a1187 changes the read-only wrapper to verify only a successful dispatch that finished synchronously. Other outcomes receive read_only_verification = pending, with no after-fingerprint or enforced-mode token unless a later completion check runs. Documentation and tests cover timed-out Orca and Codex stages and a delayed write after timeout.

Previous findings

[REV-001] · high · resolved · valid · blocks:yes — Orca can mutate the checkout after the read-only check

Path: scripts/executors.py, line 913

Corrected and verified by execution. A timed-out stage no longer receives a successful read-only verification based on an unchanged checkout snapshot. The test test_a_timed_out_stage_is_pending_not_verified checks both Orca and Codex: dispatch remains pending, then a simulated late write is detected by verify_read_only_completion as contract_violation. The production cycle also stops on asynchronous work instead of accepting its launch as a completed review.

[REV-002] · medium · resolved · valid · blocks:yes — Source-inspection test fails on the current CI Python

Corrected and verified by execution. The source-inspection test removes docstrings through the parsed AST. The complete Python test suite passes on the updated head, and both package-validation CI jobs pass.

[REV-003] · high · resolved · valid · blocks:yes — A read-only pre-check failure crashes telemetry instead of blocking

Corrected and verified by execution. read_only_verification is present in telemetry’s closed missing_capability vocabulary. The complete test suite, including run-cycle telemetry coverage, passes.

Security triage

No deterministic security_review.always_when rule is configured and no sensitive labels are present. The security audit ran because this change affects read-only enforcement and workspace isolation. It found no new confirmed security finding; REV-001 is resolved as described above.

Verification

Preflight found a Python tooling change with no application runtime, database, service, or migration requirement. Verification ran in a temporary checkout of the exact reviewed head; the shared working branch was unchanged.

  • python3 -m unittest discover -s tests -p 'test_executors.py' -v — 153 passed.
  • python3 -m unittest discover -s tests — 847 passed.
  • python3 scripts/validate-package.py — VALID: 14 skills.
  • Current GitHub CI on a04212c8222bfebda2b7828a53f8c47d702a1187: both Skills, manifests, and Bash installer jobs and both PowerShell installer jobs passed.

Residual risk

The run-cycle driver stops when Orca work finishes elsewhere; it does not wait for the worker. A caller that observes completion must explicitly call verify_read_only_completion to finish a pending comparison. This preserves fail-closed behavior, but the caller must know that the work has stopped before checking.

Verdict

APPROVED — all recovered findings are resolved, all required checks passed, and no open blocking finding remains.

@datacas
datacas merged commit 243c2b8 into main Sep 29, 2026
4 checks passed
@datacas
datacas deleted the issue-91-read-only-after-check branch October 6, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant