REPORT — detection-a-cancel-by-dispatch-review
STEP: detection-a-cancel-by-dispatch (ledger row A: cancel-by-dispatch detection)
REV: 1932f2d365fc22fb8f719915816af9685a08142a   FINAL: 3865e5e6086b17a50ad7a13c466ba7368cde24cf
CHANGED: docs/research/detection-a-cancel-by-dispatch-review.md — this report. No test or source file was modified; the reviewer's falsification probes ran on throwaway copies in /tmp (mutation copies deleted after use). No commit was made: the review brief did not authorize committing, so FINAL names the delivery under review and this report sits in the working tree.
VERIFIED:
- scripts/check-tests --fast — 914 passed, 30 deselected, 74.28s (the delivered module's 3 cases included)
- .venv/bin/python -m pytest tests/test_phase3_project_oracle.py — 5 passed, 236.50s; confirmed a module under tests/ is frozen into the oracle corpus (`_BASELINE_ROOTS = ("tests/",)` in src/orchestrator/project_oracle.py:128)
- scripts/check-static — exit 0; gated rules BLE001/S110 clean, the advisory B/SIM findings in the log are all in pre-existing modules, none in tests/test_cancel_by_dispatch.py
- scripts/check-docs — exit 0, 296 links OK
- tests/test_cancel_by_dispatch.py standalone — 3 passed, rerun 10x on this host (both race orderings observed in every run; the module asserts that itself)
- Brief CONTEXT spot-checked against the named sources: docs/record.md:26 row A verbatim; tests/test_batch3_execution.py:284-332 does hide the launder assertion behind `if runs["count"] > 0:` after an unasserted `started.wait`; tests/test_single_flight_concurrency.py has the barrier pattern; the embedded implementer brief in the review brief matches docs/research/detection-a-cancel-by-dispatch-brief.md textually (prefix lines aside)
- Anti-vacuity attacked by mutation on throwaway copies (diff-verified patches, workspace untouched), following docs/templates/report.txt's falsify-with-reproducer stance:
  * `dispatched = False` (reclaim bug) → RED: shape 2 at tests/test_cancel_by_dispatch.py:234 and shape 3 at line 322, "a dispatched charge was laundered to zero"
  * `dispatched = True` (retain bug) → RED: shape 1 (reconciles-missing/charge-0 assertions, lines 159/162) and shape 3, "an undispatched attempt was charged"
  * `store.serialized()` dropped in `Controller._cancel_attempt` → RED: shape 3 laundering assertion, 8/8 runs
  * double fault (no lock + state-only predicate — the exact pre-fix `_cancel_attempt` of commit 85959ad, the actual historical EXECUTION F3 body) → RED: shape 3, 6/6 runs
  * reducer applies a late ACTION_DISPATCHED to a CANCELLED attempt → RED: shape 1's "the late ACTION_DISPATCHED must be retained, not applied" effect assertion
  * conservative commitment charge zeroed in `_recover_accounting` → attacked-and-not-falsified-as-assertion: the ledger's own invariant raises LedgerStateError (reclamation must equal commitment minus actual), so the probe responds by error, not by the named assertion; second line of defence confirmed intact
- pytest-timeout 2.4.0 is installed (pytest.ini pins timeout=120, thread method), so the module's @pytest.mark.timeout markers are enforced, not inert
NOT VERIFIED: none
FINDINGS:
  A | SEVERITY: P2 | ORIGIN: BRIEF | STATE: declined
  Shape 2's "the executor is in flight (blocked inside dispatch)" is ambiguous between the dispatch boundary and the dispatch body; the delivery blocks at the boundary (an instance-attribute wrapper on `ScriptedExecutor.dispatch` returns before `_dispatch` runs, so the scripted work never starts), which the implementer already declared in METHOD FRICTION.
  FIXED: declined, not a defect: the named guarantees are all directly asserted at that blocking point (durable incremental ACTION_DISPATCHED ordered before CANCELLATION_CONFIRMED at tests/test_cancel_by_dispatch.py:225, retained charge >0, no reconcile-to-zero at line 239), and the honest settlement is identical whether the executor's body has started or not — the implementer's friction entry covers it; rectifying the wording is planner territory, not this step's.
  B | SEVERITY: P2 | ORIGIN: CODE | STATE: declined
  With the admission lock retained, removing the durable-log predicate (`Controller._attempt_was_dispatched`) leaves the module green (10/10 runs): no reachable interleave under the lock distinguishes state-only from log-combined, so the fallback cannot be pinned by a red/green shape while the lock holds.
  FIXED: declined, not a defect: the double-fault mutant (predicate dropped AND lock dropped — the historical regression shape) reds shape 3 reliably, and dropping the lock alone reds shape 3, so every reachable misbehaviour is caught; the survivor is behaviour-equivalent code. Recorded so a later maintainer form-modeling "the log scan is redundant" knows the module's silence there is by design, not blindness.
SHAPES:
- Shapes the delivered module builds that the previous suite did not (confirmed: none of the three existed): (1) forced cancel-fully-admitted-before-ACTION_DISPATCHED with a late dispatch reapplied against a settled attempt, asserted retained-not-applied plus zero liability; (2) forced durable-dispatch-then-cancel with the executor delivery pending, asserted retained settlement with reconcile-to-zero absent; (3) unforced cancel x ACTION_DISPATCHED admission race over 40 iterations asserting settled-charge iff durable-dispatch-first plus both orderings across the loop, plus per-case replay.
- Reviewer-probed shapes beyond the delivery, by mutation: (a) reducer re-materialising a dispatched attempt after final settlement — caught by shape 1; (b) conservative settlement understating the true commitment — blocked by the ledger invariant (error, not assertion), second line of defence; (c) the pre-fix double-fault regression — caught by shape 3. All three are non-obvious states the repo's test suite did not previously build.
TRIPPED: none (docs/residuals.md has no dispatch/cancel entries)
PROPOSED ROWS: none (the implementer's proposed row-A detection update is not contradicted by this review)
METHOD FRICTION:
- The falsification method is not covered by the brief: I ran every mutant on a /tmp copy of the tree (rsync without .git/.venv, workspace venv symlinked) so no mutation ever touched the workspace two diffs verified before each run. Two early runs were invalidated by my own patch tooling (a short replace pattern re-spliced corrupt lines into the copy); both were discarded and redone after diff-verifying each mutant. Reviewers repeating this should diff the mutant against `git show <rev>:...` before trusting any pass/fail.
- The review brief embeds the implementer brief inline but points the CLOSEOUT acceptance at the standalone brief file; I confirmed the embedded copy matches docs/research/detection-a-cancel-by-dispatch-brief.md, so the divergence risk is currently nil but the double-maintenance cost is real.
INHERITED:
none

CLOSEOUT
DECLINED:
A | SEVERITY: P2 | ORIGIN: BRIEF | STATE: declined
Shape 2's "the executor is in flight (blocked inside dispatch)" is ambiguous between the dispatch boundary and the dispatch body; the delivery blocks at the boundary (an instance-attribute wrapper on `ScriptedExecutor.dispatch` returns before `_dispatch` runs, so the scripted work never starts), which the implementer already declared in METHOD FRICTION.
declined, not a defect: the named guarantees are all directly asserted at that blocking point (durable incremental ACTION_DISPATCHED ordered before CANCELLATION_CONFIRMED at tests/test_cancel_by_dispatch.py:225, retained charge >0, no reconcile-to-zero at line 239), and the honest settlement is identical whether the executor's body has started or not — the implementer's friction entry covers it; rectifying the wording is planner territory, not this step's.
B | SEVERITY: P2 | ORIGIN: CODE | STATE: declined
With the admission lock retained, removing the durable-log predicate (`Controller._attempt_was_dispatched`) leaves the module green (10/10 runs): no reachable interleave under the lock distinguishes state-only from log-combined, so the fallback cannot be pinned by a red/green shape while the lock holds.
declined, not a defect: the double-fault mutant (predicate dropped AND lock dropped — the historical regression shape) reds shape 3 reliably, and dropping the lock alone reds shape 3, so every reachable misbehaviour is caught; the survivor is behaviour-equivalent code. Recorded so a later maintainer form-modeling "the log scan is redundant" knows the module's silence there is by design, not blindness.
DIVERGENCES CLOSED: none
