REPORT — detection-a-cancel-by-dispatch-implementer
STEP: detection-a-cancel-by-dispatch (ledger row A: cancel-by-dispatch detection)
REV: 1932f2d365fc22fb8f719915816af9685a08142a   FINAL: 3865e5e6086b17a50ad7a13c466ba7368cde24cf
CHANGED: tests/test_cancel_by_dispatch.py — new module: forced undispatched branch, forced retained branch, unforced cancel x ACTION_DISPATCHED race, replay in every case
CHANGED: docs/research/detection-a-cancel-by-dispatch-implementer.md — this report
VERIFIED: scripts/check-tests --fast — 914 passed, 30 deselected, 72.12s (new module included; 3 passed alone in 0.41s)
VERIFIED: .venv/bin/python -m pytest tests/test_phase3_project_oracle.py — 5 passed, 226.78s
VERIFIED: scripts/check-static — exit 0
VERIFIED: scripts/check-docs — exit 0
VERIFIED: tests/test_cancel_by_dispatch.py race case repeated 30x standalone, including after the final anti-vacuity edit — 30 passed (both orderings observed each run)
NOT VERIFIED: none
FINDINGS: none
SHAPES: the suite did not build any of the three shapes. Newly built: (1) cancel fully admitted before ACTION_DISPATCHED, dispatch forced to a halt at its emission window — reclaims and proves the late dispatch is reducer-retained and adds no ledger liability; (2) ACTION_DISPATCHED durable and the executor blocked in flight before the cancel is admitted — retains the commitment and proves no reconcile-to-zero exists; (3) an unforced cancel x ACTION_DISPATCHED admission race on a barrier with no forced winner, over 40 iterations, asserting settled accounting equals the durable log order in every iteration and that both orderings occur. Existing probes covered only the retain side and used a conditionally asserted, unforced loop.
TRIPPED: none
PROPOSED ROWS: A. inverted or stale predicate laundering accounting — Detection today "partial: barrier pattern in test_single_flight_concurrency.py; cancel-by-dispatch absent" is now false; propose "test: tests/test_cancel_by_dispatch.py" (both cancel-time branches forced under interleave, plus an unforced admission race and replay).
METHOD FRICTION:
- The brief's shape-3 invariant, "liability is retained if and only if the durable log shows the attempt was dispatched," is ambiguous once shape 1 explicitly allows a late ACTION_DISPATCHED to be appended after reclamation. The final log can show ACTION_DISPATCHED while liability is legitimately 0. I resolved it as "dispatched before the CANCELLATION_CONFIRMED admission" (log position order), which is the only reading consistent with shape 1. Recorded here in case the intended reading was the final log, which no correct implementation could satisfy.
- Shape 3 requires both orderings to be observed from an unforced race; that depends on scheduler jitter rather than a barrier hook. It passed 30/30 standalone runs and in the full fast suite on this host. The brief anticipated a host that cannot produce one ordering and directed reporting it in METHOD FRICTION rather than dropping the assertion; no fallback was needed here.
- Shape 2 blocks at the entry to `executor.dispatch` (a plain instance-attribute wrapper), before the real `ScriptedExecutor.dispatch` body runs. The evidence is still that the durable ACTION_DISPATCHED exists and the request has been handed to the executor and not completed when the cancel is admitted; this matches the blocking point the existing `test_batch3_execution.py` probe uses. A stricter "inside dispatch" block would patch the private `_dispatch`; I did not, to avoid reaching past the registered executor's public surface.
- No commit was made despite CLOSE OUT: yes. The brief did not instruct a commit and the session was not authorized to commit, so FINAL names the uncommitted working tree. If a commit is required, the report's FINAL must be replaced with the resulting sha.
- check-static's advisory B023 fired while the race workers were closures over the loop's variables; I moved the per-iteration body into `_race_once` so the new module adds no advisory errors. This was a quality choice, not a gate requirement (B rules run `--exit-zero`).
INHERITED:
none

--- when CLOSE OUT is yes, the PLANNER appends, copying and adding no judgement: ---
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
