Skip to content

Run each driven /ship phase as one command, count its calls, and stop it at 100 minutes (GST-2984) - #4451

Merged
capy-ai[bot] merged 6 commits into
mainfrom
capy/run-each-driven-ship
Nov 17, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
capy/run-each-driven-ship

Conversation

@garrytan

@garrytan garrytan commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

A driven /ship now runs each ship/DRIVER.md phase as one command, shows how many calls the run made, and stops itself with a printed line at 100 minutes.
Why: measured /ship runs made 121 to 308 calls where the driver plans 9 to 12, and 10 of 12 ran past the 100-minute stop while those limits were only prose.
Nothing to do: older ship records without calls= still validate and print.

What changed

Driven /ship runs kept making hundreds of tool calls and running long, because the one-call-per-phase rule and the 100-minute stop were only written down. They are now code.

  • One command per phase. gstack-ship-phase run --dir <run dir> --phase <n> [--record <rec>] -- '<cmd>'... runs a phase's commands in order, each in the background with its log under <run dir>/phases/<n>/, and prints only result lines. A command still running after 200 s keeps running and the call returns NEXT: rerun; the same command picks the wait back up. A failed command prints STOP: (exit 3), and after the fix the same command starts at the failed step. If you change the command list while an old command is still running, the runner now stops that old process first, so its exit status can never be counted for the new command.
  • One call per phase on Capy. gstack-ship-phase program serves lib/capy-ship-phase.js, loaded like the review pass program. It reads the thread's cost counter for the commands, runs the phase, then the review pass or the closing budget note, then the next phase's section parts. When Capy reports cost.dollars but no cost.credits (as it does today), this program and the review pass program now use dollars × 1,000 instead of passing an empty reading that every budget note refused.
  • Calls are counted. gstack-ship-budget note records calls= since the previous note, and BUDGET_TIMELINE: shows them per phase. gstack-ship-receipt write --budget-record <rec> (or --calls <n>) puts the run's total in the record, and SHIP_RECEIPT: prints calls=<n>. The field is optional.
  • Printed 100-minute stop. In observe mode, the first note or phase run past 100 minutes prints STOP: past 100 minutes ..., writes the head, review passes, next step and calls to stop.json, and keeps the run stopped until gstack-ship-budget resume restarts the clock. Admission mode has no clock.
  • Waits priced by length in ship/DRIVER.md and the Capy skill: a 200 s keep-alive for waits under about 80 minutes, one wait that ends the turn for longer ones, and no 10-15 minute polls.
Blast radius

Only driven /ship runs (ship/DRIVER.md, observe mode) use the phase runner and the stop. Review requirements, the round cap and every check's verdict are unchanged, and the calls field is optional, so older records still validate (test/ship-phase.test.ts runs both shapes through write and placement; script ran). The credits fallback only fills a reading that was otherwise missing.

Calls in this PR's own /ship run

This PR's own /ship run (on its final head 5f04632) printed calls=44 (CALLS: source=log calls=37 ... keepalive_est=7 total_est=44). The handoff's baseline was 121 to 308 parent turns across 12 measured conductor runs. That's one data point, not a measured saving: it ran on the branch that adds the runner, the call log counts only calls that ran a gstack command plus estimated keep-alives (the baseline counted every turn), and the run took two review passes and one CI wait.

Agent notes

Tests: test/ship-phase.test.ts (12 cases, all free): runner resume after a failure, the 200 s return and reattach, result-line filtering, usage errors; the Capy program driving a real Phase 2 (gstack-ship-budget start plus gstack-ship-preflight --audit) on a fixture repo on a fake host whose shell is real, and handing a pass to the review pass program; the time stop by note and by phase run, resume restarting the clock, admit mode untouched; calls per note and in the timeline; receipt write with --budget-record and --calls; the schema field; carry of receipts with and without calls. test/exercised-map.test.ts gains a reviewed-superset row for lib/ship-clock.ts.

Handoffs: org drive handoffs/fold-subagents-2026-11-17 (G2) and handoffs/ship-conductor-cost-2026-11-16.

Open in Capy

Test Coverage

Coverage: 22 of 30 changed paths have a test at two stars or better (73%); the other 8 are new-code edge paths with no test yet (an edited command list's journal cut, a killed command's exit=lost, the 60-line output cap, a bad --calls value, bad program input, a closing note without a thread id, the 32 KB return cap, next-phase parts). No regression test was needed: every changed behavior is new except the credits fallback, which has its own tests.
Tests ran: phase 58
Tests ran: guards 8

Pre-Landing Review

The full review panel ran on this change (two specialists, a red-team reader, a native adversarial reader, a second-model review on GPT-6.1 Sol, and a targeted money reader), then a second pass on the fix. One blocking finding, from the second-model review and confirmed by the adversarial reader, was fixed: a replaced command that was still running could write its exit status into the file its replacement is judged by, so a failing replacement could be recorded as passed. Nothing else met the blocking bar; the items below are recorded and not fixed here.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL lib/ship-phase.ts:87 the journal keys finished commands by their text only, so a same-text rerun after a fix shows the earlier results as done (test evidence is still rechecked at finish)
  • INFORMATIONAL lib/ship-phase.ts:34 liveness is judged by pid alone; a pid reused after a machine sleep keeps a killed command waiting until the 100-minute stop
  • INFORMATIONAL lib/ship-phase.ts:75 no lock around the journal's read, start and write; two runners could start the same command twice
  • INFORMATIONAL lib/ship-phase.ts:85 after SIGTERM only the group leader is checked, so a group member that handles SIGTERM can still write the shared log
  • INFORMATIONAL lib/ship-phase.ts:80 a running entry whose command already wrote its exit file can be signalled if its pid was reused
  • INFORMATIONAL lib/ship-phase.ts:83 on Windows the process-group kill throws, so a changed list with a running entry stops after 5 s instead of continuing
  • INFORMATIONAL lib/capy-ship-phase.js:31 the credits fallback reads 0 when both cost.credits and cost.dollars are missing (same expression in lib/capy-review-pass.js:91)
  • INFORMATIONAL lib/capy-ship-phase.js:45 a phase call with only a review pass dispatches readers without the run's stop check that gstack-ship-phase run --record makes
  • INFORMATIONAL bin/gstack-ship-receipt:243 write fails hard when the budget record is missing, over a calls count that is only informational
  • INFORMATIONAL lib/ship-clock.ts:32 the call count filters the shared call log by time only, so two runs on one state root count each other's calls
  • INFORMATIONAL lib/ship-clock.ts:43 the next-step reader treats a bullet starting with a heading word as the next heading
  • INFORMATIONAL docs/ship-budget.md:112 the long-wait advice names a long local preflight, but phase commands are detached processes with no Capy operation id, so a turn-ending wait lets the machine sleep and stop them
  • INFORMATIONAL test/ship-phase.test.ts:107 the new replacement test gives the old command about 1 s of slack, so a heavily loaded runner could make it flake (the scope tool classed it a note)
Documentation

Status: updated. One factual correction, no blockers.

Scope: the base b49ed6a..193c1a9 on capy/run-each-driven-ship (5 commits, 19 files), with no staged, unstaged or new files. The changes add the gstack-ship-phase runner and its Capy program, the 100-minute clock stop (lib/ship-clock.ts), calls= in budget notes and receipts, and a fallback from cost.dollars to credits.

Documentation health:

  • docs/ship-budget.md: Updated. The Credits paragraph now covers the cost.dollars x 1,000 fallback. The new sections on the 100-minute stop, the phase runner and calls= match the code.
  • ship/DRIVER.md.tmpl and ship/DRIVER.md: Current. Both describe the phase runner, --budget-record and the 100-minute stop.
  • capy/skill/gstack/SKILL.md: Current, with one note. It still names only cost.credits as the credits source. Agents load this file, so it was left for the parent.
  • changelog.d/capy-run-each-driven-ship.md: Current. Not edited, because it is a changelog fragment.
  • docs/troubleshooting.md: Current, with a gap. It has no entry for STOP: past 100 minutes.

Coverage debt:

  • gstack-ship-phase run and gstack-ship-phase program have reference docs in docs/ship-budget.md only. There is no how-to and no troubleshooting entry.
  • STOP: past 100 minutes and stop.json have reference docs only. There is no troubleshooting anchor.
  • gstack-ship-receipt write --calls and --budget-record have reference docs only.

Diagram drift: none found.

Tests
  • bun test test/ship-phase.test.ts test/ship-driver.test.ts test/exercised-map.test.ts: 58 pass, 0 fail
  • bun test test/script-invocation-tripwire.test.ts test/parity-suite.test.ts: 8 pass, 0 fail
  • bun test test/review-pass.test.ts -t 'only cost.dollars': 1 pass (fails without the fix)
  • bun run typecheck: clean
  • CI free-tests run 44123993071 at 5f04632: green
Agent notes

Agent notes

🤖 Generated with Claude Code

REVIEW_LOOP: passes=2 blocking_found=1 deferred=0 noted=6 fixed=1 scope=frozen ledgers_read=2 dispatches=8
Gate edits: none detected (3 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Second-model review: openai/gpt-6.1-sol, completed, 1 blocking finding (fixed in bf0bedd).
Evals: not run on this PR; the selector picks 111 behavioral probes, which the 8-hourly gate on main runs.
Handoffs: org drive handoffs/fold-subagents-2026-11-17 (G2) and handoffs/ship-conductor-cost-2026-11-16.

{
  "schema_version": 1,
  "pr": 4451,
  "head": "5f04632d4b4f2c917e964d5fa011ac69e6a52bd0",
  "version": "1.100.0.0",
  "base": "main",
  "gate": {
    "phase": {
      "pass": 58,
      "fail": 0,
      "skip": 0
    },
    "guards": {
      "pass": 8,
      "fail": 0,
      "skip": 0
    }
  },
  "calls": 44,
  "session_kind": "unattended",
  "run": "ship4451-run",
  "head_tree": "324b9ec218c1a23d338541ad397f5e83e3bd83be",
  "product_patch_id": "e560ac0ed38dd54440b26be461cf6965fc602547",
  "gstack_version": "1.100.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 460,
    "rules": "66e5174161eecc2c",
    "base": "e0c4136dc2999840720091ee772666127099e13d",
    "registry": "e0c4136dc2999840720091ee772666127099e13d",
    "gate_scan": {
      "tagged": 0,
      "head": "5f04632d4b4f2c917e964d5fa011ac69e6a52bd0"
    },
    "reasons": [
      "gate-class",
      "risk:money",
      "risk:security",
      "runtime=460"
    ],
    "risk": [
      "money",
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @324b9ec218c1 (8 checks, current for 5f04632d4b4f)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44123993071/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44124007321/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=324b9ec218c1 tests=37510 skipped=75 runs=44123993071/1 profiles=ci-reuse/free-tests heads=5f04632d4b4f verified=2026-11-17T16:33:24.528Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, README.md, CONTRIBUTING.md, CLAUDE.md, AGENTS.md, ship/DRIVER.md.tmpl, capy/skill/gstack/SKILL.md"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 1,
    "deferred": 0,
    "noted": 6,
    "fixed": 1,
    "scope": "frozen",
    "rounds": 2,
    "ledgers_read": 5,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  },
  "gate_dispositions": [],
  "review_targeted": {
    "classes": [
      "money"
    ],
    "rules": "8811fd300bf305f0",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "e560ac0ed38dd54440b26be461cf6965fc602547",
    "status": "done",
    "findings": 1,
    "raised_by": "targeted"
  }
}

…t, and print the 100-minute stop

Adds gstack-ship-phase (a resumable phase runner plus the Capy phase program), calls= per
budget note and in the ship receipt, a printed STOP: past 100 minutes with stop.json, and the
length-priced wait rule in ship/DRIVER.md (GST-2984).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai capy-ai Bot changed the title Run each driven /ship phase as one command, show its calls in the receipt, and stop at 100 minutes (GST-2984) Run each driven /ship phase as one command, count its calls, and stop it at 100 minutes (GST-2984) Nov 17, 2026
garrytan and others added 5 commits November 17, 2026 15:29
…lower phase tests room

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…redits

Capy thread.get now returns cost.dollars without cost.credits, so the phase and review pass programs passed --credits undefined and every budget note refused it. Both programs fall back to dollars x 1,000.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…me log

A changed command list left the old process running, and its exit status could settle the new command (a failing replacement journaled as passed). The runner now stops the replaced process group first and stops the phase if it will not exit.

Review-Finding: p1/outside-voice#1 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 0ee5914 into main Nov 17, 2026
78 checks passed
This was referenced Nov 18, 2026
capy-ai Bot added a commit that referenced this pull request Nov 18, 2026
- A test, or a scratch repository in the temp directory, can no longer write approval rows into your real Capy Drive (GST-3027). (#4466)
- An unattended /autoplan run on Claude Code no longer says the publication guard is off while it is on. (#4481)
- A phase report written only in reasoning now gets a denial that says so and names the fix. (#4481)
- `gstack-autoplan revise` no longer refuses a plan that the first `next` accepted. (#4470)
- `revise --plan` with a different file now says the run follows that file. (#4470)
- A second-model plan review in `/autoplan` is no longer reported as unavailable when it actually ran (GST-3051). (#4471)
- The /ship conductor trial plan now lets case reverts that conflict with later code be resolved by hand in docs, tests and the planted file, so large pull requests can be cases (GST-3003). (#4460)
- A locked plan for a trial of /ship without its separate conductor subagent (GST-3003). (#4456)
- A driven /ship now runs each phase as one command, counts its calls, and stops itself at 100 minutes. (#4451)
- /ship stops asking owners to clear two kinds of bookkeeping noise: base-side merge text and a reviewer's confirmation prose. (#4458)
- A base merge that only touched base-side text no longer stops `/ship` finish for an owner's grant. (#4458)
- A reviewer's confirmation prose no longer becomes a Critical finding that only an owner can clear. (#4458)
- A CI run that passed only after its failed jobs were re-run is now marked wherever gstack reuses it. (#4473)
- /ship reuses CI's passing test run when merging the base changed no file, and stops instead of quietly starting hour-long test runs or reviewing an empty diff (GST-3019). (#4461)
- /ship on Codex no longer stops at the test coverage audit. (#4489)
- A cold first-use check before an app build reaches its owner (GST-3025). (#4465)
- `skill_prefix=true` now survives updates when gbrain is installed. (#4454)
- The OpenClaw docs no longer send you to ClawHub, which held only April 2026 builds of office-hours, ceo-review and retro and no longer has gstack skills (the docs also said four skills while listing three). (#4454)
- `gstack-issue-links` no longer reads other repositories' issues as gstack's. (#4454)
- /ship's pre-gate finds the tests of a monorepo app that imports through its own `@/` alias. (#4464)
- /office-hours explains why it recommends a mode. (#4450)
- /office-hours keeps its 34 founder videos and essays out of the skill file. (#4463)
- Two `gstack-owner-answers add` runs for the same answer no longer collide. (#4490)
- A Captain can check an ask against the owner's earlier answers before sending it. (#4467)
- `gstack-post` stops reading /ship's own receipt identifiers as phone numbers, so posting a /ship PR body no longer needs a confirm. (#4488)
- GitHub release notes now list every change in plain words, with a link to its pull request. (#4390)
- gstack's router no longer gives bug reports a special rule, so the model fixes a bug the way it would without gstack. (#4442)
- /ship's review plan now sorts Swift and Xcode files by risk instead of sending every iOS PR to the full review panel (GST-3041). (#4469)
- /ship's review plan now sends Swift code that touches private user data to the full review panel (GST-3052). (#4472)
- A round grant at /ship's review round cap now buys the fix round it names, in the same run or the next (GST-2968). (#4479)
- The secrets check stops flagging three kinds of ordinary code as a secret, and catches two misses. (#4457)
- A security finding's location and reason no longer go into a PR body. (#4486)
- The token-capped /ship child on Claude Code now starts its prompt with the typed `/ship` command, so the skill actually loads. (#4487)
- A /ship receipt now counts the second-model review's blocking findings, and refuses to be written while one is still open. (#4485)
- A `/ship` with a token cap on Claude Code no longer stops at its first handoff. (#4452)
- /ship's push step now always ends with one line that says whether it pushed (GST-3053). (#4474)
- A PR's review-round count can no longer be overwritten by the body `/ship` posts. (#4440)
- One queued record with a malformed path no longer stops artifacts sync for every project. (#4455)
- A failed artifacts push stays reported until a push succeeds. (#4455)
- The /sync-gbrain memory row no longer says OK when pages failed to import. (#4455)
- ### Tests (#4495)
- A policy-floor test no longer fails once gstack's own version reaches the minor after the newest policy key; it now checks a floor above both, so the v1.101.0.0 release can pass CI. (#4495)
- CI now uploads free-suite test results to Trunk with analytics-uploader v2.1.8 and analytics-cli 0.17.0, up from v2.1.6 and 0.16.2. (#4453)
- Packing a checkout for a Ubicloud run no longer fails when git beside it is rewriting a ref. (#4447)
- The /plan-ceo-review HOLD SCOPE eval no longer fails a review because its follow-up question didn't repeat the mode name. (#4447)
- Unattended /autoplan now records the owner's relayed gate reply instead of refusing it. (#4484)
- Unattended /autoplan now runs the second-model review you turned on, and waits for it instead of ending the session. (#4459)
- Two /autoplan runs started in the same second no longer share a run id. (#4459)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant