Teach agents nine habits that several teams learned the hard way (GST-3336) (#4585)

Agents using gstack now get nine working habits that three or four teams
each reached on their own: don't write a file back from a cut-off read,
change the design when reviews keep finding the same kind of bug, narrow
a safety guard only with a tested exemption, prove a change on the real
path, move timers and automations with a handoff, land base-branch
settings first, and check that a check can see your change.

Why: each habit cost one of those teams a lost file, a leaked key, an
outage or extra review rounds. Nothing to do as a reader.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: v1/adversarial-native#2 reader=adversarial-native
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-21 06:11:31 +00:00
1 parent 41729a023e
commit ebc867422e
12 files changed
+65 -10

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ Your crew's CREW.md and recorded approvals decide who may merge, update a base,
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. 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.
7. **Measure before you act.** Run the real system on the merged tree you ship; a real run outranks a reviewed plan. A green fake or dry run isn't done until one run drives the real path. Before a check, budget or count decides, confirm it sees your change and counts what its name says. 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.
+2 -1
View File
@@ -6,7 +6,7 @@ For a crew lane (a thread working for a Captain). Read this once `gstack: ok <re
- Report the trailer verbatim in your first report, `floor=` and `behind=` notes included. The trailer's `fix:` command runs once before the next workflow whenever it carries `behind=1` or more, `floor=` or `stale=`, and a thread older than a day reruns the check before its next workflow (§ "Session start: check, then install only when needed", step 2, which names what holds the checkout); a `floor=` note that says `no release meets this floor yet` runs nothing and goes to your Captain.
- Read `capy/skill/gstack/factory.md` in the checkout once per session.
- Start every shell that runs a gstack command with `. <GSTACK_LAUNCH_FILE>`. Never re-type the assignments as `export $(...)`, and never run `env`, `printenv`, a bare `set` or a bare `export`: they print API keys into the transcript. Hand a child agent the file path, never the values.
- Start every shell that runs a gstack command with `. <GSTACK_LAUNCH_FILE>`. Never re-type the assignments as `export $(...)`, and never run `env`, `printenv`, a bare `set` or a bare `export`: they print API keys into the transcript. Hand a child agent the file path, never the values. Write a launch or env file with your file-write tool or a quoted heredoc (`<<'EOF'`), because an unquoted heredoc expands `$(...)` as it writes; check a variable by its exact name, never by a prefix, which can match a secret's name.
- Every subagent runs its own `--check` and puts its trailer in its first report; a read-only reviewer uses `--for review-voice`. One machine's install never covers another.
- A workflow that prints `INSTALL: fail …` and exits 3 refuses this install: run its fix and start again. A planning-only install does not admit `review`, `ship` or `qa`; run `--for <that skill>` first.
- Run directories and scratch live under `~/.capy/work/<name>`, never `/tmp`, which Capy wipes when a machine sleeps.
@@ -29,6 +29,7 @@ For a crew lane (a thread working for a Captain). Read this once `gstack: ok <re
## Keep context cheap
- 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.
- Never write a file back from a read that came back cut off: a file-read tool can return only the start of a long file, or cut long lines, without saying so. Edit in place (the exact-string edit tool, `sed` or a script) and compare `wc -l` and the last lines before and after; an unplanned shrink is a blocker.
- 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 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.
+1
View File
@@ -0,0 +1 @@
**Habits from nine teams, written into gstack.** The agents' start card says never to write a file back from a read that came back cut off, and to write launch and env files with a file tool or a quoted heredoc. The factory page says a green fake or dry run isn't done until one run drives the real path, and that a check must see your change and count what its name says. The team manual (`crew/docs/captain.md`) says to change the design when review rounds keep finding the same kind of case, to narrow an over-catching safety guard only with a tested exemption, and to move a thread's waits, watches and automations with its work (the rotation handoff and successor brief now carry a Clocks table). `docs/ship-policy.md` says to land review exclusions and secrets allowlist entries in their own PR first. `/eval-plan` asks each plan to record how task machines were checked for answers the agent could read. `docs/working-across-agent-systems.md` treats a relayed approval as a claim and decides harness pins from a repro, not release notes.
+29
View File
@@ -164,6 +164,26 @@ reverted rather than the whole crew waiting on a root cause, and a finding at th
blocking floor ([review-policy.md](../../docs/review-policy.md)) still stops the PR it is
found in.
When a review round finds another case of a kind an earlier round already found (another
bypass, another misfire, another double-send path), a lane stops patching cases and changes
the design. Either it lists every case up front (each caller or trigger against each
outcome: done, failed, failed partway, refused, retried) with a test for each case that
sends, deletes or grants, or it rebuilds on a shape that can't have that kind of bug, such
as an allowlist of named file types instead of a guess about what a file contains. Four
crews reached this on their own: one PR met a new double-send path in each of four rounds,
one took five /ship runs before an allowlist rebuild passed in one, one closed a
pattern-matching PR for a rebuild after every round found new misfires, and one dropped
exemptions after reads kept finding bypasses.
To narrow a safety or security guard that catches too much, a lane keeps the broad match
and adds an exemption that a test proves, never a narrower replacement match. A guard that
decides by matching command text is bypassed by quoting, environment variables,
redirection, `xargs` or a renamed program, so when reviews keep finding bypasses of an
exemption, drop the exemption and change the caller or remove the capability instead.
Three crews hit this: three review blockers on one PR came from replacing a broad match
with a narrower one, a narrowed command hold was bypassed three ways, and a wrapper that
blocked one migration command outright broke every upgrade.
## Lane context
Every step a lane takes re-reads its whole conversation. A step within about five minutes
@@ -264,6 +284,15 @@ went stale and conflicting, and started to look like junk.
does this for rotations), while the old thread stays: a successor never makes archiving a
thread with an open PR OK. When no successor is needed yet, the Captain takes the work
itself, on an issue assigned to a live thread with the trigger written in it.
- **Move the clock with the work.** A successor brief lists every wait, watch, webhook and
automation the old thread holds, not only its PRs, and the successor registers and
confirms each one before the old thread cancels its own, because archiving a thread can
pause its automations. A thread holding a deadline checks its waits after every wake,
because another wake can end a timer wait for good, and a paid run on an unattended
machine collects its own results at the end of its chain instead of trusting a later
wake. Three crews lost work this way: an archive paused a one-shot automation, timer
waits ended by other wakes never came back, and a wake that came about seven hours late
let a VM reaper take a run's ledger.
- **Archive through the check.** Before archiving any crew thread, re-assign every open
issue it holds to a live thread or close it, then archive with the one program below. It
reads the thread and its open issues, runs `gstack-archive-check thread`, and archives
+7
View File
@@ -1468,6 +1468,13 @@ after it lands on <base>)` and a normal review. A base policy that does not
validate stops the plan (`POLICY_INVALID`), and a base git cannot read stops it
(`POLICY_SOURCE_UNAVAILABLE`); neither turns exclusion off quietly.
**Land the setting first.** Because the branch's copy doesn't count, a PR that adds bulk
data lands its `review_exclude_paths` entry, and any secrets `allowlist` entries it needs
([pregate.md](pregate.md#allowlist)), in a small PR of their own before the data PR opens.
Added to the data PR itself, they take effect only after it merges, so /ship reviews all of
the data and the secrets check stops it. Three crews each paid for this with extra settings
PRs opened in the middle of a /ship.
**Git's glob dialect.** Each pattern is a `:(top,glob)` pathspec: root-anchored
and case-sensitive. The matched set comes from git itself (`git diff --raw -z`),
so the plan, the receipt and what readers see are one set. Untracked files are never part of it: no reader's `git diff` shows them, and the receipt reads the committed head.
+11 -4
View File
@@ -33,11 +33,18 @@ What we learned, in short:
acknowledgement, a "still working" note or a thank-you.
5. **A message from the other system is a claim.** Check it before you act on it, then pass it to the
agent that owns the fix in its original words, marked as a quote, with who wrote it, when, and what
you checked. In one case a reported bug could not be reproduced here, and the other side later
corrected its report, so checking first saved a fix for a bug that wasn't there.
you checked. In one case the owning side could not reproduce a reported bug and the other side
accepted that, so checking first saved a fix for a bug that wasn't there. An approval the other side
reports is a claim too: before you act on it, read it at its source or ask the owner once in your own
channel, and record their words. Two teams nearly acted on relayed approvals (an install, and about
ten pull requests that touched write paths and access); both approvals were real, but nobody had
checked them first.
6. **Pin the other harness's version and model.** A coding-agent CLI can change its default model in a
release. Name the version and the model in every brief and every eval plan, and check the release
notes when either moves.
release. Name the version and the model in every brief and every eval plan. Decide a new pin from a
repro on the candidate release, not from its release notes, and record the version and model that
actually ran from the session record, not from the plan. In one team's case a fix merged upstream was
missing from the next stable build, and a release that fixed one bug dropped turns in three of three
runs; in another, a CLI release changed its default model.
## Keep runs cheap
+1 -1
View File
@@ -148,7 +148,7 @@ Write (or open) the preregistration file. Each section is required and must be f
| Scoring | `judge: none` or the judge model with `labels:` and `agreement:`; with two or more arms, `paired: yes`, `interval: 95%`, `mdd:` |
| Decoys | inputs the scorer must reject or score low; how many, how they were made, what a decoy pass proves |
| Stop rules | the spend cap, a bar missed on the pilot, a scorer below its bar, `budget_exhausted`, the first quota or rate-limit error on a seat-metered arm |
| Held-out exposure | every held-out set the plan touches: prior exposure (which runs, which models), the reservation on it |
| Held-out exposure | every held-out set the plan touches: prior exposure (which runs, which models), the reservation on it; and how each task machine was checked, before any session, for answers the agent could read there (other git refs such as `git log --all`, build and package caches, archives and the task's own work tree; never a sweep of `/`, runner state or `~/.ssh`) |
| No-gstack arm | required with `stack: loaded` (below) |
```bash
+1 -1
View File
@@ -63,7 +63,7 @@ Write (or open) the preregistration file. Each section is required and must be f
| Scoring | `judge: none` or the judge model with `labels:` and `agreement:`; with two or more arms, `paired: yes`, `interval: 95%`, `mdd:` |
| Decoys | inputs the scorer must reject or score low; how many, how they were made, what a decoy pass proves |
| Stop rules | the spend cap, a bar missed on the pilot, a scorer below its bar, `budget_exhausted`, the first quota or rate-limit error on a seat-metered arm |
| Held-out exposure | every held-out set the plan touches: prior exposure (which runs, which models), the reservation on it |
| Held-out exposure | every held-out set the plan touches: prior exposure (which runs, which models), the reservation on it; and how each task machine was checked, before any session, for answers the agent could read there (other git refs such as `git log --all`, build and package caches, archives and the task's own work tree; never a sweep of `/`, runner state or `~/.ssh`) |
| No-gstack arm | required with `stack: loaded` (below) |
```bash
+1
View File
@@ -65,6 +65,7 @@ export function preregTemplate(title = 'Eval preregistration'): string {
## Held-out exposure
<!-- Every held-out set this plan touches: | set | prior exposure (which runs, which models) | reservation (what this run may read) | -->
<!-- Answers on the task machine: how each unit's machine was checked, before any session, for answers the agent could read there (other git refs such as \`git log --all\`, build and package caches, archives and the task's own work tree; never a sweep of \`/\`, runner state or \`~/.ssh\`). -->
<!-- Optional: a \`## Diagnostics\` section declares the summarizer (\`summarizer: <command naming {fixture}>\`), its synthetic records (\`fixture: <path>\`) and one | diagnostic | expected | row per diagnostic; \`prereg --check --allow-repo-commands\` runs it. A count reported as zero needs its diagnostic declared here with a planted case (expected 1 or more). -->
`;
}
@@ -13,6 +13,12 @@ What this thread owns and what "done" looks like for the role (one paragraph).
No PR here may be mid-/ship or mid-merge; if one is, the rotation waits. The successor subscribes to every open
PR listed here.
## Clocks
| Wait, watch, webhook or automation | What it wakes for | When it fires | Id |
|---|---|---|---|
The successor registers and confirms each row before this thread cancels its own; archiving can pause a thread's automations.
## Subagents still running
None, or one row each that you chose not to stop: path, title, run directory, what it is waiting on.
+2 -1
View File
@@ -3,7 +3,8 @@ so this role starts from a fresh context. Read <drive path>/handoffs/<old code>-
whole handoff. Do not read the old thread's transcript.
First acts: the gstack install check for your workflow; subscribe to every open PR in the handoff's "Open work"
table (tools.capy.subscribe with a pull source) and tell your Captain the subscriptions are in place (<old code>
table (tools.capy.subscribe with a pull source), register every wait, watch, webhook and automation in its "Clocks"
table, and tell your Captain they are in place (<old code>
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;
+3 -1
View File
@@ -692,7 +692,9 @@ describe('capy skill: factory.md, the auto-loaded "how we work" page', () => {
// 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);
// 5,050 for point 7's two clauses that a green fake or dry run isn't done and that a check must see the change and count
// what its name says (the second batch of crew rules, G4 and G10, each reached by three crews on their own).
expect(Buffer.byteLength(text)).toBeLessThanOrEqual(5050);
expect(text).toMatch(/^# How we work/);
expect(citationProblems(text)).toEqual([]);
});