Skip to content

ship budget: count a Capy /ship helper's calls from the call log (GST-1585) - #4059

Merged
capy-ai[bot] merged 6 commits into
mainfrom
capy/gst-1585-helper-calls
Nov 6, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
capy/gst-1585-helper-calls

Conversation

@garrytan

@garrytan garrytan commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Draft. /ship writes the final body.

A Capy /ship helper can't read its own transcript, so every helper reported CALLS: unavailable. On Capy, the gstack-ship-* bins and the review pass loader now append one row each to <state root>/ship-calls.jsonl, and gstack-ship-budget calls --record <rec> rebuilds the helper's calls from those rows (no added call). GSTA-330 H1.

Open in Capy

{
  "schema_version": 1,
  "pr": 4059,
  "head": "4e896b983b741d4e71fe232f8e5e85d20385c2e2",
  "version": "1.96.0.0",
  "base": "main",
  "gate": {
    "free": {
      "pass": 35856,
      "fail": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 42187969619,
      "attempt": 1,
      "tree": "28fbeabd8f61608fedde5e173fff92ffde68bffe"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "28fbeabd8f61608fedde5e173fff92ffde68bffe",
  "product_patch_id": "9b9b1aa02fb94df470e9881a36dec27156f3a213",
  "gstack_version": "1.96.0.0",
  "review_depth": {
    "depth": "full",
    "class": "code",
    "runtime_lines": 149,
    "rules": "70895942bb8a8ee2",
    "base": "4b1a1152844abf3e0562fb72767856dcdd5ba331",
    "registry": "4b1a1152844abf3e0562fb72767856dcdd5ba331",
    "gate_scan": {
      "tagged": 0,
      "head": "4e896b983b741d4e71fe232f8e5e85d20385c2e2"
    },
    "reasons": [
      "risk:money",
      "runtime=149"
    ],
    "risk": [
      "money"
    ],
    "mode": "panel"
  },
  "pregate": "pass @28fbeabd8f61 (7 checks, current for 4e896b983b74)",
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, README.md and capy/skill/gstack against base 12d18a2e: docs/ship-budget.md updated"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 7,
    "fixed": 4,
    "scope": "frozen",
    "fix_checks": 2,
    "rounds": 3,
    "unrecorded": 1,
    "ledgers_read": 5,
    "unbound": 5,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  },
  "review_loop_exception": {
    "accepted_by": "GStack Minder",
    "date": "2026-11-06",
    "via": "GSTA-333 parent message 2026-11-06 (approval a-d3519c3ba452)",
    "reason": "one scoped fix-check after round 2 for outside-voice#2 and adversarial-native#1; outside-voice#1 ruled below the floor as a disclosed note",
    "fix_check": {
      "head": "0029bbe1ec80bd4f28e69fe74f00b5972e7939ea",
      "findings": 3,
      "files": [
        "lib/ship-call-log.ts",
        "docs/ship-budget.md",
        "test/ship-call-log.test.ts"
      ]
    }
  },
  "review_targeted": {
    "classes": [
      "money"
    ],
    "rules": "30e6bce187be0d59",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "9b9b1aa02fb94df470e9881a36dec27156f3a213",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}

What changed

Before: a Capy /ship helper had no way to count its calls. After: calls --record rebuilds them from the call log the ship bins write.

Before: a Capy /ship helper had no way to count its calls. After: calls --record rebuilds them from the call log the ship bins write.

Before/after as text: Before: a Capy /ship helper had no way to count its calls. After: calls --record rebuilds them from the call log the ship bins write.
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+$ gstack-ship-budget calls --record ship-gst1585/record.md   # this branch
+CALLS: source=log calls=24 phase=7 pass=8 section=1 other=8 keepalive_est=4 total_est=28 pass_overhead_s=p50:0,max:0 gaps_over_300s=1 max_gap_s=340 first=2026-11-06T07:42:24.779Z last=2026-11-06T08:28:35.137Z
+(exit 0)
-$ gstack-ship-budget calls --record ship-gst1585/record.md   # main
-gstack-ship-budget: unknown flag --record; valid: --events --since --until (usage)
-(exit 2)
 
Before (main) After (this branch)
What a Capy /ship helper reports at Step 22 CALLS: unavailable (it can't read its own transcript) CALLS: source=log calls= phase= pass= section= other= keepalive_est= total_est= ...
Where the count comes from nowhere one row per gstack-ship-* or gstack-review-dispatch command, written to <state root>/ship-calls.jsonl when it exits, on Capy only
gstack-ship-budget calls --events <file> only also --run <id> or --record <path> (with --log, --since, --until)
A run window with no rows n/a CALLS: unavailable source=log reason=no rows in the run window log=<file>, never zeros
A background lane or finish that runs for minutes n/a ends its call where it starts, so the calls made meanwhile still count

Why

"Every Capy /ship helper reported CALLS: unavailable", so nobody could tell how many calls a helper spends or whether a 240 s keep-alive would pay off (GSTA-330 plan item H1). Now each helper gets a real call count and a keep-alive estimate from the commands it already runs, at no extra call.

Blast radius

Seven bins (gstack-ship-budget, parts, policy, preflight, queue, release and gstack-review-dispatch) gain one logShipCall line, and gstack-ship-budget calls gains the log mode. The logger runs only under GSTACK_CAPY=1, writes at process exit inside a try/catch, and a child bin writes nothing, so a failed write can't change any command's output or exit code. That is tested: test/ship-call-log.test.ts compares the stdout, stderr and exit of a run whose log write fails against a normal run (script ran). bin/gstack-ship-receipt is untouched.

Approvals

Approved: yes (record r-aa3ca219ddad). The full approval record stays private: this repository is public or its visibility is unknown.

Summary

A Capy /ship helper runs as a subagent, and a subagent can't read its own transcript, so every helper reported CALLS: unavailable and we had no data on how many calls a run spends. The ship bins now log one row per command on Capy, and gstack-ship-budget calls --record <rec> turns those rows into a call count with phase, pass and section splits plus a keep-alive estimate. Review found that a long background command, an early-settled pass and back-to-back pass loaders could each skew the count (one case printed Infinity); those are fixed and pinned by tests, and an empty window now says unavailable instead of printing zeros.

Test Coverage

Step 7 ran audit-only (no generation allowance, unattended): 8 of 15 changed paths have a test (53%), 7 of 15 a strong one (47%). Gaps with no test: rotation past 8 MiB is now covered; still uncovered are malformed-line skipping, calls --run <id>, and the row write for gstack-ship-policy, preflight, queue and release (gstack-ship-parts, budget and review-dispatch are tested).
Tests: 4 → 7 in test/ship-call-log.test.ts (+3 new: long background row, non-rerun loaders, early-settled pass), and 1 existing test extended (rotated log, empty window).
Regression proof: the two granted-fix tests failed before commit 0029bbe (5 pass, 2 fail) and pass after; probes 002 and 003 failed at ec01ae7 and pass on the fix.
Tests ran: free 1602 files (carried from CI run 42187969619/1 at tree 28fbeabd8f61, 35856 tests; 6 files skipped here, 5 not owed)

Pre-Landing Review

Pre-Landing Review: 4 issues — 2 auto-fixed, 2 asked (1 fixed, 1 skipped), 0 deferred, 0 noted.
REVIEW_LOOP: passes=1 blocking_found=2 deferred=0 noted=7 fixed=4 scope=frozen unrecorded=1 unbound=5 ledgers_read=5 fix_checks=2 dispatches=4
Review-loop exception: accepted by GStack Minder 2026-11-06 via GSTA-333 parent message 2026-11-06 (approval a-d3519c3ba452): one scoped fix-check after round 2 for outside-voice#2 and adversarial-native#1; outside-voice#1 ruled below the floor as a disclosed note (fix-check at 0029bbe, 3 findings)
Gate edits: none detected (1 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: openai/gpt-6.1-sol (host subagent) completed with 2 findings. outside-voice#2 (loaders under 200 s apart made the keep-alive cycle 0 and the totals Infinity) is fixed under GStack Minder's grant of one scoped fix-check (approval a-d3519c3ba452). outside-voice#1 (concurrent helpers on one state root count in each other's window) was ruled below the floor by GStack Minder on 2026-11-06 as a disclosed note; the follow-up is a run id from the launch file, tracked on GST-1585.
Native adversarial: completed, 5 findings (Blocks: no); #1 (an early-settled pass swallowed the next phase call) is fixed under the same grant. Targeted (money): NO FINDINGS on every pass.

Review notes

  • p1/specialist-batched#1, outside-voice#1, adversarial-native#2: rows carry no run identity, so a sibling helper or the parent lane on the same state root counts inside this run's window. Follow-up: a run id from the launch file (GST-1585).
  • adversarial-native#3: overhead could go negative or huge; the granted fix limits it to 200 s poll reruns and clamps it at 0. A rerun gap still has no upper bound (fix-check p4#1).
  • p4 fix-check#2 and Project-local .claude/skills/gstack install breaks /browse and setup can report false success #3: the rerun floor is 195 s (200 s less the 5 s join), so a rerun 181–194 s after the last loader is not counted, and the docs say 200 s.
  • adversarial-native#4, p2 fix-check#3: rotation is a stat-then-rename with no lock, so two writers at 8 MiB can drop the rotated file. Metric data only.
  • adversarial-native#5: step, reading and credits are logged but not read yet; --events wins over --record; --log has no ~ expansion.
  • p2 fix-check#2: a background row of 230 s or less still extends its call.

Exploratory QA

Functional smoke on the CLI, report in the run dir (verdict pass): 001 a bin writes one row on Capy (pass); 002 a 20-minute background row absorbed three later calls (failed at ec01ae7, replayed as 004 on the fix: calls=3, pass); 003 a missing log printed zeros (failed at ec01ae7, replayed as 005: CALLS: unavailable, pass). Not probed live: rotation, sibling-run rows and the other six bins.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed (gstack-diff-scope SCOPE_PROMPTS=false) — evals skipped.

Review bot comments

No review bot comments.

Scope Drift

Scope Check: CLEAN

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Fix: add "Plan: " to the PR body, or run /autoplan.

Issues

Refs p1/specialist-batched#2
Refs p3/adversarial-native#1
Refs p3/outside-voice#2

Verification Results

No plan-specific verification items (no plan file). Automatic exploratory QA above: 5 captures, 3 pass on current inputs, 2 superseded.

TODOS

No TODO items completed in this PR.

Documentation

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

Scope: committed, staged, unstaged and new-file changes from base 12d18a2 to head 818cc6f on capy/gst-1585-helper-calls. The change adds call-log rows written by the gstack-ship-* bins and gstack-review-dispatch, plus gstack-ship-budget calls --run|--record|--log.

Documentation health:

  • docs/ship-budget.md: updated. The call-log usage now shows the supported --since/--until flags.
  • capy/skill/gstack/SKILL.md: current. Step 22 points to calls --record <rec>.
  • changelog.d/capy-gst-1585-helper-calls.md: current. Reviewed only; changelog edits are not allowed here.

Coverage debt: the call log has reference and explanation coverage in docs/ship-budget.md. It has no how-to or tutorial (a common gap). No diagram drift.

Test plan

  • bun run test: carried from CI run 42187969619/1 at tree 28fbeabd8f61 (green, 1602 files)
  • bun test test/ship-call-log.test.ts test/ship-calls.test.ts test/test-value-bar.test.ts test/module-size-ratchet.test.ts test/spawnsync-timeout-tripwire.test.ts: 52 pass, 0 fail
  • bun run typecheck: zero errors; bun run typecheck:test: 812 known diagnostics, none new

garrytan and others added 2 commits November 6, 2026 06:42
…tack-ship-* bins write (GST-1585)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…er Step 22 line keeps the capy skill budget (GST-1585)

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

trunk-io Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 4 commits November 6, 2026 08:05
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Review-Finding: p1/specialist-batched#2 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…asses

Review-Finding: p3/outside-voice#2 reader=outside-voice
Review-Finding: p3/adversarial-native#1 reader=adversarial-native
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…fixes

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

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

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

E2E Evals: ✅ PASS

[test:paid] VERDICT GREEN — lane gate/pr, attempt 1
  rule 0/0 · behavior 0/0 · judge 0/0 · quarantined 0 (0 failing the lane)
  SKIPPED 0 · INFRA 0 · INCOMPLETE 0 · unattributed 0 · ACTION REQUIRED 0
  wall 0m00s · cost $0.00

0 executed, 0 reused rule/judge records | 0 manual accepted (unscored; no score-cache credit) | $0 rule/judge cost | reconcile exit: 0

Profile: pr / mode pr; selected behaviors: 0, judges: 0. Deferred to scheduled/release coverage: 0 behaviors and 0 changed prompt files. Deferred checks did not run and receive no PR-pass credit.

Rule and judge shards
Shard Automated result Manual/unscored Executed Reused Status Cost
Fail-closed reconciliation
[test:paid] report: 1/1 slices, 0 planned shards, tier=gate, attempt 1
[test:paid] coverage: profile=pr mode=pr; selected E2E=0, judges=0
[test:paid] deferred: 0 broad behaviors, 0 changed prompts without quick live coverage; these are not PR passes
[test:paid] collector final outcomes: 0 executed, 0 reused; 0 passed, 0 failed, 0 manual accepted (unscored; no score-cache credit) (0 attempt records from 0 collectors; every record counts)
[test:paid] VERDICT GREEN — lane gate/pr, attempt 1
  rule 0/0 · behavior 0/0 · judge 0/0 · quarantined 0 (0 failing the lane)
  SKIPPED 0 · INFRA 0 · INCOMPLETE 0 · unattributed 0 · ACTION REQUIRED 0
  wall 0m00s · cost $0.00
[test:paid] exercised-path map (shadow, non-blocking): 0 MAP_GAP line(s) over 0 executed case(s) with recorded commands
[test:paid] report: every planned shard accounted and passed

Sliced lane: planner → duration-packed executors → fail-closed report. Behavior cases run a pre-registered 3-trial panel (PASS at 2/3 with no contract violation); a PASS 2/3 is shown with its failed trial, never as a clean pass. Reused results retain their original provenance and expiry.

Dispatched narrow screen (gstack-ship-queue ready --screen) of merge commit c67edfa785151dc108c67891f2880f8fad5e12b7.

@capy-ai
capy-ai Bot marked this pull request as ready for review November 6, 2026 08:45
@capy-ai
capy-ai Bot merged commit 3c7ff03 into main Nov 6, 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