CI reuse: a neutral run no longer blocks a passing one, and workflow_call checks clear only at the exact commit (GST-3554) (#4713)

A newer CI run that concluded `neutral` no longer blocks reusing a
passing run on the same commit, and a check that only runs inside
another workflow (`workflow_call`) now clears only from a run that
tested your exact commit.

Why: gbrain kept hitting `newer_run_vetoes` on passing runs (#9827,
#10058, #10021), and a calling workflow's green run from any commit
could clear such a check.

Nothing to do: gbrain's skipped-run case was already fixed on main by
#4695; this adds `neutral`, the exact-commit rule and regression tests
built from gbrain's real runs.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/outside-voice#1 reader=outside-voice
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-22 18:18:36 +00:00
1 parent 00a6b7a353
commit d3aed00dbe
11 files changed
+422 -11

No files matched your search

+8
View File
@@ -146,6 +146,14 @@ describe('waitForRun', () => {
expect((await o([run(4, { conclusion: 'failure' }), skipped])).state).toBe('red');
expect(await o([skipped])).toMatchObject({ state: 'red', run: { id: 5 } });
});
// Value: protects=the wait agrees with verifyRun on a neutral run too (GST-3554); fails_when=a newer neutral run is read as the commit's result
test('a newer neutral run is passed over like a skipped one; a newer failed run is still red', async () => {
const o = (runs: ApiRun[]) => waitForRun(source(runs).deps, { workflow: 'free-tests.yml', events: PROFILE.events, head: HEAD, timeoutMs: 60_000, intervalMs: 20_000, ...clockAt() });
const neutral = run(5, { event: 'pull_request', conclusion: 'neutral', created_at: run(4).created_at });
expect(await o([run(4), neutral])).toMatchObject({ state: 'green', run: { id: 4 } });
expect(await o([run(4), run(5, { event: 'pull_request', conclusion: 'failure', created_at: run(4).created_at })])).toMatchObject({ state: 'red', run: { id: 5 } });
});
});
describe('ship_lanes_from config and the ci_carried receipt field', () => {
+298
View File
@@ -0,0 +1,298 @@
{
"source": "garrytan/gbrain #10021 at 435e38c5, read with gh api on 2026-11-22 (GST-3554); trimmed to the fields verifyRun reads",
"head": "435e38c5c2eae4508a0cb0daeb3933efef07a12f",
"tree": "a23834cdcc7849b7f02927a6cbb17e0fc2ab1d03",
"profiles": {
"macos-validation.yml/macos-26": {
"workflow": "macos-validation.yml",
"events": [
"workflow_dispatch"
],
"jobs": [
"macOS 26 validation"
],
"artifact": "macos-26-tree",
"os": "macOS"
},
"native-locks.yml/native": {
"workflow": "test.yml",
"events": [
"workflow_dispatch",
"push"
],
"jobs": [
"full-suite",
"native-locks / linux-x64-glibc / Bun 1.4.4",
"native-locks / linux-arm64-glibc / Bun 1.4.4",
"native-locks / darwin-arm64 / Bun 1.4.4",
"native-locks / darwin-x64 / Bun 1.4.4",
"native-locks / win32-x64 / Bun 1.4.4",
"native-locks / win32-arm64 / Bun 1.4.4"
],
"artifact": "full-suite-tree"
}
},
"macos": {
"runs_for_head": [
{
"id": 45041640526,
"run_attempt": 1,
"status": "completed",
"conclusion": "skipped",
"event": "pull_request",
"head_sha": "435e38c5c2eae4508a0cb0daeb3933efef07a12f",
"head_branch": "fix/skill-resolver-symlinked-skills",
"path": ".github/workflows/macos-validation.yml",
"created_at": "2026-11-22T16:03:04Z",
"run_started_at": "2026-11-22T16:03:04Z",
"updated_at": "2026-11-22T16:03:05Z",
"repository": {
"full_name": "garrytan/gbrain"
},
"head_repository": {
"full_name": "garrytan/gbrain"
}
},
{
"id": 45041640171,
"run_attempt": 1,
"status": "completed",
"conclusion": "success",
"event": "workflow_dispatch",
"head_sha": "435e38c5c2eae4508a0cb0daeb3933efef07a12f",
"head_branch": "fix/skill-resolver-symlinked-skills",
"path": ".github/workflows/macos-validation.yml",
"created_at": "2026-11-22T16:03:04Z",
"run_started_at": "2026-11-22T16:03:04Z",
"updated_at": "2026-11-22T16:46:07Z",
"repository": {
"full_name": "garrytan/gbrain"
},
"head_repository": {
"full_name": "garrytan/gbrain"
}
},
{
"id": 44987920051,
"run_attempt": 1,
"status": "completed",
"conclusion": "skipped",
"event": "pull_request",
"head_sha": "435e38c5c2eae4508a0cb0daeb3933efef07a12f",
"head_branch": "fix/skill-resolver-symlinked-skills",
"path": ".github/workflows/macos-validation.yml",
"created_at": "2026-11-22T05:06:09Z",
"run_started_at": "2026-11-22T05:06:09Z",
"updated_at": "2026-11-22T05:06:10Z",
"repository": {
"full_name": "garrytan/gbrain"
},
"head_repository": {
"full_name": "garrytan/gbrain"
}
}
],
"dispatch": {
"id": 45041640171,
"run_attempt": 1,
"status": "completed",
"conclusion": "success",
"event": "workflow_dispatch",
"head_sha": "435e38c5c2eae4508a0cb0daeb3933efef07a12f",
"head_branch": "fix/skill-resolver-symlinked-skills",
"path": ".github/workflows/macos-validation.yml",
"created_at": "2026-11-22T16:03:04Z",
"run_started_at": "2026-11-22T16:03:04Z",
"updated_at": "2026-11-22T16:46:07Z",
"repository": {
"full_name": "garrytan/gbrain"
},
"head_repository": {
"full_name": "garrytan/gbrain"
}
},
"jobs": [
{
"name": "macOS 26 typecheck",
"conclusion": "success",
"started_at": "2026-11-22T16:25:31Z",
"completed_at": "2026-11-22T16:34:43Z"
},
{
"name": "macOS 26 validation",
"conclusion": "success",
"started_at": "2026-11-22T16:34:46Z",
"completed_at": "2026-11-22T16:46:07Z"
}
],
"artifact": {
"tree": "a23834cdcc7849b7f02927a6cbb17e0fc2ab1d03",
"sha": "435e38c5c2eae4508a0cb0daeb3933efef07a12f",
"workflow": "macOS 26 validation",
"event": "workflow_dispatch",
"run_id": 45041640171,
"run_attempt": 1,
"os": "macOS",
"files": [
"test/connector-physical-root-device.test.ts",
"test/persistence-physical-root-device.test.ts"
]
}
},
"test": {
"runs_for_head": [
{
"id": 45041701289,
"run_attempt": 1,
"status": "completed",
"conclusion": "success",
"event": "workflow_dispatch",
"head_sha": "435e38c5c2eae4508a0cb0daeb3933efef07a12f",
"head_branch": "fix/skill-resolver-symlinked-skills",
"path": ".github/workflows/test.yml",
"created_at": "2026-11-22T16:03:42Z",
"run_started_at": "2026-11-22T16:03:42Z",
"updated_at": "2026-11-22T16:47:33Z",
"repository": {
"full_name": "garrytan/gbrain"
},
"head_repository": {
"full_name": "garrytan/gbrain"
}
},
{
"id": 44987920129,
"run_attempt": 1,
"status": "completed",
"conclusion": "success",
"event": "pull_request",
"head_sha": "435e38c5c2eae4508a0cb0daeb3933efef07a12f",
"head_branch": "fix/skill-resolver-symlinked-skills",
"path": ".github/workflows/test.yml",
"created_at": "2026-11-22T05:06:09Z",
"run_started_at": "2026-11-22T05:06:09Z",
"updated_at": "2026-11-22T05:11:49Z",
"repository": {
"full_name": "garrytan/gbrain"
},
"head_repository": {
"full_name": "garrytan/gbrain"
}
}
],
"jobs": [
{
"completed_at": "2026-11-22T16:05:59Z",
"conclusion": "success",
"name": "native-locks / Windows PowerShell console probe / windows-2022 / Bun 1.4.4",
"started_at": "2026-11-22T16:05:12Z"
},
{
"completed_at": "2026-11-22T16:06:32Z",
"conclusion": "success",
"name": "native-locks / Windows PowerShell console probe / windows-11-arm / Bun 1.4.4",
"started_at": "2026-11-22T16:05:16Z"
},
{
"completed_at": "2026-11-22T16:06:25Z",
"conclusion": "success",
"name": "native-locks / OpenClaw 2026.9.4 native context-engine startup",
"started_at": "2026-11-22T16:05:09Z"
},
{
"completed_at": "2026-11-22T16:05:55Z",
"conclusion": "success",
"name": "native-locks / linux-x64-musl / Bun 1.4.4",
"started_at": "2026-11-22T16:05:09Z"
},
{
"completed_at": "2026-11-22T16:05:35Z",
"conclusion": "success",
"name": "native-locks / linux-arm64-musl / Bun 1.4.4",
"started_at": "2026-11-22T16:04:51Z"
},
{
"completed_at": "2026-11-22T16:06:38Z",
"conclusion": "success",
"name": "native-locks / Windows ACL API probe / windows-2022 / Bun 1.4.4",
"started_at": "2026-11-22T16:05:45Z"
},
{
"completed_at": "2026-11-22T16:07:41Z",
"conclusion": "success",
"name": "native-locks / Windows ACL API probe / windows-11-arm / Bun 1.4.4",
"started_at": "2026-11-22T16:05:12Z"
},
{
"completed_at": "2026-11-22T16:14:50Z",
"conclusion": "success",
"name": "native-locks / win32-arm64 / Bun 1.4.4",
"started_at": "2026-11-22T16:06:07Z"
},
{
"completed_at": "2026-11-22T16:46:54Z",
"conclusion": "success",
"name": "native-locks / darwin-arm64 / Bun 1.4.4",
"started_at": "2026-11-22T16:43:40Z"
},
{
"completed_at": "2026-11-22T16:06:58Z",
"conclusion": "success",
"name": "native-locks / linux-x64-glibc / Bun 1.4.4",
"started_at": "2026-11-22T16:05:09Z"
},
{
"completed_at": "2026-11-22T16:06:55Z",
"conclusion": "success",
"name": "native-locks / linux-arm64-glibc / Bun 1.4.4",
"started_at": "2026-11-22T16:04:51Z"
},
{
"completed_at": "2026-11-22T16:13:46Z",
"conclusion": "success",
"name": "native-locks / win32-x64 / Bun 1.4.4",
"started_at": "2026-11-22T16:07:05Z"
},
{
"completed_at": "2026-11-22T16:12:02Z",
"conclusion": "success",
"name": "native-locks / darwin-x64 / Bun 1.4.4",
"started_at": "2026-11-22T16:06:48Z"
},
{
"completed_at": "2026-11-22T16:04:19Z",
"conclusion": "skipped",
"name": "reused-full-suite",
"started_at": "2026-11-22T16:04:19Z"
},
{
"completed_at": "2026-11-22T16:47:10Z",
"conclusion": "success",
"name": "native-locks / darwin-x64 heartbeat finalize",
"started_at": "2026-11-22T16:46:57Z"
},
{
"completed_at": "2026-11-22T16:47:33Z",
"conclusion": "success",
"name": "full-suite",
"started_at": "2026-11-22T16:47:20Z"
}
],
"artifact": {
"tree": "a23834cdcc7849b7f02927a6cbb17e0fc2ab1d03",
"sha": "435e38c5c2eae4508a0cb0daeb3933efef07a12f",
"workflow": "Test",
"event": "workflow_dispatch",
"run_id": 45041701289,
"run_attempt": 1,
"profile": "full",
"os": "Linux",
"files": [
"evals/functional-area-resolver/harness-runner.test.ts",
"test/abort-check.test.ts",
"test/accepted-pending-status.test.ts"
],
"tests": 74955
}
}
}
+1
View File
@@ -224,6 +224,7 @@ export const FREE_FIXTURES: Readonly<Record<string, readonly string[]>> = {
'test/fixtures/review-design-lite-reports-ci-36633323521.json': ['test/review-finalization-budget.test.ts'],
'test/fixtures/review-gate-integrity-opus-reports.json': ['test/gate-integrity-templates.test.ts'],
'test/fixtures/review-wrong-tree/**': ['test/review-dispatch.test.ts'],
'test/fixtures/run-evidence/gbrain-435e38c5.json': ['test/run-evidence.test.ts'],
'test/fixtures/scrape-prototype-goto-42571575838.json': ['test/helpers/session-runner.test.ts'],
'test/fixtures/screen-verdict-41662815506/**': ['crew/test/ship-queue-screen-verdict.test.ts'],
'test/fixtures/sealed-guard-off-golden.json': ['test/sealed-guard.test.ts'],
+38 -5
View File
@@ -78,7 +78,7 @@ function runOfWorkflow(repo: FixtureRepo, head: string, workflow: string, state:
const c = check(repo, []);
const run = (id: number): ApiRun => {
if (id !== 300) throw new Error('HTTP 404');
return { id, run_attempt: 1, ...state, event: 'pull_request', head_sha: head, path: `.github/workflows/${workflow}`, repository: { full_name: 'fx/fx' }, head_repository: { full_name: 'fx/fx' } };
return { id, run_attempt: 1, ...state, event: 'workflow_dispatch', head_sha: head, path: `.github/workflows/${workflow}`, repository: { full_name: 'fx/fx' }, head_repository: { full_name: 'fx/fx' } };
};
return { ...c, deps: { ...c.deps, run, jobs: () => jobs } };
}
@@ -231,7 +231,7 @@ describe.skipIf(process.platform === 'win32')('clear --run: Actions runs as remo
test('a reusable-workflow lane (workflow_call only) clears from a run of a caller whose job uses ./.github/workflows/<lane workflow>; an unrelated workflow still refuses, and no fix line dispatches a workflow without workflow_dispatch (GST-971)', async () => {
const repo = fixture();
const head = repo.git('rev-parse', 'HEAD');
let head = repo.git('rev-parse', 'HEAD');
const base = await pregateAt(repo);
const wf = (name: string, text: string) => { fs.mkdirSync(path.join(repo.work, '.github/workflows'), { recursive: true }); fs.writeFileSync(path.join(repo.work, '.github/workflows', name), text); };
wf('r.yml', 'name: Reusable\non:\n workflow_call:\n inputs:\n scope:\n type: string\njobs:\n job:\n runs-on: ubuntu-latest\n steps:\n - run: echo reusable\n');
@@ -241,7 +241,7 @@ describe.skipIf(process.platform === 'win32')('clear --run: Actions runs as remo
const file: PregateFile = { ...base, requires_remote: [...base.requires_remote!, { lane: PLATFORM, platform: 'windows', workflow: 'r.yml', job: 'job', tests: ['test/a.test.ts'], receipt: null }] };
const url = 'https://github.com/fx/fx/actions/runs/300';
const msg = (d: ReturnType<typeof clearDecision>) => ('refused' in d ? `${d.refused}: ${d.message}; fix: ${d.fix}` : `cleared ${d.receipt}`);
const at = (): PregateFile => { repo.git('add', '-A', '.github'); return { ...file, tree: repo.git('write-tree') }; };
const at = (): PregateFile => { repo.git('add', '-A', '.github'); repo.git('commit', '-q', '--allow-empty', '-m', 'workflows'); head = repo.git('rev-parse', 'HEAD'); return { ...file, head, tree: repo.git('rev-parse', 'HEAD^{tree}') }; };
expect(msg(clearDecision(at(), PLATFORM, { runUrl: url, evidence: runOfWorkflow(repo, head, 'c.yml') }, repo.work))).toBe(`cleared ${url}/attempts/1`);
expect(msg(clearDecision(at(), PLATFORM, { runUrl: `${url}/job/9`, evidence: runOfWorkflow(repo, head, 'c.yml') }, repo.work))).toBe(`cleared ${url}/attempts/1`);
expect(msg(clearDecision(at(), PLATFORM, { runUrl: url, evidence: runOfWorkflow(repo, head, 'c.yml', undefined, [{ name: 'native (linux) / job', conclusion: 'success' }]) }, repo.work))).toBe(`cleared ${url}/attempts/1`);
@@ -257,9 +257,40 @@ describe.skipIf(process.platform === 'win32')('clear --run: Actions runs as remo
expect(msg(clearDecision(at(), PLATFORM, { runUrl: url, evidence: runOfWorkflow(repo, head, 'c.yml') }, repo.work))).toBe(`cleared ${url}/attempts/1`);
}, 120_000);
// Value: protects=a workflow_call-only lane clears from a caller run only when that run tested pregate.json's exact head and tree (GST-3554); fails_when=a green caller run of another commit, a pull_request merge or a tree pregate.json did not record clears the lane
test('a caller run of a reusable-workflow lane clears only when it tested pregate.json\'s head and tree; another commit, a pull_request merge or another tree refuses (GST-3554)', async () => {
const repo = fixture();
const before = repo.git('rev-parse', 'HEAD');
const base = await pregateAt(repo);
const dir = path.join(repo.work, '.github/workflows');
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(path.join(dir, 'r.yml'), 'name: Reusable\non:\n workflow_call:\njobs:\n job:\n runs-on: ubuntu-latest\n steps:\n - run: echo r\n');
fs.writeFileSync(path.join(dir, 'c.yml'), 'name: Caller\non:\n pull_request:\n workflow_dispatch:\njobs:\n native:\n uses: ./.github/workflows/r.yml\n');
repo.git('add', '-A', '.github');
repo.git('commit', '-q', '-m', 'workflows');
const head = repo.git('rev-parse', 'HEAD');
const tree = repo.git('rev-parse', 'HEAD^{tree}');
const PLATFORM = 'r.yml/job';
const file: PregateFile = { ...base, head, tree, requires_remote: [...base.requires_remote!, { lane: PLATFORM, platform: 'windows', workflow: 'r.yml', job: 'job', tests: ['test/a.test.ts'], receipt: null }] };
const url = 'https://github.com/fx/fx/actions/runs/300';
const msg = (d: ReturnType<typeof clearDecision>) => ('refused' in d ? `${d.refused}: ${d.message}; fix: ${d.fix}` : `cleared ${d.receipt}`);
const refused = (why: string, fix: string) => `PREGATE_RECEIPT_INVALID: REUSE: refused reason=${why}; ${PLATFORM} stays uncleared; fix: ${fix}`;
const fresh = `gh workflow run c.yml --ref <branch> at ${head.slice(0, 12)}, then gstack-pregate clear --remote ${PLATFORM} --run-url <that run's URL>`;
expect(msg(clearDecision(file, PLATFORM, { runUrl: url, evidence: runOfWorkflow(repo, head, 'c.yml') }, repo.work))).toBe(`cleared ${url}/attempts/1`);
expect(msg(clearDecision(file, PLATFORM, { runUrl: url, evidence: runOfWorkflow(repo, before, 'c.yml') }, repo.work))).toBe(refused(`head_mismatch — run 300 attempt 1 of c.yml ran at ${before.slice(0, 12)}, not pregate.json's head ${head.slice(0, 12)}, and a caller run clears r.yml only at that exact head`, fresh));
const pr = runOfWorkflow(repo, head, 'c.yml');
const prRun = pr.deps.run;
expect(msg(clearDecision(file, PLATFORM, { runUrl: url, evidence: { ...pr, deps: { ...pr.deps, run: id => ({ ...prRun(id), event: 'pull_request' }) } } }, repo.work))).toBe(refused('merge_tested — run 300 attempt 1 of c.yml is a pull_request run, which tested GitHub\'s merge of the head with its base, not the head itself', fresh));
fs.writeFileSync(path.join(repo.work, 'lib/uncommitted.js'), 'exports.x = 1;\n');
repo.git('add', '-A');
const dirty = repo.git('write-tree');
expect(msg(clearDecision({ ...file, tree: dirty }, PLATFORM, { runUrl: url, evidence: runOfWorkflow(repo, head, 'c.yml') }, repo.work))).toBe(refused(`tree_mismatch — run 300 attempt 1 of c.yml tested tree ${tree.slice(0, 12)} at its head, not pregate.json's tree ${dirty.slice(0, 12)}`, `commit what pregate.json recorded, rerun gstack-pregate, then ${fresh}`));
expect(msg(clearDecision({ ...file, head: undefined }, PLATFORM, { runUrl: url, evidence: runOfWorkflow(repo, head, 'c.yml') }, repo.work))).toBe(refused(`head_mismatch — run 300 attempt 1 of c.yml ran at ${head.slice(0, 12)}, not pregate.json's head (none recorded), and a caller run clears r.yml only at that exact head`, `rerun gstack-pregate at the head, then gh workflow run c.yml --ref <branch> at the head, then gstack-pregate clear --remote ${PLATFORM} --run-url <that run's URL>`));
}, 120_000);
test('a caller run counts only through a successful <calling job> / <lane job> job; names with comments or expressions match; callers are read at pregate.json\'s tree, not the working tree; a flow-mapping on: with workflow_dispatch counts (GST-971 fix-check)', async () => {
const repo = fixture();
const head = repo.git('rev-parse', 'HEAD');
let head = repo.git('rev-parse', 'HEAD');
const base = await pregateAt(repo);
const PLATFORM = 'r.yml/job';
const lane: PregateFile = { ...base, requires_remote: [...base.requires_remote!, { lane: PLATFORM, platform: 'windows', workflow: 'r.yml', job: 'job', tests: ['test/a.test.ts'], receipt: null }] };
@@ -270,7 +301,9 @@ describe.skipIf(process.platform === 'win32')('clear --run: Actions runs as remo
'c.yml': 'name: Caller\non: { pull_request: {}, workflow_dispatch: {} }\njobs:\n native:\n name: Native (${{ inputs.scope }}) # calls r.yml\n uses: ./.github/workflows/r.yml\n',
});
repo.git('add', '-A', '.github');
const file: PregateFile = { ...lane, tree: repo.git('write-tree') };
repo.git('commit', '-q', '-m', 'workflows');
head = repo.git('rev-parse', 'HEAD');
const file: PregateFile = { ...lane, head, tree: repo.git('rev-parse', 'HEAD^{tree}') };
const url = 'https://github.com/fx/fx/actions/runs/300';
const msg = (d: ReturnType<typeof clearDecision>) => ('refused' in d ? `${d.refused}: ${d.message}; fix: ${d.fix}` : `cleared ${d.receipt}`);
const caller = (jobs: ApiJob[], state?: Pick<ApiRun, 'status' | 'conclusion'>) => msg(clearDecision(file, PLATFORM, { runUrl: url, evidence: runOfWorkflow(repo, head, 'c.yml', state, jobs) }, repo.work));
+53
View File
@@ -111,6 +111,59 @@ describe('verifyRun', () => {
expect(reason(world({ others: [skipped({ event: 'workflow_dispatch', status: 'in_progress', conclusion: null })] }))).toBe('newer_run_vetoes');
});
// Value: protects=gbrain #10021's real runs at 435e38c5 (GST-3554): the dispatch run clears though a pull_request run that skipped itself, or concluded neutral, was created in the same second and is listed first; fails_when=a skipped or neutral run vetoes, or a newer failed, cancelled, timed-out or running run stops vetoing;
// why_new=GST-3514 covered skipped with a synthetic run; this binds the API's real order and timestamps, and neutral; seam=verifyRun's newer-run filter; no_claim=GitHub's API shape (ghRunDeps)
describe('the real gbrain runs at 435e38c5 (GST-3554)', () => {
const fx = JSON.parse(fs.readFileSync(path.join(import.meta.dir, 'fixtures/run-evidence/gbrain-435e38c5.json'), 'utf8'));
const AT = new Date('2026-11-22T17:30:00Z');
const lane = (key: 'macos' | 'test', over: { runs?: (runs: ApiRun[]) => ApiRun[]; jobs?: (jobs: ApiJob[]) => ApiJob[]; head?: string } = {}) => {
const runs: ApiRun[] = (over.runs ?? (r => r))(structuredClone(fx[key].runs_for_head));
const d: RunDeps = {
run: id => { const r = runs.find(x => x.id === id); if (!r) throw new Error('HTTP 404'); return r; },
runsForHead: (_wf, sha) => runs.filter(r => r.head_sha === sha),
jobs: () => (over.jobs ?? (j => j))(structuredClone(fx[key].jobs)),
artifact: () => structuredClone(fx[key].artifact),
commitTree: sha => (sha === fx.head ? fx.tree : null),
};
return d;
};
const MAC = 'macos-validation.yml/macos-26';
const NATIVE = 'native-locks.yml/native';
const verdict = (name: string, d: RunDeps, runRef: string, vetoHeads: string[] = [fx.head]) => {
const v = verifyRun(d, { repo: REPO, runRef, profileName: name, profile: fx.profiles[name], vetoHeads, now: AT });
return v.ok ? 'ok' : `${v.reason}: ${v.detail}`;
};
const skippedRun = 45041640526;
const as = (conclusion: string | null, status = 'completed') => (runs: ApiRun[]) => runs.map(r => (r.id === skippedRun ? { ...r, status, conclusion } : r));
test('the macOS dispatch run 45041640171 clears though the skipped pull_request run 45041640526, created the same second, is listed first', () => {
expect(fx.macos.runs_for_head.map((r: ApiRun) => `${r.id} ${r.event} ${r.conclusion} ${r.created_at}`)).toEqual([
'45041640526 pull_request skipped 2026-11-22T16:03:04Z', '45041640171 workflow_dispatch success 2026-11-22T16:03:04Z', '44987920051 pull_request skipped 2026-11-22T05:06:09Z',
]);
expect(verdict(MAC, lane('macos'), '45041640171')).toBe('ok');
});
test('a newer neutral run does not veto either; a newer failed, cancelled, timed-out or unfinished run still does', () => {
expect(verdict(MAC, lane('macos', { runs: as('neutral') }), '45041640171')).toBe('ok');
for (const conclusion of ['failure', 'cancelled', 'timed_out', 'startup_failure', 'action_required'])
expect(verdict(MAC, lane('macos', { runs: as(conclusion) }), '45041640171')).toBe(`newer_run_vetoes: newer run 45041640526 of macos-validation.yml on 435e38c5c2ea is ${conclusion}`);
expect(verdict(MAC, lane('macos', { runs: as(null, 'in_progress') }), '45041640171')).toBe('newer_run_vetoes: newer run 45041640526 of macos-validation.yml on 435e38c5c2ea is in_progress');
});
test('the workflow_call-only native-locks lane clears from the Test dispatch run 45041701289 that called it, through its called job names, and from no other run', () => {
expect(verdict(NATIVE, lane('test'), '45041701289')).toBe('ok');
const drop = (name: string) => (jobs: ApiJob[]) => jobs.filter(j => j.name !== name);
const red = (name: string) => (jobs: ApiJob[]) => jobs.map(j => (j.name === name ? { ...j, conclusion: 'failure' } : j));
expect(verdict(NATIVE, lane('test', { jobs: drop('native-locks / win32-arm64 / Bun 1.4.4') }), '45041701289')).toBe('job_missing: run 45041701289 attempt 1 has no job named native-locks / win32-arm64 / Bun 1.4.4');
expect(verdict(NATIVE, lane('test', { jobs: red('native-locks / darwin-x64 / Bun 1.4.4') }), '45041701289')).toBe('job_not_success: run 45041701289 attempt 1\'s native-locks / darwin-x64 / Bun 1.4.4 job concluded failure');
const OTHER = 'c'.repeat(40);
const elsewhere: RunDeps = { ...lane('test', { runs: runs => runs.map(r => ({ ...r, head_sha: OTHER })) }), artifact: () => ({ ...structuredClone(fx.test.artifact), sha: OTHER, tree: 'd'.repeat(40) }), commitTree: sha => (sha === OTHER ? 'd'.repeat(40) : sha === fx.head ? fx.tree : null) };
expect(verdict(NATIVE, lane('test', { runs: runs => runs.map(r => ({ ...r, head_sha: OTHER })) }), '45041701289')).toBe(`artifact_mismatch: run 45041701289 attempt 1's full-suite-tree records sha ${fx.head} (expected ${OTHER})`);
expect(verifyFromRun({ repo: REPO, deps: elsewhere, profiles: fx.profiles, now: AT }, '45041701289', [NATIVE], fx.tree, fx.head)).toEqual({ ok: false, reason: 'tree_mismatch', detail: `run 45041701289 tested tree dddddddddddd, not this tree ${fx.tree.slice(0, 12)}` });
expect(verdict(NATIVE, lane('macos'), '45041640171')).toMatch(/^workflow_mismatch: /);
});
});
test('a newer failure on another head the consumer names (same tree, the lane\'s own head) vetoes too', () => {
const w = world();
const other = 'e'.repeat(40);