Skip to content

v1.91.325.0 fix(ship-budget): thresholds above the host call floor; children hand off instead of stopping; batches admit a prefix (GSTA-167) - #3620

Merged
capy-ai[bot] merged 12 commits into
mainfrom
gsta-167-handoff-floor
Oct 30, 2026
Merged

capy-ai[bot] merged 12 commits into
mainfrom
gsta-167-handoff-floor

Conversation

@garrytan

@garrytan garrytan commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3620,
  "head": "ae0b348bcf2e9337d082316eae8fdbb4c4c9fec4",
  "version": "1.91.319.0",
  "base": "main",
  "gate": {
    "ship-budget": {
      "pass": 45,
      "fail": 0,
      "skip": 0
    },
    "guards": {
      "pass": 20,
      "fail": 0,
      "skip": 0
    },
    "remote-pregate": {
      "pass": 18762,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "a228e1f45ad1ac7ba1ad0aad9a20e15cfc4ef3b5",
  "product_patch_id": "451dcd748a7128dc4aa1d70fc3425a6cbd409fa7",
  "gstack_version": "1.91.321.0",
  "review_depth": {
    "depth": "standard",
    "class": "code",
    "runtime_lines": 229,
    "rules": "55726fab80631072",
    "base": "53db038c6ba6f1408e12418a4adaf61c21808607",
    "registry": "53db038c6ba6f1408e12418a4adaf61c21808607",
    "gate_scan": {
      "tagged": 0,
      "head": "ae0b348bcf2e9337d082316eae8fdbb4c4c9fec4"
    },
    "reasons": [
      "runtime=229>50"
    ]
  },
  "pregate": "requires-remote cleared @a228e1f45ad1 (1 checks, current for ae0b348bcf2e)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/40959621175",
    "windows-free-tests.yml/windows-free-shard: https://github.com/garrytan/gstack/actions/runs/40959621230",
    "pregate.json/remote_gate: remote-gate tree=a228e1f45ad1 tests=18802"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, README.md, ship/sections/budget-handoff.md.tmpl (grep-scoped to the budget contracts; docs/troubleshooting.md ship-budget section)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 16,
    "fixed": 4,
    "scope": "frozen",
    "dispatches": {
      "specialist": 10,
      "red-team": 2
    }
  },
  "carry": {
    "from": "d2a6e60df21b4ce90d8b0dca9a0e3c230865e2e6",
    "reason": "stack parent gst-101-ship-budget-calibration landed + base merge + test-only change + release metadata",
    "product_patch_id": "451dcd748a7128dc4aa1d70fc3425a6cbd409fa7",
    "changed_paths": [
      "product:.github/workflows/evals.yml",
      "product:.github/workflows/free-tests.yml",
      "metadata:CHANGELOG.md",
      "metadata:VERSION",
      "metadata:agents-digest/gstack-AGENTS.md",
      "product:bin/gstack-review-plan",
      "product:docs/TESTING_INTERNALS.md",
      "product:docs/pregate.md",
      "product:docs/review-policy.md",
      "product:docs/ship-policy.md",
      "product:docs/troubleshooting.md",
      "product:lib/gstack-post.ts",
      "product:lib/pregate/checks/lanes.ts",
      "product:lib/review-depth.ts",
      "product:lib/review-scope.ts",
      "product:lib/ship-queue-train-ready.ts",
      "product:package.json",
      "product:scripts/harness-version.json",
      "product:scripts/lib/paid-select.ts",
      "product:scripts/review-dispatch-compare.ts",
      "product:scripts/test-pr-profile.ts",
      "product:ship/sections/pr-body.md",
      "product:ship/sections/pr-body.md.tmpl",
      "product:ship/sections/review-army.md",
      "product:ship/sections/review-army.md.tmpl",
      "test:test/chromium-sandbox-ci.test.ts",
      "test:test/gstack-post.test.ts",
      "test:test/helpers/touchfiles-data.ts",
      "test:test/pr-dependencies.test.ts",
      "test:test/pregate-selection.test.ts",
      "test:test/pregate-user-policy.test.ts",
      "test:test/review-depth.test.ts",
      "test:test/review-plan-cli.test.ts",
      "test:test/review-scope.test.ts",
      "test:test/ship-receipt-depth.test.ts",
      "test:test/size-ledger/ship/fix-pregate-own-policy-and-post-duplicate.json",
      "test:test/size-ledger/ship/gsta152-pr-b.json"
    ],
    "merge_commits": 1,
    "range_diff": "1:  f30c33f =  1:  f30c33f fix(ship-budget): calibrate projections from the run's own meter, settle dispatch reservations when reviewers return (GST-101)\n 2:  00aba4e =  2:  00aba4e fix: pre-landing review fixes (GST-101)\n 3:  9499a63 =  3:  9499a63 docs(ship-budget): handoff sub-cap subtracts unknown charges and the calibrated reserve\n 4:  adb3b10 =  4:  adb3b10 chore: changelog (Unreleased) for GST-101 ship-budget calibration\n 5:  ac8cd2a =  5:  ac8cd2a test(ship-budget): give the GSTA-152 PR B replay an explicit 120s timeout\n 6:  d334618 =  6:  d334618 fix(ship-budget): thresholds above the host call floor; a child hands off instead of stopping; parallel batches admit a prefix (GSTA-167)\n 7:  109be19 =  7:  109be19 fix(ship-budget): a child returns incomplete while a grandchild is unreconciled or an ADMIT remainder was never re-checked; join a child's meter only after its handoff succeeds (GSTA-167)\n 8:  30ce6a6 =  8:  30ce6a6 docs(troubleshooting): BUDGET_CAP_REACHED admits a fitting prefix of a reviewer batch (GSTA-167)\n 9:  d2a6e60 =  9:  d2a6e60 chore: changelog (Unreleased) for GSTA-167 handoff floor\n -:  ------- > 10:  ae0b348 chore: move GSTA-167 changelog entry into [Unreleased]",
    "covers": [
      "pre-landing review",
      "adversarial review",
      "gate integrity",
      "documentation audit"
    ],
    "reruns": [
      "CI at head (gstack-ship-queue ready requires it); test and helper code changed since the reviewed head runs there unreviewed"
    ],
    "ancestry": "linear",
    "trees": [
      "6b3b3bf1154e786ba414d157dbfee42d08584e49"
    ]
  }
}

Stacked on #3614 (budget projection calibration). Part of GSTA-167 / GST-134: cut /ship token cost on Capy.

Stacked on #3614 (budget projection calibration). Part of GSTA-167 / GST-134: cut /ship token cost on Capy.

What changed

A fresh Capy call (150k, all host prompt) no longer delegates the whole /ship at start: thresholds now measure context above the host call floor. (Image render failed on this machine; text version below.)

Before/after as text: A fresh Capy call (150k, all host prompt) no longer delegates the whole /ship at start: thresholds now measure context above the host call floor
--- Before · before.txt · captured output
+++ After · after.txt · captured output
 $ gstack-ship-budget start --token-cap 60M --reading 248000 --prior-reading 98000   # a fresh Capy call: 150k
+BUDGET: admission_cap=60000000 call=150000 call_floor=150000 above_floor=0 next=1 verdict=continue
-BUDGET: admission_cap=60000000 call=150000 next=1 verdict=delegate
-DELEGATE: Steps 1-22 go to a fresh child: gstack-ship-budget handoff --run ship-20261029T193529-3ec27f --from 1 --to 22 --base origin/<base> (ship/sections/budget-handoff.md)
 
  • Per-call thresholds sit above the host's call floor. Each meter has a calibrated floor (lib/ship-budget-calibration.json: Capy 150k, Claude Code 40k, estimate 0), overridable with start --call-floor <n> and inherited by children. Delegation fires when call − floor is 100k or more at start, or 150k or more at a segment boundary; an unknown charge behaves as before. BUDGET/STOP lines print call_floor= and above_floor=.
  • A child never stops on the context rule. After a completed step it hands its remaining steps to a grandchild through the same handoff, verify, return and reconcile path (sub-cap = its remaining sub-cap, depth recorded, max 3). Before its first completed step, at max depth, or past its segment, it continues with one CONTEXT_HIGH: line. The admission-cap stop is unchanged.
  • A child cannot return complete with work left over. return reports status=incomplete with UNRECONCILED: / DROPPED: lines while one of its own grandchildren is unreconciled or an ADMIT remainder was never re-checked (found by this /ship's review, fixed in 109be19).
  • Parallel batches are admitted as a fitting prefix. Each reader is priced at max(projection, the run's measured mean for that role). When the whole batch does not fit, check admits the largest prefix k ≥ 1 and prints ADMIT: k of n (remaining=<roles>); only k = 0 stops. close flags remaining roles nobody re-checked.

Why

"Can we get 95% of the outcome but with 50% of the token use" (Garry, rule 30). On Capy a fresh agent's call costs 98-230k before any work, so DELEGATE_START_CALL (100k) fired on every capped Capy start and DELEGATE_SEGMENT_CALL (150k) stopped two gstack-evals #36 children at their first boundary; #35's 7-reader batch near the cap was refused whole. Capped runs now delegate only on real context growth, a child keeps going, and a near-cap batch runs the readers that fit.

Blast radius

Only gstack-ship-budget (lib/ship-budget*.ts, lib/ship-handoff.ts), the budget-handoff section and docs change; nothing runs this code unless /ship has a token cap, and an uncapped run (this one) prints BUDGET: unmetered and never reaches the thresholds (script ran: gstack-ship-budget start --token-cap none). Child ledgers written by an older gstack lack depth/call_floor and fall back to depth 1 and the calibrated floor (lib/ship-handoff.ts read).

Approvals

No approvals recorded for branch gsta-167-handoff-floor.

Summary

/ship's token budget was tuned on Claude Code and tripped on Capy's per-call floor, so capped runs delegated or stopped before doing work. Thresholds now subtract a calibrated host floor, delegated children chain to a grandchild instead of stopping, and near-cap reviewer batches admit the prefix that fits. Review on this /ship found that a delegated child could return complete with reviewers dropped or a grandchild still running; return now reports incomplete in both cases.

Test Coverage

Step 7 audit (audit-only): 15 changed behaviors covered, 3 gaps (83%). Gaps: --call-floor inheritance into a child ledger; a child that inherited --delegate never (CONTEXT_HIGH path); the out-of-segment handoff guard (now covered by a test added in 109be19).
Regression proof: the two incomplete-return tests fail at d334618 and pass at 109be19.
Tests ran: ship-budget 45
Tests ran: guards 20

Pre-Landing Review

Pass 1 (full depth, 7 dispatches: testing, maintainability, simplification, state-machines, red-team, native adversarial, cross-family outside voice on openai/gpt-6-astra): 2 blocking findings, both fixed in 109be19 (lib/ship-budget-cli.ts:292 close's DROPPED audit never saw a delegated child's ledger; lib/ship-handoff.ts:165 return ignored an unreconciled grandchild). Two informational auto-fixes (join a child's meter only after its handoff succeeds; test for the out-of-segment guard). Pass 2 on the fix range (7 dispatches) and a fresh native adversarial on the range: no blocking findings.
Gate edits: 5 listed, 5 read, 0 findings (test expectations changed with the intended behavior: prefix admission, floor-adjusted thresholds; size ledger raised for the budget-handoff prose with its reason recorded).
Outside review: completed (openai/gpt-6-astra subagent); its one BLOCKING finding is the first fix above. Codex CLI not installed; the cross-family subagent is the outside voice.

Review notes

Informational, not fixed (rule 30: listed, never looped):

  • lib/ship-budget-cli.ts:114: delegate boundaries are only next=7 and next=12, so grandchild chaining happens only from a start-delegated 1-22 child; a heavy 12-22 child continues on CONTEXT_HIGH.
  • lib/ship-budget-calibration.json:74: a 40k Claude floor plus the 150k segment threshold needs at least 190k per-call context, close to a 200k window's auto-compaction, so segment delegation may rarely fire there.
  • lib/ship-budget-cli.ts:160 / :271: ADMIT remaining clears when a later check requests the role (not when the reader starts), a re-check can splice roles from an older reservation at the same step, and there is no way to drop a remainder on purpose (release keeps it).
  • lib/ship-budget.ts:181: the per-role measured mean splits a multi-role settlement evenly, averaging expensive roles down.
  • lib/ship-budget-cli.ts:198: --call-floor is unbounded; a huge value disables delegation for the whole chain.
  • lib/ship-budget-cli.ts:83: the threshold fallback in stopLines is unreachable.
  • lib/ship-handoff.ts:110: if joinMeter throws after the handoff commits, the handoff is saved without its HANDOFF lines (fails toward incomplete).
  • lib/ship-handoff.ts:171-176: a child can reconcile its grandchild with no return file (interrupted) and then return complete; return does not repeat close's BUDGET_CHECK_SKIPPED check; UNRECONCILED/DROPPED lines are uncapped against the 40-line return contract (fails safe as interrupted).
  • docs/ship-budget.md:136: "cannot leave a grandchild writing after the parent moves on" is stronger than the code (return reports it; it does not stop the grandchild).
  • bin/gstack-ship-budget usage header omits start --call-floor.

Exploratory QA

CLI smoke on this branch: start at a 150k Capy call continues (call_floor=150000 above_floor=0); a child at a 500k call delegates at the 6→7 boundary; a child with no grandchild returns complete. The QA section's method reads were not run (budget CLI only, covered by the harness tests above).

Eval Results

eval:select fell back to every gate case (unknown dependency test/size-ledger/ship/gst-101-ship-budget-calibration.json); deferred to the train gate, not run here.

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches).

Documentation

Status: updated. One factual fix, no blockers.

Scope: git diff ac8cd2a on gsta-167-handoff-floor (2 commits, 13 files including the unstaged CHANGELOG): host call floor thresholds, child to grandchild handoff chaining (depth 3 at most), ADMIT prefix admission for reviewer batches, and incomplete child returns. Docs and templates were found by grepping the whole repo for the changed contracts.

Documentation health:

  • docs/troubleshooting.md: Updated. BUDGET_CAP_REACHED now says only a batch whose first reader does not fit stops, and a batch that partly fits admits a prefix with ADMIT:.
  • docs/ship-budget.md: Current (updated in the diff and checked against the code).
  • ship/sections/budget-handoff.md.tmpl: Current (updated in the diff).
  • docs/unattended.md, docs/captain.md, capy/skill/gstack/captain.md, capy/skill/gstack/SKILL.md, ship/SKILL.md.tmpl, ship/sections/review-army.md.tmpl, ship/sections/adversarial.md.tmpl: Current.
  • CHANGELOG.md: Not edited (left to the parent).

Documentation debt:

  • No doc shows the STOP: reason=context_threshold line or its new call_floor=/above_floor= fields (reference gap).
  • CONTEXT_HIGH: has no troubleshooting entry (how-to gap).
  • docs/ship-budget.md cannot be reached from README.md or CLAUDE.md; this predates the branch.
  • No architecture diagrams are affected.

Test plan

  • bun test test/ship-budget.test.ts test/ship-budget-batch.test.ts test/ship-budget-calibration.test.ts test/ship-budget-chain.test.ts: 45 pass, 0 fail
  • bun test test/parity-suite.test.ts test/module-size-ratchet.test.ts test/catalog-budget.test.ts test/context-budget-ratchet.test.ts <skill-md-size tests>: 20 pass, 0 fail
  • bun run typecheck and bun run typecheck:test: clean, no new diagnostics
  • remote pregate (gstack-pregate --stage tests --remote) at the frozen head

🤖 Generated with Claude Code

garrytan and others added 9 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>
…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>
… off instead of stopping; parallel batches admit a prefix (GSTA-167)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…reconciled or an ADMIT remainder was never re-checked; join a child's meter only after its handoff succeeds (GSTA-167)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…a reviewer batch (GSTA-167)

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 changed the base branch from gst-101-ship-budget-calibration to main October 29, 2026 20:27
@trunk-io

trunk-io Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@garrytan
garrytan force-pushed the gsta-167-handoff-floor branch from ede6c52 to b7912c3 Compare October 29, 2026 21:38
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>
@github-actions github-actions Bot changed the title fix(ship-budget): thresholds above the host call floor; children hand off instead of stopping; batches admit a prefix (GSTA-167) v1.91.325.0 fix(ship-budget): thresholds above the host call floor; children hand off instead of stopping; batches admit a prefix (GSTA-167) Oct 30, 2026
@capy-ai
capy-ai Bot merged commit dcd62c3 into main Oct 30, 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