diff --git a/ETHOS.md b/ETHOS.md index bdb427660..2c88c5de0 100644 --- a/ETHOS.md +++ b/ETHOS.md @@ -327,7 +327,9 @@ or from an unmasked arm is a lead, not a verdict. When a fair test shows an existing part doesn't help, it gets one "Why null?" cycle: did the model use the part, did the task fit, was there enough power and room below the ceiling, and does today's model do the job without it. Then -keep it, fix the method, or cut it, and say which plainly. +keep it, fix the method, or cut it, and say which plainly. A cut, like any +attempt that fails or is shelved, gets a short write-up before it closes +(docs/shelved-attempt.md). Safety and security guards (careful, freeze, guard, unfreeze, cso) stay on their stated reason: they stop the rare bad run that an average score can't see. diff --git a/captain/SKILL.md b/captain/SKILL.md index 7b1fe49c1..29d9cc3e6 100644 --- a/captain/SKILL.md +++ b/captain/SKILL.md @@ -428,7 +428,8 @@ A lane that finishes writes `reports/.md` (`captain/templates/report.md`): with its `Unverified:` line (after `Failed or skipped:` and `Also changed:`), PR (number, head, version, checks), Needs (what the owner must do), Cost, Lesson, and the Approvals table. The controller reads reports before chat and turns each Lesson into a rule, a standing-rules line (`captain/templates/AGENTS.md`) -or a filed tool fix. Its log (`captain/templates/NOTES.md`) is append-only and timestamped; +or a filed tool fix. Work that closes as failed, shelved, cut, null or not now gets a +write-up first (`docs/shelved-attempt.md`), and the report, issue and PR close link it. Its log (`captain/templates/NOTES.md`) is append-only and timestamped; the digest comes from it. After a revert or S1 fix of a merged crew PR, the controller writes a postmortem (`captain/templates/postmortem.md`): why did the lane and every reviewer believe it was right? Its rule change ships as a gstack PR. diff --git a/captain/SKILL.md.tmpl b/captain/SKILL.md.tmpl index 03622be32..9b2c90adc 100644 --- a/captain/SKILL.md.tmpl +++ b/captain/SKILL.md.tmpl @@ -349,7 +349,8 @@ A lane that finishes writes `reports/.md` (`captain/templates/report.md`): with its `Unverified:` line (after `Failed or skipped:` and `Also changed:`), PR (number, head, version, checks), Needs (what the owner must do), Cost, Lesson, and the Approvals table. The controller reads reports before chat and turns each Lesson into a rule, a standing-rules line (`captain/templates/AGENTS.md`) -or a filed tool fix. Its log (`captain/templates/NOTES.md`) is append-only and timestamped; +or a filed tool fix. Work that closes as failed, shelved, cut, null or not now gets a +write-up first (`docs/shelved-attempt.md`), and the report, issue and PR close link it. Its log (`captain/templates/NOTES.md`) is append-only and timestamped; the digest comes from it. After a revert or S1 fix of a merged crew PR, the controller writes a postmortem (`captain/templates/postmortem.md`): why did the lane and every reviewer believe it was right? Its rule change ships as a gstack PR. diff --git a/captain/templates/report.md b/captain/templates/report.md index 39292b894..21d0cb6a6 100644 --- a/captain/templates/report.md +++ b/captain/templates/report.md @@ -4,7 +4,7 @@ Written by the lane when it finishes. The controller reads this before chat. ## Outcome - + Unverified: diff --git a/capy/skill/gstack/factory.md b/capy/skill/gstack/factory.md index c62eb4353..8e7c536bd 100644 --- a/capy/skill/gstack/factory.md +++ b/capy/skill/gstack/factory.md @@ -18,3 +18,4 @@ Your crew's CREW.md and recorded approvals decide who may merge, update a base, 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] 16. **Drain the queue.** Captains run `gstack-ship-queue count` every sweep and standing wake; a `DRAIN:` line means drain that turn: low-risk PRs land alone, risky ones in bundles of 3 to 6, idle owners get their next step. [crew/docs/captain.md: Drain the queue] +17. **Write it up before you shelve it.** Before an attempt closes as failed, shelved, cut, null or not now, a short write-up of what worked, what didn't and what would reopen it exists, and the close links it. [docs/shelved-attempt.md] diff --git a/changelog.d/write-it-up-before-you-shelve-it.md b/changelog.d/write-it-up-before-you-shelve-it.md new file mode 100644 index 000000000..b840fbd78 --- /dev/null +++ b/changelog.d/write-it-up-before-you-shelve-it.md @@ -0,0 +1 @@ +**gstack now writes up a failed or shelved attempt before closing it.** Any experiment, eval arm, prototype or PR that closes as failed, shelved, cut, null or not now first gets a short write-up (takeaways, what worked, what didn't with its numbers, why it stopped, what would reopen it, where the data is, cost), and the close links it. The template is docs/shelved-attempt.md; the factory page, ETHOS.md's "Why null?" verdict, /eval-plan's results step, /captain's report and close rules, and the lane report template all point at it, and `gstack-archive-check thread` prints a `NOTE:` for each PR that closed without merging so the archive step checks the link. diff --git a/crew/docs/captain.md b/crew/docs/captain.md index d00da8b17..deb0adba2 100644 --- a/crew/docs/captain.md +++ b/crew/docs/captain.md @@ -327,12 +327,24 @@ went stale and conflicting, and started to look like junk. outside PRs with no verdict after 5 days, and re-own each one. Nothing is closed for being old. - **Close only as landed, superseded or dropped.** A crew PR closes only as landed (link - the merge commit), superseded (link the replacement) or dropped (quote the decision). + the merge commit), superseded (link the replacement) or dropped (quote the decision, and + link the write-up when an attempt was shelved: [Write it up before you shelve it](#write-it-up-before-you-shelve-it)). Anything else is salvage: a live owner rebuilds it onto current main, in the area's next wave when the queue is long. Old and conflicting is how finished work looks when its owner went away, not a reason to close it. Age a PR by its `createdAt`: bots touch every PR, so "last updated" means nothing. +## Write it up before you shelve it + +When an attempt closes as failed, shelved, cut, null or not now (an experiment, an eval +arm, a prototype, a dropped PR), the lane writes a short write-up first, from +[docs/shelved-attempt.md](../../docs/shelved-attempt.md): takeaways, what worked, what +didn't with its numbers, why it's shelved, what would reopen it, where the data is, what +wasn't done, what went wrong on our side, and cost. Every close links it: the issue's +Canceled comment, the PR's close comment, the lane's report and a "Why null?" verdict. +Before archiving, `gstack-archive-check thread` prints a `NOTE:` for each PR that closed +without merging; when that close was a shelve, check the write-up is linked. + ## Keep issues tidy Issues show what the crew is really doing, so keep them true: diff --git a/docs/shelved-attempt.md b/docs/shelved-attempt.md new file mode 100644 index 000000000..85baa555d --- /dev/null +++ b/docs/shelved-attempt.md @@ -0,0 +1,66 @@ +# Write it up before you shelve it + +When we try something and it doesn't work out, we write down what happened before we +put it away. That covers any attempt closed as failed, shelved, cut, null or not now: an +experiment, an eval arm, a prototype, a PR we drop, a tool we stop using. The write-up +is short, it exists before the close, and the close (the issue, the PR, the report, the +eval verdict) links to it. + +Garry Tan, 2026-11-23: "when we try things and fail we must document it before we shelve. +Remember this. Make it a gstack directive that is our default thing we do." + +Why: a failed attempt is paid-for knowledge. Without a write-up the next person retries +the same thing, or never learns which part worked. A page of notes costs minutes; a +repeated experiment costs days. + +Where it goes: beside the project's other findings (an eval's results file, a research +findings folder, or `docs/` in the repo), with one line in that folder's index when it +has one. An eval's results file already is the write-up when it carries these sections. + +## Template + +Keep each section to a few lines. Lead with what helps the reader, put mechanics last, +and never round a number in our favor. + +```markdown +# : . Shelved. + +status: on , by + +## Takeaways + + +## What we tried, and why + + +## What worked + + +## What didn't + + +## Why it's shelved + + +## What would reopen it + + +## Where the data and scripts are + + +## Not done, and unverified + + +## What went wrong on our side + + +## Cost + +``` + +## The close + +The issue, PR or report that closes the attempt links the write-up in its close reason +(`Shelved: `). Before a Captain archives a crew thread, `gstack-archive-check thread` +prints a `NOTE:` line for each of its PRs that closed without merging, as a reminder to +link the write-up when that close was a shelve. diff --git a/eval-plan/SKILL.md b/eval-plan/SKILL.md index 922f0a876..34c645026 100644 --- a/eval-plan/SKILL.md +++ b/eval-plan/SKILL.md @@ -437,6 +437,11 @@ The results file opens with two or three plain takeaways ("We learned X. You sho X."): what works first, then what didn't, with its number. Cost appears only as part of a lesson, and nothing is opened without a stated reason (ETHOS.md, Explain the Number). +A run that ends null, as a cut candidate, at option C of the approval ask, or on +`budget_exhausted` is shelved work: before the question closes, its results file also says +why it's shelved, what would reopen it and where the data is (`docs/shelved-attempt.md` in +gstack), and the verdict links it. + ## Tier 3, after P7 (not in this skill yet) Each of these waits for the adoption number in the multi-agent wave plan (P7); one line each so the shape is known: diff --git a/eval-plan/SKILL.md.tmpl b/eval-plan/SKILL.md.tmpl index a3904c540..ffb5a0a4f 100644 --- a/eval-plan/SKILL.md.tmpl +++ b/eval-plan/SKILL.md.tmpl @@ -345,6 +345,11 @@ The results file opens with two or three plain takeaways ("We learned X. You sho X."): what works first, then what didn't, with its number. Cost appears only as part of a lesson, and nothing is opened without a stated reason (ETHOS.md, Explain the Number). +A run that ends null, as a cut candidate, at option C of the approval ask, or on +`budget_exhausted` is shelved work: before the question closes, its results file also says +why it's shelved, what would reopen it and where the data is (`docs/shelved-attempt.md` in +gstack), and the verdict links it. + ## Tier 3, after P7 (not in this skill yet) Each of these waits for the adoption number in the multi-agent wave plan (P7); one line each so the shape is known: diff --git a/lib/archive-check.ts b/lib/archive-check.ts index 5f2dca116..f20b1d1b1 100644 --- a/lib/archive-check.ts +++ b/lib/archive-check.ts @@ -10,6 +10,8 @@ * An open issue still assigned to the thread refuses too until it is * re-assigned to a live thread or closed. Every run prints a handoff stub * (PR, branch, head, CI at that head, open issues) for a successor brief. + * A PR that closed without merging prints a NOTE, never a refusal: if the + * close was a shelve, it links a write-up (docs/shelved-attempt.md). * * landedIssues serves the land step: the tracker codes in a merged PR's * trailing title group (R76), which the Captain then closes with @@ -137,9 +139,11 @@ export function checkThread(raw: unknown, o: CheckOptions): CheckResult { if (isFailure(list)) return fail(list); const live: LivePr[] = []; + const unmerged: string[] = []; for (const p of thread.prs) { const pr = readPr(o.ghFor(p.repo), p.repo, p.number); if (isFailure(pr)) return fail(pr); + if (pr.state === 'CLOSED') unmerged.push(p.repo + '#' + p.number); if (pr.state !== 'OPEN') continue; let ci: string; try { @@ -158,6 +162,7 @@ export function checkThread(raw: unknown, o: CheckOptions): CheckResult { ...live.map(p => 'ORPHAN: pr ' + p.repo + '#' + p.number + ' open head=' + p.head.slice(0, 12) + ' ci=' + p.ci + ' (R91: never archive a thread that holds an open PR; it stays until the PR merges or closes)'), ...work.map(i => 'ORPHAN: issue ' + i.code + ' ' + i.state + ' (re-assign it to a live thread or close it)'), ...openIssues.filter(i => NOT_WORK.has(i.state)).map(i => 'NOTE: issue ' + i.code + ' ' + i.state + ' (not live work; re-assign or close it when the work is dropped)'), + ...unmerged.map(ref => 'NOTE: pr ' + ref + ' closed without merging (if it was shelved, cut or null, its close links a write-up: docs/shelved-attempt.md)'), ]; const verdict = live.length || work.length ? 'refused' : 'clean'; lines.push('ARCHIVE_CHECK: ' + verdict + ' thread=' + o.thread + ' prs=' + live.length + ' issues=' + work.length); diff --git a/test/archive-check.test.ts b/test/archive-check.test.ts index efdc71daa..b3b03a26d 100644 --- a/test/archive-check.test.ts +++ b/test/archive-check.test.ts @@ -85,6 +85,16 @@ describe('archive check (reads and verdict)', () => { expect(ci.lines.some(l => l.includes('ci=unknown'))).toBe(true); }); + // Value: protects=a PR closed without merging reminds the Captain to link the shelved-attempt write-up and never refuses the archive; fails_when=the note is missing, fires on a merged PR, or changes the verdict + test('a PR closed without merging prints a write-up NOTE; a merged one prints none', () => { + const r = checkThread(reads({ thread: thread('GSTA-1', 'idle', [pr(12), pr(13)]) }), opts({ 'garrytan/gstack#12': { state: 'CLOSED' }, 'garrytan/gstack#13': { state: 'MERGED' } })); + expect(r.verdict).toBe('clean'); + expect(r.lines.filter(l => l.startsWith('NOTE: pr'))).toEqual(['NOTE: pr garrytan/gstack#12 closed without merging (if it was shelved, cut or null, its close links a write-up: docs/shelved-attempt.md)']); + expect(r.json.notes).toContain(r.lines[0]); + expect(r.lines.at(-1)).toBe('ARCHIVE_CHECK: clean thread=GSTA-1 prs=0 issues=0'); + expect(fs.existsSync(path.join(import.meta.dir, '..', 'docs', 'shelved-attempt.md'))).toBe(true); + }); + // Value: protects=only OPEN, CLOSED and MERGED are PR states, anything else fails closed; fails_when=an empty or unknown gh state is read as closed and the thread archives clean test('an unknown or empty live PR state is unreadable, never closed', () => { const t = thread('GSTA-1', 'idle', [pr(7)]); diff --git a/test/capy-skill-wrapper.test.ts b/test/capy-skill-wrapper.test.ts index b5a2a886e..4d8786ce9 100644 --- a/test/capy-skill-wrapper.test.ts +++ b/test/capy-skill-wrapper.test.ts @@ -696,7 +696,9 @@ describe('capy skill: factory.md, the auto-loaded "how we work" page', () => { // what its name says (the second batch of crew rules, G4 and G10, each reached by three crews on their own). // 5,300 for point 16's queue drain (R119, Garry's rule of 2026-11-22: every Captain that lands PRs runs a standing process // that stops finished PRs piling up; the procedure is crew/docs/captain.md's Drain the queue). - expect(Buffer.byteLength(text)).toBeLessThanOrEqual(5300); + // 5,550 for point 17's write-up before a shelve (Garry's "do it" of 2026-11-23: an attempt that fails or is shelved is + // documented first, as gstack's default; the template is docs/shelved-attempt.md). + expect(Buffer.byteLength(text)).toBeLessThanOrEqual(5550); expect(text).toMatch(/^# How we work/); expect(citationProblems(text)).toEqual([]); });