<!-- informative -->

# Reviewer Brief: EXECUTION-Gate Adversarial Review

## Mandate

Independently attempt to falsify the EXECUTION-gate guarantees on the current revision. The automated suite is green
and is not a verdict; the previous SPEND-gate review found four reachable falsifications that the delivered test
mechanisms missed. Assume the happy paths are covered and attack the seams: interleavings, host-specific layouts,
process-tree escapes, and import/scope bypasses.

**Independence:** you must not be the author of the Batch 3 commit `33945bb` or of any commit that added the
EXECUTION test mechanisms. Read the source and the normative documents before the implementer's tests.

## Target

- Repo: `/home/ruben/Projectos/meta-project/orchestrator`
- Revision reviewed: `33945bb` (Batch 3). Preceded by `5be1c23` (A4/A3 test work), `d24c505` (A1/A8 defect fixes),
  `9e657e5` (SPEND-gate fixes).
- Work on a frozen revision, not a moving tree:
  `git worktree add --detach /tmp/kilo/execution-review-33945bb 33945bb`
- Primary reference: `docs/report-milestone8-readiness.md`, findings **R01, R04, R07, R15, R21**.
- Normative documents: `docs/executors.md`, `docs/control-plane.md`, `docs/budgets.md`, `docs/tables/limits.yaml`.
- Run tests with `.venv/bin/python -m pytest -q`. Probes go under `/tmp/kilo/`; do not edit source.

## Environment

- Host-capable review: you may inspect cgroups and process trees, because several guarantees are host-specific.
- Record the host layout (cgroup v2 delegation, controllers, mount options, kernel) with every host-dependent finding.
- **No real credentials, no network, no paid calls.** Synthetic clients and local fixtures only. Do not modify the
  host cgroup configuration outside the reviewer's own delegated subtree.

## In scope

1. **Trusted import cannot be steered by candidate content** (R01/R07): candidate Git metadata, `.git` variants,
   symlink and rename TOCTOU, path normalisation, and glob bypasses cannot reach trusted Git, change the committed
   tree, or escape the frozen scope.
2. **Verification binds the committed object** (R07/R21): the verified hash and scope describe the committed tree,
   the candidate object graph is durable before cleanup, and a mutation of the underlying object is detected.
3. **Limits and membership are real or honestly absent** (R15): controller activation, limit writes, and placement
   are verified before work is released; a denial cannot be reported as enforcement; teardown kills, reaps, closes,
   and removes on every surviving path.
4. **Cancellation stops work and preserves liability** (R04): a cancelled attempt interrupts a blocking runner, never
   produces a result or charge, and the never-dispatched versus dispatched liability split holds under interleavings.
5. **One attempt deadline and truthful accounting** (R15): a multi-command attempt shares one monotonic deadline;
   `resource_source`, `limits_verified`, and evidence never overstate what was enforced.

## Out of scope

- The SPEND gate (R02/R03/R06/R09/R11/R12) — already reviewed and fixed in `9e657e5`.
- R08 evaluator isolation, R10 repair, R13 grade persistence, R14 recovery breadth, R17 output admission,
  R18 scheduling, R19 coverage, R20 metrics, R22 timers, R23 non-test oracles — owned by other batches.
- Incidental interactions are welcome, but keep the verdict scoped to the EXECUTION gate.

## Known residuals — acknowledge, do not re-report as novel

- **Controller-death kill.** Teardown runs only if the controller survives; killing the workload when the controller
  dies needs an independent supervisor outside the controller, which the single-machine MVP does not provide. This is
  a documented scope decision. Do test that a *surviving* controller cleans up on every ordinary path.
- **CPU is measured, not enforced.** The sandbox promises no aggregate CPU budget; `cpu.max` is a rate quota and is
  not written. `cpu.stat` measurement is the claim; `cpu.max` enforcement is not.
- **Token-ceiling one-call overshoot.** A client declaring `(0, 0)` declares no bound; the aggregate ceiling can be
  overshot by one call before refusal. Pinned by a test; not an EXECUTION finding.
- **Ledger tamper-evidence.** A SPEND-gate concern, out of scope here.
- **Host cgroup quirk.** On this host a delegated cgroup can reject a `cpu.max` write with `EINVAL`; the sandbox
  deliberately does not write `cpu.max`. Treat cgroup-layout differences as a verification-design question, not a bug
  report, unless a limit is reported as enforced when it is not.

## Attacks to attempt (minimum)

- **Import and scope:** `.git` as a file, a symlink, and nested; `.git/config`, `.git/hooks`, `.gitattributes`
  filters; a file replaced by a directory and vice versa at the same path; an ignored file; a mode-only change; a
  directory symlink; a rename between snapshot and import; `..` and absolute paths; scope globs that match a prefix
  but not the intended subtree; a candidate path that normalises onto a hidden path.
- **Verification:** mutate the committed blob after verification; present a bundle whose HEAD differs from the
  verified commit; verify that `tree_digest` and `content_hash` describe the committed tree, not the working tree;
  ensure excluded base content survives import.
- **Limits and cgroups:** pre-enabled controllers; read-only `subtree_control`; partial delegation; denied limit
  write; a limit that does not read back; `cpu.max` rejection; placement of a pid that does not appear in
  `cgroup.procs`; cgroup removal while a grandchild is still alive.
- **Teardown:** kill/reap on every path including setup failure and exception; `SIGKILL` during launch; a child that
  escapes the process group; verify no leaked cgroup, pid, temporary file, or mount remains.
- **Cancellation:** cancel during setup, during the workload, during teardown, twice, and concurrently with
  acknowledgement; verify the runner is interrupted promptly, the process tree is gone, no result or charge is
  produced, and the attempt ends `CANCELLED` with the correct liability.
- **Deadline:** a multi-command attempt with the first command consuming the budget; verify the second does not
  receive the full budget afresh and that the deadline is monotonic.
- **Evidence honesty:** a run where cgroup limits could not be verified must report `cgroup=None`,
  `limits_verified=False`, and `resource_source=RUSAGE_CHILDREN`.

## Method

- Read first: `sandbox.py` (`SandboxRunner.run`, `_Cgroup`, `set_limits`, `place`, `_enable_controllers`, `_teardown`,
  `_kill`, `capabilities`), `command_executor.py` (`_dispatch`, `_run_command`, `cancel`), `controller.py`
  (`cancel_run`, `_cancel_attempt`, `_recover_accounting`, `dispatch_attempt` exception handling), `worktree.py`
  (`create_candidate`, `materialise`, `_apply_changes`, `_expected_entries`, `_reject_git_metadata`, `_git`),
  `reducer.py` (accounting and acceptance guards).
- Build minimal reproducers that isolate one invariant each. Prefer a failing reproducer to an argument.
- For host-dependent behaviour, run on the real host and record the layout; a skip is not a pass.
- For each attack record: exact commands, observed result, expected result, and whether the invariant is violated.

## Deliverable

1. **Verdict:** GO / NO-GO for the EXECUTION gate, one sentence.
2. **Findings**, each with severity (P0/P1/P2), the invariant violated, a minimal reproducer (commands and code),
   observed versus expected, a proposed permanent regression test, and the readiness finding it maps to (R01/R04/R07/
   R15/R21) if any.
3. **Claims verified:** for each in-scope item, how you attempted falsification and what you observed. "Verified"
   means attacked, not that tests pass.
4. **Residual unknowns:** anything you could not test (host limits, controller death, other environments) and why.
5. **Execution-path audit:** every path that starts a workload, imports a candidate, or releases a limit, and whether
   it verifies and cleans up.

## Exit criteria

- Every in-scope claim is either falsified with a reproducer or explicitly "attacked, not falsified" with the method.
- No real credentials, no network, no paid calls, no source edits, no host cgroup changes outside your own subtree.
- Findings are reproducible from the report alone, against `33945bb`.
- The review states what it did not cover.

## Reproduce everything

List every probe command here so the verdict can be re-run against the corrective revision.
