Skip to content

Isolate direct Orca review dispatches - #24

Merged
datacas merged 2 commits into
mainfrom
issue-21-isolate-orca-review-dispatches
Sep 22, 2026
Merged

datacas merged 2 commits into
mainfrom
issue-21-isolate-orca-review-dispatches

Conversation

@datacas

@datacas datacas commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Closes #21. Adds an explicit Orca review workspace contract requiring an immutable or disposable workspace separate from the implementer tree. Direct and generic fallback dispatches fail closed without it and launch reviews in the isolated workspace. Tests: 441 unit tests, package validator, compileall, and git diff --check.

@datacas

datacas commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260922-006] · manual_reviewer · anthropic/claude-opus-5→? · high · schema:1

Executive summary

CHANGES_REQUESTED. The change is the right shape: it closes the Orca half of
PR #17's REV-001 by making the review workspace an explicit, validated argument
instead of an assumption, it fails closed in both the direct and the generic
path, and it records the workspace in the dispatch artifacts where an auditor
can see it. The tests are real tests — they assert on the argv and the cwd the
worker actually received, not on the adapter's own summary.

The blocking problem is that the separation check is an equality check. A
workspace that contains the implementer's tree, or one nested inside it,
satisfies path != implementer_path and is accepted, so the contract admits
exactly the arrangement it exists to forbid. That is verified at runtime below,
not inferred from reading.

Reviewed scope

  • Base main at 54e1ee056737e05dd59a4a97c7113ee6d1421e2a, head
    9cfde833ed4637d8fda7a58bca755da12736a76d, accumulated diff from the
    merge-base (not the last commit alone).
  • scripts/executors.py (+67 −3), tests/test_executors.py (+90 −7).
  • Not a draft, no labels, one commit.

Findings

[REV-001] · high · open · - · blocks:yes — The isolation check compares paths for equality, so a containing or nested workspace passes

scripts/executors.py:106-108

OrcaReviewWorkspace.__post_init__ rejects only the case where the two
canonical paths are equal. Containment is never tested, so both of these are
accepted and launch a worker:

  • path="/repo", implementer_path="/repo/implementer" — the review workspace
    is the parent directory that holds the implementer's tree;
  • path="/repo/implementer/.review", implementer_path="/repo/implementer" —
    the review workspace is inside the implementer's tree.

Observed, with the adapter's own dispatch path and a stubbed runner:

== A2: review workspace is the PARENT that CONTAINS the implementer tree ==
  ACCEPTED -> /repo contains /repo/implementer
== A3: the nested workspace actually launches a worker ==
  outcome: succeeded | worker cwd: /repo
  worktree arg: path:/repo

The worker is started with --worktree path:/repo and cwd=/repo, which hands
the reviewer the implementer's tree inside its own workspace. The class
docstring states the workspace must be "explicitly separate from the
implementer's tree" and that "this contract verifies the separation"; for these
two arrangements it does not. This is the property issue #21 and PR #17's
REV-001 are about, so the guarantee the PR advertises is not the guarantee it
enforces.

The fix is a containment test on the canonical paths in both directions, plus a
test for each direction — the current suite only covers the equal-paths case
(test_a_review_workspace_cannot_be_the_implementer_workspace), which is the
one arrangement nobody would write by accident.

Note that _canonical_path does handle the spellings it was built for: a
trailing slash is correctly refused, and resolve() collapses .. and
symlinks. The gap is specifically containment, not normalisation.

[REV-002] · medium · open · - · blocks:no — docs/instrumentation.md still states the opposite of what the code now does

docs/instrumentation.md:511-518

The design document says review dispatch is confined to Codex and that a
non-enforcing adapter "is blocked before it starts", then:

If Codex is unavailable, a review blocks instead of silently falling back to
Claude or Orca without a proven read-only workspace. [...] any future
fallback must first provide an immutable or otherwise enforced non-mutating
workspace.

This PR is that future fallback: OrcaAdapter.enforces_read_only is now
True and Orca passes the generic gate. The paragraph now describes a boundary
the code no longer has. docs/instrumentation.md:351 likewise enumerates what
OrcaDispatchContext takes without the new review_workspace field, and
CHANGELOG.md has no Unreleased entry although the change adds two new
BLOCKED capability names (review_workspace_isolation,
review_workspace_mismatch) that callers can observe.

The precedent is in this file's own history: db40fc6, which introduced
enforces_read_only, updated docs/instrumentation.md and
skills/cc-orchestrator/SKILL.md in the same commit. A security-boundary
document that contradicts the code is how the boundary gets relaxed again by
someone reading only the document.

[REV-003] · medium · open · - · blocks:no — enforces_read_only = True is a class-level claim backed only by a caller-supplied string

scripts/executors.py:650-653

The generic gate at scripts/executors.py:907 reads adapter.enforces_read_only
as a security property — its comment calls writes=False "a security boundary,
not a hint". Codex earns that flag with -s read-only, which the sandbox
enforces. Orca now carries the same flag on the strength of isolation, a field
that is accepted verbatim: nothing checks that the directory exists, that it is
a distinct git worktree, or that it is in any way immutable or disposable. A
caller who writes isolation="immutable" over an ordinary read-write checkout
gets a passing dispatch.

The class docstring is honest that the caller declares this ("The caller
prepares that workspace and declares whether it is immutable or disposable"),
and the fail-closed behaviour is a genuine improvement over the previous silent
sharing. The concern is the asymmetry: one flag now means two different
strengths of evidence, and enforces_read_only is the name a future adapter
author will copy. Either the flag should distinguish enforced from declared, or
the constructor should verify what it can — that the path exists and is a
separate worktree — so the declaration is not the only thing standing between a
review and a writable tree. Combined with REV-001 this is what makes that
finding reachable rather than theoretical.

[REV-004] · low · open · - · blocks:no — A declared review workspace is silently discarded when writes=True

scripts/executors.py:692, scripts/executors.py:718

The whole workspace block is inside if not writes:, so a context that carries
a review_workspace on a writing dispatch has it ignored: the worker runs in
cwd, and artifacts["reviewWorkspace"] is absent. Observed:

== C: writes=True silently ignores a declared review workspace ==
  outcome: succeeded | worker cwd: /repo/implementer | reviewWorkspace recorded: False

A context that declares an isolated review workspace and asks for write
permission is contradictory input. Resolving it silently in favour of the
writable tree is the more dangerous of the two readings, and it leaves no trace
in the artifacts that the declaration was dropped. Refusing it, or at least
recording it, matches how the rest of this module treats a request it must not
serve.

[REV-005] · low · open · - · blocks:no — The review_workspace_mismatch check is skipped entirely when cwd is None

scripts/executors.py:700-706

The cross-check that cwd identifies the declared implementer_path is guarded
by cwd is not None. When a caller passes no cwd, implementer_path is never
compared against anything, so it can name an unrelated tree and the dispatch
still succeeds:

== D: review with cwd=None skips the mismatch check entirely ==
  outcome: succeeded | worker cwd: /repo/review

Here implementer_path="/somewhere/else" went unverified and was recorded into
artifacts["reviewWorkspace"] as though it had been checked. The declared
contract goes unverified in exactly the case where the caller supplied the least
information, and the artifact then reports a relationship nobody established.

Security triage and audit

Sensitive change: the security audit was performed. The diff modifies an
authorization boundary — the read-only enforcement gate that decides whether a
review stage may mutate the tree it is judging — which is a trigger under both
this skill's default list and the area the repository's own history treats as
security-relevant (PR #17, REV-001).

Audit result, scoped to the change and its trust boundaries:

  • Fails closed on the direct path. OrcaAdapter.dispatch blocks with
    review_workspace_isolation when a non-writing dispatch arrives without a
    workspace, including for callers that never go through the generic
    dispatch() gate. Verified by
    test_a_review_requires_an_explicit_isolated_workspace, whose runner calls
    self.fail — the worker provably does not start.
  • No privilege escalation in the argv. --worktree path:<...> is the only
    new argument; no bypass, trust or full-access flag is introduced. The
    worktree value is passed both as the flag and as the subprocess cwd, which
    is consistent.
  • No secret, credential or network surface is touched.
  • The residual weakness is the containment gap in REV-001, which lets a
    caller satisfy the check with a workspace that encloses the implementer's
    tree. That is an isolation failure, not an escalation: it requires a caller
    that constructs the contract wrongly, and it cannot be reached from untrusted
    input, since OrcaReviewWorkspace is built in code and no caller in
    scripts/ constructs one yet.

Commands executed and observed results

Command Result
python3 scripts/validate-package.py VALID: 12 skills (6 cycle, 6 supporting), shared sections in sync, cross-agent manifests aligned
python3 -m unittest discover -s tests Ran 441 tests in 9.358s — OK
python3 -m unittest tests.test_executors -v 104 tests, all ok
python3 -m compileall -q scripts/ clean
git diff --check <merge-base> HEAD clean
Targeted repro of REV-001, REV-004, REV-005 reproduced, output quoted in each finding

The findings above were validated by execution, not by inspection alone: each
one was driven through OrcaAdapter.dispatch with a stubbed runner that records
the argv and cwd the worker would have received. Preflight succeeded —
Python 3.10.12, no service or database dependency, no port ownership involved.

Unverified items

  • Real Orca behaviour. Every observation here uses a stubbed runner. That
    orca-ide orchestration worker-start --worktree path:<...> actually confines
    the worker to that directory is assumed from the CLI contract, never observed.
    The adapter's docstring is candid that Orca "does not offer a trustworthy
    read-only permission flag", so the isolation ultimately rests on the
    workspace, which makes REV-001 the load-bearing check.
  • Whether immutable and disposable mean anything operationally. No
    caller in scripts/ constructs an OrcaReviewWorkspace, so the end-to-end
    behaviour of a real review dispatch through Orca is exercised nowhere, by this
    PR or by the suite.
  • Windows path semantics. _canonical_path was exercised on Linux only. CI
    runs the validator on Windows, but not this comparison.

CI and expected gates

All four check runs on the head commit passed; gh pr checks 24 reports
Passed: 4, Failed: 0, exit 0.

Check Workflow State
Skills, manifests, and Bash installer Validate package SUCCESS
PowerShell installer Validate package SUCCESS

.github/workflows/validate.yml defines exactly two jobs, validate and
powershell-installer, and both ran. No gate the repository defines is missing,
pending, cancelled or skipped on this PR.

Residual risks

  • A review dispatched with a workspace that encloses or is nested inside the
    implementer's tree is reported as isolated and is not (REV-001). Because the
    artifacts record reviewWorkspace unconditionally, the audit trail will
    assert an isolation that did not hold.
  • enforces_read_only no longer distinguishes an OS-enforced sandbox from a
    caller's declaration (REV-003), so the next adapter to set it may set it on
    weaker grounds still.
  • The documentation states the pre-change boundary (REV-002), so the code and
    its design document disagree about what is allowed.

Verdict

CHANGES_REQUESTED. REV-001 blocks: the containment gap means the PR does not
deliver the isolation guarantee it describes, and it is the guarantee issue #21
asks for. REV-002 through REV-005 are worth folding into the same pass while the
code is open, but none of them blocks on its own.

@datacas

datacas commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Review resolution update

All five findings from the review are addressed in commit ab06eaa.

[REV-001] · high · resolved · valid · blocks:yes — Review workspace containment gap

OrcaReviewWorkspace now rejects equal, parent, and nested paths after canonicalisation. Tests cover all three arrangements.

[REV-002] · medium · resolved · valid · blocks:no — Documentation described the old Orca boundary

Updated docs/instrumentation.md, skills/cc-orchestrator/SKILL.md, and CHANGELOG.md to document the explicit Orca workspace contract and observable blocked capabilities.

[REV-003] · medium · resolved · valid · blocks:no — Orca was presented as a read-only enforcer

Orca no longer sets the class-level enforces_read_only claim. The generic gate now uses supports_non_writing(), while Orca qualifies only with its validated workspace contract and still rechecks it in direct dispatches.

[REV-004] · low · resolved · valid · blocks:no — Review workspace was silently ignored for writing dispatches

Writing Orca dispatches carrying a review workspace now fail closed with review_workspace_conflict.

[REV-005] · low · resolved · valid · blocks:no — Missing cwd skipped implementer-workspace verification

Non-writing Orca dispatches now require cwd and reject missing or mismatched implementer paths with review_workspace_mismatch.

Verification after the fixes:

  • python3 -m unittest discover -s tests -q — 444 tests, OK
  • python3 -m unittest discover -s tests -p 'test_executors.py' — 106 tests, OK
  • python3 -m compileall -q scripts tests — OK
  • python3 scripts/validate-package.py — VALID
  • git diff --check — OK

The PR remains open for rereview; this update does not claim approval.

@datacas

datacas commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260922-007] · manual_reviewer · anthropic/claude-opus-5→? · high · schema:1

Executive summary

APPROVED. All five findings from CCR-20260922-006 are corrected, and each
one was re-checked by running the original reproduction against the new code
rather than by reading the diff. The fixes are the right fixes, not the minimum
ones: REV-003 in particular was resolved by removing the false claim instead of
papering over it, which is the harder and better of the two options I offered.

One new low finding (REV-006) is recorded. It does not block: it is reachable
only on a case-insensitive filesystem, which is neither of the two platforms
this repository tests.

What changed since the previous review

Previous reviewed head 9cfde833ed4637d8fda7a58bca755da12736a76d, current head
ab06eaa0b9792bb326f17da8d373c1f7b2eb1861 (Resolve Orca review isolation findings). The accumulated diff against main is now 5 files, +256 −34.

File Since previous review
scripts/executors.py +35 −11 — _paths_overlap, the supports_non_writing hook, the writing-conflict branch, mandatory cwd
tests/test_executors.py +54 −14 — containment subtests, the hook, the two new blocked paths
docs/instrumentation.md +19 −13
skills/cc-orchestrator/SKILL.md +6 −4
CHANGELOG.md +3

Status of every previous finding

[REV-001] · high · resolved · valid · blocks:yes — The isolation check compares paths for equality, so a containing or nested workspace passes

Corrected and verified by execution. scripts/executors.py:88-94 replaces
the equality test with _paths_overlap, which compares canonical paths in both
directions via Path.parents. Re-running the exact reproduction from the
previous review:

REV-001 — the three containment arrangements
  equal                    refused: an Orca review workspace must not contain or be contained by the implementer workspace
  PARENT of implementer    refused: an Orca review workspace must not contain or be contained by the implementer workspace
  NESTED in implementer    refused: an Orca review workspace must not contain or be contained by the implementer workspace
  control: genuinely disjoint sibling -> accepted (correct)
  control: symlink/.. spelling of the parent -> refused (canonicalised)

Both previously-accepted arrangements are now refused, and the controls confirm
the check did not simply become a blanket refusal: a disjoint sibling still
passes, and a .. spelling of the parent is caught after canonicalisation.
test_a_review_workspace_cannot_be_the_implementer_workspace now covers all
three arrangements as subtests, so the regression has a guard.

[REV-002] · medium · resolved · valid · blocks:no — docs/instrumentation.md still states the opposite of what the code now does

Corrected. docs/instrumentation.md:510-523 no longer claims Orca is
excluded; it states that Orca qualifies only with the explicit workspace
contract, "does not claim an OS-level read-only flag", and fails closed on a
missing, mismatched or overlapping workspace. docs/instrumentation.md:349-362
now lists the OrcaReviewWorkspace requirement alongside the rest of
OrcaDispatchContext. skills/cc-orchestrator/SKILL.md:253-261 carries the
matching wording, and CHANGELOG.md gains an entry naming the fail-closed
behaviour. The documented boundary and the code now agree.

Verified against the copy-drift rule in CONTRIBUTING.md: none of these edits
touch a duplicated shared section, and validate-package.py reports the shared
sections still in sync.

[REV-003] · medium · resolved · valid · blocks:no — enforces_read_only = True is a class-level claim backed only by a caller-supplied string

Corrected and verified by execution. Orca sets enforces_read_only = False
again, and the generic gate at scripts/executors.py:931 now asks
adapter.supports_non_writing(**kw) instead of reading the flag. Orca's
override qualifies only when the validated workspace contract is present.
Observed:

  enforces_read_only          = False
  supports_non_writing(ctx)   = True
  supports_non_writing(none)  = False
  codex.enforces_read_only    = True | supports_non_writing = True
  claude.supports_non_writing = False

  generic gate, Orca review WITHOUT a workspace:
    blocked | read_only_enforcement

This is the stronger of the two resolutions available. enforces_read_only now
means only what it always meant — an OS-enforced sandbox, which Codex has and
Orca does not — and the weaker, contract-based qualification has its own name.
The next adapter author copying enforces_read_only will copy the strict
meaning. Codex and Claude are unchanged, confirming no adapter was loosened to
make room for the hook.

[REV-004] · low · resolved · valid · blocks:no — A declared review workspace is silently discarded when writes=True

Corrected and verified by execution. The elif branch at
scripts/executors.py:725-729 refuses the contradictory context instead of
resolving it silently toward the writable tree:

REV-004 — writing dispatch carrying a review workspace
    blocked | review_workspace_conflict

The runner in the reproduction raises if called, so the worker provably does not
start. test_a_writing_dispatch_rejects_a_review_workspace guards it.

[REV-005] · low · resolved · valid · blocks:no — The review_workspace_mismatch check is skipped entirely when cwd is None

Corrected and verified by execution. scripts/executors.py:718-724 inverts
the guard: a non-writing dispatch now requires cwd, and both the missing and
the mismatched case are refused.

REV-005 — review with cwd=None, and with a mismatched cwd
    cwd=None     blocked | review_workspace_mismatch
    cwd mismatch blocked | review_workspace_mismatch

An unverified implementer_path can no longer reach
artifacts["reviewWorkspace"], so the artifact no longer asserts a relationship
nobody established. Making cwd mandatory is a real behaviour change for
callers, and the commit correctly propagates it through the existing Orca tests
rather than leaving them passing by accident.

The happy path still works end to end:

    succeeded | worker cwd: /repo/review | path:/repo/review | artifact: disposable

New findings

[REV-006] · low · open · - · blocks:no — Containment is compared case-sensitively, so a nested workspace slips through on a case-insensitive filesystem

scripts/executors.py:88-94

_paths_overlap compares PosixPath values, and Path.resolve() does not fold
case. Observed on Linux with directories that really exist:

Path comparison is case-sensitive here: False
real  : /tmp/tmp5z1y80ct/implementer
shouty: /tmp/tmp5z1y80ct/IMPLEMENTER
-> a differently-cased nested path is ACCEPTED

resolve() returned the shouty spelling unchanged rather than the on-disk one,
so /tmp/.../IMPLEMENTER/sub was not recognised as nested inside
/tmp/.../implementer and the workspace was accepted.

On Linux this is correct — the two spellings are genuinely different
directories. The exposure is a case-insensitive filesystem, where they are the
same directory and the reviewer would get a workspace inside the implementer's
tree while the contract reports isolation. Windows is not affected, because
WindowsPath comparison is already case-insensitive. macOS with its default
case-insensitive APFS is the exposed platform; that part is inferred from the
mechanism shown above rather than observed, since no macOS host was available
here and CI runs Linux and Windows only.

Low severity and non-blocking for that reason: it needs an unsupported platform
and a caller who spells the same directory two ways. Normalising both sides
with os.path.normcase before comparison would close it in one line, and would
be a reasonable thing to fold into a later change rather than this one.

Security triage and audit

Sensitive change: the security audit was performed. The diff still modifies
the authorization boundary that decides whether a review stage may mutate the
tree it is judging — the same trigger as the previous review, and the same area
as PR #17's REV-001.

Audit result for the current head:

  • The boundary is now two independent gates that agree. The generic
    dispatch() gate refuses a non-writing Orca dispatch with no workspace
    (read_only_enforcement), and OrcaAdapter.dispatch refuses it again
    (review_workspace_isolation) for callers that never pass through the gate.
    Both were exercised above.
  • Every refusal is fail-closed. All four blocked paths were driven with a
    runner that raises when called; none of them started a worker.
  • The validity of the workspace cannot be bypassed by the hook.
    supports_non_writing accepts nothing but an OrcaReviewWorkspace instance,
    OrcaDispatchContext.__post_init__ rejects any other object in that field,
    and OrcaReviewWorkspace.__post_init__ validates isolation mode and
    non-overlap at construction. A non-None workspace is therefore always a
    validated one.
  • No privilege escalation, no new credential, network or secret surface.
    --worktree path:<...> remains the only added argument.
  • Residual weakness is REV-006 only, and it requires a caller that
    constructs the contract with an inconsistent spelling on an untested platform.

Verification evidence

Command Result
python3 scripts/validate-package.py VALID: 12 skills (6 cycle, 6 supporting), shared sections in sync, cross-agent manifests aligned
python3 -m unittest discover -s tests Ran 444 tests in 8.426s — OK (441 before, +3)
python3 -m compileall -q scripts tests clean
git diff --check <merge-base> HEAD clean
Re-run of the REV-001/003/004/005 reproductions all now refused; output quoted per finding
Case-folding probe for REV-006 reproduced, output quoted

No previous finding was marked resolved from the diff alone. Each was closed by
re-executing the reproduction that opened it, through OrcaAdapter.dispatch
with a runner that records the argv and cwd the worker would have received.

Preflight succeeded: Python 3.10.12, no service, database or port dependency.

Unverified items

  • Real Orca behaviour remains unobserved. Every result here uses a stubbed
    runner. That orca-ide orchestration worker-start --worktree path:<...>
    actually confines the worker to that directory is taken from the CLI contract.
    The adapter is now explicit that it has no OS-level read-only permission, so
    the isolation rests entirely on the workspace being genuinely separate — which
    is exactly what REV-001 now enforces, and the reason REV-006 is worth closing
    eventually.
  • No end-to-end Orca review exists. No caller in scripts/ constructs an
    OrcaReviewWorkspace, so nothing exercises a real review dispatch through
    Orca. Unchanged by this PR, and out of its scope.
  • macOS. Asserted from the mechanism, not observed. See REV-006.

CI

All four check runs on ab06eaa passed; gh pr checks 24 reports
Passed: 4, Failed: 0, exit 0. The run IDs differ from the previous review's,
confirming CI re-ran on the new head rather than reporting stale results.

Check Workflow State
Skills, manifests, and Bash installer Validate package SUCCESS
PowerShell installer Validate package SUCCESS

.github/workflows/validate.yml defines exactly two jobs, validate and
powershell-installer; both ran on this head. No gate the repository defines is
pending, failed, cancelled, skipped or missing.

Residual risk

  • REV-006, scoped above: low, unsupported platform.
  • The workspace is still trusted to exist and to be what it says. Nothing
    checks that the path exists, is a git worktree, or is actually immutable or
    disposable; isolation remains the caller's word. This was the second half of
    REV-003, and resolving it by renaming the capability — rather than by adding
    verification — is a legitimate choice: the claim is now accurate, which was
    the finding. It is recorded here as the standing property of the design, not
    as an unresolved finding.
  • Making cwd mandatory for non-writing Orca dispatches is a breaking change
    for any caller outside this repository. Nothing in scripts/ constructs such a
    dispatch today, so the blast radius is currently zero, and CHANGELOG.md
    records it.

Verdict

APPROVED. The current head was rereviewed in full against the merge-base.
All five previous findings are corrected and verified by execution, every check
the repository defines passed on this head, and the one new finding is low and
non-blocking. REV-006 is worth a follow-up but should not hold this PR.

@datacas
datacas merged commit 8f9bfaf into main Sep 22, 2026
4 checks passed
@datacas
datacas deleted the issue-21-isolate-orca-review-dispatches branch September 24, 2026 09:21
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.

Isolate direct Orca review dispatches

1 participant