Skip to content

Commit 92c3cb6

Browse files
authored
Merge pull request #2044 from bradygaster/bradygaster-fix-bootstrap-triage-continuity
fix(gh-aw): bridge automatic bootstrap into triage
2 parents aec73c7 + 2e37a82 commit 92c3cb6

7 files changed

Lines changed: 430 additions & 24 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@bradygaster/squad-cli": patch
3+
"@bradygaster/squad-sdk": patch
4+
---
5+
6+
Make automatic bootstrap proposals immediately available to `/squad triage`
7+
after the linked Cast PR merges, and recognize the deterministic bootstrap Cast
8+
branch during team-required command gating.

‎docs/src/content/docs/guide/gh-aw.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,12 @@ validated payload:
117117
- a draft Cast PR on `squad/bootstrap-cast`; and
118118
- `[Research Proposals] Agent-discovered repo opportunities`.
119119

120-
Review and merge the Cast PR, then use the issue's focused research commands,
121-
triage the findings, plan the accepted work, and run `/squad activate`. The
122-
bootstrap journey ends when assignable implementation issues exist.
120+
Review and merge the Cast PR, then rerun `/squad triage` on the linked issue to
121+
classify its existing bootstrap proposals. If a proposal needs deeper or newer
122+
evidence, use one of the issue's focused `/squad research ...` commands first;
123+
that replaces the bootstrap research seed. Review the resulting plan and run
124+
`/squad activate`. The bootstrap journey ends when assignable implementation
125+
issues exist.
123126

124127
---
125128

‎test/gh-aw-bootstrap-workflow.test.ts‎

Lines changed: 117 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ import {
1717
BOOTSTRAP_ISSUE_MARKER,
1818
BOOTSTRAP_ISSUE_TITLE,
1919
BOOTSTRAP_PR_TITLE,
20+
BOOTSTRAP_RESEARCH_TITLE,
2021
PAYLOAD_CHUNK_BYTES,
2122
PAYLOAD_CHUNK_STRING_MAX_BYTES,
2223
PAYLOAD_MAX_BYTES,
2324
PAYLOAD_MAX_CHUNKS,
2425
classifyBootstrapState,
2526
createBootstrapPayloadEnvelope,
27+
createBootstrapResearchComment,
28+
findBootstrapResearchArtifacts,
29+
isBootstrapResearchSeed,
2630
reconstructBootstrapPayload,
2731
} from '../workflows/shared/squad-bootstrap-validator.mjs';
2832

@@ -198,6 +202,10 @@ Review the corresponding [draft Cast PR](${link}) before accepting the roster.
198202
199203
## How to launch work
200204
205+
1. Review and merge the linked draft Cast PR.
206+
2. Rerun \`/squad triage\` to classify these existing proposals, or use focused \`/squad research ...\` first when deeper research is desired.
207+
3. Run \`/squad plan\`, review the plan, then run \`/squad activate\` to create assignable implementation issues.
208+
201209
\`\`\`text
202210
/squad research Evaluate proposals P1 and P2 together, focusing on shared dependencies.
203211
/squad research Evaluate proposals P1 through P3 as one program.
@@ -212,7 +220,7 @@ Use \`/squad implement\` only on generated implementation tasks, never on a prop
212220
## Actionable backlog
213221
214222
- [ ] Review and merge the draft Cast PR.
215-
- [ ] Research and triage selected proposals.
223+
- [ ] Triage the existing proposals, or run focused research first when deeper evidence is desired.
216224
- [ ] Review the plan and activate assignable implementation issues.
217225
`;
218226
}
@@ -370,7 +378,24 @@ describe('automatic Squad bootstrap workflow', () => {
370378
expect(classifyBootstrapState({ pullRequests: [], issues: [], defaultBranch: 'main' }).action).toBe('create_both');
371379
expect(classifyBootstrapState({ pullRequests: [pull()], issues: [], defaultBranch: 'main' }).action).toBe('create_issue');
372380
expect(classifyBootstrapState({ pullRequests: [], issues: [issue()], defaultBranch: 'main' }).action).toBe('create_pr');
373-
expect(classifyBootstrapState({ pullRequests: [pull()], issues: [issue()], defaultBranch: 'main' }).action).toBe('noop');
381+
expect(classifyBootstrapState({
382+
pullRequests: [pull()],
383+
issues: [issue()],
384+
comments: [],
385+
defaultBranch: 'main',
386+
}).action).toBe('create_research');
387+
const research = {
388+
id: 9,
389+
created_at: '2026-09-14T00:00:00Z',
390+
user: { login: 'github-actions[bot]' },
391+
body: createBootstrapResearchComment(issueBody(), 6),
392+
};
393+
expect(classifyBootstrapState({
394+
pullRequests: [pull()],
395+
issues: [issue()],
396+
comments: [research],
397+
defaultBranch: 'main',
398+
}).action).toBe('noop');
374399
expect(classifyBootstrapState({ pullRequests: [pull('closed')], issues: [], defaultBranch: 'main' }).action).toBe('opt_out');
375400
expect(classifyBootstrapState({ pullRequests: [pull('closed', true)], issues: [], defaultBranch: 'main' }).action).toBe('create_issue');
376401
});
@@ -393,6 +418,89 @@ describe('automatic Squad bootstrap workflow', () => {
393418
defaultBranch: 'main',
394419
}),
395420
).toThrow(/expected exact title and durable marker/);
421+
expect(() =>
422+
classifyBootstrapState({
423+
pullRequests: [],
424+
issues: [{
425+
number: 6,
426+
title: BOOTSTRAP_ISSUE_TITLE,
427+
body: `${BOOTSTRAP_ISSUE_MARKER}\n${BOOTSTRAP_ISSUE_MARKER}`,
428+
}],
429+
defaultBranch: 'main',
430+
}),
431+
).toThrow(/expected exact title and durable marker/);
432+
});
433+
434+
it('materializes one canonical research seed that normal triage can consume', () => {
435+
const comment = createBootstrapResearchComment(issueBody(), 6);
436+
expect(comment).toContain(BOOTSTRAP_RESEARCH_TITLE);
437+
expect(comment).toContain('| R1 | P1 is a validated bootstrap proposal');
438+
expect(comment).toContain('focused `/squad research ...`');
439+
expect(comment).not.toContain('### P1 — Strengthen runtime contracts');
440+
expect(comment).toContain(
441+
'{"squad_artifact":"research","schema_version":"1","origin_issue":6,"phases":[]}',
442+
);
443+
444+
const artifacts = findBootstrapResearchArtifacts([
445+
{
446+
id: 9,
447+
created_at: '2026-09-14T00:00:00Z',
448+
user: { login: 'github-actions[bot]' },
449+
body: comment,
450+
},
451+
], 6);
452+
expect(artifacts).toHaveLength(1);
453+
expect(isBootstrapResearchSeed(artifacts[0])).toBe(true);
454+
expect(isBootstrapResearchSeed({
455+
body: comment.replace(BOOTSTRAP_RESEARCH_TITLE, '## 🔬 Squad Research — Focused follow-up'),
456+
})).toBe(false);
457+
});
458+
459+
it('fails closed on malformed research envelopes and repairs duplicate artifacts', () => {
460+
const valid = createBootstrapResearchComment(issueBody(), 6);
461+
expect(() => findBootstrapResearchArtifacts([
462+
{
463+
id: 10,
464+
created_at: '2026-09-14T00:00:00Z',
465+
user: { login: 'github-actions[bot]' },
466+
body: valid.replace('"origin_issue":6', '"origin_issue":7'),
467+
},
468+
], 6)).toThrow(/canonical research envelope/);
469+
470+
const duplicates = findBootstrapResearchArtifacts([
471+
{
472+
id: 10,
473+
created_at: '2026-09-14T00:00:00Z',
474+
user: { login: 'github-actions[bot]' },
475+
body: valid,
476+
},
477+
{
478+
id: 11,
479+
created_at: '2026-09-14T01:00:00Z',
480+
user: { login: 'github-actions[bot]' },
481+
body: valid,
482+
},
483+
], 6);
484+
expect(duplicates.map(({ id }) => id)).toEqual([10, 11]);
485+
expect(classifyBootstrapState({
486+
pullRequests: [{
487+
number: 3,
488+
state: 'closed',
489+
merged: true,
490+
title: BOOTSTRAP_PR_TITLE,
491+
head: { ref: BOOTSTRAP_BRANCH },
492+
base: { ref: 'main' },
493+
html_url: 'https://github.com/octo/example/pull/3',
494+
}],
495+
issues: [{
496+
number: 6,
497+
state: 'open',
498+
title: BOOTSTRAP_ISSUE_TITLE,
499+
body: issueBody('https://github.com/octo/example/pull/3'),
500+
}],
501+
comments: duplicates,
502+
defaultBranch: 'main',
503+
}).action).toBe('create_research');
396504
});
397505

398506
it('validates the shared Cast and issue payload with exact success output', () => {
@@ -543,7 +651,7 @@ describe('automatic Squad bootstrap workflow', () => {
543651
branch: 'attacker/override',
544652
issue_body: issueBody()
545653
.replace('| **Runtime** | Runtime Engineer |', '| **Runtime** | Security Engineer |')
546-
.replace('/squad activate', '/squad implement P1'),
654+
.replaceAll('/squad activate', '/squad implement P1'),
547655
};
548656
writeFileSync(fixture.payloadPath, `${JSON.stringify(mutated)}\n`);
549657
const result = validateFixture(fixture);
@@ -601,6 +709,12 @@ describe('automatic Squad bootstrap workflow', () => {
601709
expect(WORKFLOW).toContain("state: 'all'");
602710
expect(WORKFLOW).toContain('github.paginate(github.rest.pulls.list');
603711
expect(WORKFLOW).toContain('github.paginate(github.rest.issues.listForRepo');
712+
expect(WORKFLOW).toContain('github.paginate(github.rest.issues.listComments');
713+
expect(WORKFLOW).toContain('createBootstrapResearchComment(');
714+
expect(WORKFLOW).toContain('findBootstrapResearchArtifacts(');
715+
expect(WORKFLOW).toContain('isBootstrapResearchSeed(currentResearch)');
716+
expect(WORKFLOW).toContain('Preserving focused research artifact comment');
717+
expect(WORKFLOW).toContain('github.rest.issues.deleteComment');
604718
expect(WORKFLOW).toContain("draft: true");
605719
expect(WORKFLOW).toContain("ref: `refs/heads/${stateModule.BOOTSTRAP_BRANCH}`");
606720
expect(WORKFLOW).not.toContain('auto-merge:');

‎test/gh-aw-quality.test.ts‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,12 +2598,14 @@ describe('gh-aw: auto-cast pivot and resumable work (#1689)', () => {
25982598
// Must use headRefName field and startsWith to match squad/cast-{repo} patterns
25992599
expect(content).toMatch(/gh pr list/i);
26002600
expect(content).toMatch(/headRefName/);
2601+
expect(content).toContain('.headRefName == "squad/bootstrap-cast"');
26012602
expect(content).toMatch(/startswith\("squad\/cast-"\)/);
26022603
expect(content).toMatch(/open Cast PR.*found|cast PR.*found|Cast PR is found/i);
26032604
// Exact --head matching truncates the branch name and never finds squad/cast-{repo}; must be forbidden
26042605
expect(content).not.toMatch(/--head "squad\/cast-"/);
26052606
// squad/cast-member-* must be excluded so Cast Member PRs cannot satisfy Cast dedup
26062607
expect(content).toMatch(/startswith\("squad\/cast-member-"\).*\| not|\| not.*startswith\("squad\/cast-member-"\)/);
2608+
expect(content).toMatch(/More than one candidate is ambiguous: fail closed/i);
26072609
});
26082610

26092611
it('Cast PR dedup stops without opening a duplicate PR', () => {
@@ -2875,13 +2877,23 @@ describe('gh-aw: Cast PR dedup jq filter behavioral coverage (#1689 revision)',
28752877
expect(result).toContain('"number": 42');
28762878
});
28772879

2878-
it('Cast Member branch (squad/cast-member-*) is excluded and returns null', () => {
2880+
it('deterministic bootstrap Cast branch satisfies the filter', () => {
2881+
const filter = extractJqFilter();
2882+
const prs = JSON.stringify([
2883+
{ headRefName: 'squad/bootstrap-cast', number: 2, url: 'https://github.com/org/repo/pull/2' },
2884+
]);
2885+
const result = runJqFilter(prs, filter);
2886+
expect(result).toContain('"headRefName": "squad/bootstrap-cast"');
2887+
expect(result).toContain('"number": 2');
2888+
});
2889+
2890+
it('Cast Member branch (squad/cast-member-*) is excluded and returns an empty array', () => {
28792891
const filter = extractJqFilter();
28802892
const prs = JSON.stringify([
28812893
{ headRefName: 'squad/cast-member-dev', number: 43, url: 'https://github.com/org/repo/pull/43' },
28822894
]);
28832895
const result = runJqFilter(prs, filter);
2884-
expect(result).toBe('null');
2896+
expect(result).toBe('[]');
28852897
});
28862898

28872899
it('a closed Cast PR is absent from the open-PR scan, allowing additive retry', () => {
@@ -2895,7 +2907,7 @@ describe('gh-aw: Cast PR dedup jq filter behavioral coverage (#1689 revision)',
28952907
},
28962908
];
28972909
const openPrs = allPrs.filter(pr => pr.state === 'OPEN');
2898-
expect(runJqFilter(JSON.stringify(openPrs), filter)).toBe('null');
2910+
expect(runJqFilter(JSON.stringify(openPrs), filter)).toBe('[]');
28992911
expect(squadContent).toMatch(/If no open Cast PR found.*Execute Cast Mode/s);
29002912
});
29012913

@@ -2909,6 +2921,18 @@ describe('gh-aw: Cast PR dedup jq filter behavioral coverage (#1689 revision)',
29092921
expect(result).toContain('"headRefName": "squad/cast-myrepo"');
29102922
expect(result).not.toContain('squad/cast-member-dev');
29112923
});
2924+
2925+
it('returns every exact Cast candidate so ambiguity cannot be hidden by first', () => {
2926+
const filter = extractJqFilter();
2927+
const prs = JSON.stringify([
2928+
{ headRefName: 'squad/bootstrap-cast', number: 2, url: 'https://github.com/org/repo/pull/2' },
2929+
{ headRefName: 'squad/cast-myrepo', number: 42, url: 'https://github.com/org/repo/pull/42' },
2930+
{ headRefName: 'squad/cast-member-dev', number: 43, url: 'https://github.com/org/repo/pull/43' },
2931+
]);
2932+
const result = JSON.parse(runJqFilter(prs, filter));
2933+
expect(result.map((pullRequest: { number: number }) => pullRequest.number)).toEqual([2, 42]);
2934+
expect(squadContent).toContain('Never choose the first result heuristically.');
2935+
});
29122936
});
29132937

29142938
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)