Skip to content

docs: crew lanes keep context cheap (bounded warm waits, lane start card, names-only AGENTS.md index) - #4060

Merged
capy-ai[bot] merged 2 commits into
mainfrom
gsta-332-lane-context
Nov 6, 2026
Merged

capy-ai[bot] merged 2 commits into
mainfrom
gsta-332-lane-context

Conversation

@garrytan

@garrytan garrytan commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 4060,
  "head": "4c62cbcd99ec0dcf67e4ba1973487b56f34e0192",
  "version": "1.96.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1601,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42180117992,
      "attempt": 1,
      "tree": "0d9e05b75f86d54290b0939b7624d2096470cab7"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "0d9e05b75f86d54290b0939b7624d2096470cab7",
  "product_patch_id": "3d4a01ec1e52e4e868fbe522f73c4a526958bf01",
  "gstack_version": "1.96.0.0",
  "review_depth": {
    "depth": "full",
    "class": "code",
    "runtime_lines": 246,
    "rules": "70895942bb8a8ee2",
    "base": "12d18a2e1075bfe472c62f55b32f7ea10ed47275",
    "registry": "12d18a2e1075bfe472c62f55b32f7ea10ed47275",
    "gate_scan": {
      "tagged": 0,
      "head": "4c62cbcd99ec0dcf67e4ba1973487b56f34e0192"
    },
    "reasons": [
      "risk:money",
      "risk:security",
      "risk:data",
      "runtime=246"
    ],
    "risk": [
      "money",
      "security",
      "data"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @0d9e05b75f86 (7 checks, current for 4c62cbcd99ec)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42180117992/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=0d9e05b75f86 tests=35850 skipped=69 runs=42180117992/1 profiles=ci-reuse/free-tests heads=4c62cbcd99ec verified=2026-11-06T07:31:05.130Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "AGENTS.md, README.md, docs/, capy/skill/gstack/, captain/templates/, changelog.d/ (read-only audit at 4c62cbc)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 1,
    "fixed": 6,
    "scope": "frozen",
    "rounds": 2,
    "ledgers_read": 2,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  },
  "review_targeted": {
    "classes": [
      "money"
    ],
    "rules": "30e6bce187be0d59",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "3d4a01ec1e52e4e868fbe522f73c4a526958bf01",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}
{"head":"4c62cbcd99ec0dcf67e4ba1973487b56f34e0192","version":"1.96.0.0","gstack_version":"1.96.0.0","review_loop":{"passes":2,"blocking_found":2,"deferred":0,"noted":1,"fixed":6,"scope":"frozen","rounds":2,"ledgers_read":2,"dispatches":{"specialist":6,"red-team":2}},"depth":"full"}

What changed

docs/captain.md gains a Lane context section: bounded warm waits, batched reads, the lane start card and a tail check

docs/captain.md gains a Lane context section: bounded warm waits, batched reads, the lane start card and a tail check.

Before/after as text: docs/captain.md gains a Lane context section: bounded warm waits, batched reads, the lane start card and a tail check
--- Before · docs/captain.md § Lane context at 12d18a2 · source text (section not present before)
+++ After · docs/captain.md § Lane context on this branch · source text
+## Lane context
+Every step a lane takes re-reads its whole conversation. A step within about five minutes
+of the previous one reads it from the prompt cache; after five idle minutes the cache is
+gone and the next step costs about eight times as much. Fixed instruction text and idle
+restarts, not checks, are now most of a lane's own spend, so a lane keeps its context
+cheap:
+
+- **Warm waits.** When a lane expects a wait under about 30 minutes (a CI run, a test
+  tier, a background build), it checks in every 240 seconds: on Capy, `wait` on the
+  operation with `duration_seconds: 240`, and on a timer wake that brings nothing new it
+  re-issues the same wait silently, with no message. Once a warm wait has run about 30
+  minutes, or past the end the lane expected, the lane stops re-issuing the timer and
+  sleeps on the operation or pull request watch alone. A wait expected to run longer sleeps
+  on its operations alone. For short lane waits this overrides "waits go on operations,
+  never on polling wakes" ([unattended.md](unattended.md#report-length)). The controller
+  never warm-waits, and a lane still sleeps while /ship runs
+  ([the lane's /ship sequence](#the-lanes-ship-sequence-before-ready)).
+- **Batched reads.** Independent reads (files, greps, pull request and thread state) go in
+  one parallel program, not one call each. Each call returns 4k characters or less; long
+  output (logs, test output, diffs) goes to a file under `~/.capy/work`, and the lane reads
+  the part it needs with `grep` or a paged read.
+- **Start card.** Once the install check passes, a lane reads
+  [lane-card.md](../capy/skill/gstack/lane-card.md) instead of the rest of the gstack
+  skill's SKILL.md. It still reads the SKILL.md sections on /ship before it ships.
+- **Tail check.** When a lane's spend passes twice the crew's median lane spend per merged
+  PR (about $50 at today's prices), it writes `handoffs/<code>/next.md` in the controller's
+  drive (what is done, what is left and what finishing costs) and tells the controller in
+  one line. The controller decides whether the lane continues, rotates to a fresh lane
+  that starts from that file, or parks. This sits below the crew's hard spend stop (a
+  per-PR figure in the controller's rules), where the lane stops and asks whether the PR
+  is still worth it. Spend is the
+  thread's credit meter, never a token count.

Why

Plan GSTA-330 found that lanes pay mostly for re-read instruction text and for cold restarts after idle waits, not for checks. Garry said "Do it" on all six items. This PR carries four of them. Lanes keep their prompt cache warm through short waits, with a 30-minute cap, and batch their reads. They read a 4.5 KB start card instead of the whole Capy skill. A lane past twice the median spend now hands off before it reaches the hard stop. AGENTS.md also stops loading about 9.8 KB of skill tables into every session.

Blast radius

Only docs and prompt text change: AGENTS.md, docs/captain.md, docs/unattended.md, docs/skills.md, the captain brief template, the Capy gstack skill (SKILL.md plus the new lane-card.md) and one test. No bin, lib or generated file reads the AGENTS.md tables. The adversarial reader grepped scripts/, lib/ and bin/ for that and found only ## Skill routing probes, which still match. SKILL.md stays under its 5,315-token eager budget (context-budget-ratchet passed), and CI Free Tests passed at this exact tree (run 42180117992).

Approvals

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

Garry, 2026-11-06: "Do it" on plan GSTA-330, decision D1 (all six items at full scope). This PR carries L1, L3, L4 and T1.

Summary

Crew lanes were spending most of their budget re-reading instructions and restarting cold after idle waits. Lanes now warm-wait short waits for 30 minutes at most, batch independent reads, and start from a short lane card. Past twice the median lane spend they write a handoff. AGENTS.md becomes a names-only skill index that points to docs/skills.md, and the /cso catalog details it alone held moved to docs/skills.md. A review fix round then bounded the warm wait and replaced a claimed but undefined "three times the median" stop with the crew's own spend stop. The same round fixed the brief's wait to watch the operation and filled in the lane card's plan exemptions.

Test Coverage

The diff is docs and skill prose, so the Step 7 audit covered its contracts. 6 of 10 paths are tested (60% value-weighted). The tested paths: the lane card cites real SKILL.md sections and stays under 6,800 bytes, SKILL.md points to it, docs/captain.md carries the Lane context rules (now including the warm-wait cutoff), and the brief has a Read: line. The untested paths are prose that a test would only copy: the brief's Context: line, the unattended.md cross-reference, the docs/skills.md /cso paragraph and the changelog fragment.

Tests: 1726 → 1726 files (+0 new files; one assertion added to the existing lane-card test in test/captain-skill.test.ts for the warm-wait cutoff).
Test value: 0 tests written, 2 rejected by the authoring gate, 1 existing test extended, 1 path weakly covered.
Tests ran: test 1601 (carried from CI run 42180117992 at tree 0d9e05b75f86)

Pre-Landing Review

Pass 1 (full depth, 5 dispatches plus the coverage audit) found 2 blocking items. The fix round in 4c62cbc closed both, plus four informational items. Pass 2 (the fix range, 3 dispatches) found one informational note.

  • [CRITICAL, fixed] docs/captain.md:150: the warm-wait loop had no cap; a stuck CI run would wake a lane about 15 times an hour indefinitely. It now stops re-issuing the timer after about 30 minutes or past the expected end (docs/captain.md, lane-card.md, brief.md).
  • [CRITICAL, fixed] captain/templates/brief.md:15: the brief's Context: line said to wait with a 240 s timer without naming the operation, which lets a Capy machine sleep and kill the work being waited on. It now says to wait on the operation.
  • [fixed] docs/captain.md:169 and the changelog: "the existing hard stop at three times the median" existed nowhere; they now point to the crew's hard spend stop.
  • [fixed] lane-card.md: the plan-exemption list is now complete, the dangling "Other bug fixes" is gone, and the card points to SKILL.md for loading another workflow.
  • [fixed] brief.md: names a fallback when the Drive skill copy has no lane-card.md yet.

REVIEW_LOOP: passes=2 blocking_found=2 deferred=0 noted=1 fixed=6 scope=frozen ledgers_read=2 dispatches=8

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 (a Capy subagent, cross-family, at reasoning high, outside the certified medium setting) completed with no actionable findings.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL captain/templates/brief.md:15 The lane-card fallback names "the checkout's" copy, which a lane on another repository reads as its working repository; it should name the certified install root ($GSTACK_CAPY_ROOT, default ~/.local/share/gstack).
  • INFORMATIONAL docs/captain.md:150 Warm-wait re-waits count as empty turns in lib/runaway.ts emptyWakes(). A lane that follows the rule can cross the empty-wake WARN line, and runaway-stopper's "One wait" brief line still says never to poll. A follow-up should teach the detector about warm waits.
  • INFORMATIONAL capy/skill/gstack/lane-card.md:3 The card does not repeat the CAPY_WRAPPER_STALE rule ("never write the skill folder yourself").
  • INFORMATIONAL captain/templates/brief.md:15 The Drive copy of the skill has no lane-card.md until an owner recopies the folder, and the wrapper number did not change, so no stale-copy warning fires.
  • INFORMATIONAL The warm-wait rule departs from Capy's "never use wait as a polling loop" guidance by design (Garry's "Do it" on GSTA-330 L1). The "about eight times" cold-restart figure was not measured in this PR.
  • INFORMATIONAL AGENTS.md The area labels file /make-pdf and /diagram under "safety + scoping". The docs audit adds that about 10 skills (plan-devex-review, plan-tune, devex-review, landing-report, document-generate, context-save, context-restore, benchmark-models, setup-gbrain, sync-gbrain) have no dedicated docs/skills.md section, so the names-only index points them at thin docs.
  • INFORMATIONAL docs/captain.md "Tail check" has one short wrapped line ("is still worth it. Spend is the"); it renders the same.

Exploratory QA

Functional surface, smoke budget (5 minutes or 12 probes), report-only. Probes ran at cccff5f and were rerun on the fixed tree at 4c62cbc:

  • bun test test/captain-skill.test.ts: pass (11 tests).
  • A link and anchor check over the changed docs (every relative link and #anchor in lane-card.md, captain.md, unattended.md, brief.md and AGENTS.md): pass, 0 broken. The first run's 25 misses were a checker defect: it ignored explicit <a id> anchors. The fixed checker found none.

Verdict: pass. Limit: whether a live lane actually warm-waits or reads the card is prose behavior and was not exercised.

Design Review

No frontend files changed, so design review was skipped.

Eval Results

The eval selector (scripts/eval-select.ts, PR profile) picked no behavioral probes and no quality judges for these 9 files, so no paid evals ran ($0).

Review bot comments

No review bot comments (the PR did not exist during review).

Scope Drift

Scope Check: CLEAN. Intent: lane context items L1, L3, L4 and T1 from plan GSTA-330. Delivered: the Lane context section, the lane start card, the brief's Read:/Context: lines, the unattended.md exception, the names-only AGENTS.md index with the /cso paragraph moved, and one test.

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/adversarial-native#1
Refs p1/red-team#3
Refs p1/red-team#4
Refs p1/red-team#5
Refs p1/red-team#6
Refs p1/targeted#1

Verification Results

No plan-specific verification items (no plan file bound). Automatic QA above: 2 PASS, 0 FAIL, 0 BLOCKED, 0 NOT RUN.

TODOS

No TODO items completed in this PR.

Documentation

Status: current. The audit made no edits (read-only mode) and found no blockers.

Scope: the candidate at head 4c62cbc on gsta-332-lane-context against base 12d18a2, covering committed content (nothing staged, unstaged or untracked). Reviewed in full: AGENTS.md, captain/templates/brief.md, capy/skill/gstack/SKILL.md, capy/skill/gstack/lane-card.md, changelog.d/gsta-332-lane-context.md, docs/captain.md, docs/skills.md (the /cso addition) and docs/unattended.md. Cross-links and anchors were checked.

Documentation health:

  • AGENTS.md: current. The names-only skill index points to docs/skills.md and the iOS how-to, both of which exist.
  • captain/templates/brief.md: current. The Read/Context lines match docs/captain.md § Lane context.
  • capy/skill/gstack/SKILL.md and lane-card.md: current. The card is linked from SKILL.md and docs/captain.md.
  • changelog.d/gsta-332-lane-context.md: current.
  • docs/captain.md: current. The new Lane context section's internal anchors resolve.
  • docs/skills.md: current. The /cso catalog details moved here from AGENTS.md.
  • docs/unattended.md: current. The warm-wait exception links to captain.md#lane-context.

Coverage debt: about 10 skills (plan-devex-review, plan-tune, devex-review, landing-report, document-generate, context-save, context-restore, benchmark-models, setup-gbrain, sync-gbrain) have no dedicated section in docs/skills.md, so AGENTS.md's pointer to docs/skills.md for what each skill does is incomplete for them. This predates the change. Diagram drift: none found.

Test plan

  • bun run test (carried from CI Free Tests run 42180117992 at tree 0d9e05b75f86): 1601 files, exit 0
  • Focused at 4c62cbc: captain-skill, captain-brief, capy-skill-wrapper, context-budget-ratchet, prose-voice-floor, skill-validation, test-value-bar, parity-suite, agents-digest, spawnsync-timeout-tripwire: 458 pass, 0 fail
  • bun run gen:skill-docs fresh (no diff); bun run typecheck:test 812 known diagnostics, none new; typecheck and conflict-marker guards pass

garrytan and others added 2 commits November 6, 2026 06:42
…) and a names-only AGENTS.md index

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ane-card fallback and exemptions)

Review-Finding: p1/targeted#1 reader=targeted
Review-Finding: p1/adversarial-native#1 reader=adversarial-native
Review-Finding: p1/red-team#3 reader=red-team
Review-Finding: p1/red-team#4 reader=red-team
Review-Finding: p1/red-team#5 reader=red-team
Review-Finding: p1/red-team#6 reader=red-team
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.

@capy-ai
capy-ai Bot merged commit 01572de into main Nov 6, 2026
64 checks passed
capy-ai Bot added a commit that referenced this pull request Nov 6, 2026
* runaway: warm-wait check-ins are not empty wakes (GST-1597)

lib/runaway.ts counted each 240-second warm-wait check-in (docs/captain.md,
#4060) as an empty wake, so /runaway-stopper could flag a lane that follows
the rule. A turn whose only call re-issues the wait on the same operation, or
a 240-second timer, within 30 minutes of the wait that started the run is
now left out of the rate.

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

* fix: pre-landing review fixes

Review-Finding: p1/specialist-batched#1 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>

* docs: note the warm-wait exclusion in the /runaway-stopper summary; rewrap captain.md (GST-1597 docs audit)

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

* runaway: keep wait input in the skill collector; 240 s timers chain only on the run's operations; status reads keep the warm window (GST-1597)

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>
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