Skip to content

v1.91.324.0 fix(ship-budget): project steps and reviewers from the run's own spend, settle reviewers when they return (GST-101) - #3614

Merged
capy-ai[bot] merged 6 commits into
mainfrom
gst-101-ship-budget-calibration
Oct 29, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
gst-101-ship-budget-calibration

Conversation

@garrytan

@garrytan garrytan commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3614,
  "head": "ac8cd2abe16f9b139e192b844bf4b8a955dfed22",
  "version": "1.91.319.0",
  "base": "main",
  "gate": {
    "remote_gate": {
      "pass": 18575,
      "fail": 0,
      "skip": 0
    },
    "focused-local": {
      "pass": 114,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "run": "jam_01M646M97GB2C3RX99666SWMPD",
  "head_tree": "c1ce761bb4dd495c696f0eb1fc2db2f2726d8bc3",
  "product_patch_id": "46d9395f18c83711381a47ffe4577f38824bb273",
  "gstack_version": "1.91.319.0",
  "review_depth": {
    "depth": "standard",
    "class": "code",
    "runtime_lines": 163,
    "rules": "9bc0e4d2f74ef6b4",
    "base": "319ef500ca2ff1294e0e08e90afef94d75222367",
    "registry": "319ef500ca2ff1294e0e08e90afef94d75222367",
    "gate_scan": {
      "tagged": 0,
      "head": "ac8cd2abe16f9b139e192b844bf4b8a955dfed22"
    },
    "reasons": [
      "runtime=163>50"
    ]
  },
  "pregate": "requires-remote cleared @c1ce761bb4dd (1 checks, current for ac8cd2abe16f)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/40920052005",
    "windows-free-tests.yml/windows-free-shard: https://github.com/garrytan/gstack/actions/runs/40920057224",
    "pregate.json/remote_gate: remote-gate tree=c1ce761bb4dd tests=18575"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/ship-budget.md, ship/sections/budget-handoff.md.tmpl, docs/troubleshooting.md, docs/unattended.md (docs referencing gstack-ship-budget)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 8,
    "fixed": 2,
    "scope": "frozen",
    "fix_checks": 1,
    "dispatches": {
      "specialist": 2
    }
  }
}

What changed

An 8M /ship budget now projects steps from the run's own measured cost (0.47M) instead of the 2.25M prior, so it reaches Step 6.5 instead of stopping at Step 6

An 8M /ship budget now projects steps from the run's own measured cost (0.47M) instead of the 2.25M prior, so it reaches Step 6.5 instead of stopping at Step 6.

Before/after as text: An 8M /ship budget now projects steps from the run's own measured cost (0.47M) instead of the 2.25M prior, so it reaches Step 6.5 instead of stopping at Step 6
--- Before · before.txt · captured output
+++ After · after.txt · captured output
 $ gstack-ship-budget check --token-cap 8M  (GSTA-2 replay: Steps 1-5 cost ~0.27M each)
+BUDGET: used=1161000 tail=2900000 next=5 projected=470000 calibration=step:0.207,dispatch:prior verdict=continue
+BUDGET: used=1485000 tail=2920000 next=6 projected=490000 calibration=step:0.216,dispatch:prior verdict=continue
+BUDGET: used=1822500 tail=2930000 next=6.5 projected=510000 calibration=step:0.225,dispatch:prior verdict=continue
+BUDGET: used=2173500 tail=2950000 next=7 projected=3850000 calibration=step:0.234,dispatch:prior verdict=stop
+# admits Steps 6 and 6.5 from the run's own measured step cost; still stops with room to stop
-BUDGET: used=1161000 tail=4480000 next=5 projected=2250000 verdict=continue
-BUDGET: used=1485000 tail=4480000 next=6 projected=2250000 verdict=stop
-STOP: reason=budget_exhausted spent=1485000 admission_cap=8000000 next=6 projected=2250000
-# stops before Step 6 with 6.5M of the 8M cap unspent: every step projected at the 2.25M prior
 

Why

GST-101: "7.43M projected vs 0.23-1.02M actual" per reviewer on GSTA-152, and about 2.25M projected per step against roughly 0.27M spent on GSTA-2, so real token caps refused work that cost a small fraction of the guess. Once a run has measured a step or a reviewer, it now projects the next one from its own spend, with the same 1.5x headroom the committed fit uses, and it still stops with room to stop.

Blast radius

Only gstack-ship-budget, gstack-review-log --finish and the handoff read the new fields, and every run starts at the calibrated prior until its first measurement, so a run with no reading behaves as before. Old ledgers parse unchanged because the new samples and unseen fields are optional; this was walked in review and is covered by the existing ship-budget suites (114 tests across 15 files pass locally).

Approvals

No approvals recorded for branch gst-101-ship-budget-calibration.

Summary

The /ship budget projected every step and dispatch from fixed constants, so caps refused cheap work (GSTA-152 refused its third reviewer at 29.28M; GSTA-2 stopped before Step 6 at 8M). Each settled reservation is now measured on the next reading and the run projects with its own factor, the largest actual/prior ratio of its last three measurements times 1.5. Reviewers admitted one at a time are settled when they return (check --returned, --finish for the whole pass, or a step change), and DRIFT:/BUDGET_DRIFT: lines print projected against actual. Review found two gate defects in the first cut, and both are fixed here. Charges the meter cannot see were being measured, and handoff held back a different reserve than check.

Test Coverage

CODE PATH COVERAGE (GST-101, ad8e12d..f30c33f)
lib/ship-budget.ts
 ├─ measuredFactor  prior until 1st sample ............ [★★★ TESTED] projection:118
 │   ├─ max over last SAMPLE_WINDOW=3 ................. [★★  TESTED] PR B replay:65 (window slide not isolated)
 │   └─ epoch filter (meter epoch change) ............. [GAP] no test resets epoch
 ├─ projector.reserve scaled / explicit --reserve ..... [★★★ TESTED] :118, :134
 ├─ projector.segment (RECOVER tail) .................. [★★  TESTED] GSTA-2 replay:42
 ├─ measureSettled step / dispatch group split ........ [★★★ TESTED] :118, :161
 │   └─ last < reading_at / no reading guards ......... [GAP]
 ├─ budgetLine calibration= label ..................... [★★★ TESTED] :118, :134
 └─ settleReviewFinish settles whole pass ............. [★★★ TESTED] :161
lib/ship-budget-cli.ts
 ├─ check --returned ok / unknown id usage error ...... [★★★ TESTED] :146
 ├─ check step change settles consumed dispatches ..... [★★★ TESTED] :181
 ├─ settle --reading -> DRIFT ......................... [★★★ TESTED] :65 (l.90)
 ├─ close BUDGET_DRIFT totals ......................... [★★★ TESTED] :191
 └─ freshReading under claude meter (no --reading) .... [GAP] only capy meter exercised
bin/gstack-review-log finish message ................. [★★ TESTED] via :161 (exit code only)
test/ship-budget.test.ts boundary rewrite ............ updated expectation, passes
COVERAGE: 11/14 paths (79%); regression proof: 8 red at ad8e12d, green at f30c33f

Tests: 11 new in test/ship-budget-projection.test.ts (8 from the fix, 3 from review); 2 existing tests in test/ship-budget.test.ts re-pinned to the calibrated behaviour.
Coverage: 79% value-weighted (11 of 14 paths; 1 weakly covered path: the 3-sample window slide is exercised only inside the PR B replay).
Test value: 3 tests written by review fixes, 0 rejected by the authoring gate, 0 existing tests extended, 1 path weakly covered.
Regression proof — fails at HEAD: yes (8 at ad8e12d; the 3 review-fix tests at f30c33f) · passes at base: unavailable (new behaviour, no base control run) · passes after fix: yes
Gaps, not filled (audit-only): the meter-epoch filter in measuredFactor, measureSettled's no-reading guards, and freshReading under the Claude meter.

Pre-Landing Review

Pre-Landing Review: 9 issues — 2 fixed (blocking), 7 noted. Pass 2 on the fix range: no issues at the floor, 1 noted.

REVIEW_LOOP: passes=2 blocking_found=2 deferred=0 noted=8 fixed=2 scope=frozen dispatches=2

Gate edits: 5 listed, 3 read, 0 findings — the three untagged hunks in test/ship-budget.test.ts re-pin the tests to the calibrated behaviour (dead STEP2 removed; the exact-at-cap boundary now uses an unmeasured dispatch; the spend test expects the measured factor). None relaxes an assertion.

Outside review: completed by openai/gpt-6.1-sol (Capy subagent, cross-family); it found both blocking defects fixed here. Codex CLI not installed, so the Codex passes were unavailable.

Review notes

Below the blocking floor, listed rather than looped (CREW rule 23):

  • lib/ship-budget.ts measuredFactor has no floor of 1, so one cheap early step lowers every later projection and the tail reserve. That is the intended calibration (trail rows 4-5); the stop overhead is never scaled.
  • A dispatch check in the middle of a step settles and measures that step at its partial cost.
  • --finish settles sibling dispatch reservations of the same step that are still running.
  • --returned settles a reservation that never started instead of releasing it.
  • A Claude-metered dispatch mixing outside-voice with metered roles is marked unseen as a whole; the error makes the factor too high, never too low.
  • A ledger open across this upgrade with a pending unmeasured --unknown settle could still be sampled once.
  • The handoff brief text still prints the unscaled l.tail, and handoff reads the reserve without measuring first (it agrees with the delegate check at the same reading).
  • The PR B replay takes 4.6 to 5.0s on 2 cores, near bare bun test's 5s default; bun run test uses 30s.
  • Child sub-caps still use the prior segmentEstimate.

Exploratory QA

CLI replay of GSTA-2 through the real gstack-ship-budget at ad8e12d and at this branch (the image above): the base stops before Step 6 with 6.5M unspent; the branch admits Steps 6 and 6.5 and stops at Step 7 with the stop reserve intact.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related eval selected: the only skill prose change is two sentences in ship/sections/budget-handoff.md(.tmpl); gen:skill-docs is fresh and the parity suite passes.

Plan Completion

6 of 6 plan items done (the 4 design rows of the decision trail plus the two ledger notes in the GSTA-152 PR B evidence).

TODOS

No TODO items completed in this PR.

Documentation

Status: updated — one factual fix in docs/ship-budget.md.

Scope: base ad8e12d..HEAD (2 commits, 11 files: ship-budget CLI/lib, handoff, review-log, tests) plus unstaged CHANGELOG.md; docs referencing gstack-ship-budget (docs/ship-budget.md, ship/sections/budget-handoff.md.tmpl, docs/troubleshooting.md, docs/unattended.md).

Documentation health

File Status
docs/ship-budget.md Updated: Delegation step 1 sub-cap now subtracts unknown charges and the calibrated tail reserve plus stop overhead, matching lib/ship-handoff.ts
ship/sections/budget-handoff.md.tmpl Current (already updated in branch)
docs/troubleshooting.md Current
docs/unattended.md Current

Coverage debt: --returned, settle --reading, DRIFT:/BUDGET_DRIFT: and the calibration= field have reference coverage in docs/ship-budget.md only (no how-to or troubleshooting entries); common gaps, not filled. No diagram drift (no diagrams reference these modules).

Test plan

  • gstack-pregate --stage tests --remote --spend-cap 2 --timeout 2700 --allow-repo-commands at ac8cd2a: remote gate 18575 tests, 0 failed (tree c1ce761bb4dd, $0.09); preflight regen, secrets, strays, literals, timing and guards pass
  • bun test --timeout=30000 on the ship-budget suites, claude-usage, parity-suite, module-size-ratchet, spawnsync tripwire and bun-entry-isolation: 114 pass, 0 fail
  • bun run typecheck: clean; bun run typecheck:test: none new
  • bun run gen:skill-docs: fresh
  • macOS named regressions and the Windows free shard: cleared at ac8cd2a by dispatched Free Tests run 40920052005 and Windows Free Tests run 40920057224 (the adb3b10 Windows shard 5 timeout in this PR's GSTA-152 PR B replay test is fixed in ac8cd2a with a 120s test timeout)

Decision trail: reports/GSTA-166-decisions.tsv in the GStack Minder drive.

🤖 Generated with Claude Code

garrytan and others added 4 commits October 29, 2026 16:28
…tle dispatch reservations when reviewers return (GST-101)

The /ship budget projected every step and dispatch from fixed constants
(7.43M per dispatch, 2.25M per default step) plus a fixed 4.48M reserve, so
real caps refused work that cost 3-20x less (GSTA-152 PR B, GSTA-2). Each
settled reservation is now measured on the next reading, and the run projects
with its own factor (max actual/prior of its last three measurements x 1.5),
the prior only before the first measurement. The default tail reserve scales
with the step factor; the stop overhead keeps its fit.

Reservations of reviewers admitted one at a time no longer pile up: check
--returned settles named dispatches, --finish settles the pass's dispatches of
that step, and a step change settles consumed dispatches. DRIFT and
BUDGET_DRIFT lines print projected against actual.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Unseen charges (settle --unknown, a Claude-metered outside voice) are booked
at their reservation and never measured, so they cannot shrink the dispatch
factor. The handoff holds back the same calibrated reserve as check, so a
delegate verdict is one the handoff admits.

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

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>
@trunk-io

trunk-io Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…eout

It spawns about 100 CLI processes; on windows-latest it ran past the
shard runner's 30s per-test timeout (windows-free-shard 5, run
40917695070), and on 2 cores it sat at bare bun test's 5s default.

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

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

# Conflicts:
#	CHANGELOG.md
@github-actions github-actions Bot changed the title fix(ship-budget): project steps and reviewers from the run's own spend, settle reviewers when they return (GST-101) v1.91.324.0 fix(ship-budget): project steps and reviewers from the run's own spend, settle reviewers when they return (GST-101) Oct 29, 2026
@capy-ai
capy-ai Bot merged commit 53db038 into main Oct 29, 2026
62 checks passed
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