/gstack-ship keeps a run's token cap when its budget start reruns mid-run, and four more budget-run fixes (GST-4132) (#4882)

A /gstack-ship run that reruns its budget start while it is still open
keeps its own token cap and clock instead of getting a fresh (or no)
cap.

Why: the budget cap is the money guard on /gstack-ship, and #4877 left
five ways around or past it, listed in its ruled notes.

Nothing to do: the fixes take effect on the next gstack upgrade.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/specialist-batched#1 reader=state-machines
Review-Finding: p1/specialist-batched#2 reader=testing
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: v2/targeted#1 reader=targeted
Review-Finding: v2/outside-voice#1 reader=outside-voice
Review-Finding: v2/outside-voice#2 reader=outside-voice
Review-Finding: v2/outside-voice#3 reader=outside-voice
Review-Finding: v2/outside-voice#4 reader=outside-voice
Review-Finding: v2/outside-voice#5 reader=outside-voice
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-28 18:47:13 +00:00
1 parent be9b34e3dc
commit 37cad2b526
11 files changed
+621 -99

No files matched your search

+26 -9
View File
@@ -84,7 +84,9 @@ ship/DRIVER.md stops a run past 100 minutes. Measured conductors ran past it in
line of prose (handoffs/ship-conductor-cost-2026-11-16), so it is now code (`lib/ship-clock.ts`). The clock counts
active minutes, not wall time (GST-4109): any stretch longer than 5 minutes with no gstack call in the call log
(below) is the lane parked on CI, a reviewer it ended its turn on, or a Captain's ruling, so only its first 5 minutes
count. Only calls made in the run's own checkout count, so another lane on the same machine never keeps it running. A run that keeps calling gstack, such as a pass or phase loop that never settles, never parks, so it still
count. Only calls made in the run's own checkout count (a call whose working directory has that checkout as its git
toplevel; a nested checkout or submodule inside it is another checkout, GST-4132), so another lane on the same machine
never keeps it running. A run that keeps calling gstack, such as a pass or phase loop that never settles, never parks, so it still
stops at 100 minutes. With no call log (off Capy) the clock is wall time. In observe mode the first `note`, or
`gstack-ship-phase run --record`, past 100 active minutes from the ledger's start prints
@@ -317,14 +319,29 @@ ledger has already gone past its start (a note, a check or a handoff), whose /gs
ended, or that started over 5 minutes ago mints a new run, marks the earlier ledger `superseded_by` it (so it
stops holding gstack upgrades and never writes the record or removes the marker again) and prints
`SUPERSEDED: run <id> …`, so an earlier /gstack-ship in the same thread never counts against this run's cap or
clock (GST-4109); a rerun of the same start inside the same open run re-attaches. A start never lifts a stop:
on a stopped ledger it re-attaches, exits 3 and prints a `STOP:` line naming `resume`, which alone continues a
stopped run (a cap raise with the owner's `--approved-by` and `--words`). The same holds for a run that is past its
limit but not yet stopped (an observe run stops only at its next note): while the checkout's /gstack-ship run record that
opened after the ledger is still open, a `start` whose reading puts that ledger over its cap, or whose clock is past 100
active minutes, records the stop, re-attaches, exits 3 and prints a `RESUME:` line instead of minting a new run. A
/gstack-ship that has ended is superseded untouched.
Continue an earlier run with `resume --run <id>`, which clears `superseded_by`. A `resume --meter capy` that moves a run onto the Capy counter needs `--reading`, the new
clock (GST-4109). While the checkout's /gstack-ship run record is that ledger's and still open (preflight bound the
ledger to its run id, or for an older ledger the record opened after it), `start` always re-attaches the run, however far it
got: a stricter `--token-cap` (lower, or a cap where the run had none) applies and prints `CAP: lowered …`, while a higher
cap or `none` prints `CAP: kept admission_cap=<n> …`, since only `resume --token-cap` with the owner's words raises or removes
one (GST-4132). A start never lifts a stop: on a stopped ledger it
re-attaches, exits 3 and prints a `STOP:` line naming `resume`, which alone continues a stopped run (a cap raise with the
owner's `--approved-by` and `--words`). Every re-attach first checks the run's limits at this start's reading (an observe
run stops only at its next note): a run past its cap, or past 100 active minutes, records the stop, exits 3 and prints a
`RESUME:` line. A /gstack-ship that has ended is superseded untouched. In full:
| The checkout's run record | Ledger open, within its limits | Open, past a limit | Stopped | Closed |
|---|---|---|---|---|
| Open, and this ledger's | re-attach, exit 0 | record the stop, re-attach, exit 3 | re-attach, exit 3 | new run |
| Ended after the ledger started | supersede, exit 0 | supersede untouched, exit 0 | re-attach, exit 3 | new run |
| None, or another run's | a rerun within 5 minutes and before any progress re-attaches (exit 3 past a limit); otherwise supersede, exit 0 | the same | re-attach, exit 3 | new run |
`start` decides and writes while holding the earlier ledger's lock, so a `note --run <old>` racing it lands before the
supersede (which then points the record at the new run) or finds the old run superseded, and a second `start` racing it
re-reads the record and joins the run the first one opened; and it refuses `--ledger <path>`
when the path is the earlier ledger's file (by path, symlink or hard link), which a new run would overwrite.
Continue an earlier run with `resume --run <id>`, which clears `superseded_by` and marks the newest run that had
superseded it superseded in turn (`SUPERSEDED: run <id> superseded run <id>, and this resume …`), so that run stops
holding gstack upgrades; a closed one is left as it was (GST-4132). A `resume --meter capy` that moves a run onto the Capy counter needs `--reading`, the new
epoch's baseline, or it would count the thread's whole counter as the run's use. The ledger and record are
mirrored to a private Drive checkpoint (`GSTACK_SHIP_BUDGET_CHECKPOINT_DIR`, else the
project-user Drive folder on Capy) bound to the run id and their hashes, so after a machine
+2 -1
View File
@@ -1824,7 +1824,8 @@ without `--owner-ref` stop. Only gstack's commands end it: `finish` removes the
record (only when the open PR's body names that run), `gstack-ship-receipt stop`
marks it stopped (a new run's preflight replaces it), `gstack-skill-end` marks it finished on any
outcome, the run's own Step 22 `gstack-ship-budget close` marks its open record finished (the next
preflight does the same for an open record whose run's budget ledger already closed, GST-4109), and `gstack-ship-run abandon` ends a run that stopped working, never
preflight does the same for an open record whose run's budget ledger already closed, GST-4109; that ledger is the one
the run's preflight bound to its run id, so an earlier run's late close never ends a later run, GST-4132), and `gstack-ship-run abandon` ends a run that stopped working, never
within 60 minutes of its last beat unless the harness process it ran under is
provably gone (GST-3546). No timer ends a run. A bare marker from an
older gstack reads as `legacy` and an unreadable record as `unreadable`; both