Skip to content

Commit aeca8d4

Browse files
authored
Merge branch 'dev' into bradygaster-orchestration-scope-control
2 parents fa9dd45 + 26c51f0 commit aeca8d4

10 files changed

Lines changed: 634 additions & 124 deletions

File tree

‎.github/workflows/squad-ci.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,10 @@ jobs:
791791
test "$(find .github/workflows -maxdepth 1 -name 'squad*.md' | wc -l | tr -d ' ')" = 8
792792
test "$(find .github/workflows/shared -type f ! -name 'squad-bootstrap-trigger-probe.json' | wc -l | tr -d ' ')" = 17
793793
test "$(find .github/skills/gh-aw-enlistment -type f | wc -l | tr -d ' ')" = 1
794+
node --input-type=module -e '
795+
import { compileWithPinnedActions } from "./.github/workflows/shared/squad-install-verifier.mjs";
796+
compileWithPinnedActions(process.cwd());
797+
'
794798
gh aw compile --strict --approve --no-check-update
795799
for workflow in squad squad-implement-worker squad-review squad-deps-worker squad-retro squad-improvement-worker squad-bootstrap squad-command-router; do
796800
gh aw compile "$workflow" --strict --no-check-update

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ validated payload:
150150
- a draft Cast PR on `squad/bootstrap-cast`; and
151151
- `[Research Proposals] Agent-discovered repo opportunities`.
152152

153+
Bootstrap submits the shared payload through one authenticated command. Runtime
154+
code assembles and validates its bounded chunks, then passes JSON directly to
155+
the existing typed safe-output tool; the agent never copies chunks into tool
156+
arguments. Missing, duplicate, reordered, malformed, oversized, or mismatched
157+
payloads fail closed before submission, and the write job independently
158+
revalidates the payload. A submission error is terminal, not permission to retry.
159+
153160
Review and merge the Cast PR, then rerun `/squad triage` on the linked issue to
154161
classify its existing bootstrap proposals. If a proposal needs deeper or newer
155162
evidence, use one of the issue's focused `/squad research ...` commands first;
@@ -1802,6 +1809,31 @@ then reapply them before the final compile. Never customize generated
18021809
ownership record, missing source/lock pair, or absent runtime resource and
18031810
prints the exact safe recovery commands.
18041811
1812+
The schema-v2 integrity manifest records two complete compiled lock digests per
1813+
workflow: `lock_sha256` for a per-workflow source annotation and
1814+
`package_lock_sha256` for a package-root annotation. gh-aw v0.89.21 emits
1815+
`bradygaster/squad/workflows@SHA` for direct package includes, but can emit
1816+
`bradygaster/squad/workflows/package/<workflow>.md@SHA` when installing dispatched
1817+
dependencies. Fresh and forced installs can therefore contain different mixtures.
1818+
The verifier selects one digest from the exact, ownership- and source-validated
1819+
annotation; it never tries both until one passes. Compiled source comments,
1820+
URLs, action pins, permissions and runtime bytes remain integrity-checked.
1821+
No additional fields are removed during lock normalization.
1822+
1823+
Manifest generation and installation test fixtures seed isolated compiler action
1824+
locks with the immutable `setup` and `setup-cli` pins for gh-aw v0.89.21. Both
1825+
source variants use the real strict compiler and validate its version and emitted
1826+
action pins. This avoids a second network resolution returning a mutable version
1827+
tag when credentials or the API are unavailable. Missing or altered pins fail
1828+
generation; mutable-tag compiled locks still fail installation integrity.
1829+
1830+
This fixes the post-merge installation failure in #2103: the old generator and
1831+
local-consumer tests covered only per-workflow annotations, while the native
1832+
installer also emitted package-root annotations. The difference was installation
1833+
provenance, not the squash commit identity or a generated timestamp. Old manifests
1834+
or manifests missing either digest are rejected; upgrade the entire package,
1835+
including the verifier and manifest, using the block above.
1836+
18051837
Use the complete upgrade block even when a failure appears limited to the
18061838
first-run bootstrap workflow. Updating only `squad-bootstrap.md` is unsupported
18071839
because it can leave its validator or the rest of the workflow set at a

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

Lines changed: 130 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { afterAll, describe, expect, it } from 'vitest';
22
import {
33
cpSync,
4+
chmodSync,
5+
existsSync,
46
mkdirSync,
57
mkdtempSync,
68
readFileSync,
@@ -12,6 +14,7 @@ import { createHash } from 'node:crypto';
1214
import { dirname, join, resolve } from 'node:path';
1315
import { tmpdir } from 'node:os';
1416
import { fileURLToPath } from 'node:url';
17+
import { parse } from 'yaml';
1518
import {
1619
BOOTSTRAP_BRANCH,
1720
BOOTSTRAP_ISSUE_MARKER,
@@ -375,6 +378,48 @@ function validateFixture(
375378
);
376379
}
377380

381+
function submissionFixture() {
382+
const fixture = createFixture();
383+
const targetBytes = 40_843;
384+
const remaining = targetBytes - Buffer.byteLength(JSON.stringify(fixture.payload));
385+
const rationale = ' Repository evidence informs this proposed specialist; human review is required before activation.';
386+
fixture.payload.pr_body += rationale.repeat(Math.ceil(remaining / rationale.length)).slice(0, remaining);
387+
const text = JSON.stringify(fixture.payload);
388+
expect(Buffer.byteLength(text)).toBe(targetBytes);
389+
writeFileSync(fixture.payloadPath, text);
390+
const envelope = createBootstrapPayloadEnvelope(text) as Record<string, string>;
391+
expect(envelope.payload_chunk_count).toBe('7');
392+
const envelopePath = join(fixture.root, 'envelope.json');
393+
writeFileSync(envelopePath, JSON.stringify(envelope));
394+
const capture = join(fixture.root, 'calls.jsonl');
395+
const proxy = join(fixture.root, 'bin/safeoutputs');
396+
write(fixture.root, 'bin/safeoutputs', `#!${process.execPath}
397+
const fs = require('node:fs');
398+
const args = process.argv.slice(2);
399+
if (JSON.stringify(args) !== JSON.stringify(['materialize_bootstrap', '.'])) process.exit(2);
400+
const input = JSON.parse(fs.readFileSync(0, 'utf8'));
401+
if (Object.values(input).some(value => typeof value !== 'string' || Buffer.byteLength(value) > 10240)) process.exit(3);
402+
fs.appendFileSync(process.env.CAPTURE, JSON.stringify(input) + '\\n');
403+
if (process.env.PROXY_FAIL === '1') { console.error('proxy rejected request'); process.exit(4); }
404+
console.log('tool accepted');
405+
`);
406+
chmodSync(proxy, 0o700);
407+
const env = {
408+
...process.env,
409+
PATH: `${join(fixture.root, 'bin')}:${process.env.PATH}`,
410+
CAPTURE: capture,
411+
GITHUB_WORKSPACE: fixture.root,
412+
GITHUB_REPOSITORY: 'octo/example',
413+
DEFAULT_BRANCH: 'main',
414+
};
415+
const submit = (overrides = {}) => spawnSync(process.execPath, [
416+
VALIDATOR, '--submit-envelope', envelopePath,
417+
'--root', fixture.root, '--payload', fixture.payloadPath,
418+
'--repository', 'octo/example', '--default-branch', 'main', '--link-mode', 'placeholder',
419+
], { env: { ...env, ...overrides }, encoding: 'utf8' });
420+
return { ...fixture, text, envelope, envelopePath, capture, proxy, env, submit };
421+
}
422+
378423
function compileWorkflow(source = WORKFLOW): string {
379424
const root = mkdtempSync(join(tmpdir(), 'gh-aw-bootstrap-compile-'));
380425
workspaces.push(root);
@@ -601,12 +646,8 @@ describe('automatic Squad bootstrap workflow', () => {
601646
});
602647

603648
it('fails closed for every chunk transport corruption class', () => {
604-
const payloadText = JSON.stringify({
605-
shared: 'Cast and research stay in one validated payload.',
606-
content: 'x'.repeat(PAYLOAD_CHUNK_BYTES * 2),
607-
});
608-
const valid = createBootstrapPayloadEnvelope(payloadText) as Record<string, string>;
609-
expect(Number(valid.payload_chunk_count)).toBeGreaterThanOrEqual(3);
649+
const fixture = submissionFixture();
650+
const valid = fixture.envelope;
610651

611652
const mutations: Array<[string, (envelope: Record<string, string>) => void, RegExp]> = [
612653
['missing', (envelope) => delete envelope.payload_chunk_00, /payload_chunk_00 is missing/],
@@ -653,6 +694,8 @@ describe('automatic Squad bootstrap workflow', () => {
653694
/decoded length does not match|length mismatch/,
654695
],
655696
['hash mismatch', (envelope) => { envelope.payload_sha256 = '0'.repeat(64); }, /SHA-256 mismatch/],
697+
['noncanonical count', (envelope) => { envelope.payload_chunk_count = '07'; }, /canonical decimal/],
698+
['invalid slot', (envelope) => { envelope.payload_chunk_16 = '16:QQ=='; }, /not a valid fixed chunk slot/],
656699
[
657700
'trailing data',
658701
(envelope) => {
@@ -680,7 +723,74 @@ describe('automatic Squad bootstrap workflow', () => {
680723
() => reconstructBootstrapPayload(envelope),
681724
`${name} corruption must fail closed`,
682725
).toThrow(error);
726+
writeFileSync(fixture.envelopePath, JSON.stringify(envelope));
727+
const result = fixture.submit();
728+
expect(result.status, name).not.toBe(0);
729+
expect(result.stderr, name).toMatch(error);
730+
expect(existsSync(fixture.capture), `${name} must not invoke safeoutputs`).toBe(false);
731+
}
732+
});
733+
734+
it('submits seven chunks through the authenticated runner without printing or transcribing them', () => {
735+
const fixture = submissionFixture();
736+
cpSync(resolve(ROOT, 'workflows/shared'), join(fixture.root, '.github/workflows/shared'), { recursive: true });
737+
write(fixture.root, '.github/workflows/squad-bootstrap-payload.json', fixture.text);
738+
const config = parse(WORKFLOW.split('---')[1]);
739+
const prepare = config['pre-agent-steps'].find(
740+
(step: { name: string }) => step.name === 'Prepare authenticated bootstrap validator',
741+
);
742+
const setup = spawnSync('bash', ['-c', prepare.run], { env: fixture.env, encoding: 'utf8' });
743+
expect(setup.status, setup.stderr).toBe(0);
744+
const result = spawnSync(
745+
join(fixture.root, '.github/workflows/run-squad-bootstrap-validator'),
746+
[],
747+
{ env: fixture.env, encoding: 'utf8' },
748+
);
749+
expect(result.status, result.stderr).toBe(0);
750+
expect(result.stdout).toBe('Squad bootstrap validation passed; materialize_bootstrap submitted.\n');
751+
const calls = readFileSync(fixture.capture, 'utf8').trim().split('\n');
752+
expect(calls).toHaveLength(1);
753+
expect(JSON.parse(calls[0])).toEqual(fixture.envelope);
754+
expect(reconstructBootstrapPayload(JSON.parse(calls[0]))).toBe(fixture.text);
755+
expect(result.stdout.length).toBeLessThan(100);
756+
expect(result.stderr).toBe('');
757+
});
758+
759+
it('rejects schema, repository, Cast, and stale payload mutations before submitting', () => {
760+
for (const mutate of [
761+
(payload: ReturnType<typeof createFixture>['payload']) => { payload.schema_version = '2'; },
762+
(payload: ReturnType<typeof createFixture>['payload']) => { payload.repository = 'other/repo'; },
763+
(payload: ReturnType<typeof createFixture>['payload']) => { payload.default_branch = 'other'; },
764+
(payload: ReturnType<typeof createFixture>['payload']) => { payload.files[0].content += '\nchanged'; },
765+
]) {
766+
const fixture = submissionFixture();
767+
mutate(fixture.payload);
768+
const text = JSON.stringify(fixture.payload);
769+
writeFileSync(fixture.payloadPath, text);
770+
writeFileSync(fixture.envelopePath, JSON.stringify(createBootstrapPayloadEnvelope(text)));
771+
const result = fixture.submit();
772+
expect(result.status).not.toBe(0);
773+
expect(result.stderr).toContain('Squad bootstrap validation failed');
774+
expect(existsSync(fixture.capture)).toBe(false);
683775
}
776+
const fixture = submissionFixture();
777+
writeFileSync(fixture.payloadPath, `${fixture.text}\n`);
778+
expect(fixture.submit().stderr).toContain('does not match the generated payload bytes');
779+
expect(existsSync(fixture.capture)).toBe(false);
780+
});
781+
782+
it('fails explicitly without retries when the mounted tool fails or is unavailable', () => {
783+
const fixture = submissionFixture();
784+
const failed = fixture.submit({ PROXY_FAIL: '1' });
785+
expect(failed.status).not.toBe(0);
786+
expect(failed.stderr).toContain('proxy rejected request');
787+
expect(failed.stderr).toContain('Do not retry');
788+
expect(readFileSync(fixture.capture, 'utf8').trim().split('\n')).toHaveLength(1);
789+
rmSync(fixture.proxy);
790+
const unavailable = fixture.submit({ PATH: join(fixture.root, 'bin') });
791+
expect(unavailable.status).not.toBe(0);
792+
expect(unavailable.stderr).toContain('ENOENT');
793+
expect(unavailable.stdout).toBe('');
684794
});
685795

686796
it('enforces encoder total-size and fixed chunk-count bounds', () => {
@@ -738,6 +848,10 @@ describe('automatic Squad bootstrap workflow', () => {
738848
expect(lock).toContain('"payload_sha256"');
739849
expect(lock).not.toMatch(/"materialize-bootstrap":\{"inputs":\{"payload":/);
740850
expect(lock).toContain('reconstructBootstrapPayload(items[0])');
851+
expect(lock).toContain('mcp-cli');
852+
expect(lock).toContain('--submit-envelope');
853+
expect(parse(lock).jobs.agent.env.DEFAULT_BRANCH).toBe('${{ github.event.repository.default_branch }}');
854+
expect(parse(WORKFLOW.split('---')[1]).tools['cli-proxy']).toBe(true);
741855
expect(lock).toContain('SQUAD_BOOTSTRAP_INSTALL_SHA: ${{ github.sha }}');
742856
expect(lock).toContain('SQUAD_BOOTSTRAP_REPOSITORY: ${{ github.repository }}');
743857
expect(lock).toContain('SQUAD_BOOTSTRAP_RUN_ID: ${{ github.run_id }}');
@@ -762,6 +876,16 @@ describe('automatic Squad bootstrap workflow', () => {
762876
);
763877
}, 180000);
764878

879+
it('detects a compiled mutation that removes the file-backed safe-output CLI', () => {
880+
const assertMounted = (lock: string) => {
881+
const agent = parse(lock).jobs.agent;
882+
expect(agent.steps.some((step: { id?: string }) => step.id === 'mount-mcp-clis')).toBe(true);
883+
expect(lock).toContain('GH_AW_MCP_CLI_SERVERS=\'["safeoutputs"]\'');
884+
};
885+
assertMounted(compileWorkflow());
886+
expect(() => assertMounted(compileWorkflow(WORKFLOW.replace(' cli-proxy: true\n', '')))).toThrow();
887+
}, 180000);
888+
765889
it('declares deterministic output bounds and paginated recovery checks', () => {
766890
expect(WORKFLOW).toContain('max: 1');
767891
expect(WORKFLOW).toContain("state: 'all'");

0 commit comments

Comments
 (0)