Repository navigation
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
Conversation
…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
Bot
changed the base branch from
gst-101-ship-budget-calibration
to
main
October 29, 2026 20:27
|
😎 This pull request was merged. |
garrytan
force-pushed
the
gsta-167-handoff-floor
branch
from
October 29, 2026 20:41
d2a6e60 to
ede6c52
Compare
2 of 3 tasks
garrytan
force-pushed
the
gsta-167-handoff-floor
branch
from
October 29, 2026 21:38
ede6c52 to
b7912c3
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
lib/ship-budget-calibration.json: Capy 150k, Claude Code 40k, estimate 0), overridable withstart --call-floor <n>and inherited by children. Delegation fires whencall − flooris 100k or more at start, or 150k or more at a segment boundary; an unknown charge behaves as before.BUDGET/STOPlines printcall_floor=andabove_floor=.CONTEXT_HIGH:line. The admission-cap stop is unchanged.returnreportsstatus=incompletewithUNRECONCILED:/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).checkadmits the largest prefix k ≥ 1 and printsADMIT: k of n (remaining=<roles>); only k = 0 stops.closeflags 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 andDELEGATE_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) printsBUDGET: unmeteredand never reaches the thresholds (script ran:gstack-ship-budget start --token-cap none). Child ledgers written by an older gstack lackdepth/call_floorand 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;
returnnow reports incomplete in both cases.Test Coverage
Step 7 audit (audit-only): 15 changed behaviors covered, 3 gaps (83%). Gaps:
--call-floorinheritance 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:292close's DROPPED audit never saw a delegated child's ledger;lib/ship-handoff.ts:165return 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 onCONTEXT_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: ADMITremainingclears 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 (releasekeeps 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-flooris unbounded; a huge value disables delegation for the whole chain.lib/ship-budget-cli.ts:83: thethresholdfallback instopLinesis unreachable.lib/ship-handoff.ts:110: ifjoinMeterthrows 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;returndoes not repeat close'sBUDGET_CHECK_SKIPPEDcheck;UNRECONCILED/DROPPEDlines are uncapped against the 40-line return contract (fails safe asinterrupted).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-budgetusage header omitsstart --call-floor.Exploratory QA
CLI smoke on this branch:
startat 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:selectfell back to every gate case (unknown dependencytest/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 ac8cd2aongsta-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 withADMIT:.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:
STOP: reason=context_thresholdline or its newcall_floor=/above_floor=fields (reference gap).CONTEXT_HIGH:has no troubleshooting entry (how-to gap).docs/ship-budget.mdcannot be reached from README.md or CLAUDE.md; this predates the branch.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 failbun 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 failbun run typecheckandbun run typecheck:test: clean, no new diagnosticsgstack-pregate --stage tests --remote) at the frozen head🤖 Generated with Claude Code