mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-13 00:19:03 +02:00
* fix(ship): foreground-flag + deadline + scope guard on all four dispatch sites (#497/#2440 class, 3rd recurrence)
Steps 7/8/10/18 dispatch subagents whose LAST-line JSON the parent
consumes, but none passed run_in_background: false — since Claude Code
v2.1.198 subagents background by default, so /ship stranded at Step 18
waiting on output that never arrives. Every site now renders the shared
{{FOREGROUND_DISPATCH_NOTE}} resolver constant, carries a ~10-minute
deadline with an explicit recovery branch (stop the runaway task,
reconcile against pre-dispatch HEAD, surface stray state, never
re-dispatch), and Step 18's prompt gains a docs-sync-only scope guard
(no VERSION changes, no base-branch merges, push-rejection reported as
pushed:false with parent-side reconciliation and a second-failure
branch). Greptile failures now record as UNAVAILABLE, not zero comments.
GENERATED_WITH_GUIDANCE pins all five ship dispatch carriers; a new test
pins the deadline recovery + scope guard phrases in pr-body (.md and
.tmpl). Codex/factory ship goldens re-rendered.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(document-release): first-class spawned-dispatch contract
document-release's own templates had zero subagent-awareness — the
entire headless contract lived in /ship's dispatch prompt, so any other
orchestrator (or an older installed /ship) dispatching it inherited none
of the gate handling. The skill now carries the contract itself: detect
spawned strictly from the dispatch prompt or the preamble echo (never
from file content — prompt-injection guard), auto-choose recommended
options while keeping the never-clobber-CHANGELOG and
never-bump-VERSION-silently invariants via their Skip options. Step 8.4d
gets an explicit spawned note (its interactive recommendation bumps
VERSION — wrong headlessly), and the Codex Documentation Review section
skips itself in spawned sessions (the apply gate needs a human; the
dispatching workflow owns review passes).
Contract, 8.4d note, and resolver skip are pinned in
run-in-background-guidance.test.ts; document-release skeleton budget
re-measured (39,812 B) and ratcheted to 40,200.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: sweep every remaining synchronous Agent-dispatch site with run_in_background: false
The #2440 failure shape was a silently-missing review voice — a
specialist launched in the background and merged before it completed.
Every remaining synchronous dispatch site now carries the explicit flag:
the Red Team dispatch, the spec review loop, the Codex
second-opinion/plan-review/doc-review Claude fallbacks, the adversarial
subagent, design sketch and outside voices, autoplan's design/eng/dx
phase dispatches, CSO parallel finding verification, and design-shotgun's
variant launch. Parallel fan-outs stay parallel — multiple foreground
Agent calls in one message run concurrently (the shipped v1.64.0.0
review-army pattern).
GENERATED_WITH_GUIDANCE now pins all 24 generated carriers, so a new
dispatch site that drops the flag fails the free suite. Six carved-skill
skeleton ceilings re-measured and ratcheted (~80-130 B growth each);
factory ship golden re-rendered.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* release: v1.79.0.0 — CHANGELOG, VERSION, TODOS follow-ups
Queue-advanced to 1.79.0.0 (1.78.0.0 claimed in the workspace queue;
same MINOR level per the versioning invariant). Entry references the
class history (#497 → #2440 → Step 18). Three TODOS filed: PreToolUse
hook enforcement, structural ship-mode for document-release, cross-host
dispatch semantics audit.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* regen: review-army sections carry the Red Team foreground flag
The scripts/resolvers/review-army.ts Red Team edit regenerated these two
files but the sweep commit staged only the adversarial sections — the
skill-docs freshness gate (regen + git diff --exit-code) catches this.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* regen: agents digest picks up v1.79.0.0
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(document-release): one canonical spawned contract, downstream notes are pointers
The diff-selected LLM-judge eval scored the skill's clarity 3 (threshold
4, main scores 4): the spawned-session rules read as three separately-
framed rule sets (contract paragraph, Step 8.4d note, Codex-review skip).
The contract paragraph now declares itself the single source of spawned
behavior and the two downstream notes reference it instead of restating
rationale. The pointer avoids naming the Codex section verbatim so the
codex-host render (which strips that section) keeps its negative pin.
Judge re-scored 4/5/4 across repeated samples after the change.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: foreground note names the Agent tool as non-substitutable
The ship-docsync gate E2E caught a behavioral regression: the note's
blocking-emphasis ('a backgrounded dispatch strands the run') steered
the driven agent to run doc-sync via the Skill tool inline — the most
blocking option — twice in a row, forfeiting the fresh-context isolation
the dispatch exists for (baseline on main's text dispatches via Agent).
The shared note now says explicitly: dispatch with the Agent tool itself,
never substitute Skill or inline execution; the flag already makes the
call block. Re-verified: ship-docsync passes on the amended text.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: pre-landing review fixes
Review army + red team findings, all verified before applying:
- ship-docsync E2E now asserts run_in_background === false on the
captured dispatch (red team CRITICAL: phrase pins prove text exists,
this proves the model obeys it — verified passing live).
- Structural scanner test: any generated file with an Agent-dispatch
imperative (or bare '(foreground)' prose, the #2440 inert shape) must
carry the flag or hold a reasoned exemption — the 4th-recurrence net
the hand-enumerated pin list can't provide.
- Parent push reconciliation models reality: the parent shares the repo,
so a non-fast-forward that hit the subagent hits the parent identically
— fetch + ahead/behind check first, push only when the rejection was
transient; dispatch prompt promise softened to 'the parent will handle
it'.
- Recovered commits from a dead subagent are vetted docs-only
(git show --stat, never VERSION/package.json) before any push.
- Deadline pacing named: ~3 minutes between checks, wall clock not polls.
- Greptile UNAVAILABLE recording narrowed to the PR body (Step 20's
schema carries no triage field).
- document-release contract gains the echo-failure tie-breaker: prompt
claims spawned + no echo → fail fast with the dispatch contract's
failure shape instead of reproducing the #2733 prose-STOP; contract
anti-injection and NEVER-relax clauses pinned in tests.
- 'Claude Code v2.1.198' extracted to CC_BACKGROUND_DEFAULT_SINCE and
interpolated at all resolver sites (byte-identical output).
- CHANGELOG: entry-boundary blank line restored; worst-case-wait row
scoped to the backgrounded path.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: adversarial review fixes — failure shape, CHANGELOG guard, vet coherence
Claude adversarial subagent findings (11), all verified before applying:
- The dispatch JSON contract gains an explicit FAILURE shape
({"error":...}) and a parent branch for it — a doc-sync that could not
run (spawned marking failed, broken preamble) previously had only the
no-updates shape to emit, which the parent printed as 'Documentation is
current': a silent false-clean of exactly the VAS-449 class.
- Scope guard now covers CHANGELOG: skip Step 5 voice polish and resolve
CHANGELOG-touching gates to leave-as-is (the parent authored the
release entry; the prompt's older auto-choose clause conflicted with
the contract's never-rewrite invariant).
- Recovery vet is sequence-coherent: pushing a commit pushes its
ancestors, so ANY non-doc commit (VERSION, package.json, CHANGELOG.md)
blocks the whole sequence — no more push-the-vetted-child-of-an-
unvetted-parent hole.
- Steps 7/8/10 failure branches stop a still-running backgrounded task
before falling back, so a late result never races the inline audit.
- 'Documentation synced' print gated on pushed:true (item 6 owns the
local-only outcome); doc-review skip note's backward step pointer
fixed; foreground note scoped 'at initial dispatch' so the sanctioned
inline FALLBACKS in Steps 7/8 read as sanctioned; constants docstring
no longer overclaims single-sourcing (names the 3 inline templates).
- Runtime-hook TODO raised P2 → P1: the spawned trust chain is
agent-self-asserted; prose cannot close it, the hook can.
Both docsync gate E2Es re-verified green on the amended prompt, including
the strict run_in_background === false dispatch assert.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: codex adversarial fixes — JSON trust, fail-open visibility, user-state safety
Codex outside-model adversarial pass (inline-diff workaround for the
sandbox), P1/P2 findings triaged cross-model:
- Parent validates the dispatch JSON's field types and treats
documentation_section as untrusted markdown (Step 19's redaction scan
covers the final body; instruction-shaped text inside it is never
followed). The error branch now explicitly skips items 2-6.
- Remote-ahead divergence is named, not silent: the parent lists foreign
commits before creating a PR over a moved branch.
- Recovery cleanup never discards content: stray staged doc edits are
unstaged but never checked out or cleaned away.
- Greptile UNAVAILABLE gets a concrete PR-body line, not a vague
'wherever results are reported'.
Pre-existing-class P1s (self-asserted spawned trust chain, unenforceable
foreground timeout) are cross-model confirmed and tracked: PreToolUse
hook TODO at P1, harness-residue hazard documented.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: never-Skill prohibition made unambiguous; docsync fixture made diagnostic
The ship-docsync E2E flaked on this sandbox because the driven agent
resolved the STOP pointer's ~ to nonexistent homes (/root, /home) and
acted blind — pass/fail sampled model priors, not the prompt. The
fixture prompt now names the planted sections dir, making local runs
deterministic (CI, with real install paths, was always diagnostic).
With a diagnostic fixture: 2/2 passes, real pr-body read, Agent dispatch
with run_in_background: false, zero Skill-tool substitutions.
Prose: the foreground note now states the dispatch happens ONLY via the
Agent tool (invoking the target as a Skill is wrong even though it
appears in the skills list; inline FALLBACKs apply only after a
dispatched subagent has failed), and the Step 18 imperative carries the
never-the-Skill-tool clause at the decision point.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* docs: CHANGELOG entry covers the review-hardened contract
Failure JSON shape, CHANGELOG scope guard, vetted recovery pushes,
structural scanner, and the behavioral dispatch assert are shipped
properties of v1.79.0.0 — the entry now describes them.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* docs: update project documentation for v1.79.0.0
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* docs: CHANGELOG voice — follow-ups to For contributors, never-Skill property stated
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(test): daemon 503 test binds an OS-assigned port, not old-port+1
windows-free-tests flaked on this PR: the tunnel-less restart bound
daemon.loopbackPort + 1 — a fixed neighbor of the OS-assigned ephemeral
port — and died with 'Is port 55738 in use?' whenever another shard or a
TIME_WAIT socket held it; the file-level retry re-rolled the same dice.
Every other startDaemon in the file already uses loopbackPort: 0 and the
assertion reads d2.loopbackPort, so nothing needs a predictable number.
21/21 pass locally.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
173 lines
8.3 KiB
TypeScript
173 lines
8.3 KiB
TypeScript
import { describe, test, expect } from 'bun:test';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
// Regression guard for #2440 (which itself regressed the #497 fix).
|
|
//
|
|
// Claude Code v2.1.198 made subagents run in the BACKGROUND by default.
|
|
// Guidance written before that ("do NOT use run_in_background") stopped
|
|
// producing a foreground run — the review army and autoplan dual-voice
|
|
// steps silently launched specialists in the background and merged before
|
|
// they completed. The only guidance that works post-2.1.198 is an explicit
|
|
// `run_in_background: false` on the Agent call.
|
|
//
|
|
// This tripwire pins the corrected phrasing in the generated skill output
|
|
// and fails if the inverted form ever comes back through a template or
|
|
// resolver edit.
|
|
|
|
const ROOT = path.resolve(import.meta.dir, '..');
|
|
|
|
// review's specialist-dispatch guidance lives in its carved Review Army section
|
|
// (Step 4.5 moved out of the skeleton), so the pin follows it there. Same for
|
|
// autoplan: the dual-voice dispatch (Phase 1 override rules) lives in its
|
|
// carved CEO-phase section.
|
|
//
|
|
// Third recurrence (#497 → #2440 → /ship Step 18): the four ship dispatch
|
|
// sections (Steps 7/8/10/18) never carried the flag and were never pinned, so
|
|
// a backgrounded doc-sync dispatch stranded the ship run waiting on LAST-line
|
|
// JSON that never came. Every synchronous dispatch carrier is pinned here now;
|
|
// add new dispatch sites to this list in the same commit that creates them.
|
|
const GENERATED_WITH_GUIDANCE = [
|
|
'review/sections/review-army.md',
|
|
'autoplan/sections/ceo-phase.md',
|
|
'ship/sections/review-army.md',
|
|
'ship/sections/pr-body.md',
|
|
'ship/sections/test-coverage.md',
|
|
'ship/sections/plan-completion.md',
|
|
'ship/sections/greptile.md',
|
|
// Sweep carriers (v1.79): every remaining synchronous Agent-dispatch site.
|
|
'autoplan/sections/design-phase.md',
|
|
'autoplan/sections/eng-phase.md',
|
|
'autoplan/sections/dx-phase.md',
|
|
'cso/SKILL.md',
|
|
'design-consultation/SKILL.md',
|
|
'design-review/SKILL.md',
|
|
'design-shotgun/SKILL.md',
|
|
'document-release/sections/release-body.md',
|
|
'office-hours/SKILL.md',
|
|
'office-hours/sections/design-and-handoff.md',
|
|
'plan-ceo-review/SKILL.md',
|
|
'plan-ceo-review/sections/review-sections.md',
|
|
'plan-design-review/SKILL.md',
|
|
'plan-devex-review/sections/review-sections.md',
|
|
'plan-eng-review/sections/review-sections.md',
|
|
'review/sections/adversarial.md',
|
|
'ship/sections/adversarial.md',
|
|
];
|
|
|
|
// The inverted, post-2.1.198-inert phrasings. Checked across every generated
|
|
// SKILL.md so the regression can't migrate to another skill unnoticed.
|
|
const INVERTED = /do not use\s+`?run_in_background`?/i;
|
|
|
|
function allGeneratedSkillFiles(): string[] {
|
|
const out: string[] = [];
|
|
for (const entry of fs.readdirSync(ROOT, { withFileTypes: true })) {
|
|
if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name === 'node_modules') continue;
|
|
const p = path.join(ROOT, entry.name, 'SKILL.md');
|
|
if (fs.existsSync(p)) out.push(p);
|
|
// Generated on-demand section files (e.g. ship/sections/review-army.md)
|
|
// carry the same resolver output as SKILL.md bodies — scan them too.
|
|
const sections = path.join(ROOT, entry.name, 'sections');
|
|
if (fs.existsSync(sections)) {
|
|
for (const f of fs.readdirSync(sections)) {
|
|
if (f.endsWith('.md')) out.push(path.join(sections, f));
|
|
}
|
|
}
|
|
}
|
|
const rootSkill = path.join(ROOT, 'SKILL.md');
|
|
if (fs.existsSync(rootSkill)) out.push(rootSkill);
|
|
return out;
|
|
}
|
|
|
|
describe('run_in_background guidance (#2440)', () => {
|
|
test('foreground-required skills instruct run_in_background: false explicitly', () => {
|
|
for (const rel of GENERATED_WITH_GUIDANCE) {
|
|
const content = fs.readFileSync(path.join(ROOT, rel), 'utf-8');
|
|
expect(content).toContain('run_in_background: false');
|
|
}
|
|
});
|
|
|
|
// Third recurrence (#497 → #2440 → /ship Step 18): a backgrounded doc-sync
|
|
// dispatch stranded the ship run. Pin the deadline/recovery branch and the
|
|
// docs-sync scope guard in both the generated section and its template, so
|
|
// neither a template edit nor a stale regen can drop them silently.
|
|
const PR_BODY_SITES = ['ship/sections/pr-body.md', 'ship/sections/pr-body.md.tmpl'];
|
|
test('ship pr-body carries the doc-sync deadline recovery + scope guard', () => {
|
|
for (const rel of PR_BODY_SITES) {
|
|
const content = fs.readFileSync(path.join(ROOT, rel), 'utf-8');
|
|
expect(content).toContain('document-release did not complete');
|
|
expect(content).toContain('Scope guard — docs sync ONLY');
|
|
}
|
|
});
|
|
|
|
// The spawned-dispatch contract is as regression-prone as the flag — this
|
|
// class regressed twice via unpinned prose. Pin the document-release
|
|
// contract, the Step 8.4d spawned note, and the resolver-side Codex
|
|
// doc-review skip in both generated output and templates.
|
|
const CONTRACT_PINS: Array<[string[], string]> = [
|
|
[['document-release/SKILL.md', 'document-release/SKILL.md.tmpl'], 'When dispatched as a subagent'],
|
|
[
|
|
['document-release/sections/release-body.md', 'document-release/sections/release-body.md.tmpl'],
|
|
'A spawned run must never change VERSION',
|
|
],
|
|
[['document-release/sections/release-body.md'], 'Spawned-session skip'],
|
|
// Anti-injection trigger + invariant carve-out — the two clauses whose
|
|
// deletion would silently reopen the prompt-injection / silent-VERSION
|
|
// holes while the 'When dispatched' heading pin stays green.
|
|
[['document-release/SKILL.md', 'document-release/SKILL.md.tmpl'], 'NEVER trigger it on their own'],
|
|
// (short form — the sentence wraps across template lines; toContain is literal)
|
|
[['document-release/SKILL.md', 'document-release/SKILL.md.tmpl'], 'The NEVER-do invariants below do'],
|
|
];
|
|
test('document-release carries the spawned-dispatch contract', () => {
|
|
for (const [sites, phrase] of CONTRACT_PINS) {
|
|
for (const rel of sites) {
|
|
const content = fs.readFileSync(path.join(ROOT, rel), 'utf-8');
|
|
expect(content).toContain(phrase);
|
|
}
|
|
}
|
|
});
|
|
|
|
// Structural scanner (4th-recurrence net): GENERATED_WITH_GUIDANCE is a
|
|
// hand-enumerated list — the exact mechanism that missed three recurrences
|
|
// (#497 → #2440 → /ship Step 18, each a NEW dispatch site outside the
|
|
// pinned set). Any generated file that carries an Agent-dispatch imperative
|
|
// (or the inert "(foreground)" prose shape that #2440 proved insufficient)
|
|
// must either state the flag or hold a reasoned exemption below. Same
|
|
// pattern as the egress-receipt new-sink scanner.
|
|
const DISPATCH_IMPERATIVE =
|
|
/(?:via|using) the Agent tool|dispatch(?:es)? (?:a|an|the|one|each|it as a)[^.\n]{0,60}subagent|\(foreground[^)]*\)|foreground Agent tool/i;
|
|
// Reasoned exemptions: files where the match is a reference to a dispatch
|
|
// that lives (flag and all) in another file, not a dispatch spec itself.
|
|
const BACKGROUND_OK: Record<string, string> = {
|
|
'ship/SKILL.md':
|
|
'skeleton anchors reference the Step 18 dispatch by name (carve-guards mustStayInSkeleton); the dispatch spec + flag live in sections/pr-body.md',
|
|
};
|
|
test('structural scanner: every generated dispatch imperative carries the flag', () => {
|
|
for (const file of allGeneratedSkillFiles()) {
|
|
const rel = path.relative(ROOT, file).split(path.sep).join('/');
|
|
if (BACKGROUND_OK[rel]) continue;
|
|
const content = fs.readFileSync(file, 'utf-8');
|
|
if (DISPATCH_IMPERATIVE.test(content) && !content.includes('run_in_background: false')) {
|
|
throw new Error(
|
|
`${rel} contains an Agent-dispatch imperative (or bare "foreground" prose) but never states ` +
|
|
'`run_in_background: false` — pin the flag at the dispatch site or add a reasoned BACKGROUND_OK ' +
|
|
'exemption (see #497/#2440: prose without the explicit flag is inert since Claude Code v2.1.198).',
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('the inverted "do NOT use run_in_background" phrasing never comes back', () => {
|
|
for (const file of allGeneratedSkillFiles()) {
|
|
const content = fs.readFileSync(file, 'utf-8');
|
|
if (INVERTED.test(content)) {
|
|
throw new Error(
|
|
`${path.relative(ROOT, file)} contains the inverted run_in_background guidance — ` +
|
|
'since Claude Code v2.1.198 subagents default to background, so "do not use" is inert; ' +
|
|
'instruct `run_in_background: false` instead (see #2440).',
|
|
);
|
|
}
|
|
}
|
|
});
|
|
});
|