mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 08:31:44 +01:00
Capy threads use halved token limits and follow three new rules on subagents, relays and going forward (GST-3323) (#4582)
Capy threads working on a PR now check in at 500M own tokens, standing threads rotate at 250M, and any subagent past 50M gets a look; `gstack-runaway scan` and /ship's default subagent cap use the new lines. Why: Capy's token counts have read about half what they did before 2026-11-15, so the old lines were double the ones in use, and three standing rules (subagents, relays, going forward) were missing from the factory rules every Capy thread reads. Nothing to do: the new lines apply on the next gstack upgrade. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
507ebfc16d
commit
1a95eae330
18 files changed
+124
-89
No files matched your search
@@ -173,7 +173,7 @@ Each skill feeds into the next. `/office-hours` writes a design doc that `/plan-
|
||||
| `/canary` | **SRE** | Post-deploy monitoring loop. Watches for console errors, performance regressions, and page failures. |
|
||||
| `/benchmark` | **Performance Engineer** | Baseline page load times, Core Web Vitals, and resource sizes. Compare before/after on every PR. |
|
||||
| `/ubicloud` | **Remote Runner** | Run a heavy suite, build or eval on an ephemeral 16-vCPU Ubicloud VM: owner- and TTL-named VMs with a reaper, quota preflight, a hang watchdog, and one committed verify per repository. |
|
||||
| `/runaway-stopper` | **Spend Warden** | Find runaway agent threads and subagents on Capy (a standing thread past 500M own tokens or 3 days, a subagent past 100M, empty wakes, endless review rounds), stop them at a clean point, rotate standing threads through a handoff (a crew thread keeps its PR until it merges or closes), and set the defaults that keep them from coming back. `gstack-runaway scan` reads the host's own thread data and never acts. |
|
||||
| `/runaway-stopper` | **Spend Warden** | Find runaway agent threads and subagents on Capy (a standing thread past 250M own tokens or 3 days, a subagent past 50M, empty wakes, endless review rounds), stop them at a clean point, rotate standing threads through a handoff (a crew thread keeps its PR until it merges or closes), and set the defaults that keep them from coming back. `gstack-runaway scan` reads the host's own thread data and never acts. |
|
||||
| `/eval-plan` | **Eval Planner** | Preregister a paid eval before the first priced call: bars, arms, decoys and stop rules, a $0 stub-model dry run over the real inputs, and a three-item priced pilot whose extrapolation and spend table gate the approval. |
|
||||
| `/document-release` | **Technical Writer** | Audit changed behavior against project docs on every ship, before final verification and publication. Also runs standalone. Shows updated, reviewed/current or blocked docs and any remaining gaps. |
|
||||
| `/document-generate` | **Documentation Author** | Generate missing docs from scratch using the Diataxis framework. Researches the codebase first, then writes reference / how-to / tutorial / explanation docs that actually match the code. Invokable standalone or chained from `/document-release` when the coverage map finds gaps. Learn more: [tutorial](docs/tutorial-document-generate.md) • [how-to](docs/howto-document-a-shipped-feature.md) • [why Diataxis](docs/explanation-diataxis-in-gstack.md). |
|
||||
|
||||
+5
-2
@@ -106,8 +106,11 @@ reads one full gate, stamps versions at merge, and merges each PR with
|
||||
finding blocks only when it "would fail a test, break production, or lose data
|
||||
or secrets" (Garry's floor); the rest goes in the PR body.
|
||||
|
||||
**Fix waves.** When main goes red, lanes hold `/ship`, one owner finds the root
|
||||
cause, and everyone merges main once. Deferred review findings and test-only
|
||||
**Go forward, don't stop and fix.** When one item goes bad (a page, a file, a
|
||||
test case), a lane sets it aside, keeps the rest moving, says what it set aside
|
||||
and repairs it afterwards. When main goes red, the change that broke it is
|
||||
reverted instead of every lane waiting on a root cause, and a blocking finding
|
||||
still stops the PR it is found in. Deferred review findings and test-only
|
||||
follow-ups get folded into one wave PR instead of one PR each. On one crew a
|
||||
single audit-pin fix cleared a main-wide red and ten PRs landed within the hour.
|
||||
|
||||
|
||||
@@ -14,6 +14,11 @@ and the Captain's drive) is the `/captain` skill and `crew/docs/captain.md` in t
|
||||
question to the person. The Captain relays it in plain language and sends back the person's exact words.
|
||||
A thread with no Captain asks the person directly with a Capy question. Either way, never use a bare
|
||||
question, gate codes or slot numbers.
|
||||
- **Every relay quotes its source.** The person's answer is one case of a wider rule: whatever an agent
|
||||
passes on (an answer, another crew's finding, a report from another agent system, a summary it was given)
|
||||
goes out in the source's own words, unchanged and marked as a quote, with who wrote them, when, and what the
|
||||
relayer checked ("checked: nothing" when it checked nothing). A summary may sit beside the quote, never in
|
||||
place of it, because a summary repeated unchecked is how a wrong claim reaches the owner.
|
||||
- **Scope.** An answer covers the thread and scope it was asked for. It is not a blanket approval for
|
||||
later work.
|
||||
- **Standing approvals** are the ones the Captain lists in its own rules, for example "merge when green,
|
||||
@@ -166,7 +171,7 @@ warm price. The merge lane reports to the Captain only a landing, a decision or
|
||||
A token cap in a brief goes to /ship as `--token-cap <n>`. Run each /ship in a fresh subagent titled
|
||||
`ship #<n> at <head7> <4-char nonce>` (unique), with `GSTACK_SHIP_TASK_TITLE=<that title>` in its brief and the instruction to
|
||||
take every reading (start, notes, close) from its own row of the root thread's `tasks` and start the budget with
|
||||
`--reading-from task`, so it caps at 100M by default; never message a finished /ship subagent to run another. When /ship stops on it (`STOP:
|
||||
`--reading-from task`, so it caps at 50M by default; never message a finished /ship subagent to run another. When /ship stops on it (`STOP:
|
||||
reason=budget_exhausted`, `status=incomplete`), the lane reports the BUDGET and RECOVER lines and asks the
|
||||
owner; it never raises the cap itself. The owner's answer runs the RECOVER line with
|
||||
`--approved-by <who> --words "<their words>"`, and `gstack-approvals add` records the same words.
|
||||
|
||||
@@ -5,14 +5,15 @@ Your crew's CREW.md and recorded approvals decide who may merge, update a base,
|
||||
1. **Plan, then a yes.** New functionality starts with /autoplan sized to the work; the build waits for "do it". [SKILL.md: Plan, approve, ship]
|
||||
2. **Someone else merges.** Run /ship to a receipt on your final pushed head, send one READY quoting gstack's verify output verbatim, and stop. One open PR per lane; follow-ups ride it. The merge owner merges on green and assigns versions; docs-only PRs run only docs checks. [crew/docs/captain.md: The READY contract]
|
||||
3. **Block only on the floor.** A finding blocks if it would fail a test, break production, or lose data or secrets; deferred findings stay on the PR and never become issues. [docs/review-policy.md]
|
||||
4. **Fix waves.** When main goes red, hold /ship while one owner finds the root cause; bring main in once, as your rules allow. Follow-ups get one issue with an owner and one PR. [docs/triage.md]
|
||||
4. **Go forward, don't stop and fix.** Set a bad item aside, keep the rest moving, say what you set aside and repair it after. A red main gets its culprit reverted; a floor blocker still stops its PR. Follow-ups get one issue with an owner and one PR. [crew/docs/captain.md: Lane discipline]
|
||||
5. **Severe first, same gates.** A severe user-facing bug jumps the queue with a short plan; receipt, checks and merge owner stay.
|
||||
6. **Trade findings, not small talk.** Another crew's finding goes to its Captain, through yours, with evidence.
|
||||
6. **Trade findings, not small talk.** Another crew's finding goes to its Captain, through yours, with evidence. A relay quotes its source unchanged and marked: who wrote it, when, and what you checked.
|
||||
7. **Measure before you act.** Run the real system on the merged tree you ship; a real run outranks a reviewed plan. Each number names its run, commit or uncapped query; say what you did not verify.
|
||||
8. **Evals decide, and losses get reported.** Preregister bars, cap and stop rule before paying [/eval-plan]. Cheap proof (a keyless fake, a smoke) first. Controls: no-skill and placebo arms, clean decoys. Report use and pass apart; quote spend from the meter. A new part needs proof it helps or a dated test plan [ETHOS.md: 9. Earn Its Place].
|
||||
9. **Flakes: one rerun, a ledger, a daily fix.** Only the policy's rerun, never for a harness or infra red; a second red is real; never loosen a test. [crew/docs/captain.md: The daily flaky pass]
|
||||
10. **Quiet.** Messages wake the Captain cold: send READY, a blocker, done or a Captain or owner call, else end_turn; no acks or progress notes. Reports and replies open with `Failed or skipped:`, `Unverified:` and `Also changed:` lines (each item, or none), under 250 words; top 10 of long lists. Findings write-ups follow [ETHOS.md: 8. Explain the Number]. Broadcasts go in its notes.
|
||||
11. **Ask once, plainly** (every skill's Ground Rules). One ask per decision, explained like the owner is five: your Captain's name, then a lettered line each: "A: <code> hit problem p, which happens when h. We could do 1) x, 2) y or 3) z. Recommendation x because why. A1 to take recommendation." "do it" takes every recommendation; "A2" takes option 2. Owner tasks: the exact link (in Capy: path and field), numbered steps, the reply word. Never re-ask a standing rule. [crew/docs/captain.md: The ask format]
|
||||
12. **Fresh threads, closed out.** One thread per unit of work. A thread keeps its PR until it merges or closes and hands off only then, never mid-PR on a token count; past 1B own tokens it checks in with its Captain once and carries on. Standing threads that wake on every event (merge lanes, watchers) rotate at 500M tokens or 3 days [/runaway-stopper]. Crew threads never create threads: ask your Captain (Captain to Captain across projects), or report one you made by code for crew.add. Its Captain archives only its crew's threads, never one holding an open PR, successor or not (R91), or an open issue; a PR closes only as landed, superseded or dropped. Threads outside every crew are the owner's, even its automation's. Size reviews to the diff. [docs/ship-budget.md; crew/docs/captain.md: New threads join the crew]
|
||||
12. **Fresh threads, closed out.** One thread per unit of work. A thread keeps its PR until it merges or closes and hands off only then, never mid-PR on a token count; past 500M own tokens it checks in with its Captain once and carries on. Standing threads that wake on every event (merge lanes, watchers) rotate at 250M tokens or 3 days; look at any subagent past 50M [/runaway-stopper]. Crew threads never create threads: ask your Captain (Captain to Captain across projects), or report one you made by code for crew.add. Its Captain archives only its crew's threads, never one holding an open PR, successor or not (R91), or an open issue; a PR closes only as landed, superseded or dropped. Threads outside every crew are the owner's, even its automation's. Size reviews to the diff. [docs/ship-budget.md; crew/docs/captain.md: New threads join the crew]
|
||||
13. **The owner's model preference.** `gstack-models resolve --role agent` picks agent models, except cross-family voices and eval subjects. [docs/model-policy.md: Your model preference]
|
||||
14. **Finish before starting.** No new fix thread in a repo while more than 10 finished PRs (green, reviewed, waiting only to merge) sit in its queue: merge or close them first. Severe hotfixes are exempt: security, data loss, red main, a broken install. [crew/docs/captain.md: New threads join the crew]
|
||||
15. **Subagents earn their context.** Start one only for parallel work you can throw away, a fresh-eyes review or another model family, never for a step of your own procedure; name the compact result it returns. [crew/docs/captain.md: Lane context]
|
||||
@@ -31,7 +31,8 @@ For a crew lane (a thread working for a Captain). Read this once `gstack: ok <re
|
||||
- Batch independent reads in one parallel program. Return 4k characters or less per call; write long output to a file under `~/.capy/work` and read the part you need.
|
||||
- A wait you expect to last under about 30 minutes checks in every 240 s: `wait` on the operation with `duration_seconds: 240`, then re-issue it silently on a wake that brings nothing new. After about 30 minutes, or past the expected end, stop re-issuing and sleep on the operation or pull request watch. A longer wait sleeps on its operations. While /ship runs, sleep.
|
||||
- Past twice the crew's median lane spend, write `handoffs/<code>/next.md` and tell the Captain in one line; it decides whether you continue, rotate or park.
|
||||
- Keep your PR until it merges or closes; never hand off mid-PR on a token count. Past 1B own tokens (about $330), check in with the Captain once, then carry on unless told otherwise.
|
||||
- Keep your PR until it merges or closes; never hand off mid-PR on a token count. Past 500M own tokens, check in with the Captain once, then carry on unless told otherwise. Capy's token counts read about half what they did before 2026-11-15, so every token line here is half its old figure.
|
||||
- Start a subagent only for parallel work whose context can be thrown away, a fresh-eyes review or a model from another family, never to run a step of your own procedure. Its brief names the compact result it returns (a verdict line, a file path, a short list), and nothing else comes back. /ship keeps its own subagent until gstack's trial of /ship without one reports. Stop and look at any subagent past 50M tokens.
|
||||
|
||||
## Before a push
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
**Crew threads on Capy now check in at 500M own tokens, standing threads rotate at 250M and any subagent past 50M gets a look, half the old lines, because Capy's token counts read about half what they did before 2026-11-15.** `gstack-runaway scan` and the /ship subagent's default token cap (`BUDGET_DEFAULT_CAP: 50M`) use the new lines. The factory rules every Capy thread reads also gain three standing rules. Start a subagent only for throwaway parallel work, a fresh-eyes review or another model family, and name the result it returns. Relay a source's words unchanged and marked, with who wrote them, when and what you checked. Go forward instead of stopping to fix, setting a bad item aside while the rest keeps moving, with a red main getting its culprit reverted.
|
||||
+23
-6
@@ -154,6 +154,14 @@ such decision with a plain-language explanation of every option: what it is, why
|
||||
matters, what each answer does, and what it costs. A gate code or a tool's result line
|
||||
alone is not an ask.
|
||||
|
||||
A lane goes forward instead of stopping to fix. When one item goes bad (a page, a file,
|
||||
a test case, a line of a report), it sets that item aside, keeps the rest of the work
|
||||
moving, says in its next report what it set aside and why, and repairs the item
|
||||
afterwards. Two things still stop work: a red main gets the change that broke it
|
||||
reverted rather than the whole crew waiting on a root cause, and a finding at the
|
||||
blocking floor ([review-policy.md](../../docs/review-policy.md)) still stops the PR it is
|
||||
found in.
|
||||
|
||||
## Lane context
|
||||
|
||||
Every step a lane takes re-reads its whole conversation. A step within about five minutes
|
||||
@@ -191,15 +199,24 @@ cheap:
|
||||
is still worth it. Spend is the
|
||||
thread's credit meter, never a token count.
|
||||
- **Keep the PR to the end.** A lane keeps its PR until it merges or closes and hands
|
||||
off only at that boundary, never mid-PR on a token count. When its own tokens pass 1
|
||||
billion (about $330), it checks in with the controller once, then carries on unless
|
||||
told otherwise. Standing threads that wake on every event (merge lanes, watchers, an
|
||||
automation's standing thread) still rotate at 500M own tokens or 3 days, and subagent
|
||||
limits stay as they are: look at any subagent past 100M, and never reuse one across PRs
|
||||
([/runaway-stopper](../../runaway-stopper/SKILL.md)). Why: every handoff wakes the
|
||||
off only at that boundary, never mid-PR on a token count. When its own tokens pass
|
||||
500M, it checks in with the controller once, then carries on unless told otherwise.
|
||||
Standing threads that wake on every event (merge lanes, watchers, an automation's
|
||||
standing thread) rotate at 250M own tokens or 3 days. Look at any subagent past 50M,
|
||||
and never reuse one across PRs ([/runaway-stopper](../../runaway-stopper/SKILL.md)).
|
||||
These lines are half their figures before 2026-11-15, because Capy's token counts have
|
||||
read about half what they did since then for the same work. Why: every handoff wakes the
|
||||
controller, whose tokens cost about 1.7 times a lane's, and handoffs are where orphaned
|
||||
PRs came from. One PR went through four threads in eight hours (about 103k credits) on
|
||||
per-thread token stops and was still a draft.
|
||||
- **Subagents earn their context.** A lane starts a subagent only for parallel work whose
|
||||
context can be thrown away, a fresh-eyes review, or a model from another family. It
|
||||
never starts one to run a step of its own procedure (a test run, a rebase, a report),
|
||||
because the subagent re-reads its own brief and context on every step and its tree's
|
||||
spend adds to the lane's: subagent trees were about a quarter of one day's crew spend.
|
||||
The brief names the compact result the subagent returns, such as a verdict line, a file
|
||||
path or a short list, and nothing else comes back. /ship keeps its own subagent until
|
||||
gstack's trial of /ship without one reports.
|
||||
|
||||
## New threads join the crew
|
||||
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
long runs hand their heavy segments to fresh-context children. The helper is
|
||||
`bin/gstack-ship-budget`; the skill's procedure is `ship/sections/budget-handoff.md`.
|
||||
There is one default cap: an observe-mode /ship subagent that meters its own task row (`--reading-from task`,
|
||||
below) and names no cap gets 100M, the line where /runaway-stopper stops a subagent, and prints
|
||||
`BUDGET_DEFAULT_CAP: 100M`; `--token-cap none` turns it off. Without a cap, /ship meters usage when it can and prints it, and
|
||||
below) and names no cap gets 50M, the line where /runaway-stopper stops a subagent, and prints
|
||||
`BUDGET_DEFAULT_CAP: 50M`; `--token-cap none` turns it off. Without a cap, /ship meters usage when it can and prints it, and
|
||||
nothing else changes.
|
||||
|
||||
## What the cap guarantees
|
||||
|
||||
+8
-7
@@ -1027,23 +1027,24 @@ sets the defaults that keep it from coming back.
|
||||
|
||||
- **Detect.** One program fetches each crew thread (`tools.thread.get`, with its transcript) to files, then
|
||||
`gstack-runaway scan --dir <dir>` prints a `RUNAWAY:` line per thread and a `FLAG:` line per limit crossed:
|
||||
own tokens past 500M or active past 3 days (rotate, for a standing thread that wakes on every event; a crew
|
||||
thread keeps its PR until it merges or closes and checks in with its Captain once past 1B, and no thread holding an
|
||||
open PR rotates), a subagent past 100M (stop), empty wakes past 25% of the
|
||||
own tokens past 250M or active past 3 days (rotate, for a standing thread that wakes on every event; a crew
|
||||
thread keeps its PR until it merges or closes and checks in with its Captain once past 500M, and no thread holding an
|
||||
open PR rotates), a subagent past 50M (stop), empty wakes past 25% of the
|
||||
last 40 turns (warm-wait check-ins are left out), and review rounds past 2 per PR. Captains are reported, never rotated.
|
||||
The `RUNAWAY:` line also prices the wakes it read: `cold_wakes` and `empty_wakes` are their shares by count,
|
||||
`cold_extra_spend` the share of spend that cold model calls add over warm ones (a wake that starts after the
|
||||
5-minute prompt cache lapsed, or a call after a tool that ran that long), and `empty_spend` the share the empty wakes cost. `scan --wakes` prints one `WAKE:` line per wake with its cost in warm model calls.
|
||||
- **Stop.** A live subagent past 100M is stopped with its reason. A standing thread is rotated at a clean point through
|
||||
- **Stop.** A live subagent past 50M is stopped with its reason. A standing thread is rotated at a clean point through
|
||||
a handoff file and a successor brief (`runaway-stopper/templates/`), then archived by its own Captain once none of
|
||||
its PRs is open (R91), through `gstack-archive-check thread`. A thread
|
||||
mid-/ship or mid-merge gets `DEFER:` and nothing happens until that work finishes.
|
||||
- **Prevent.** One wait on all pending operations, quiet wakes, compact program returns, one /ship subagent per
|
||||
PR head (metering its own row with a 100M default cap, `BUDGET_DEFAULT_CAP:`), two review rounds, and a fresh
|
||||
PR head (metering its own row with a 50M default cap, `BUDGET_DEFAULT_CAP:`), two review rounds, and a fresh
|
||||
thread per automation run.
|
||||
|
||||
Scanning FOUN-4, FOUN-14 and FOUN-71 as read on 2026-11-03, before R70's 2026-11-09 amendment (today only a thread
|
||||
marked standing gets `ROTATE`, a crew thread past 1B gets `CHECK_IN`, and a thread holding an open PR never rotates) (excerpt):
|
||||
Scanning FOUN-4, FOUN-14 and FOUN-71 as read on 2026-11-03, before R70's 2026-11-09 amendment and the 2026-11-15 halving of
|
||||
its token lines (today only a thread marked standing gets `ROTATE`, past 250M; a crew thread past 500M gets `CHECK_IN`; a
|
||||
subagent past 50M gets `STOP` or `LOOK`; and a thread holding an open PR never rotates) (excerpt):
|
||||
|
||||
```
|
||||
RUNAWAY: thread=FOUN-4 verdict=ROTATE own=4.04B(upper) total=6.90B credits=2299398 age_days=13.1 active=yes ...
|
||||
|
||||
+8
-8
@@ -4,20 +4,20 @@
|
||||
* optionally tools.subagent.list (the whole tree) and transcript items (tools.thread.get transcript,
|
||||
* tools: true). Output is one RUNAWAY line per thread, FLAG lines, a DEFER line when the thread is
|
||||
* mid-/ship or mid-merge or a standing thread holds an open PR, and a SWEEP total for a directory. It never acts.
|
||||
* Only a thread the Captain marks `standing: true` rotates; a crew thread checks in once past 1B own tokens (R70 as
|
||||
* amended 2026-11-09), and a thread holding an open PR, or whose PRs the file doesn't list, is never rotated (R91).
|
||||
* Only a thread the Captain marks `standing: true` rotates; a crew thread checks in once past 500M own tokens (R70 as
|
||||
* amended 2026-11-09, its lines halved since: Capy's token counts read about half from 2026-11-15), and a thread holding an open PR, or whose PRs the file doesn't list, is never rotated (R91).
|
||||
*/
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { CACHE_TTL_S, isKeepalive, type TranscriptItem } from './ship-calls';
|
||||
|
||||
export const LIMITS = {
|
||||
ownRotate: 500e6,
|
||||
ownWarn: 400e6,
|
||||
ownCheckIn: 1e9,
|
||||
ownRotate: 250e6,
|
||||
ownWarn: 200e6,
|
||||
ownCheckIn: 500e6,
|
||||
ageDays: 3,
|
||||
activeHours: 24,
|
||||
subagentStop: 100e6,
|
||||
subagentStop: 50e6,
|
||||
emptyRate: 0.25,
|
||||
emptyWindow: 40,
|
||||
emptyMinTurns: 20,
|
||||
@@ -288,9 +288,9 @@ const USAGE = [
|
||||
'Lines: RUNAWAY (one per thread, largest own tokens first), FLAG ROTATE|STOP|LOOK|WARN|REPORT|CHECK_IN, DEFER, SWEEP (--dir).',
|
||||
'Review rounds count only subagent titles that name the PR (#N); the rest show as unattributed.',
|
||||
'Limits (R70 as amended 2026-11-09): only a thread file with "standing": true (a merge lane, a watcher, an automation\'s',
|
||||
'standing thread) rotates, at own > 500M or active > 3d (warn 400M), and never while it holds an open PR or its',
|
||||
'standing thread) rotates, at own > 250M or active > 3d (warn 200M), and never while it holds an open PR or its',
|
||||
'pull_requests are missing or partial (DEFER, R91); any other thread is a crew thread that keeps its PR and gets one',
|
||||
'CHECK_IN past 1B own; subagent > 100M stop (LOOK when it already ended); empty wakes > 25% of the last 40 turns',
|
||||
'CHECK_IN past 500M own; subagent > 50M stop (LOOK when it already ended); empty wakes > 25% of the last 40 turns',
|
||||
'(20+; warm-wait check-ins left out); review rounds > 2 per PR; Captains REPORT, never rotate.',
|
||||
'Each wake read is priced in warm model calls (one per tool call); it is cold when it starts more than ' + CACHE_TTL_S + ' s after the',
|
||||
' thread\'s previous item (the prompt cache lapsed), and its first call then costs ' + COLD_CALL_PRICE + ', as does a call after a tool that ran',
|
||||
|
||||
+4
-3
@@ -47,10 +47,11 @@ export const SEGMENTS: Record<string, string> = { '1': '22', '9': '11.5', '12':
|
||||
export const DEFAULT_TAIL = 2_000_000;
|
||||
/**
|
||||
* The cap an observe-mode /ship subagent metering its own task row (--reading-from task) gets when it names none:
|
||||
* R70's 100M stop-and-look line. Single-run /ship subagent rows on 2026-11-03 (GSTA crew and FOUN-4/14/71, n=9):
|
||||
* p50 64M, p90 92M; the one past 100M (485M) was a subagent reused for five runs.
|
||||
* R70's stop-and-look line, 50M since Capy's token counts read about half from 2026-11-15 (it was 100M). Single-run /ship
|
||||
* subagent rows on 2026-11-03, on the old count (GSTA crew and FOUN-4/14/71, n=9): p50 64M, p90 92M; the one past 100M
|
||||
* (485M) was a subagent reused for five runs.
|
||||
*/
|
||||
export const SUBAGENT_DEFAULT_CAP = 100_000_000;
|
||||
export const SUBAGENT_DEFAULT_CAP = 50_000_000;
|
||||
const DIFF_REVIEW_STEP: Record<string, string> = { review: '9', 'review-fix-check': '9', 'design-review-lite': '9', 'adversarial-review': '11', 'codex-review': '11' };
|
||||
|
||||
export type MeterKind = 'capy' | 'claude' | 'estimate';
|
||||
|
||||
+12
-11
@@ -203,11 +203,12 @@ return scan.output + (failed.length ? "\nFETCH_FAILED: " + failed.join(" ") : ""
|
||||
A lane with nested subagents can also write `tools.subagent.list()` to `<code>.subagents.json` in that directory:
|
||||
it lists the whole tree, where thread.get lists 200 rows at most (`own` is then an upper bound).
|
||||
|
||||
Limits (org rule R70, amended 2026-11-09): a standing thread that wakes on every event (a merge lane, a watcher, an
|
||||
automation's standing thread) rotates past 500M own tokens (total minus subagents) or 3 days active (working,
|
||||
waiting, or a turn in the last 24 hours), warn at 400M. A crew thread keeps its PR until it merges or closes, never
|
||||
rotated mid-PR on a token count; past 1B own tokens it checks in with its Captain once. Open or unknown PRs block rotation
|
||||
(R91). A subagent past 100M: stop and look. Empty wakes past 25% of the
|
||||
Limits (org rule R70, amended 2026-11-09, token lines halved because Capy's token counts read about half from
|
||||
2026-11-15): a standing thread that wakes on every event (a merge lane, a watcher, an automation's standing thread)
|
||||
rotates past 250M own tokens (total minus subagents) or 3 days active (working, waiting, or a turn in the last 24
|
||||
hours), warn at 200M. A crew thread keeps its PR until it merges or closes, never rotated mid-PR on a token count;
|
||||
past 500M own tokens it checks in with its Captain once. Open or unknown PRs block rotation
|
||||
(R91). A subagent past 50M: stop and look. Empty wakes past 25% of the
|
||||
last 40 turns (warm-wait check-ins left out). Review rounds past 2 per PR. `cold_extra_spend` and `empty_spend` are the shares of spend that
|
||||
cold starts (after the 5-minute cache lapsed) and empty wakes cost; `scan --wakes` prices each wake. Act on each line:
|
||||
|
||||
@@ -217,7 +218,7 @@ cold starts (after the 5-minute cache lapsed) and empty wakes cost; `scan --wake
|
||||
| `FLAG: CHECK_IN` | Hear its one check-in; never rotate it. |
|
||||
| `FLAG: REPORT` | A Captain over a limit: report it, never rotate it (Garry decides Captain rotation). |
|
||||
| `FLAG: STOP` | Step 2. |
|
||||
| `FLAG: LOOK` | A finished subagent past 100M: find why (reused for several runs? full-depth review?) and fix that cause from Step 4. |
|
||||
| `FLAG: LOOK` | A finished subagent past 50M: find why (reused for several runs? full-depth review?) and fix that cause from Step 4. |
|
||||
| `FLAG: WARN` | Tell the thread the Step 4 rule it breaks, once. |
|
||||
| `DEFER:` | Mid-/ship, mid-merge or holding a PR: act on nothing; rescan once that ends. |
|
||||
| `RUNAWAY_INPUT:`, `FETCH_FAILED:` | That thread wasn't read: fetch it again and rerun; never count it as OK. |
|
||||
@@ -228,8 +229,8 @@ goes ahead.
|
||||
|
||||
## 2. Stop a subagent
|
||||
|
||||
Your own: `tools.subagent.stop({ paths: ["<path>"] })`, and record the reason: "<tokens> > 100M (R70), <what it was
|
||||
doing>". A crew thread's subagent: send that thread one message, "Stop Subagent <path>: <tokens> > 100M (R70)." Its
|
||||
Your own: `tools.subagent.stop({ paths: ["<path>"] })`, and record the reason: "<tokens> > 50M (R70), <what it was
|
||||
doing>". A crew thread's subagent: send that thread one message, "Stop Subagent <path>: <tokens> > 50M (R70)." Its
|
||||
PR stays open; a fresh subagent with the run directory picks the work up if it is still needed.
|
||||
|
||||
## 3. Rotate a thread
|
||||
@@ -256,12 +257,12 @@ Put the lines that apply into every brief you write:
|
||||
- **One /ship subagent per PR head.** A rerun or another PR gets a fresh subagent with the run directory path; never
|
||||
message a finished /ship subagent to run another. Title it `ship #<n> at <head7> <4-char nonce>` and put
|
||||
`GSTACK_SHIP_TASK_TITLE=<title>` in its brief: /ship then takes every reading from that one row and caps at
|
||||
100M by default (`BUDGET_DEFAULT_CAP:`); raising the cap needs the owner's words.
|
||||
50M by default (`BUDGET_DEFAULT_CAP:`); raising the cap needs the owner's words.
|
||||
- **Two review rounds.** Reader and review rounds stop at 2 per PR (R51), and every reader's title names the PR
|
||||
(`#<n>`) so the scan can count them.
|
||||
- **Rotate standing roles** at 500M own tokens or 3 days. An automation gets a fresh thread per run that archives
|
||||
- **Rotate standing roles** at 250M own tokens or 3 days. An automation gets a fresh thread per run that archives
|
||||
itself, or a slower schedule, instead of waking a standing thread.
|
||||
- **Crew threads keep their PR to the end:** no token stop mid-PR; one Captain check-in past 1B own tokens.
|
||||
- **Crew threads keep their PR to the end:** no token stop mid-PR; one Captain check-in past 500M own tokens.
|
||||
|
||||
## Report
|
||||
|
||||
|
||||
@@ -67,11 +67,12 @@ return scan.output + (failed.length ? "\nFETCH_FAILED: " + failed.join(" ") : ""
|
||||
A lane with nested subagents can also write `tools.subagent.list()` to `<code>.subagents.json` in that directory:
|
||||
it lists the whole tree, where thread.get lists 200 rows at most (`own` is then an upper bound).
|
||||
|
||||
Limits (org rule R70, amended 2026-11-09): a standing thread that wakes on every event (a merge lane, a watcher, an
|
||||
automation's standing thread) rotates past 500M own tokens (total minus subagents) or 3 days active (working,
|
||||
waiting, or a turn in the last 24 hours), warn at 400M. A crew thread keeps its PR until it merges or closes, never
|
||||
rotated mid-PR on a token count; past 1B own tokens it checks in with its Captain once. Open or unknown PRs block rotation
|
||||
(R91). A subagent past 100M: stop and look. Empty wakes past 25% of the
|
||||
Limits (org rule R70, amended 2026-11-09, token lines halved because Capy's token counts read about half from
|
||||
2026-11-15): a standing thread that wakes on every event (a merge lane, a watcher, an automation's standing thread)
|
||||
rotates past 250M own tokens (total minus subagents) or 3 days active (working, waiting, or a turn in the last 24
|
||||
hours), warn at 200M. A crew thread keeps its PR until it merges or closes, never rotated mid-PR on a token count;
|
||||
past 500M own tokens it checks in with its Captain once. Open or unknown PRs block rotation
|
||||
(R91). A subagent past 50M: stop and look. Empty wakes past 25% of the
|
||||
last 40 turns (warm-wait check-ins left out). Review rounds past 2 per PR. `cold_extra_spend` and `empty_spend` are the shares of spend that
|
||||
cold starts (after the 5-minute cache lapsed) and empty wakes cost; `scan --wakes` prices each wake. Act on each line:
|
||||
|
||||
@@ -81,7 +82,7 @@ cold starts (after the 5-minute cache lapsed) and empty wakes cost; `scan --wake
|
||||
| `FLAG: CHECK_IN` | Hear its one check-in; never rotate it. |
|
||||
| `FLAG: REPORT` | A Captain over a limit: report it, never rotate it (Garry decides Captain rotation). |
|
||||
| `FLAG: STOP` | Step 2. |
|
||||
| `FLAG: LOOK` | A finished subagent past 100M: find why (reused for several runs? full-depth review?) and fix that cause from Step 4. |
|
||||
| `FLAG: LOOK` | A finished subagent past 50M: find why (reused for several runs? full-depth review?) and fix that cause from Step 4. |
|
||||
| `FLAG: WARN` | Tell the thread the Step 4 rule it breaks, once. |
|
||||
| `DEFER:` | Mid-/ship, mid-merge or holding a PR: act on nothing; rescan once that ends. |
|
||||
| `RUNAWAY_INPUT:`, `FETCH_FAILED:` | That thread wasn't read: fetch it again and rerun; never count it as OK. |
|
||||
@@ -92,8 +93,8 @@ goes ahead.
|
||||
|
||||
## 2. Stop a subagent
|
||||
|
||||
Your own: `tools.subagent.stop({ paths: ["<path>"] })`, and record the reason: "<tokens> > 100M (R70), <what it was
|
||||
doing>". A crew thread's subagent: send that thread one message, "Stop Subagent <path>: <tokens> > 100M (R70)." Its
|
||||
Your own: `tools.subagent.stop({ paths: ["<path>"] })`, and record the reason: "<tokens> > 50M (R70), <what it was
|
||||
doing>". A crew thread's subagent: send that thread one message, "Stop Subagent <path>: <tokens> > 50M (R70)." Its
|
||||
PR stays open; a fresh subagent with the run directory picks the work up if it is still needed.
|
||||
|
||||
## 3. Rotate a thread
|
||||
@@ -120,12 +121,12 @@ Put the lines that apply into every brief you write:
|
||||
- **One /ship subagent per PR head.** A rerun or another PR gets a fresh subagent with the run directory path; never
|
||||
message a finished /ship subagent to run another. Title it `ship #<n> at <head7> <4-char nonce>` and put
|
||||
`GSTACK_SHIP_TASK_TITLE=<title>` in its brief: /ship then takes every reading from that one row and caps at
|
||||
100M by default (`BUDGET_DEFAULT_CAP:`); raising the cap needs the owner's words.
|
||||
50M by default (`BUDGET_DEFAULT_CAP:`); raising the cap needs the owner's words.
|
||||
- **Two review rounds.** Reader and review rounds stop at 2 per PR (R51), and every reader's title names the PR
|
||||
(`#<n>`) so the scan can count them.
|
||||
- **Rotate standing roles** at 500M own tokens or 3 days. An automation gets a fresh thread per run that archives
|
||||
- **Rotate standing roles** at 250M own tokens or 3 days. An automation gets a fresh thread per run that archives
|
||||
itself, or a slower schedule, instead of waking a standing thread.
|
||||
- **Crew threads keep their PR to the end:** no token stop mid-PR; one Captain check-in past 1B own tokens.
|
||||
- **Crew threads keep their PR to the end:** no token stop mid-PR; one Captain check-in past 500M own tokens.
|
||||
|
||||
## Report
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ table (tools.capy.subscribe with a pull source) and tell your Captain the subscr
|
||||
stays unarchived until every PR it opened or carries is merged or closed, R91); then pick up the table in order.
|
||||
Work rules for this role (from /runaway-stopper, Step 4): one wait on all pending operations; a wake with nothing to
|
||||
decide ends without a message; no acknowledgment or progress messages to your Captain; compact program returns;
|
||||
one /ship subagent per PR head; at most 2 review rounds per PR. When you pass 500M own tokens or 3 days active,
|
||||
one /ship subagent per PR head; at most 2 review rounds per PR. When you pass 250M own tokens or 3 days active,
|
||||
write your own rotation handoff and tell your Captain.
|
||||
|
||||
Report to your Captain only with a READY, a decision you need, a blocker or your final report.
|
||||
@@ -689,7 +689,10 @@ describe('capy skill: factory.md, the auto-loaded "how we work" page', () => {
|
||||
// 4,200 for point 12's keep-the-PR-to-the-end and standing-thread rotation clause and point 14's cap of 10 finished PRs before a new fix thread (Garry's "do it" 2026-11-09, relayed by FOUN-32).
|
||||
// 4,400 for point 10's report shape, Failed or skipped / Unverified / Also changed lines first, and its pointer to ETHOS.md section 8 for
|
||||
// findings write-ups (GST-1455, Garry's "do it" 2026-11-05 on R73; the clause is the wording GEVA-2's dev climb measured, so it is not trimmed).
|
||||
expect(Buffer.byteLength(text)).toBeLessThanOrEqual(4400);
|
||||
// 4,875 for the token lines halved (500M check-in, 250M standing rotation, 50M subagent look; Capy's token counts read about
|
||||
// half since 2026-11-15), point 4's go-forward rule, point 6's relay clause and point 15's subagent rule (crew rules R70, R104,
|
||||
// R105 and R109, each the owner's standing rule).
|
||||
expect(Buffer.byteLength(text)).toBeLessThanOrEqual(4875);
|
||||
expect(text).toMatch(/^# How we work/);
|
||||
expect(citationProblems(text)).toEqual([]);
|
||||
});
|
||||
|
||||
+23
-23
@@ -39,14 +39,14 @@ describe('gstack-runaway scan', () => {
|
||||
test('FOUN-4: own tokens and age rotate, the reused /ship subagent is flagged, review rounds counted per PR', () => {
|
||||
const crew = run('scan', '--thread', write('foun4-crew.json', FOUN4), '--now', NOW).out;
|
||||
expect(crew).not.toContain('ROTATE');
|
||||
expect(crew).toContain('FLAG: CHECK_IN own_tokens 6.06B > 1.00B (upper bound)');
|
||||
expect(crew).toContain('FLAG: CHECK_IN own_tokens 6.06B > 500M (upper bound)');
|
||||
const r = run('scan', '--thread', write('foun4.json', FOUN4_STANDING), '--now', NOW);
|
||||
expect(r.code).toBe(0);
|
||||
expect(r.out).toContain('RUNAWAY: thread=FOUN-4 verdict=ROTATE');
|
||||
expect(r.out).toMatch(/own=6\.06B\(upper\)/);
|
||||
expect(r.out).toContain('FLAG: ROTATE own_tokens 6.06B > 500M (upper bound)');
|
||||
expect(r.out).toContain('FLAG: ROTATE own_tokens 6.06B > 250M (upper bound)');
|
||||
expect(r.out).toMatch(/FLAG: ROTATE age 13\.1d > 3d and active/);
|
||||
expect(r.out).toContain('FLAG: LOOK subagent 40 "Run /ship on PR #442 (careless margin)" 485M > 100M (done)');
|
||||
expect(r.out).toContain('FLAG: LOOK subagent 40 "Run /ship on PR #442 (careless margin)" 485M > 50M (done)');
|
||||
expect(r.out).toContain('FLAG: WARN review_rounds 5 on #501 > 2');
|
||||
expect(r.out).toContain('review_subagents=5(unattributed 0)');
|
||||
});
|
||||
@@ -65,7 +65,7 @@ describe('gstack-runaway scan', () => {
|
||||
tasks: [task(3, 'gate fix lane', 150e6, 'idle'), task(4, 'ship 1 outside-voice (#535)', 2e6, 'working')] };
|
||||
const other = run('scan', '--thread', write('defer.json', doc), '--now', NOW);
|
||||
expect(other.out).toContain('verdict=STOP');
|
||||
expect(other.out).toContain('FLAG: STOP subagent 3 "gate fix lane" 150M > 100M (idle)');
|
||||
expect(other.out).toContain('FLAG: STOP subagent 3 "gate fix lane" 150M > 50M (idle)');
|
||||
expect(other.out).not.toContain('DEFER:');
|
||||
const self = { ...doc, tasks: [task(5, 'ship #4001 at abc1234 q7x2', 140e6, 'working')] };
|
||||
const s = run('scan', '--thread', write('defer-self.json', self), '--now', NOW);
|
||||
@@ -96,7 +96,7 @@ describe('gstack-runaway scan', () => {
|
||||
const r = run('scan', '--thread', write('captain.json', cap), '--now', NOW);
|
||||
expect(r.out).toContain('verdict=REPORT captain=yes');
|
||||
expect(r.out).not.toContain('FLAG: ROTATE');
|
||||
expect(r.out).toContain('FLAG: REPORT own_tokens 3.90B > 500M');
|
||||
expect(r.out).toContain('FLAG: REPORT own_tokens 3.90B > 250M');
|
||||
});
|
||||
|
||||
test('empty-wake rate: turns whose only calls are status reads, waits and end_turn', () => {
|
||||
@@ -205,18 +205,18 @@ describe('gstack-runaway scan', () => {
|
||||
});
|
||||
|
||||
test('a subagent.list file replaces thread.get tasks: own sums top-level paths only, truncation makes it an upper bound', () => {
|
||||
const doc = { code: 'GSTA-266', status: 'working', created_at: '2026-11-03T20:00:00Z', cost: { tokens: 700e6 }, tasks: [], standing: true, pull_requests: [] };
|
||||
const doc = { code: 'GSTA-266', status: 'working', created_at: '2026-11-03T20:00:00Z', cost: { tokens: 350e6 }, tasks: [], standing: true, pull_requests: [] };
|
||||
const subs = { total: 3, tasks: [
|
||||
{ path: '1', title: 'build', status: 'done', cost: { tokens: 150e6, credits: 1 } },
|
||||
{ path: '1.1', title: 'reader', status: 'done', cost: { tokens: 50e6, credits: 1 } },
|
||||
{ path: '2', title: 'docs', status: 'done', cost: { tokens: 120e6, credits: 1 } },
|
||||
{ path: '1', title: 'build', status: 'done', cost: { tokens: 75e6, credits: 1 } },
|
||||
{ path: '1.1', title: 'reader', status: 'done', cost: { tokens: 25e6, credits: 1 } },
|
||||
{ path: '2', title: 'docs', status: 'done', cost: { tokens: 60e6, credits: 1 } },
|
||||
] };
|
||||
const r = run('scan', '--thread', write('sl.json', doc), '--subagents', write('sl.subagents.json', subs), '--now', NOW);
|
||||
expect(r.out).toContain('own=430M(exact)');
|
||||
expect(r.out).toContain('FLAG: WARN own_tokens 430M > 400M warn line');
|
||||
expect(r.out).toContain('FLAG: LOOK subagent 1 "build" 150M > 100M (done)');
|
||||
expect(r.out).toContain('own=215M(exact)');
|
||||
expect(r.out).toContain('FLAG: WARN own_tokens 215M > 200M warn line');
|
||||
expect(r.out).toContain('FLAG: LOOK subagent 1 "build" 75M > 50M (done)');
|
||||
const t = run('scan', '--thread', write('sl2.json', doc), '--subagents', write('sl2.subagents.json', { ...subs, truncated: true }), '--now', NOW);
|
||||
expect(t.out).toContain('own=430M(upper)');
|
||||
expect(t.out).toContain('own=215M(upper)');
|
||||
});
|
||||
|
||||
test('--dir sweeps every thread file, largest own tokens first, with a SWEEP total', () => {
|
||||
@@ -285,7 +285,7 @@ describe('gstack-runaway scan', () => {
|
||||
expect(run('scan', '--thread', write('e.json', doc), '--events', write('e.events.json', shape), '--now', NOW).out).toContain('empty_wake=100%/20');
|
||||
});
|
||||
|
||||
test('a finished subagent past 100M makes the verdict LOOK, not OK', () => {
|
||||
test('a finished subagent past 50M makes the verdict LOOK, not OK', () => {
|
||||
const doc = { code: 'GSTA-245', status: 'idle', created_at: '2026-11-03T10:00:00Z', cost: { tokens: 200e6 }, tasks: [task(1, '/ship #3749', 150e6)] };
|
||||
expect(run('scan', '--thread', write('look.json', doc), '--now', NOW).out).toContain('verdict=LOOK');
|
||||
});
|
||||
@@ -314,29 +314,29 @@ describe('gstack-runaway scan', () => {
|
||||
expect(run('scan', '--dir', path.join(tmp, 'nope')).err).toContain('RUNAWAY_USAGE: no directory');
|
||||
expect(run('scan', '--thread', write('ok4.json', FOUN4), '--event', 'x.json').err).toContain('RUNAWAY_USAGE: unknown argument "--event"');
|
||||
});
|
||||
// Value: protects=R70 as amended 2026-11-09 and R91: a crew thread keeps its PR to the end and checks in once at 1B own tokens; only a
|
||||
// Value: protects=R70 as amended 2026-11-09 (token lines halved 2026-11-15) and R91: a crew thread keeps its PR to the end and checks in once at 500M own tokens; only a
|
||||
// standing thread with no open PR rotates; unknown PR data counts as holding one; fails_when=scan tells a Captain to rotate a crew
|
||||
// thread that holds an open PR (GST-2226); seam=assess via gstack-runaway scan; no_claim=whether a thread is standing (the Captain says so)
|
||||
test('a crew thread holding a PR never rotates, checks in at 1B, and only a standing thread with no open PR rotates', () => {
|
||||
test('a crew thread holding a PR never rotates, checks in at 500M, and only a standing thread with no open PR rotates', () => {
|
||||
const pr = (state: string) => ({ repo: 'garrytan/gstack', number: 4300, title: 'x', state, relation: 'owner' });
|
||||
const base = { code: 'GSTA-500', status: 'working', created_at: '2026-11-03T10:00:00Z', tasks: [] };
|
||||
const crew = run('scan', '--thread', write('crew-pr.json', { ...base, cost: { tokens: 600e6 }, pull_requests: [pr('open')], pull_requests_total: 1 }), '--now', NOW).out;
|
||||
const crew = run('scan', '--thread', write('crew-pr.json', { ...base, cost: { tokens: 300e6 }, pull_requests: [pr('open')], pull_requests_total: 1 }), '--now', NOW).out;
|
||||
expect(crew).not.toContain('ROTATE');
|
||||
expect(crew).not.toContain('FLAG: WARN');
|
||||
expect(crew).toContain('verdict=OK');
|
||||
const big = run('scan', '--thread', write('crew-big.json', { ...base, cost: { tokens: 1.1e9 }, pull_requests: [pr('open')], pull_requests_total: 1 }), '--now', NOW).out;
|
||||
const big = run('scan', '--thread', write('crew-big.json', { ...base, cost: { tokens: 550e6 }, pull_requests: [pr('open')], pull_requests_total: 1 }), '--now', NOW).out;
|
||||
expect(big).toContain('verdict=CHECK_IN');
|
||||
expect(big.match(/^FLAG: /gm)).toEqual(['FLAG: ']);
|
||||
expect(big).toContain('FLAG: CHECK_IN own_tokens 1.10B > 1.00B');
|
||||
expect(big).toContain('FLAG: CHECK_IN own_tokens 550M > 500M');
|
||||
const old = run('scan', '--thread', write('crew-old.json', { ...base, created_at: '2026-10-25T00:00:00Z', cost: { tokens: 10e6 }, pull_requests: [] }), '--now', NOW).out;
|
||||
expect(old).toContain('verdict=OK');
|
||||
const standing = { ...base, cost: { tokens: 600e6 }, standing: true, pull_requests: [pr('merged'), pr('closed')], pull_requests_total: 2 };
|
||||
const standing = { ...base, cost: { tokens: 300e6 }, standing: true, pull_requests: [pr('merged'), pr('closed')], pull_requests_total: 2 };
|
||||
const s = run('scan', '--thread', write('standing.json', standing), '--now', NOW).out;
|
||||
expect(s).toContain('verdict=ROTATE');
|
||||
expect(s).toContain('FLAG: ROTATE own_tokens 600M > 500M');
|
||||
expect(s).toContain('FLAG: ROTATE own_tokens 300M > 250M');
|
||||
const aged = run('scan', '--thread', write('standing-aged.json', { ...standing, cost: { tokens: 10e6 }, created_at: '2026-10-25T00:00:00Z' }), '--now', NOW).out;
|
||||
expect(aged).toContain('FLAG: ROTATE age 9.9d > 3d and active');
|
||||
expect(run('scan', '--thread', write('standing-warn.json', { ...standing, cost: { tokens: 450e6 } }), '--now', NOW).out).toContain('FLAG: WARN own_tokens 450M > 400M warn line');
|
||||
expect(run('scan', '--thread', write('standing-warn.json', { ...standing, cost: { tokens: 225e6 } }), '--now', NOW).out).toContain('FLAG: WARN own_tokens 225M > 200M warn line');
|
||||
for (const [name, prs] of [['open', { pull_requests: [pr('open')], pull_requests_total: 1 }], ['draft', { pull_requests: [pr('draft')] }],
|
||||
['unlisted', { pull_requests: [pr('merged')], pull_requests_total: 2 }], ['unknown', { pull_requests: undefined }]] as const) {
|
||||
const held = run('scan', '--thread', write('standing-' + name + '.json', { ...standing, ...prs }), '--now', NOW).out;
|
||||
@@ -345,7 +345,7 @@ describe('gstack-runaway scan', () => {
|
||||
expect(held).toContain('verdict=DEFER');
|
||||
expect(held).toMatch(/DEFER: holds (an open PR|PRs it can't see); rotate after every PR merges or closes \(R91\)/);
|
||||
}
|
||||
const unknownCrew = run('scan', '--thread', write('crew-unknown.json', { ...base, cost: { tokens: 600e6 } }), '--now', NOW).out;
|
||||
const unknownCrew = run('scan', '--thread', write('crew-unknown.json', { ...base, cost: { tokens: 300e6 } }), '--now', NOW).out;
|
||||
expect(unknownCrew).not.toContain('ROTATE');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -122,20 +122,20 @@ describe('meter scope (GST-467)', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Value: protects=a /ship subagent metering its own task row can't grow past R70's 100M stop-and-look line; fails_when=an observe-mode --reading-from task start with no cap stays uncapped, its note past 100M doesn't stop, a task-row run is labeled tree, or none, an explicit cap, admit mode, a root run or a tree-metered subagent get the default;
|
||||
// Value: protects=a /ship subagent metering its own task row can't grow past R70's 50M stop-and-look line (100M before Capy's token counts halved on 2026-11-15); fails_when=an observe-mode --reading-from task start with no cap stays uncapped, its note past 50M doesn't stop, a task-row run is labeled tree, or none, an explicit cap, admit mode, a root run or a tree-metered subagent get the default;
|
||||
// why_new=FOUN-4's Subagent 40 reached 485M over five /ship runs in one context (GST-1279); a tree reading would count sibling lanes (autoplan review d2); seam=none; no_claim=that the lane passes the title
|
||||
test('an observe-mode /ship subagent metering its own task row gets the 100M default; none, an explicit cap or a tree meter does not', () => {
|
||||
const sub = ['--mode', 'observe', '--reading', '20000000', '--credits', '100', '--reading-from', 'task'];
|
||||
test('an observe-mode /ship subagent metering its own task row gets the 50M default; none, an explicit cap or a tree meter does not', () => {
|
||||
const sub = ['--mode', 'observe', '--reading', '10000000', '--credits', '100', '--reading-from', 'task'];
|
||||
const h = fresh();
|
||||
const s = h.sb(['start', '--record', h.record(), ...sub]);
|
||||
expect(s.code, s.err).toBe(0);
|
||||
expect(s.out).toContain('BUDGET_DEFAULT_CAP: 100M (a /ship subagent metering its own task row; --token-cap <n> or none to change it)');
|
||||
expect(s.out).toContain('BUDGET_DEFAULT_CAP: 50M (a /ship subagent metering its own task row; --token-cap <n> or none to change it)');
|
||||
expect(s.out).not.toContain(TREE);
|
||||
const run = h.field(s.out, 'BUDGET_RUN', 'id');
|
||||
expect(h.sb(['note', '--run', run, '--step', '6', '--reading', '100000000', '--credits', '150']).code).toBe(0);
|
||||
expect(h.sb(['note', '--run', run, '--step', '9', '--reading', '125000000', '--credits', '160']).code).toBe(3);
|
||||
expect(h.sb(['note', '--run', run, '--step', '6', '--reading', '50000000', '--credits', '150']).code).toBe(0);
|
||||
expect(h.sb(['note', '--run', run, '--step', '9', '--reading', '62500000', '--credits', '160']).code).toBe(3);
|
||||
const viaEnv = fresh();
|
||||
expect(viaEnv.sb(['start', '--record', viaEnv.record(), '--mode', 'observe', '--reading', '20000000'], { GSTACK_SHIP_TASK_TITLE: 'ship #1 at abc1234 q7x2' }).out).toContain('BUDGET_DEFAULT_CAP: 100M');
|
||||
expect(viaEnv.sb(['start', '--record', viaEnv.record(), '--mode', 'observe', '--reading', '10000000'], { GSTACK_SHIP_TASK_TITLE: 'ship #1 at abc1234 q7x2' }).out).toContain('BUDGET_DEFAULT_CAP: 50M');
|
||||
for (const [args, env] of [[[...sub, '--token-cap', 'none'], {}], [sub, { GSTACK_SHIP_TOKEN_CAP: 'none' }], [[...sub, '--token-cap', '200M'], {}],
|
||||
[['--mode', 'observe', '--reading', '1000000000'], {}], [['--reading', '1000000000', '--reading-from', 'task'], {}],
|
||||
[['--mode', 'observe', '--reading', '1000000000', '--subagent', '--reading-from', 'this'], {}]] as const) {
|
||||
|
||||
@@ -446,7 +446,7 @@ describe('meter epochs', () => {
|
||||
test('estimate spend survives a change of meter (estimate -> capy -> estimate)', () => {
|
||||
const l = { meter: { contract: METER_CONTRACTS.estimate, epoch: 0, baseline: 0, last: 0 }, epochs: [], carried_used: 0, estimate_used: 20_000_000, unknown: 0, reservations: [] } as unknown as Ledger;
|
||||
expect(tally(l).used).toBe(20_000_000);
|
||||
newEpoch(l, METER_CONTRACTS.capy, 100_000_000);
|
||||
newEpoch(l, METER_CONTRACTS.capy, 100_000_000); // pregate-literal: SUBAGENT_DEFAULT_CAP=100_000_000 a meter baseline reading, not the cap
|
||||
expect(tally(l).used).toBe(20_000_000);
|
||||
l.meter.last = 103_000_000;
|
||||
newEpoch(l, METER_CONTRACTS.estimate, 0);
|
||||
|
||||
Reference in new issue
Block a user