IMPLEMENTER BRIEF — phase5-run-entry-fixes (Phase 5: the run-entry fixes — F11–F16)

GOAL: F11–F16 are fixed and the Phase 5 exit gate holds for every documented operator form. F11: `--workdir` and `--store` resolve to absolute paths at entry (the same pipeline runs under a relative and an absolute form), so `start` settles through the Start shape's branches — an evidence-bound acceptance claim or a recorded refusal — never a traceback with a live run. F12: a wall-clock overrun of the root's visible command settles the run through the recorded-refusal path the failing-command branch already uses (a terminal `Controller.get_outcome` value with the failure recorded on the node and the attempt), and after a mid-run `stop` from another process the launcher exits through the documented contract — non-zero, the settled outcome as the CLI's JSON document, no traceback. F13: the no-harness-import pin catches every import spelling — `ast.Import` names, `ast.ImportFrom` alias names (`from orchestrator import experiment`), relative imports (`from . import experiment`), and late function-level imports — the review's two green mutants go red. F14: `scripts/orchestrate.py` carries the `sys.path` bootstrap its siblings have, so `python3 scripts/orchestrate.py …` runs from a clean env at the repo root. F15: `docs/run-entry.md`'s `executor_profile` row states the truth — a schema-required label, recorded nowhere, executor selection is separate work — and an absence pin binds the corrected claim. F16: every malformed run-spec class is refused before any store is opened — the obligations completeness check moves into `validate_run_spec`, making the "before any store is opened" sentence true in both `docs/run-entry.md` and `run_entry`'s own module docstring and pinned.

CONTEXT: The review (`docs/research/phase5-run-entry-review.md`) attacked all eleven questions. Everything outside F11–F16 is attacked-and-not-falsified and is not re-opened here: the budgets wiring, the load and refusal shapes, the Start shape's binding and refusal surface (R09's refusals hold), the Observe and Stop shapes including the reducer's late-event rule, the evidence-policy binding, the `<!-- normative -->` marker question, and report hygiene (answers 1–7, 9, 11). Red at this brief's `REV` (`aa33970c6d3b8f369b25be99145075fe7f48b64c`): the suite is green (961 passed, 66 deselected under `scripts/check-tests --fast`) — the review left its probes under `/tmp`, not in the tree. Red evidence for this step is written first: each code fix names its pin's failing assertion at `REV` (run the pin against `REV`'s code on a scratch copy before the fix lands — it must fail there and pass at `FINAL`) in `FIXED:`; F15 alone reads `fixed: no regression test` (a doc row's defect has no failing assertion at any revision; its absence pin is the drift guard, not red). Named remedies from the review: F11's root is `run_entry.build_command_executor` passing the CLI's workdir verbatim into `CommandExecutorConfiguration` roots (answer 8/10 reproducer) — normalise at entry; F12's root is `start_run`'s missing handler for `AttemptTimedOut` (and `AttemptCancelled` on the stop path) — the delivered failing-visible-command refusal settles `INFEASIBLE` (review answer 5) and the overrun settles through that same recorded-refusal path (one consistent reading: a failed root attempt recorded as a refusal), while `docs/run-entry.md`'s exit-code sentence ("exits zero when acceptance was authorised and non-zero when the run was refused") is extended to name every non-accepted class including a cancelled run; F13's root is the AST helper reading `ast.Import` alias names only (answer 8's two green mutants); F14's remedy is the sibling bootstrap (`scripts/smoke_run.py:110-111`'s `REPO_ROOT` + `sys.path.insert`, `scripts/stress_run.py:61-62`'s equivalent) copied into `scripts/orchestrate.py`; F16's remedy is prescribed as the move (the `non_derivable_axes`/`non_derivable_reason` completeness check into `validate_run_spec`, which already promises "nothing here touches a store or admits an event"), not the sentence narrowing — fail-closed before the store is opened is the stronger property and keeps both delivered sentences true. `REV` names the step's base — the parent of this brief commit — and is not claimed to be `FINAL`'s parent (F4's lesson).

INHERITED:

From `docs/research/phase5-run-entry-implementer.md`:

none — the only received item (F10, docstring half) is fixed by this step.

From `docs/research/phase5-run-entry-review.md` — its `INHERITED` block, then each carried finding's block from its `FINDINGS` section (the block's own "the findings above" pointer), moved verbatim:

Nothing received still open — the implementer brief's INHERITED (F10 docstring half) is fixed in FINAL and verified in answer 1. This review carries, with their IDs, the findings above: F11, F12, F13, F14, F15, F16 (all carried, per the template's rule "a defect you will not fix now is carried, never declined").

  F11 | SEVERITY: P1 | ORIGIN: CODE | STATE: carried
  A relative `--workdir` makes `start` crash and the run stay live, on both the accepting and the refusing path. `run_entry.build_command_executor` passes the CLI's `--workdir` value through verbatim into `CommandExecutorConfiguration` roots, so the candidate-bundle artefact path is relative to the sandboxed worktree's own directory; `git bundle create` fails inside the executor and the raise escapes `dispatch_attempt` ("substrate that dies on contact" form), out of `start_run`, and out of the CLI. Reproducer (CLI subprocess at FINAL, real fixture repo): `start --spec spec-accept.yaml --workdir W-REL --store SREL.db` — exit 1, empty stdout, no JSON, `orchestrator.executor_protocol.ProtocolViolation: git bundle create W-REL/artefacts/WT-RUN-OP-ACCEPT-....candidate.bundle HEAD failed: fatal: Unable to create '<worktree>/W-REL/artefacts/....bundle.lock'`; the store then holds 8 admitted events (`NODE_PROPOSED..TIMER_SCHEDULED`), attempt DISPATCHED, `inspect` shows `outcome: null`, node READY. Same crash on the refusing spec (`--workdir W2`, spec-fail): no recorded refusal. With an absolute workdir the same spec accepts end to end (`accepted: true`, `outcome: ACCEPTANCE_CLAIMED`, exit 0), so this is exactly the relative-path hazard. `docs/run-entry.md` says "`--workdir DIR` — scratch directory for worktrees and artefacts" with no absolute-path requirement, and the brief's Start shape is unconditional: "drives the run's root execution to a settled attempt and an evidence-bound acceptance claim or recorded refusal". A crash that leaves the run live (root READY, no outcome, no refusal) satisfies neither branch. Recovery exists (`stop` on the live store settles it to CANCELLED), which is why this is not P0.
  FIXED: no regression test — the deliverable has no assertion over CLI workdir forms; the eventual pin's red would name a subprocess start with a relative workdir asserting a settled run (or a refusal) instead of a traceback.
  F12 | SEVERITY: P1 | ORIGIN: CODE | STATE: carried
  A wall-clock overrun of the root's visible command is neither an acceptance claim nor a recorded refusal: `start` crashes and the run stays live. With `limits.wall_clock_seconds: 5` and a `sleep(120)` visible command (both documented run-spec fields), `CommandExecutor` raises `AttemptTimedOut`; `dispatch_attempt` catches it, emits `TIMER_FIRED` plus `ATTEMPT_EXECUTION_ENDED_UNRECONCILED`, and re-raises; `run_entry.start_run` has no handler and the exception escapes to the CLI (exit 1, traceback, no JSON). Store state after the escape: attempt TIMED_OUT with accounting PROVISIONALLY_SETTLED (not finally settled), root node READY, `outcome: None` — `Controller.get_outcome` reads None, failing the Start shape's "The run reaches a terminal Run outcomes value that `Controller.get_outcome` reads" for a reachable, documented configuration. `inspect` shows the run as live (`outcome: null`, node READY) long after the command died; `stop` afterwards settles it to CANCELLED, so recovery is operable — not P0. The same escape also surfaces in the two-process workflow: after a mid-run `stop`, the launcher process dies with an unhandled `AttemptTimedOut`/`AttemptCancelled` (exit 1, traceback, no JSON) while the store is fine (CANCELLED) — the documented "start exits zero ... non-zero" holds for exit codes but the run's own termination is reported only as a stack trace.
  FIXED: no regression test — no suite case drives a timing-out visible command through `start_run` (the timeout path in tests lives at the executor/recovery layer); the eventual red would be `start_run` with `limits.wall_clock_seconds` under the command's runtime asserting a settled run outcome (or a recorded refusal).
  F13 | SEVERITY: P2 | ORIGIN: CODE | STATE: carried
  The `No-harness-import shape`'s pin misses two import spellings. The AST helper collects module-path strings only from `ast.Import` alias names; for `ast.ImportFrom` it reads `node.module` and ignores `alias.name` and relative imports (`node.module is None` skips entirely). Mutants on a scratch copy of FINAL: adding `from orchestrator import experiment` or `from . import experiment` (extending `run_entry.py`'s own existing `from . import acceptance_checks, events, glossary, numeric, schemas` line — the most idiomatic future drift spelling in this file) leaves `pytest tests/test_run_entry.py -k harness_import` GREEN on both — the shape's guarantee is unenforced for named import statements; `import orchestrator.experiment_spec` is red as expected. The pin fails open exactly where the named guarantee ("the import surface names none of ...") is about to drift.
  FIXED: no regression test — the pin itself is the named regression guard and its assertion must-but-does-not fire on the mutants above; the next brief's red is: with the helper extended to `alias.name` (and to relative levels via the containing module), the same two mutants go red.
  F14 | SEVERITY: P2 | ORIGIN: CODE | STATE: carried
  `scripts/orchestrate.py` does not import without putting `src` on the path, so the documented invocation fails before argparse runs: plain `python3 scripts/orchestrate.py …` (the only form `docs/run-entry.md`'s Commands section shows) dies with `ModuleNotFoundError: No module named 'orchestrator'` because the repo has no packaging metadata (no pyproject/setup.py, package not installed in .venv) and the CLI lacks the `sys.path.insert(REPO_ROOT/"src")` bootstrap that sibling operator scripts have (`scripts/smoke_run.py:111`, `scripts/stress_run.py:62`). My subprocess runs needed `PYTHONPATH=src` explicitly. The exit-gate workflow is real once the path is set, but as documented the operator's whole interface does not start.
  FIXED: no regression test — an environment-shape claim (the script is runnable by its documented invocation from the repo root with a clean env) has no failing assertion at REV; the eventual pin would run a clean-env subprocess and assert a non-ModuleNotFoundError result.
  F15 | SEVERITY: P2 | ORIGIN: DOCUMENT | STATE: carried
  `docs/run-entry.md`'s field-table row for `executor_profile` ("The executor label recorded on the run") is false against the loader. The label is required by the `RunConfiguration` schema and validated, and then recorded nowhere: J-run on a real run at FINAL — the full event log JSON never contains the probe label (not in NODE_PROPOSED's contract, not in the `run_specification` binding, not in any event payload), the inspect document never contains it, and grep over `src/` shows no other sink (`executor_profile` appears only in run_entry/spec-bearing files). "Recorded on the run" is a normative claim an auditor cannot observe — the honest row would say it is a schema-required label only, with executor selection separate work.
  FIXED: no regression test — a doc-wording defect has no failing assertion at REV; the eventual pin would assert the label is absent from the store (if the doc is corrected) or present (if recording is ever added).
  F16 | SEVERITY: P2 | ORIGIN: DOCUMENT | STATE: carried
  `docs/run-entry.md`'s loading header overclaims: "Loading is fail-closed: a malformed spec is refused as a named RunSpecError before any store is opened or any event is admitted." Falsified for the obligations class the same table names ("when present, non_derivable_axes and non_derivable_reason must also be supplied"): a CLI `start` of an obligations-without-axes spec passes `load_run_spec`, the store file IS created (a fresh `axes.db` exists after the refusal), and only then does the freeze boundary refuse (`RunSpecError: cannot freeze target 'TARGET-AXES': a DECLARED target must name the axes it cannot derive…`), exit 1, zero events admitted. The zero-events half is true everywhere (see answer 4), and the class's fail-closed behaviour is real — but "before any store is opened" is false for this malformed class: the refusal happens at the freeze boundary inside `start_run`, after the CLI opens the store.
  FIXED: no regression test — a doc claim has no failing assertion at REV; the eventual check either narrows the doc sentence to "before any event is admitted" or moves the axes check into `validate_run_spec` (pin: CLI start of the class with a nonexistent store path, asserting the path is absent after the refusal).

IN SCOPE: src/orchestrator/run_entry.py, scripts/orchestrate.py, docs/run-entry.md, tests/test_run_entry.py

RESIDUALS:

None — rule 3 selects nothing here: this brief's `IN SCOPE` matches no `docs/residuals.md` trigger glob (the rows trigger on `src/orchestrator/planning_pilot.py`, `controller.py`, `reducer.py`, `decomposition.py`, `model.py`, and `derive_obligations.py`; `run_entry.py`, `scripts/`, `docs/`, and `tests/` match none). `TRIPPED` in your report copies `scripts/check-scope`'s `tripped:` line whatever it reads.

OUT OF SCOPE:
- Editing this brief file (`docs/research/phase5-run-entry-fixes-brief.md`). A committed brief is never modified; a re-cut is a new file.
- The controller stack and the target seam: `src/orchestrator/controller.py`, `reducer.py`, `store.py`, `executor.py`, `executor_protocol.py`, `command_executor.py`, `acceptance_checks.py`, `schemas.py`, `glossary.py`, `experiment_target.py`, `derive_obligations.py`, and the experiment harness (`experiment.py`, `experiment_spec.py`, `experiment_phases.py`, `trial_driver.py`, `hidden_oracle.py`, `scripts/smoke_run.py`, `scripts/stress_run.py`). F12's settlement and F11's dispatch reuse what `run_entry` already calls; F14 copies the sibling bootstrap textually, it does not edit the siblings. If one of these must change, stop and report `IN SCOPE` as insufficient.
- Model-produced candidates and recursive decomposition driving (unchanged from the run-entry brief): `start` drives the root's execution only.
- Registry and control files: `tests/open_defects.yaml`, `tests/counterexamples.yaml`, `tests/guard_mutation_matrix.yaml`, `tests/fixture_fidelity.yaml`, `tests/verifier_registry.yaml`, `tests/spend_paths.yaml`, `tests/invariants.py`, `tests/helpers.py`, `pytest.ini`, tool configuration. F13's mutants are regression guards, not defects to register; if a registry meta-gate demands a row anyway, stop and report.
- No new dependencies, no tooling configuration, no reformatting. No new `*Executor` or `*ModelClient` class and no provider-registry registration. No new arm and no `docs/tables/limits.yaml` change.
- Name no test `test_bug_*` (the open-defect registry would then own it).
- Any `docs/` file except `docs/run-entry.md` and your report: no `docs/residuals.md` edit (the planner maintains it), no `docs/record.md` edit, no `docs/event-catalogue.md` change, no new event type, no `docs/self-host.md` edit (the phase status is the OWNER's between steps and the concern is already in `record.md#pending-for-the-owner`).

ACCEPTANCE: Commands (run every one and paste what each prints into `VERIFIED`; expected result is green, exit 0, for each):

    scripts/check-tests --fast
    pytest tests/test_run_entry.py
    pytest tests/test_phase3_project_oracle.py
    scripts/check-static
    scripts/check-docs
    scripts/check-scope aa33970c6d3b8f369b25be99145075fe7f48b64c <FINAL> docs/research/phase5-run-entry-fixes-brief.md

Never put a full run in `ACCEPTANCE`; the reviewer runs `scripts/check-tests`. `pytest tests/test_phase3_project_oracle.py` is named under the standing rule for `tests/` and `scripts/` changes. `REV` below names the step's base — the parent of this brief commit — and is not claimed to be `FINAL`'s parent (F4's lesson).

Red evidence at `REV` `aa33970c6d3b8f369b25be99145075fe7f48b64c` (command `scripts/check-tests`; each unit must be replayable — cite these node ids and named failing assertions in `FIXED:`): the suite is green at `REV` (961 passed, 66 deselected), so each red is written by this step and demonstrated at `REV` against the unfixed code. Named reds to produce: `tests/test_run_entry.py`'s relative-workdir settled-run pin (F11 — at `REV` the subprocess exits 1 on a traceback with the run live), the wall-clock settled-outcome pin and the cancelled-launcher exit pin (F12 — at `REV` `AttemptTimedOut`/`AttemptCancelled` escape with `outcome: None` or a traceback), the import-spelling pin (F13 — at `REV` the extended helper's assertions on `from orchestrator import experiment` and `from . import experiment` fail), the clean-env CLI pin (F14 — at `REV` the subprocess dies `ModuleNotFoundError: No module named 'orchestrator'`), and the absent-store-after-refusal pin (F16 — at `REV` the store path exists after the obligations-class refusal). F15 reads `fixed: no regression test`; its absence pin (the label is absent from the event log and the inspect document) is a green-at-both-revisions drift guard.

Slow-mark convention: every case in `tests/test_run_entry.py` stays slow-marked by the module's existing `pytestmark = pytest.mark.slow` (`src/orchestrator/project_oracle.py:731`'s internal gate runs `scripts/check-tests --fast`, and the pre-commit hook deselects the same way); no new module is needed — put the pins in the existing one. `pytest tests/test_run_entry.py` above runs them directly.

Named shapes to build — the list of shapes, not the number of tests. One shape needs at least one test, and every named shape needs one:

- `Settled-start shape` (F11, F12): every documented `start` form and every delivered failure class settles the run — relative and absolute workdir, a failing visible command, and a wall-clock overrun. Each reaches a terminal `Controller.get_outcome` value through an acceptance claim or a recorded refusal (the failing-command refusal path already settles `INFEASIBLE`); the three named escape classes — `ProtocolViolation`, `AttemptTimedOut`, `AttemptCancelled` — never produce a traceback with a live run and are never swallowed silently (the refusal path records the failure on the node and the attempt).
- `Cancelled-launcher shape` (F12's second half): after a mid-run `stop` from a second process, the launcher exits through the documented contract — non-zero, the settled outcome as the CLI's JSON document, no traceback — and `docs/run-entry.md`'s exit-code sentence names every non-accepted class (refused, cancelled, timed out).
- `Import-spelling shape` (F13): the pin's helper flags all four spellings — `ast.Import` names, `ast.ImportFrom` module and alias names, relative imports by level, and late function-level imports — the review's two green mutants (`from orchestrator import experiment`, `from . import experiment`) go red when the helper change is reverted.
- `Clean-env CLI shape` (F14): `python3 scripts/orchestrate.py` runs from a clean env at the repo root without `PYTHONPATH` — its `--help`, a real `start`, `inspect`, and `stop` — matching the sibling bootstrap pattern.
- `Honest-label shape` (F15): the `executor_profile` label is schema-required and never recorded — the corrected `docs/run-entry.md` row's claim is pinned by asserting the label is absent from the event log and the inspect document.
- `Fail-closed-load shape` (F16): every malformed run-spec class is refused before any store is opened — the obligations completeness check lives in `validate_run_spec`; the pin starts an obligations-without-axes spec at the CLI with a nonexistent store path and asserts the path is absent after the named refusal.

REV: aa33970c6d3b8f369b25be99145075fe7f48b64c
CLOSE OUT: yes
DIVERGENCES: none

You implement one brief. You do not plan, re-scope, or decide what the work is. Read every file
in IN SCOPE before editing it; if what you find contradicts the brief, report that instead of
guessing. Modify only what IN SCOPE names. If you find uncommitted changes in the tree, stop and say
so. Stop and report rather than improvise when IN SCOPE is
insufficient, the brief contradicts the code, you have already failed twice at this goal, or the
requirement is ambiguous and no single reading is consistent with the rest of the brief. If exactly
one reading is consistent, take it and file a FINDING with ORIGIN: BRIEF that names the reading you
took. No new dependencies, no tooling configuration, no reformatting. Run every ACCEPTANCE command;
fix what is in scope and report what is not.

A defect in the brief is a FINDING, never METHOD FRICTION. METHOD FRICTION is only for the method and
its templates: any place you deviated from them, found them ambiguous, or found them silent. Report
friction you worked around — that is the section the method learns from.

Commit your own work. When ACCEPTANCE passes, commit the files you changed, and only those, in one
commit whose message ends with the trailer `Actor: IMPLEMENTER`. That commit's full sha is FINAL.
Then append docs/templates/report.txt verbatim, fill it in, write it to
docs/research/<phase>-<subject>-implementer.md, and commit it in a second commit with the same
trailer. Do not amend the first commit to add the report: FINAL must not change after the report
names it. If you cannot commit, stop and say so; do not leave work uncommitted for someone else to
commit.

# report.txt

REPORT — <phase>-<subject>-<role>
STEP: <implementer brief subject>
REV: <copied from the brief's REV — the step's base, not FINAL's parent>   FINAL: <implementer: sha of your work commit, never the commit that holds this report;
  reviewer: the sha under review, copied from the review brief>
CHANGED: <files, one line each>
VERIFIED: <command, duration, counts>
NOT VERIFIED: <why, or none>
FINDINGS: none | one block each:
  ID | SEVERITY: P0|P1|P2 | ORIGIN: BRIEF|CODE|DOCUMENT | STATE: fixed|declined|carried
  <root cause, one line>
  FIXED: <node id, command, and the named failing assertion at REV — or "no regression test">
         An error or a collection failure is not red. The assertion has to be the thing that
         failed; a run that merely crashed proves nothing.
  STATE means: fixed (above); declined = not a defect, with the reason; carried = a real defect
  left unfixed, passed on in INHERITED. A defect you will not fix now is carried, never declined.
  An ORIGIN: BRIEF finding is fixed once a later committed brief corrects the text: FIXED: names
  that brief's commit and reads "no regression test". Carried means a future actor has something to
  do with it; at closeout a finding with no possible next action is closed — a defect in an
  already-committed report reads FIXED: recorded in the review that filed it, and an authoring
  lesson from a finished brief goes into record.md's Observations.
SHAPES: <shapes probed that the suite does not build, or none with a reason>
TRIPPED: <copied from check-scope's tripped: line>
PROPOSED ROWS: <ledger rows, or none>
METHOD FRICTION: none | <where you deviated from the method or its templates, misread them, or
  found them silent. A defect in the brief is a FINDING, not friction.>
INHERITED:
<<every INHERITED item you received that is still open, copied verbatim; then each
  finding you marked carried, with its ID>>
Rule 2 governs the planner's copy of this block. What goes in it is yours: an implementer or
reviewer who received an obligation, finding, entry or trigger carries it forward verbatim, and
adds anything new that is still open. A block reading `none` is correct only when nothing came in
and nothing is open. INHERITED never carries residual rows; they are re-selected from the store per
brief.
