ship master orchestrator (v3) — Stage ⑤
Overview
The 5th stage, after Verify. harnessed has the pieces (a release-preflight gate, gstack
/ship, publish.yml CI) — this master orchestrates them into one repeatable release path,
the way comet (archive), Trellis (finish-work), and Claude-Harness (/harness-release) each
close their loop.
| order/mode |
sub |
when fires |
| 1 (serial) |
preflight |
always when stage=='ship' — read-only release-readiness gate |
After preflight passes, the master delegates PR + deploy to gstack /ship (composition —
harnessed does not reimplement it), and the actual npm publish + GitHub release happen in
publish.yml CI on tag push.
Process
- preflight (always) — run
harnessed release-preflight. If any check fails (most often
an empty ## [Unreleased]), STOP and document the release / clean the tree first.
- PR / deploy (delegate) — invoke gstack
/ship for PR creation + pre-land review.
- publish (CI) — push the
v<version> tag (with explicit user approval) → publish.yml
runs npm publish + creates the GitHub release.
Boundary (important)
This stage stops at tag-ready. It never pushes to the remote, never publishes to npm, and
never creates a git tag on its own. Those are CI + explicit-approval actions, by design —
"PR ready != release ready", and "release ready != already published".
How to invoke
!harnessed checkpoint intent ship
The banner above (when present) means this invocation is REGISTERED with the engine (an intent marker) — not yet compliant: steps 2-3 below seed the ledger, and a per-turn <workflow-intent> reminder persists until they run.
The numbered sequence below is the state machine — execute it step by step with Bash.
Do NOT improvise an equivalent flow from the Overview above: freelancing bypasses the engine
(no per-sub ledger, no evidence guard, no recovery). harnessed is the orchestration brain
(harnessed gates says which subs fire, harnessed prompt gives each spawn-ready prompt,
harnessed checkpoint records the ledger); YOU spawn with CC-native Task / Agent tools.
Do NOT pipe to harnessed run ship — that is the CI/headless path (in-process SDK spawn
that blocks the session, bypasses Agent Teams, and hangs inside Claude Code).
- If the clarification criteria fire for "$ARGUMENTS" (≥2 approaches / core algorithm / API contract / high error cost), clarify interactively in THIS session first (AskUserQuestion) and lock decisions; otherwise transparent-skip. Produce a locked spec.
1b. Bash:
harnessed facts ship --out .harnessed-facts.json → it lists ONLY the facts this stage’s gates actually read: deterministic ones already filled (change size / files touched / stage, from git), judgement calls left null with a one-line hint of what to judge. Edit the file and replace each null in facts with your honest answer from the locked spec — leave one null only if you genuinely cannot judge it (it then falls back to the built-in default). Do NOT skip this step and do NOT invent facts the command did not ask for.
- Bash:
harnessed gates ship --task "<locked spec>" --context-file .harnessed-facts.json --skip-sub discuss → parse the JSON {fire, skip, parallelism}. This is the plan SoT (no spawn). Keep the verbatim JSON.
- Bash:
harnessed checkpoint start ship --plan '<the verbatim gates JSON from step 2>' → seeds the per-sub ledger so harnessed status --recover can re-orient you after compaction.
- If
parallelism.escalate_to_teams === true: read ~/.claude/rules/agent-teams.md, then drive the fired subs as an Agent Team. There is NO create step and no create tool — spawn one background teammate per fired sub with Agent(name: <sub>, run_in_background: true, prompt: <that sub's harnessed prompt prompt>) and the team forms implicitly on the FIRST spawn, with this session as lead (the team_name input is accepted but ignored — the name is session-derived). Coordinate via SendMessage; when a sub is finished, ask that teammate to shut down BY NAME (e.g. "ask the verify-qa teammate to shut down"). Still checkpoint each sub (complete / fail) as below.
- Otherwise, for each fired sub in
order (serial subs sequentially, parallel subs concurrently):
- If the entry has
is_master: true (a stage master — e.g. /auto firing plan/task/verify): do NOT prompt+spawn it. RECURSE: run that master’s own harnessed facts <sub> --out .harnessed-facts.json (fill the nulls) → harnessed gates <sub> --task "<spec>" --context-file .harnessed-facts.json --skip-sub discuss → harnessed checkpoint start <sub> --plan '<json>' → repeat this loop for ITS fired subs.
- Else (leaf sub):
a. Bash:
harnessed prompt <sub> --task "<spec>" --json → parse {prompt, max_iterations, model}.
b. Spawn a CC-native subagent (Task / Agent tool) with that prompt and model, then drive delivery with harnessed's own completion gate:
- on return, write the subagent's final output to a file and run
harnessed checkpoint complete <sub> --result-file <path> — it is fail-closed on the declared artifacts, the TDD boundary, and the verbatim <promise>COMPLETE</promise>.
- if it blocks, run
harnessed checkpoint fail <sub> --failing-tests <n> to record the attempt; it prints BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP when a stop condition is reached.
- respawn ONLY while none of those three has fired. Any one of them means stop: re-scope the subtask, fix the blocker, or escalate to the user. Never respawn past a stop directive.
c. If the output contains
STATUS: NEEDS_CLARIFICATION + questions: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
d. On <promise>COMPLETE</promise>: write the subagent’s final output to a file, then Bash harnessed checkpoint complete <sub> --result-file <path> --summary "<one-line>". Fail-CLOSED — it blocks unless every declared artifacts_expected file exists, the TDD boundary passes (non-empty evidence / both the red and green sides present / the test file was not deleted), and the result carries a verbatim <promise>COMPLETE</promise> (or a structured COMPLETE status). --result <text> is the inline variant; --result-file wins and is quoting-safe on Windows. On a non-zero exit the sub is NOT done — re-spawn to close the gap, or pass --force only to deliberately override (records evidence_status=overridden, an audited override rather than a silent pass).
e. If the complete gate blocked: Bash harnessed checkpoint fail <sub> --failing-tests <n> to record the attempt (omit the flag when the sub has no tests — the evidence-artifact digest is the fallback progress metric). It prints BUDGET-EXHAUSTED (attempts spent vs workflows/defaults.yaml ralph_max_iterations), NO-PROGRESS (no improvement for N consecutive attempts) or BREAK-LOOP (this sub failed >= the threshold) once a stop condition is reached. Respawn ONLY while none of those three has fired; any one of them means STOP — re-scope, fix the blocker, or escalate to the user, and report it.
- After all fired subs are
done (or recorded failed), Bash harnessed status --recover to confirm the ledger and report a per-sub fired/skipped/done/failed summary to the user.
If you lose context (compaction / resume): run harnessed status --recover first — it reads the ledger and prints "you are here, this is next" so you resume at the first pending sub instead of restarting. If the ledger is empty, re-run steps 2-3.
1---2name: ship3description: Stage ⑤ Ship master orchestrator — the release stage after Verify. ship-preflight 必跑串行 (release-readiness gate) → 委派 PR/deploy 给 gstack /ship → publish 留 publish.yml CI (tag push 触发)。schema_version: harnessed.workflow.v3 with delegates_to (1 sub: preflight serial order 1) + disciplines_applied (6 default) + tools_available (release-preflight + ship + planning-with-files)。Triggered by `/ship` (bare per ADR 0030) or `harnessed ship` after `harnessed verify`. Deploy boundary = TAG-READY (no push/publish/tag).4---56# ship master orchestrator (v3) — Stage ⑤78## Overview910The 5th stage, after Verify. harnessed has the pieces (a release-preflight gate, gstack11`/ship`, `publish.yml` CI) — this master orchestrates them into one repeatable release path,12the way comet (archive), Trellis (finish-work), and Claude-Harness (`/harness-release`) each13close their loop.1415| order/mode | sub | when fires |16| ---------- | --- | ---------- |17| 1 (serial) | `preflight` | always when stage=='ship' — read-only release-readiness gate |1819After preflight passes, the master delegates PR + deploy to gstack `/ship` (composition —20harnessed does not reimplement it), and the actual `npm publish` + GitHub release happen in21`publish.yml` CI on tag push.2223## Process24251. **preflight (always)** — run `harnessed release-preflight`. If any check fails (most often26 an empty `## [Unreleased]`), STOP and document the release / clean the tree first.272. **PR / deploy (delegate)** — invoke gstack `/ship` for PR creation + pre-land review.283. **publish (CI)** — push the `v<version>` tag (with explicit user approval) → `publish.yml`29 runs `npm publish` + creates the GitHub release.3031## Boundary (important)3233This stage stops at **tag-ready**. It never pushes to the remote, never publishes to npm, and34never creates a git tag on its own. Those are CI + explicit-approval actions, by design —35"PR ready != release ready", and "release ready != already published".3637## How to invoke3839!`harnessed checkpoint intent ship`4041> The banner above (when present) means this invocation is REGISTERED with the engine (an intent marker) — not yet compliant: steps 2-3 below seed the ledger, and a per-turn `<workflow-intent>` reminder persists until they run.4243The numbered sequence below **is** the state machine — execute it step by step with Bash.44Do NOT improvise an equivalent flow from the Overview above: freelancing bypasses the engine45(no per-sub ledger, no evidence guard, no recovery). harnessed is the orchestration brain46(`harnessed gates` says which subs fire, `harnessed prompt` gives each spawn-ready prompt,47`harnessed checkpoint` records the ledger); YOU spawn with CC-native Task / Agent tools.4849Do NOT pipe to `harnessed run ship` — that is the CI/headless path (in-process SDK spawn50that blocks the session, bypasses Agent Teams, and hangs inside Claude Code).51521. If the clarification criteria fire for "$ARGUMENTS" (≥2 approaches / core algorithm / API contract / high error cost), clarify interactively in THIS session first (AskUserQuestion) and lock decisions; otherwise transparent-skip. Produce a locked spec.531b. Bash: `harnessed facts ship --out .harnessed-facts.json` → it lists ONLY the facts this stage’s gates actually read: deterministic ones already filled (change size / files touched / stage, from git), judgement calls left `null` with a one-line hint of what to judge. Edit the file and replace each `null` in `facts` with your honest answer from the locked spec — leave one null only if you genuinely cannot judge it (it then falls back to the built-in default). Do NOT skip this step and do NOT invent facts the command did not ask for.542. Bash: `harnessed gates ship --task "<locked spec>" --context-file .harnessed-facts.json --skip-sub discuss` → parse the JSON `{fire, skip, parallelism}`. This is the plan SoT (no spawn). Keep the verbatim JSON.553. Bash: `harnessed checkpoint start ship --plan '<the verbatim gates JSON from step 2>'` → seeds the per-sub ledger so `harnessed status --recover` can re-orient you after compaction.564. If `parallelism.escalate_to_teams === true`: read `~/.claude/rules/agent-teams.md`, then drive the fired subs as an Agent Team. There is NO create step and no create tool — spawn one background teammate per fired sub with `Agent(name: <sub>, run_in_background: true, prompt: <that sub's `harnessed prompt <sub>` prompt>)` and the team forms implicitly on the FIRST spawn, with this session as lead (the `team_name` input is accepted but ignored — the name is session-derived). Coordinate via `SendMessage`; when a sub is finished, ask that teammate to shut down BY NAME (e.g. "ask the verify-qa teammate to shut down"). Still checkpoint each sub (`complete` / `fail`) as below.575. Otherwise, for each fired sub in `order` (serial subs sequentially, parallel subs concurrently):58 - **If the entry has `is_master: true`** (a stage master — e.g. `/auto` firing `plan`/`task`/`verify`): do NOT prompt+spawn it. RECURSE: run that master’s own `harnessed facts <sub> --out .harnessed-facts.json` (fill the nulls) → `harnessed gates <sub> --task "<spec>" --context-file .harnessed-facts.json --skip-sub discuss` → `harnessed checkpoint start <sub> --plan '<json>'` → repeat this loop for ITS fired subs.59 - **Else (leaf sub):**60 a. Bash: `harnessed prompt <sub> --task "<spec>" --json` → parse `{prompt, max_iterations, model}`.61 b. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` and `model`, then drive delivery with harnessed's own completion gate:62 - on return, write the subagent's final output to a file and run `harnessed checkpoint complete <sub> --result-file <path>` — it is fail-closed on the declared artifacts, the TDD boundary, and the verbatim `<promise>COMPLETE</promise>`.63 - if it blocks, run `harnessed checkpoint fail <sub> --failing-tests <n>` to record the attempt; it prints BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP when a stop condition is reached.64 - respawn ONLY while none of those three has fired. Any one of them means stop: re-scope the subtask, fix the blocker, or escalate to the user. Never respawn past a stop directive.65 c. If the output contains `STATUS: NEEDS_CLARIFICATION` + questions: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.66 d. On `<promise>COMPLETE</promise>`: write the subagent’s final output to a file, then Bash `harnessed checkpoint complete <sub> --result-file <path> --summary "<one-line>"`. Fail-CLOSED — it blocks unless every declared `artifacts_expected` file exists, the TDD boundary passes (non-empty evidence / both the red and green sides present / the test file was not deleted), and the result carries a verbatim `<promise>COMPLETE</promise>` (or a structured COMPLETE status). `--result <text>` is the inline variant; `--result-file` wins and is quoting-safe on Windows. On a non-zero exit the sub is NOT done — re-spawn to close the gap, or pass `--force` only to deliberately override (records `evidence_status=overridden`, an audited override rather than a silent pass).67 e. If the complete gate blocked: Bash `harnessed checkpoint fail <sub> --failing-tests <n>` to record the attempt (omit the flag when the sub has no tests — the evidence-artifact digest is the fallback progress metric). It prints `BUDGET-EXHAUSTED` (attempts spent vs `workflows/defaults.yaml ralph_max_iterations`), `NO-PROGRESS` (no improvement for N consecutive attempts) or `BREAK-LOOP` (this sub failed >= the threshold) once a stop condition is reached. Respawn ONLY while none of those three has fired; any one of them means STOP — re-scope, fix the blocker, or escalate to the user, and report it.686. After all fired subs are `done` (or recorded `failed`), Bash `harnessed status --recover` to confirm the ledger and report a per-sub fired/skipped/done/failed summary to the user.6970**If you lose context (compaction / resume):** run `harnessed status --recover` first — it reads the ledger and prints "you are here, this is next" so you resume at the first `pending` sub instead of restarting. If the ledger is empty, re-run steps 2-3.7172<!-- harnessed-generated:v4.12.0 -->