REPORT — phase5-run-entry-fixes-4-implementer
STEP: phase5-run-entry-fixes-4 (the cancel-race disposal — F29–F32)
REV: 5711e48a57dcd9df9184083009be720bd20cd7bf   FINAL: 7f4381a
CHANGED: src/orchestrator/run_entry.py — `start_run` reads `controller.store.replay_fresh(run_id).outcome` between `dispatch_attempt` and the observation/admission chain; a terminal run settles its own accounting and returns `accepted=False` with the durable outcome, skipping the node-level chain. `_bind_acceptance` re-reads the fresh outcome before each admission and before the refusal path. The returned `StartResult` keys `accepted` and `outcome` on the durable fresh outcome.
CHANGED: src/orchestrator/reducer.py — `_on_artefact_integrated` retains an artefact-machine event whose id belongs to a terminal attempt (the follow-on of a retained admission is itself late); a genuinely unknown `artefact_id` still raises `ReducerError`.
CHANGED: docs/run-entry.md — the `start` contract sentence now names the durable settled outcome the exit code keys on (zero only when the JSON `outcome` is `ACCEPTANCE_CLAIMED`).
CHANGED: tests/test_run_entry.py — the F29 cancel-race subprocess class pin, the stop-after-observation interleave pin, and the stale-admission replay pin.
CHANGED: tests/test_phase5_run_entry_fixes_2_review.py — the four F30 guarded-surface facet pins; the F28 pin renamed to name its property; its prerequisite assertion bound to the claim via a fenced-block-stripped prose read.
VERIFIED: scripts/check-tests --fast — 961 passed, 92 deselected, 69.26s, exit 0
VERIFIED: .venv/bin/python -m pytest tests/test_run_entry.py tests/test_phase5_run_entry_fixes_2_review.py — 47 passed, 20.19s, exit 0
VERIFIED: .venv/bin/python -m pytest tests/test_milestone2_conformance.py — 41 passed, 0.17s, exit 0
VERIFIED: .venv/bin/python -m pytest tests/test_phase3_project_oracle.py — 5 passed, 224.47s, exit 0
VERIFIED: scripts/check-static — exit 0 (104 advisory lint rows printed without gating; no new row)
VERIFIED: scripts/check-docs — table verification passed, links 353/353 OK, 0 errors, exit 0
VERIFIED: scripts/check-scope 5711e48a57dcd9df9184083009be720bd20cd7bf 7f4381a docs/research/phase5-run-entry-fixes-4-brief.md — tripped: PILOT-R1; scope: ok (6 path(s)), exit 0
VERIFIED: Red evidence at REV 5711e48 — a `git archive` scratch copy (reducer.py and tests/test_run_entry.py diff-verified against `git show 5711e48:…`) with the delivered test file overlaid: `.venv/bin/python -m pytest tests/test_run_entry.py -q -k "cancel_race or stale_admission"` → 3 failed, 37 deselected, 7.00s. Named failing assertions: `test_cancel_race_class_shape` at tests/test_run_entry.py:1064 `AssertionError: F29: the launcher of a run a second process cancelled exited zero` / `assert 0 != 0`; `test_cancel_race_shape_stop_after_observation` at tests/test_run_entry.py:1111 `AssertionError: assert True is False` (the returned `StartResult.accepted` was True); `test_stale_admission_race_log_replays` at tests/test_run_entry.py:1211 `Failed: F29: the durable race log did not replay: ReducerError("ARTEFACT_INTEGRATED: unknown artefact_id 'RUN-RACE-LOG-root-attempt-…-artefact'")`. All three green at FINAL.
VERIFIED: Drift guards at REV — the delivered tests/test_phase5_run_entry_fixes_2_review.py overlaid on the same scratch tree: `.venv/bin/python -m pytest tests/test_phase5_run_entry_fixes_2_review.py -q` → 7 passed (F30/F31/F32 bind behaviour already present at REV). Green at FINAL too.
VERIFIED: F32 mutants at FINAL — two scratch copies of the tree: (mutant 1) the prerequisite sentence names `json` instead of `yaml` → `test_review_f28_documented_commands_are_python3_and_run_as_written` red at `assert "yaml" in prose and "python3" in prose` (tests/test_phase5_run_entry_fixes_2_review.py:194); (mutant 2) the prerequisite sentences deleted → red at the same assertion. The pre-fix `"yaml" in section and "python3" in section` assertion stayed True under both mutants (the vacuous-truth class).
NOT VERIFIED: none
FINDINGS:
  F29 | SEVERITY: P1 | ORIGIN: CODE | STATE: fixed
  The launcher drove its execution-phase admissions on its in-memory projection, which never observes a second process's `stop`; a mid-run cancel left `start` exiting 0 with `accepted: true` / `ACCEPTANCE_CLAIMED`, and the durable race log raised `ReducerError: unknown artefact_id` on any new connection.
  FIXED: tests/test_run_entry.py::test_cancel_race_class_shape — at REV the named assertion failed: `AssertionError: F29: the launcher of a run a second process cancelled exited zero` / `assert 0 != 0` (tests/test_run_entry.py:1064). tests/test_run_entry.py::test_cancel_race_shape_stop_after_observation — at REV `assert result.accepted is False` failed with `assert True is False` (tests/test_run_entry.py:1111). tests/test_run_entry.py::test_stale_admission_race_log_replays — at REV `pytest.fail` on `Failed: F29: the durable race log did not replay: ReducerError("ARTEFACT_INTEGRATED: unknown artefact_id …")` (tests/test_run_entry.py:1211). Green at FINAL: `start` returns the durable `CANCELLED` outcome with `accepted: false` and a non-zero exit; neither process traces back; `inspect` is clean and equals a fresh connection's replay; the race-order log replays to `CANCELLED` without creating or integrating the cancelled attempt's candidate; the unknown id still raises.
  F30 | SEVERITY: P2 | ORIGIN: CODE | STATE: fixed
  `mark_infeasible`'s dedup/settle-once/late-retention facets were hand-measured only (no committed test), and the zero-fingerprint terminal call had changed behaviour under the F27 guard.
  FIXED: no regression test — drift guard. tests/test_phase5_run_entry_fixes_2_review.py::test_review_f30_mark_infeasible_settles_an_accepted_lineage_once (:276), ::test_review_f30_duplicate_mark_infeasible_dedupes_the_shared_key (:303), ::test_review_f30_late_mark_infeasible_on_terminal_run_is_retained (:337), ::test_review_f30_zero_fingerprint_terminal_run_refuses (:365); all four green at REV and FINAL.
  F31 | SEVERITY: P2 | ORIGIN: CODE | STATE: fixed
  The absorbed F28 pin's node id `test_review_f28_documented_bare_command_is_executable` misstated the enforced property (no bare head documented; the `python3` form runs).
  FIXED: no regression test — drift guard. Renamed to tests/test_phase5_run_entry_fixes_2_review.py::test_review_f28_documented_commands_are_python3_and_run_as_written (:175), docstring meaning unchanged, module docstring reference updated; green at REV and FINAL.
  F32 | SEVERITY: P2 | ORIGIN: CODE | STATE: fixed
  The F28 pin's prerequisite assertion bound word presence (`"yaml" in section` / `"python3" in section`), both already satisfied by the heads' argument shapes, so it stayed green through a `json`-only prerequisite sentence and through deletion of the sentence.
  FIXED: no regression test — drift guard. `_commands_section_prose` (:160) strips the fenced command block and the assertion binds `"yaml"`/`"python3"` in the surrounding prose only (tests/test_phase5_run_entry_fixes_2_review.py:194). Green at REV; the two mutants go red at FINAL at that assertion; the pre-fix assertion stayed True under both.
  F33 | SEVERITY: P2 | ORIGIN: BRIEF | STATE: fixed
  The brief requires the reducer to tell a retained admission's follow-on from a genuinely unknown `artefact_id`, but `reducer.reduce(state, event)` sees no event log and `model.py` (the only place a retained-admission marker could live) is outside IN SCOPE; the brief names no mechanism.
  FIXED: the one reading consistent with the brief's own fail-closed clause and with the "retained, never created" Exec F2 guard is the controller's deterministic owner id: `ARTEFACT_INTEGRATED`'s id is `{attempt_id}-artefact`, and the owning attempt is terminal, so `_retained_artefact_admission` (src/orchestrator/reducer.py:904) retains exactly that case and raises for an id no terminal attempt owns. This is the reading the brief's "follow-on of a retained admission is itself late" requires; pinned by tests/test_run_entry.py::test_stale_admission_race_log_replays (red at REV, green at FINAL) with the unknown-id fail-closed assertion. No brief text correction is needed because no other reading is consistent with IN SCOPE. Residual of the reading, named in SHAPES: because retention leaves no state record, a crafted `{terminal_attempt}-artefact` id with no prior `ARTEFACT_ADMITTED` is retained rather than refused; the fail-closed pin uses an id owned by no terminal attempt.
SHAPES: the same-instant cancel race landing between a `_bind_acceptance`/`start_run` fresh read and the event it guards is not pinned. The pins exercise the review's deterministic drives (stop during the visible command; stop after the observation). A stop in that TOCTOU window can still append a late `EVIDENCE_ADMITTED`/`ACCEPTANCE_AUTHORISED` to the log, but it is replay-safe (`_cancel_attempt` leaves a `RESULT_PRODUCED` attempt untouched, so the acceptance bindings still resolve) and cannot change the durable outcome, which `accepted and outcome == "ACCEPTANCE_CLAIMED"` re-reads. Also named: the F33 reading's fail-closed boundary — the retained-admission follow-on is recognised by owning terminal attempt, so an unknown id that happens to equal `{terminal_attempt}-artefact` (no prior admission) is retained, since no in-scope state marks the retention; a genuinely ownerless id still refuses.
TRIPPED: PILOT-R1
PROPOSED ROWS: none
METHOD FRICTION: none
INHERITED:
none — every received INHERITED item (F26, F27, F28) is fixed by the prior step; nothing was open to carry in. The fixes-3 review's FINDINGS set was moved into this brief's body (F29–F32); all four are fixed in this step; nothing is carried.
