Skip to content

v1.92.40.0 ship-budget: a subagent's /ship cost says it is the root counter, an upper bound (GST-467) - #3696

Merged
capy-ai[bot] merged 7 commits into
mainfrom
gst-467-meter-scope
Nov 1, 2026
Merged

capy-ai[bot] merged 7 commits into
mainfrom
gst-467-meter-scope

Conversation

@garrytan

@garrytan garrytan commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3696,
  "head": "a0b2dd22b3b5636cd68abda67450c3f47c68a240",
  "version": "1.92.20.0",
  "base": "main",
  "gate": {
    "typecheck": {
      "pass": 1,
      "fail": 0,
      "skip": 0
    },
    "focused": {
      "pass": 83,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "677fb3567094d2770a9b19d1dc8a1d62a596f72e",
  "product_patch_id": "2c8d4a36d2021892357895038861682edb83dbba",
  "gstack_version": "1.92.20.0",
  "review_depth": {
    "depth": "standard",
    "class": "code",
    "runtime_lines": 68,
    "rules": "150435b0a543019a",
    "base": "83ae96e086dede0235aa80139d93249f40b215e4",
    "registry": "83ae96e086dede0235aa80139d93249f40b215e4",
    "gate_scan": {
      "tagged": 0,
      "head": "a0b2dd22b3b5636cd68abda67450c3f47c68a240"
    },
    "reasons": [
      "runtime=68>50"
    ]
  },
  "pregate": "requires-remote cleared @677fb3567094 (1 checks, current for a0b2dd22b3b5)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/41316074843",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/41316074843",
    "windows-free-tests.yml/windows-free-shard: https://github.com/garrytan/gstack/actions/runs/41316074905",
    "pregate.json/remote_gate: remote-gate tree=677fb3567094 tests=24875"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "AGENTS.md, CLAUDE.md, CONTRIBUTING.md, README.md, docs/, capy/, ship/ (diff hunks and tree grep)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 3,
    "fixed": 3,
    "scope": "frozen",
    "fix_checks": 2,
    "dispatches": {
      "specialist": 6,
      "red-team": 1
    }
  },
  "review_targeted": {
    "classes": [
      "money"
    ],
    "rules": "baeb8f7ef7da92d0",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "fcc465e227906aa25fa317fe78e561bdce194a59",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  },
  "carry": {
    "from": "16e6710fdf234075981285f50443c7594f2b6eb5",
    "reason": "base merge + base context moved (scoped review by anthropic/claude-opus-5-5: capy/skill/gstack/SKILL.md) + release metadata",
    "product_patch_id": "2c8d4a36d2021892357895038861682edb83dbba",
    "changed_paths": [
      "product:.github/docker/Dockerfile.ci",
      "product:.github/scripts/history-read.sh",
      "product:.github/workflows/evals-main-backstop.yml",
      "product:.github/workflows/evals.yml",
      "product:.github/workflows/free-tests.yml",
      "product:.github/workflows/version-gate.yml",
      "product:.gitignore",
      "metadata:CHANGELOG.md",
      "product:CLAUDE.md",
      "product:CONTRIBUTING.md",
      "product:README.md",
      "product:TODOS.md",
      "metadata:VERSION",
      "metadata:agents-digest/gstack-AGENTS.md",
      "product:bin/dev-setup",
      "product:bin/gstack-config",
      "product:bin/gstack-docs-candidate",
      "product:bin/gstack-doctor-components.sh",
      "product:bin/gstack-harness",
      "product:bin/gstack-harness-ledger.sh",
      "product:bin/gstack-host-renders.sh",
      "product:bin/gstack-install-registry.sh",
      "product:bin/gstack-retro-metrics",
      "product:bin/gstack-review-dispatch",
      "product:bin/gstack-ship-budget",
      "product:bin/gstack-ship-parts",
      "product:bin/gstack-ship-receipt",
      "product:bin/gstack-team-init",
      "product:bin/gstack-uninstall",
      "product:capy/skill/gstack/SKILL.md",
      "product:docs/ADDING_A_HOST.md",
      "product:docs/OPENCLAW.md",
      "product:docs/PROJECT_STRUCTURE.md",
      "product:docs/TESTING_INTERNALS.md",
      "product:docs/hosts.md",
      "product:docs/review-policy.md",
      "product:docs/ship-budget.md",
      "product:docs/ship-policy.md",
      "product:docs/troubleshooting.md",
      "product:docs/uninstall.md",
      "product:hosts/gemini.ts",
      "product:hosts/index.ts",
      "product:lib/capy-review-pass.js",
      "product:lib/changelog-fragments.ts",
      "product:lib/harness-register.ts",
      "product:lib/harness-start-hook.ts",
      "product:lib/history-read.ts",
      "product:lib/result-codes.ts",
      "product:lib/retro-friction.ts",
      "product:lib/review-ledger.ts"
    ],
    "merge_commits": 1,
    "range_diff": "1:  94c8962e7 = 1:  94c8962e7 gstack-ship-budget start --meter-scope self|tree: label tree-scoped cost lines, refuse METER_SCOPE_PARENT (GST-467)\n2:  e05c77089 = 2:  e05c77089 ship-budget: a ledger rebuilt from its record keeps meter_scope=tree; document the cap on a tree run\n3:  a3e80c09a = 3:  a3e80c09a ship-budget: a re-start asking for tree upgrades an open run; tree labels reach the return file, drift and reconcile lines; reading-missing fix names the subagent route\n4:  b8e4785f2 = 4:  b8e4785f2 docs/ship-budget.md: GSTACK_SHIP_SUBAGENT=1 stands in for --subagent only",
    "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": [
      "59120c249d8be91e236c8186129e7a3831fd1212"
    ]
  }
}

What changed

A subagent's /ship close output: every cost line now says it is the root counter, an upper bound

A subagent's /ship close output: every cost line now says it is the root counter, an upper bound.

Before/after as text: A subagent's /ship close output: every cost line now says it is the root counter, an upper bound
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+# the same run started with --subagent --reading-from this --meter-scope tree
-# a subagent /ship that read "this" (the root counter), on main
 $ gstack-ship-budget close --reading R --credits C
 BUDGET_FINAL: used=71092842 credits=20774 reserved=0 unknown=0 admission_cap=none unit=capy-tokens meter=capy 
+METER: tree (root counter, upper bound)
 BUDGET_TIMELINE: 9:9.2 used=15062369 credits=4227
+METER: tree (root counter, upper bound)
 BUDGET_DRIFT: steps=0 step_projected=0 step_actual=0 dispatches=0 dispatch_projected=0 dispatch_actual=0
+METER: tree (root counter, upper bound)
 

Why

A Capy subagent cannot read its own jam counter, so its /ship read "this", the root thread, and printed that total, sibling lanes included, as its own cost (#3686's ledger baseline 5,769,355,282 was the root counter). The approved rule is "a tree-scoped run can never print an unlabeled cost": a run started with --meter-scope tree, or a subagent reading "this", now prints METER: tree (root counter, upper bound) under every cost line, and a subagent asking for self while reading "this" is refused with METER_SCOPE_PARENT.

Blast radius

The change touches gstack-ship-budget's start, resume, rebuild, handoff and return paths, the result-code table, the Capy skill's budget line, docs/ship-budget.md, docs/troubleshooting.md and the driver's Step 22. It is safe because the label is added only when the ledger holds meter_scope: tree; a run started without the new flags prints byte-identical output (test 'a self run is not' labeled, and the 399 existing ship-budget tests pass unchanged).

Approvals

No approvals recorded for branch gst-467-meter-scope.

Summary

gstack-ship-budget start takes --meter-scope self|tree, --reading-from this|own and --subagent (or GSTACK_SHIP_SUBAGENT=1). A tree-scoped ledger labels BUDGET, NOTE, BUDGET_FINAL, BUDGET_TIMELINE, BUDGET_DRIFT and RECONCILED lines once each, keeps the scope through a re-start, a rebuild from the record and a handoff child, and writes the label into the return file the parent reads. The Capy skill and docs/ship-budget.md tell a subagent to pass --subagent --reading-from this --meter-scope tree and say exact per-run cost comes from a root replay thread; a --token-cap on a tree run stops on that upper bound.

Trial merges (Rule 25) at a0b2dd2: #3702 (c5036a6) merges cleanly, with DRIVER.md at 12,286 of 12,288 bytes. #3686 (e432553) conflicts in capy/skill/gstack/SKILL.md, ship/DRIVER.md, ship/DRIVER.md.tmpl and test/review-pass.test.ts; it already conflicts with main 83ae96e alone in those files, and per the Captain's Rule 19 grant #3686 merges main once after this PR lands and refits DRIVER.md against these bytes. #3698 (b15b9b2, lib/capy-review-pass.js) and #3703 (799b2d2, docs/review-policy.md and test/review-dispatch.test.ts) conflict with main alone, in files this PR does not touch.

Documentation

Status: current. No documentation edits were needed.

Scope: audited gst-467-meter-scope against base 41a67b9 at HEAD b8e4785 (clean tree). I checked the docs-relevant diff hunks and grepped the tree for stale subagent/root-counter claims. Coverage was diff-hunk and grep based, not every doc read in full.

Documentation health:
docs/ship-budget.md [Current] tree-scope text, METER_SCOPE_PARENT link and replay-thread pointer present
docs/troubleshooting.md [Current] meter-scope-parent anchor and fix present
capy/skill/gstack/SKILL.md [Current] subagent instruction matches the CLI
ship/DRIVER.md(.tmpl) [Current] Step 22 carries the METER: line
changelog.d/gst-467-meter-scope.md [Current] matches the code
ship/sections/budget-handoff.md(.tmpl) [Current, with debt] Capy recipe lacks a --meter-scope tree pointer; it does not contradict the new text

Documentation coverage: --meter-scope and METER_SCOPE_PARENT are covered in the budget doc, troubleshooting, the Capy skill, the changelog fragment and the test. Debt: add an optional one-line pointer in budget-handoff.md.tmpl and regenerate (parent-owned).

Diagram drift: none.

Test Coverage

Coverage: 11 of 14 traced paths have a test at two or three stars (Step 7 audit, audit-only, 0 tests generated); the three gaps are a one-line usage guard, the idempotent re-start (since covered) and the doctor anchor map.
Failing-first: the three original GST-467 tests all failed before the change. Each review fix added a case that failed first: resume and handoff labels, the rebuilt ledger, the re-start upgrade with the return file, and drift/reconcile labels.
Tests ran: typecheck count unavailable
Tests ran: focused 83

Pre-Landing Review

Pass 1 ran against a stale local main, so its diff also held nine merged commits from main. The red team read the PR commit in full. The two specialist findings are about main's code (lib/capy-review-pass.js, bin/gstack-wtree), so they are noted and were not fixed here. The red team found three: the rebuild path dropped the scope (fixed, with a test), a cap on a tree run (documented), and the driver's start line (noted, see below). Step 11's voices read the true merge base. The outside voice (openai/gpt-6.1-sol) flagged two as blocking: a re-start ignored the tree request, and the return file lost the label. The native adversarial pass found the re-start gap again, plus unlabeled drift/reconcile lines and a stale BUDGET_READING_MISSING fix text. All of these were fixed with tests, and they are below the floor: they mislabel a cost but lose no data. Pass 2's specialist found nothing. The targeted reader's docs note was reworded. Both fix-checks were clean. The targeted reader (money class) then re-read the whole final patch at b8e4785 against the origin/main merge base and found nothing.
After the merge of main fd5fcb4 (v1.92.20.0), the Step 22 line conflicted with main's "carry tokens and credits; report both". The merged line reads "(report BUDGET_FINAL:, BUDGET_TIMELINE: (tokens, credits), any METER: line)", and Step 20 says "the metrics row", so DRIVER.md is 12,282 bytes alone and 12,286 bytes with #3670 applied. A second fix-check over those lines was clean (NO FINDINGS), and the targeted (money) reader re-ran at 16e6710 with NO FINDINGS.

After the merge of main 83ae96e (v1.92.30.0, train 78), the merge was clean and this PR's own lines are unchanged; DRIVER.md stays at 12,286 of 12,288 bytes. Main edited the paragraph next to this PR's line in capy/skill/gstack/SKILL.md, so one scoped fix-check read that context and was clean, and the receipt carried from 16e6710.
REVIEW_LOOP: passes=2 blocking_found=0 deferred=0 noted=3 fixed=3 scope=frozen fix_checks=2 dispatches=7
Gate edits: none detected.

Noted, not fixed:

  • The driver's Step 2 start line has no tree flags. The brief guidance lives in the Capy skill and docs/ship-budget.md as approved, and DRIVER.md sits 9 bytes under its 12 KB test cap.
  • Tree scope relies on the caller declaring --subagent (or the env var) and --reading-from this. The binary cannot detect a subagent by itself.
  • A parent-metered handoff child prints both METER: parent and the tree label.
  • Exploratory QA: pass (parent CLI smoke at b8e4785, 3 of 3 contracts).
  • Evals: 260 dependent gate cases deferred to the train's gstack/full-gate (lane cap $15).

Cost

This /ship ran in a subagent and read "this", so its numbers are the root counter, an upper bound. As of Step 14.5:

NOTE: 14.5 used=71092842 credits=20773.64 readers=1 readers_tokens=3708118 readers_credits=693.46
METER: tree (root counter, upper bound)

Test plan

  • bun run typecheck: pass
  • focused at 16e6710 (ship-driver, ship-budget-meter-scope, ship-budget-meter-contract, gen-skill-docs-checks): 83 pass, 0 fail
  • rerun at a0b2dd2 after the merge of main 83ae96e, adding launch-env-echo-ratchet and ship-handoff-brief: all 97 green
  • remote pregate (UBI_OWNER=gsta167) at tree 59120c24: 24715 tests, 0 failed, $0.08
  • CI at a0b2dd2: 46 passed, 0 failed

garrytan and others added 4 commits October 31, 2026 13:52
…ost lines, refuse METER_SCOPE_PARENT (GST-467)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… document the cap on a tree run

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…bels reach the return file, drift and reconcile lines; reading-missing fix names the subagent route

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

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

trunk-io Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…meter-scope

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

# Conflicts:
#	ship/DRIVER.md
#	ship/DRIVER.md.tmpl
@github-actions github-actions Bot changed the title ship-budget: a subagent's /ship cost says it is the root counter, an upper bound (GST-467) v1.92.40.0 ship-budget: a subagent's /ship cost says it is the root counter, an upper bound (GST-467) Nov 1, 2026
@capy-ai
capy-ai Bot merged commit 6ffbfb8 into main Nov 1, 2026
64 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