Skip to content

feat(bin): require an explicit per-task delivery contract - #1563

Merged
kunchenguid merged 5 commits into
mainfrom
fm/fm-delivery-explicit-mode-impl-r1
Aug 3, 2026
Merged

kunchenguid merged 5 commits into
mainfrom
fm/fm-delivery-explicit-mode-impl-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Implements the revised explicit delivery-mode contract adopted from scout fm-delivery-explicit-mode-design-r1 (report Q7 contract, Q8 slices). Supersedes #1480, which is closed; only its project-management prose and test scenarios were salvaged, not its .delivery record architecture.

Problem

A task's delivery mode and yolo posture were resolved by a silent per-project registry lookup, independently, in two places: fm-brief.sh when shaping the definition of done, and fm-spawn.sh when writing task metadata. Nothing forced a per-task decision, and an adjusted brief could say one thing while the recorded task delivery said another.

What changes

fm-brief.sh requires --mode on ship scaffolds, validates the closed set, and records the choice as a fixed machine-readable Delivery contract: mode=<mode> line in the generated definition of done. --mode is refused on scout and secondmate scaffolds; --yolo is refused outright, since the worker never owns approval decisions.

fm-spawn.sh requires --mode and --yolo on ship spawns and validates both closed sets. Before any endpoint exists it reads the brief's recorded contract line and refuses a mismatch; a brief scaffolded before that line existed warns once and launches on the flag. A batch carries one shared contract that every pair still checks against its own brief. Scout and secondmate spawns refuse the flags, and a scout now records no mode=/yolo= at all - teardown already defaults an absent mode to no-mistakes and the snapshot renders it empty. When the explicit mode carries less rigor than the project's standing posture, a one-line deviation notice prints and the spawn continues, so the registry stays advisory rather than an enforced default.

fm-promote.sh requires the same two flags, because a scout carries no posture to inherit, and writes them into the task record alongside the kind= flip. The mode is now decided by the firstmate that just read the scout report rather than frozen from scout-spawn time.

fm-project-mode.sh remains the single registry parser for the mechanical consumers that have no task in hand (fleet sync's local-only skip, home seeding's refusal and no-mistakes init). It accepts the conditional no-mistakes-prod-only annotation and maps it to its most rigorous leg for them, and grows --raw so the deviation notice can tell a conditional policy apart from a flat mode.

Instruction surface: AGENTS.md section 7 owns the intake resolution, including the no-mistakes-prod-only surface classification and the unregistered-project fallback; the project-management skill defines the conditional policy as a registration-time posture with its defaults and initialization consequences; the registry blurb, script table, and architecture section follow.

Deliberate boundaries

  • The deviation notice fires on a rigor downgrade only (no-mistakes > direct-PR > local-only). Registered local-only shipped as direct-PR is not announced, matching the adopted contract; that case exposes a remote and may be worth revisiting.
  • An unregistered project resolves to the same no-mistakes standing default, so a downgrade there is announced too. The notice names the standing posture rather than a registry line, because for an unregistered project there is none.
  • No task-scoped state file, no new control plane, and no brief/spawn merge: the agreement invariant costs one grep of the brief.

Verification

  • bin/fm-lint.sh clean; bin/fm-doc-audience-check.sh ok (61 surfaces, 175 local links); bin/fm-test-run.sh --check-coverage ok.
  • bin/fm-test-run.sh --changed --base main: 35 scripts, 0 failed.
  • New tests/fm-task-delivery.test.sh covers the spawn contract (required and closed-set flags with no metadata written, scout/secondmate refusal, brief agreement plus the legacy-brief warning, the deviation-notice matrix, scouts recording no posture), promotion, and the registry mapping. Extended tests/fm-brief.test.sh covers the brief contract, including that the explicit mode wins over the registered posture.
  • Every suite touched by the call-site updates was run directly and passes, including the real-Herdr, Orca, cmux, busy-state, gate-refuse, and tangle-guard suites.

A ship brief's definition of done was shaped by a silent per-project registry
lookup, so an adjusted brief and the task's recorded delivery could disagree and
no one had to decide anything per task.

fm-brief now requires --mode on ship scaffolds, validates it against the closed
set, refuses the conditional no-mistakes-prod-only registry policy as a task
mode, and records the choice as a fixed machine-readable "Delivery contract:
mode=<mode>" line that fm-spawn can check. --mode is refused on scout and
secondmate scaffolds, and --yolo is refused outright because the worker never
owns approval decisions.
…omotion

fm-spawn resolved every ship and scout task's mode and yolo from the project
registry, so the delivery posture was never a per-task decision and could
contradict the brief the worker was about to follow.

fm-spawn now requires --mode and --yolo on ship spawns, validates both against
their closed sets, and reads the brief's recorded delivery contract line and
refuses a mismatch before any endpoint exists; a brief scaffolded before that
line existed warns once and launches on the flag. A batch carries one shared
contract that each pair still checks against its own brief. Scout and secondmate
spawns refuse the flags, and a scout now records no mode or yolo at all, which
teardown and the snapshot already tolerate. When the explicit mode carries less
rigor than the project's standing posture, a deviation notice is printed and the
spawn continues, so the registry stays advisory rather than an enforced default.

fm-promote requires the same two flags, because a scout carries no posture to
inherit, and writes them into the task record with the kind flip.

fm-project-mode keeps its one registry parser for the mechanical consumers that
have no task in hand, accepts the conditional no-mistakes-prod-only annotation
and maps it to its most rigorous leg for them, and grows --raw so the deviation
notice can tell a conditional policy apart from a flat mode.
AGENTS.md section 7 now owns how each ship task's mode and yolo are resolved at
intake, including the surface classification for a no-mistakes-prod-only project
and the unregistered-project fallback, and the project-management skill defines
that conditional policy as a registration-time posture with its defaults and
initialization consequences. The registry blurb, script table, and architecture
section follow: the registry records the captain's standing posture, and task
delivery is decided per task and passed explicitly.
The shared spawn helper also launches a secondmate, which refuses the flags, so
the contract belongs at each ship call site rather than inside the helper.
Both suites scaffold or spawn an ordinary ship task as the control case for a
secondmate assertion, so each needs the explicit contract the ship path now
requires.
@kunchenguid
kunchenguid merged commit 4ee4a0a into main Aug 3, 2026
12 of 13 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-delivery-explicit-mode-impl-r1 branch August 3, 2026 05:06
kaku-san added a commit to kaku-san/firstmate that referenced this pull request Aug 3, 2026