Repository navigation
2877 lines (2830 loc) · 201 KB
/
Copy pathci.yml
File metadata and controls
2877 lines (2830 loc) · 201 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Checks of this repository's own automation, so a pull request that edits
# `.github/` is tested before it merges. The one job named ci is what the
# main branch ruleset requires: a new check is added to its `needs`, with
# no change to the ruleset.
name: ci
on:
pull_request:
merge_group:
types: [checks_requested]
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# The tests of the scripts under .github, through the Justfile.
test:
runs-on: ubuntu-26.04
timeout-minutes: 25
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The hosted image's Node and Rust; the scripts have no dependencies
# to install, and test-config's crate fetches its locked ones.
# A pinned just: Ubuntu's apt carries an old one (1.21 on 24.04).
# A GitHub release outage (504s for over an hour on 2026-11-08) must not
# stop the job: build the same just from crates.io instead.
- id: just
continue-on-error: true
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.58.0
- if: steps.just.outcome == 'failure'
run: cargo install --locked --version 1.58.0 just && echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Install the supervisor's verified pinned config validator
env:
GH_TOKEN: ${{ github.token }}
run: just build-supervisor-agent-board
# Today's policy on PATH, so just test checks the current bounds for real.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: cgwalters-forge/agentic-job
ref: 2b937aaac81da06d8bff5f317e58df6ad7063e1e # v0.6.16, as dispatch.yml's run wrapper
path: _dispatch-policy
persist-credentials: false
- name: Install the pinned policy binary by verified source digest
env:
GH_TOKEN: ${{ github.token }}
WORKFLOW_REPOSITORY: cgwalters-forge/agentic-job
run: |
bash _dispatch-policy/secure-host/binary.sh get --out "$RUNNER_TEMP/dispatch-policy-bin"
echo "$RUNNER_TEMP/dispatch-policy-bin" >> "$GITHUB_PATH"
# Mandatory real resolver/policy replay at the incident's immutable pins.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: cgwalters-forge/agentic-job
ref: a5f7a3963fd41f3eb09c4406aa5bc8e30ee42be2 # v0.6.10
path: admission-policy
persist-credentials: false
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: cgwalters-forge/actions
ref: bac2da6d67101ab6ca520d9d63adc46da77e4513
fetch-depth: 0 # also contains the earlier recorded wrapper
path: admission-actions
persist-credentials: false
- name: Build the immutable admission policy
run: cargo build --locked --manifest-path admission-policy/Cargo.toml -p agentic-job --target-dir "$RUNNER_TEMP/admission-policy-target"
- name: Test bounded fix comment publication
shell: node {0}
run: |
const assert = require('node:assert/strict');
const fs = require('node:fs');
const { join } = require('node:path');
const { tmpdir } = require('node:os');
const { execFileSync, spawnSync } = require('node:child_process');
const { runInNewContext } = require('node:vm');
const workflow = fs.readFileSync('.github/workflows/dispatch.yml', 'utf8');
const run = workflow.split('\n run:\n')[1].split('\n admission-receipt:\n')[0];
const [, path, pin] = /uses: cgwalters-forge\/actions\/(\.github\/workflows\/cgwalters-agentic-job\.yml)@([a-f0-9]{40})/.exec(run);
const wrapper = execFileSync('git', ['-C', process.env.ADMISSION_ACTIONS || 'admission-actions', 'show', `${pin}:${path}`], { encoding: 'utf8' });
const step = /- name: Resolve the fix comment opt-in[^]*? run: \|\n((?: {10}.*\n|\n)+)/.exec(workflow)[1].replace(/^ {10}/gm, '');
const policyJob = wrapper.split('\n policy:\n')[1].split('\n register:\n')[0];
const policyOutputs = /^ outputs: \$\{\{ (.*) \}\}$/m.exec(policyJob)[1];
const commentTarget = /^ comment-target: \$\{\{ (.*) \}\}$/m.exec(policyJob)[1];
const advisory = wrapper.split('\n advisory:\n')[1].split('\n apply:\n')[0];
const guard = / if: >-\n \$\{\{ ([^]*?) \}\}/.exec(advisory)[1];
const verify = / script: \|\n((?: {12}.*\n)+)/.exec(advisory)[1].replace(/^ {12}/gm, '');
const applyCheck = / check: >-\n \$\{\{ ([^]*?) \}\}/.exec(wrapper.split('\n apply:\n')[1])[1];
const evaluate = (expr, context) => runInNewContext(expr.replace(/\.([\w]+(?:-[\w]+)+)/g, "['$1']"), context);
const temp = fs.mkdtempSync(join(tmpdir(), 'fix-comment-'));
const file = name => join(temp, name);
const env = { HOME: temp, PATH: `${temp}:${process.env.PATH}` };
const cli = (...args) => spawnSync('agentic-job', args, { env, encoding: 'utf8', timeout: 10000 });
const ok = result => {
assert.ifError(result.error);
assert.equal(result.status, 0, result.stderr);
return result.stdout;
};
const bot = 'cgwalters-bot', botId = 17814078, tracker = 'cgwalters-forge/tracker', pr = '7', branch = 'bot/offline';
const head = 'a'.repeat(40), banner = 'Fix run report:';
const bounds = name => `.github/agentic-job/${name}.toml`;
try {
fs.writeFileSync(file('gh'), `#!${process.execPath}
const assert = require('node:assert/strict');
const { env, argv } = process;
assert.deepEqual(argv.slice(2), ['api', 'repos/' + env.REPO.toLowerCase() + '/pulls/' + env.ITEM]);
require('node:fs').writeFileSync(env.GITHUB_OUTPUT + '.lookup', '');
process.stdout.write(env.FIXTURE);
`, { mode: 0o700 });
function optIn(repo, allow, author, expectedLookup, { item = pr, number = 7, fullName = repo, state = 'open', id = author === bot ? botId : 1 } = {}) {
fs.writeFileSync(file('output'), '');
fs.rmSync(file('output.lookup'), { force: true });
const got = ok(spawnSync('bash', ['-eo', 'pipefail', '-c', step], { encoding: 'utf8', timeout: 10000,
env: { ...env, REPO: repo, ITEM: item, FIX_ALLOW: allow, GITHUB_OUTPUT: file('output'),
FIXTURE: JSON.stringify({ number, state, base: { repo: { full_name: fullName } }, user: { login: author, id } }) } }));
assert.equal(got, '');
assert.equal(fs.existsSync(file('output.lookup')), expectedLookup, repo);
return fs.readFileSync(file('output'), 'utf8');
}
const noGrant = file('no-grant.toml');
fs.writeFileSync(noGrant, fs.readFileSync(bounds('fix'), 'utf8').replace('add_comment = { max = 1 }\n', ''));
assert.equal(optIn(tracker, noGrant, bot, false), 'enabled=false\n');
for (const override of [{ item: '7?x=1' }, { number: 8 }, { fullName: 'cgwalters-forge/actions' }, { state: 'closed' }, { id: 1 }]) {
assert.equal(optIn(tracker, bounds('fix'), bot, !override.item, override), 'enabled=false\n');
}
for (const [repo, name, author, lookup, enabled] of [
[tracker, 'fix', bot, true, true],
[tracker, 'fix', 'human', true, false],
['cgwalters-forge/ostree', 'midstream-fix', bot, true, true],
['bootc-dev/bootc', 'fix', bot, false, false],
['bootc-dev/bootc', 'fix', 'human', false, false],
['ostreedev/ostree', 'fix', bot, false, false],
]) {
const allow = bounds(name);
assert.equal(optIn(repo, allow, author, lookup), `enabled=${enabled}\n`, repo);
const inputs = { kind: 'fix', item: pr, 'fix-comment': enabled };
const list = evaluate(policyOutputs, { inputs });
const policy = JSON.parse(ok(cli('policy', '--allow', allow, '--repo', repo, '--output-repo', repo,
'--clone-url', `https://github.com/${repo}`, '--kind', 'branch', '--base', branch, '--head', head,
'--pull-request', pr, '--pull-author', author, '--outputs', list, '--max-outputs', '3')));
assert.equal(policy.safe_outputs.push_to_pull_request_branch.target, pr);
assert.equal(Object.hasOwn(policy.safe_outputs, 'add_comment'), enabled);
fs.writeFileSync(file('policy.json'), JSON.stringify(policy));
const out = file('out'), checked = file('advisory'), collected = join(checked, 'agent_output.json');
const comment = { type: 'add_comment', body: `${banner}\n\nHuman action is needed.` };
const noop = { type: 'noop', message: 'Blocked: human action is needed.' };
const jsonl = requests => [requests].flat().map(item => JSON.stringify(item) + '\n').join('');
if (enabled) {
// The producer: the runner's session only ends a no-patch fix on a reasoned noop.
const home = file('home'), work = join(home, 'work');
fs.rmSync(home, { recursive: true, force: true });
fs.mkdirSync(join(home, '.config/agentic-job'), { recursive: true });
fs.mkdirSync(join(home, 'out'));
execFileSync('git', ['init', '-q', work]);
execFileSync('git', ['-C', work, '-c', 'user.name=Test', '-c', 'user.email=test@example.test', 'commit', '-q', '--allow-empty', '-m', 'Test']);
const base = execFileSync('git', ['-C', work, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
fs.writeFileSync(join(home, '.config/agentic-job/handback.json'), JSON.stringify({ host_isolation: 'managed',
public_base: { patches: {}, secrets: {}, key_blocks: [] }, policy, checkout: work, base, run_id: '7',
commit: { author: 'Test <test@example.test>', trailers: [], format: false } }));
fs.writeFileSync(join(home, 'out/outcome.json'), JSON.stringify({ summary: 'Blocked.', tests: [], stopped_early: 'blocked',
checkpoint: { complete: true, done: 'Nothing.', left: 'Human action.', next: 'Ask a human.' } }));
for (const [requests, status] of [[comment, 1], [[comment, noop], 0]]) {
fs.writeFileSync(join(home, 'out/safe-outputs.jsonl'), jsonl(requests));
const got = spawnSync('agentic-job', ['handback', 'check'], { cwd: work, env: { ...env, HOME: home }, encoding: 'utf8', timeout: 10000 });
assert.ifError(got.error);
assert.equal(got.status, status, got.stdout + got.stderr);
}
}
for (const [request, expected] of [
[enabled ? [comment, noop] : comment, enabled ? 'publish' : 'Unexpected output type'],
...(enabled ? [
[{ ...comment, item_number: 8 }, 'outside the caller\'s fixed item'],
[{ ...comment, repo: 'cgwalters-forge/actions' }, 'which is not the policy\'s'],
[{ ...comment, body: '/command' }, 'banner'],
] : []),
[{ type: 'push_to_pull_request_branch', branch, message: 'Test push' }, 'publish'],
]) {
for (const dir of [out, checked]) {
fs.rmSync(dir, { recursive: true, force: true });
fs.mkdirSync(dir);
}
fs.writeFileSync(join(out, 'outputs.jsonl'), jsonl(request));
if (request.type === 'push_to_pull_request_branch') {
fs.writeFileSync(join(out, 'base.json'), JSON.stringify({ repo, ref: branch, commit: head }));
fs.writeFileSync(join(out, 'aw-bot-offline.patch'), `From ${'b'.repeat(40)} Mon Sep 17 00:00:00 2001\nX-GH-AW-Base-Commit: ${head}\nFrom: Test <test@example.test>\nDate: Thu, 5 Nov 2026 00:00:00 +0000\nSubject: [PATCH] Test\n\n---\ndiff --git a/test.txt b/test.txt\nnew file mode 100644\n--- /dev/null\n+++ b/test.txt\n@@ -0,0 +1 @@\n+test\n`);
}
const args = ['--policy', file('policy.json'), '--outputs', out, '--collected', collected];
const collect = cli('collect', ...args);
const check = collect.status === 0 ? cli('check', ...args, '--run-id', '7',
'--comment-repo', repo, '--comment-target', evaluate(commentTarget, { inputs })) : collect;
if (!['publish', 'banner'].includes(expected)) {
assert.ifError(check.error);
assert.notEqual(check.status, 0, JSON.stringify(request));
assert.ok(check.stderr.includes(expected), check.stderr);
continue;
}
ok(check);
const needs = { target: { outputs: { 'item-kind': 'pull-request' } },
check: { result: 'success', outputs: { 'artifact-id': '123' } },
advisory: { result: 'skipped', outputs: { 'artifact-id': '' } } };
assert.equal(evaluate(guard, { inputs, needs }), enabled);
if (enabled) {
const context = { require, process: { env: { RUNNER_TEMP: temp, PROFILE: 'fix', BANNER: banner, ARTIFACT_ID: '123' } },
core: { setOutput: (name, value) => { needs.advisory.outputs[name] = value; } } };
if (expected === 'banner') {
assert.throws(() => runInNewContext(verify, context), /banner and a blank line/);
needs.advisory.result = 'failure';
} else {
runInNewContext(verify, context);
needs.advisory.result = 'success';
}
}
const apply = () => JSON.parse(evaluate(applyCheck, { inputs, needs, toJSON: JSON.stringify }));
if (expected === 'publish') assert.deepEqual(apply(), needs.check);
else assert.equal(apply().result, 'failure');
if (enabled && expected === 'publish') {
needs.advisory.outputs['artifact-id'] = '456';
assert.equal(apply().result, 'failure', 'apply cannot take another artifact');
}
}
}
} finally { fs.rmSync(temp, { recursive: true, force: true }); }
# Keep replay inline: deployment scripts and Justfile may only shrink.
- name: Required offline dispatch admission replay
shell: node {0}
run: |
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const http = require('node:http');
const vm = require('node:vm');
const { spawn, spawnSync, execFileSync } = require('node:child_process');
const actions = path.resolve(process.env.ADMISSION_ACTIONS || 'admission-actions');
const source = path.resolve(process.env.ADMISSION_POLICY || 'admission-policy');
const binary = path.join(process.env.RUNNER_TEMP, 'admission-policy-target/debug/agentic-job');
const read = p => fs.readFileSync(p, 'utf8');
const git = (dir, ...args) => execFileSync('git', ['-C', dir, ...args], { encoding: 'utf8' }).trim();
const fixture = JSON.parse(read('.github/agentic-job/testdata/dispatch-admission.json'));
assert.equal(git(source, 'rev-parse', 'HEAD'), fixture.policy_revision);
assert.equal(git(source, 'status', '--porcelain', '--untracked-files=no'), '', 'policy source must be clean');
assert.match(execFileSync(binary, ['--version'], { encoding: 'utf8' }), /^agentic-job 0\.6\.10\s*$/);
const workflow = read('.github/workflows/dispatch.yml');
const ci = read('.github/workflows/ci.yml').split('\n lint:\n')[0];
assert.ok(ci.includes(`ref: ${fixture.policy_revision}`));
const replay = ci.split(' - name: Required offline dispatch admission replay\n')[1];
assert.ok(replay.startsWith(' shell: node {0}\n run: |\n'), 'replay must be unconditional');
const step = name => new RegExp(`- name: ${name}[^]*? run: \\|\n((?: .*\n)+)`)
.exec(workflow)[1].replace(/^ /gm, '');
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'dispatch-admission-'));
const env = { PATH: process.env.PATH, HOME: temp, GH_TOKEN: ['offline', 'fixture'].join('-') };
process.on('exit', () => fs.rmSync(temp, { recursive: true, force: true }));
const shell = (script, extra) => spawnSync('bash', ['-euo', 'pipefail', '-c', script], {
env: { ...env, ...extra }, encoding: 'utf8', timeout: 10000 });
function bounds(repo) {
const output = path.join(temp, 'output');
fs.writeFileSync(output, '');
// The recorded targets are the organization's own, not midstream forks.
const result = shell(step('Resolve the bounds'), { KIND: 'fix', REPO: repo, MIDSTREAM: 'false', GITHUB_OUTPUT: output });
assert.equal(result.status, 0, result.stderr);
const selected = Object.fromEntries(read(output).trim().split('\n').map(line => line.split('=')));
assert.deepEqual(selected, { allow: '.github/agentic-job/dispatch.toml', 'fix-allow': '.github/agentic-job/fix.toml' });
return selected;
}
for (const key of ['allow', 'fix-allow']) assert.ok(workflow.includes(`${key}: $\u007b\u007b needs.profile.outputs.${key} \u007d\u007d`));
// Read the actual immutable wrapper objects. No fixture-owned guard strings.
const guards = fixture.wrapper_revisions.map(revision => {
const wrapper = git(actions, 'show', `${revision}:.github/workflows/cgwalters-agentic-job.yml`);
assert.ok(wrapper.includes(`policy.yml@${fixture.policy_revision}`));
const jobs = {};
for (const [job, dependencies] of [['agent', '[target, policy]'], ['apply', '[policy, agent, check, session]']]) {
const block = wrapper.split(`\n ${job}:\n`)[1];
assert.ok(block.startsWith(` needs: ${dependencies}\n`));
jobs[job] = /\n if: \$\{\{ (.*) \}\}/.exec(block)[1];
}
assert.equal(jobs.agent, "needs.policy.outputs.admitted == 'true'");
assert.equal(jobs.apply, "always() && needs.policy.result == 'success'");
const select = /\n allow: \$\{\{ (.*) \}\}/.exec(wrapper)[1].replaceAll('inputs.fix-allow', 'inputs["fix-allow"]');
for (const pull of fixture.pulls) assert.equal(vm.runInNewContext(select, { inputs: { kind: 'fix', ...bounds(pull.base.repo.full_name) } }), '.github/agentic-job/fix.toml');
return jobs;
});
function downstream(refused) {
const needs = { policy: { result: refused ? 'failure' : 'success', outputs: { admitted: refused ? '' : 'true' } } };
for (const jobs of guards) for (const job of ['agent', 'apply']) {
assert.equal(vm.runInNewContext(jobs[job], { needs, always: () => true }), !refused);
}
}
// Current bounds must retain the same excluded-head rule as the historical replay.
const toml = spawnSync('python3', ['-c', 'import json,tomllib; print(json.dumps([tomllib.load(open(p,"rb"))["github"]["outputs"]["push_to_pull_request_branch"]["branches"] for p in [".github/agentic-job/fix.toml", ".github/agentic-job/testdata/incident-fix.toml"]]))'], { encoding: 'utf8' });
assert.equal(toml.status, 0, toml.stderr);
const [current, recorded] = JSON.parse(toml.stdout);
assert.deepEqual(current, recorded);
const receiptJob = workflow.split('\n admission-receipt:\n')[1];
assert.match(receiptJob, /vars.DISPATCH_ADMISSION_RECEIPT == 'enabled'/);
const receiptGuard = / if: \$\{\{ (.*) \}\}/.exec(receiptJob)[1];
for (const activation of [undefined, '', 'disabled', 'true', 'enabled']) for (const kind of ['fix', 'implement', 'review']) {
assert.equal(vm.runInNewContext(receiptGuard, { always: () => true, inputs: { kind }, vars: { DISPATCH_ADMISSION_RECEIPT: activation } }), activation === 'enabled' && kind !== 'review');
}
assert.match(receiptJob, /needs: \[profile, run\]/);
assert.match(receiptJob, /timeout-minutes: 1\n permissions: \{\}/);
assert.doesNotMatch(receiptJob.split(' run: |')[0], /inputs\.(repo|item|task)|toJSON|secrets\./);
// Check what Actions prints before running the step, not only the JSON.
const receiptEnv = receiptJob.split(' env:\n')[1].split(' run: |')[0];
assert.equal((receiptEnv.match(/: \$\{\{/g) || []).length, 4);
for (const [key, values] of [['ALLOW', ['.github/agentic-job/dispatch.toml', '.github/agentic-job/comment.toml', '.github/agentic-job/midstream.toml']], ['FIX_ALLOW', ['.github/agentic-job/fix.toml', '.github/agentic-job/midstream-fix.toml']]]) {
const expression = new RegExp(`${key}: \\$\\{\\{ (.*) \\}\\}`).exec(receiptEnv)[1].replaceAll('outputs.fix-allow', 'outputs["fix-allow"]');
for (const value of [undefined, '', 'x'.repeat(10000), '\n::error::injected', ...values]) {
const got = vm.runInNewContext(expression, { needs: { profile: { outputs: { allow: value, 'fix-allow': value } } }, fromJSON: JSON.parse, contains: (a, b) => a.includes(b) });
assert.equal(got, values.includes(value) ? value : '', 'env is allowlisted before Actions logging');
}
}
const eventPath = path.join(temp, 'event.json');
for (const result of ['success', 'failure', 'cancelled', 'skipped', undefined]) {
for (const inputs of [{ kind: 'fix', repo: 'cgwalters-forge/tracker', item: '1050' }, {}, { kind: 'x'.repeat(10000), repo: 'x'.repeat(10000), item: '9'.repeat(10000), task: 'not public\n::error::secret' }, { kind: 'fix', repo: '\n::error::secret', item: '1\n::error::secret' }]) {
fs.writeFileSync(eventPath, JSON.stringify({ inputs, task: 'not public' }));
const got = shell(step('Record dispatch admission outcome'), { GITHUB_EVENT_PATH: eventPath, GITHUB_RUN_ID: '42', GITHUB_RUN_ATTEMPT: '1', GITHUB_EVENT_NAME: 'workflow_dispatch', GITHUB_ACTOR: 'bot\n::error::secret', ...(result ? { PROFILE_RESULT: result, WRAPPER_RESULT: result, FIX_ALLOW: '.github/agentic-job/fix.toml' } : {}) });
assert.equal(got.status, 0, got.stderr);
assert.equal(got.stdout.trim().split('\n').length, 1);
assert.doesNotMatch(got.stdout, /not public|::error::|secret/);
const receipt = JSON.parse(got.stdout);
assert.ok(Object.values(receipt).every(v => v.length <= 256));
assert.equal(receipt.wrapper_result, result || '');
assert.equal(receipt.profile_result, result || '');
assert.equal(receipt.selected_bounds, inputs.kind === 'fix' && result ? '.github/agentic-job/fix.toml' : '');
}
}
const cli = (args, api) => new Promise((resolve, reject) => {
const child = spawn(binary, args, { env: { ...env, GITHUB_API_URL: api } });
let stdout = '', stderr = '';
const timer = setTimeout(() => child.kill('SIGKILL'), 10000);
child.stdout.on('data', data => { stdout += data; });
child.stderr.on('data', data => { stderr += data; });
child.on('error', error => { clearTimeout(timer); reject(error); });
child.on('close', status => { clearTimeout(timer); resolve({ status, stdout, stderr }); });
});
(async () => {
let pull;
const requests = [];
const server = http.createServer((req, res) => {
requests.push(`${req.method} ${req.url}`);
const repo = pull.base.repo.full_name;
const routes = { [`/repos/${repo}/pulls/${pull.number}`]: pull,
[`/repos/${repo}/git/ref/heads/main`]: { object: { type: 'commit', sha: pull.base.sha } } };
res.writeHead(req.method === 'GET' && Object.hasOwn(routes, req.url) ? 200 : 404, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(routes[req.url] ?? {}));
});
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
const api = `http://127.0.0.1:${server.address().port}`;
async function receive(value) {
pull = value;
requests.length = 0;
bounds(pull.base.repo.full_name);
const repo = pull.base.repo.full_name;
const resolved = await cli(['push', 'resolve', '--event', 'false', '--review', 'false', '--kind', 'branch', '--item', String(pull.number), '--repo', repo, '--output-repo', repo], api);
if (resolved.status !== 0) { downstream(true); return { ...resolved, stage: 'resolve' }; }
const outputs = Object.fromEntries(resolved.stdout.trim().split('\n').map(line => line.split('=')));
const policy = await cli(['policy', '--allow', '.github/agentic-job/testdata/incident-fix.toml', '--repo', repo, '--clone-url', `https://github.com/${repo}`, '--base', outputs.branch, '--kind', 'branch', '--outputs', 'push_to_pull_request_branch,noop,missing_tool,missing_data', '--max-outputs', '3', '--pull-request', String(pull.number), '--head', outputs.head, '--output-repo', repo], api);
downstream(policy.status !== 0);
return { ...policy, stage: 'policy' };
}
try {
for (const recorded of fixture.pulls) {
let previous;
for (let repeat = 0; repeat < 2; repeat++) {
const result = await receive({ ...recorded, state: 'open' });
assert.equal(result.stage, 'policy');
assert.equal(result.status, 1, result.stderr);
assert.ok(result.stderr.includes(`pull request branch "${recorded.head.ref}" is not within the bounds (dispatch/**, bot/**, release-train/**)`), result.stderr);
assert.equal(result.stdout, '', 'no policy reaches agent/apply');
if (previous) assert.equal(result.stderr, previous.stderr);
previous = result;
assert.equal(requests.length, 2, 'PR and base-ref GETs only');
}
for (const ref of [recorded.head.ref, 'bot/offline-admission-control']) {
const closed = await receive({ ...recorded, head: { ...recorded.head, ref } });
assert.equal(closed.stage, 'resolve');
assert.notEqual(closed.status, 0, closed.stderr);
assert.match(closed.stderr, /open pull request/);
assert.equal(requests.length, 1, 'closed/superseded stops before policy');
}
const allowed = await receive({ ...recorded, state: 'open', head: { ...recorded.head, ref: 'bot/offline-admission-control' } });
assert.equal(allowed.status, 0, allowed.stderr);
assert.equal(JSON.parse(allowed.stdout).safe_outputs.push_to_pull_request_branch.target, String(recorded.number));
}
console.log('ok: both immutable wrappers, excluded heads and identical repeats, closed/superseded targets, open bot control, bounded receipt and pre-log env');
} finally { await new Promise(resolve => server.close(resolve)); }
})().catch(error => { console.error(error); process.exitCode = 1; });
# Offline soak admission/session/config checks and a short loop smoke,
# no inference; kept here so the Justfile does not grow.
- name: Test soak contract
shell: node {0}
run: |
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { spawnSync } = require('node:child_process');
const soak = require(path.resolve('workflow/soak.cjs'));
const workflow = fs.readFileSync('.github/workflows/soak.yml', 'utf8');
const dispatch = fs.readFileSync('.github/workflows/dispatch.yml', 'utf8');
// dispatch.yml pins this wrapper; every other caller follows main.
const route = /uses: (cgwalters-forge\/actions\/\.github\/workflows\/cgwalters-agentic-job\.yml)@/;
assert.equal(route.exec(workflow)[1], route.exec(dispatch)[1]);
assert.match(workflow, /cgwalters-agentic-job\.yml@main\n/);
assert.match(workflow, /default: '90'/);
assert.match(workflow, /group: soak-\$\{\{ inputs.egress \}\}/);
assert.match(workflow, /needs: validate/);
assert.match(workflow, /Unresolved deployment prerequisite[^]*exit 1/);
assert.match(workflow, /agent: fake/);
assert.doesNotMatch(workflow, /secrets:|\$\{\{ (?:secrets|vars)\.|^ (?:model|inference-url|inference-register):/m);
const hosted = fs.readFileSync('.github/agentic-job/hosted.toml', 'utf8');
const parse = text => {
const result = spawnSync('python3', ['-c', 'import json,sys,tomllib; print(json.dumps(tomllib.loads(sys.stdin.read())))'], { input: text, encoding: 'utf8' });
assert.equal(result.status, 0, result.stderr);
return JSON.parse(result.stdout);
};
for (const egress of ['on', 'off']) {
const actual = fs.readFileSync(soak.validate('90', egress).config, 'utf8');
assert.equal(actual, soak.config(hosted, egress), 'regenerate variants after baseline changes');
const parsed = parse(actual);
assert.deepEqual(parsed.egress, { proxy: egress === 'on', 'rust-proxy': true, 'write-policy': egress === 'on' });
assert.equal(parsed.setup.script, 'workflow/soak.cjs');
delete parsed.setup.script;
parsed.egress = { proxy: false };
assert.deepEqual(parsed, parse(hosted), 'all other host, session, packages and commit settings stay identical');
}
assert.deepEqual(parse(fs.readFileSync('.github/agentic-job/soak.toml', 'utf8')).github.outputs, { noop: { max: 1 } });
const temp = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'tracker-soak-'));
async function main() {
for (const value of ['1', '90', '120']) assert.equal(soak.minutes(value), Number(value));
for (const value of [undefined, '', '0', '-1', '121', '999999999999999', '1.5', '1e2', '01', ' 90', '90\n', '90;true']) {
assert.throws(() => soak.minutes(value), /canonical integer/);
const output = path.join(temp, 'output');
fs.writeFileSync(output, '');
const result = spawnSync('node', ['workflow/soak.cjs', 'validate'], { encoding: 'utf8',
env: { ...process.env, MINUTES: value ?? '', EGRESS: 'on', GITHUB_OUTPUT: output } });
assert.equal(result.status, 1);
assert.equal(fs.readFileSync(output, 'utf8'), '');
}
for (const value of ['', 'ON', 'off\n', '../../hosted']) assert.throws(() => soak.validate('90', value), /egress/);
assert.throws(() => soak.setup(temp, undefined), /canonical integer/);
soak.setup(temp, '90');
const steps = JSON.parse(fs.readFileSync(path.join(temp, '.config/fake-agent/demo.json')));
assert.equal(steps.length, 2);
assert.deepEqual(steps[0], { execute: { title: 'Redaction control', command: "printf 'redaction trial: gh%s_%s\\n' p FAKEREDACTIONCANARY0123456789abcdef" } });
assert.match(steps[1].execute.command, /soak.cjs" loop 90$/);
let clock = 0;
const lines = [];
const results = [{ status: '503', transport: 0 }, { status: '000', transport: 28 }, { status: '200', transport: 0 }];
await soak.loop('3', temp, { now: () => clock, wait: async ms => { clock += ms; },
get: deadline => { assert.ok(deadline > 0 && deadline <= 20); return results.shift(); }, emit: line => lines.push(line) });
assert.equal(clock, 180000);
assert.equal(lines.length, 3, 'HTTP and transport failures never stop later samples');
assert.match(lines[0], /^\d{4}-\d\d-\d\dT.*Z elapsed_s=0.000 http_status=503 transport_failure=0$/);
assert.match(lines[1], /http_status=000 transport_failure=28$/);
assert.match(lines[2], /elapsed_s=120.000 http_status=200 transport_failure=0$/);
assert.match(JSON.parse(fs.readFileSync(path.join(temp, 'out/outcome.json'))).summary, /3 samples, 2 HTTP\/transport failures/);
assert.equal(JSON.parse(fs.readFileSync(path.join(temp, 'out/safe-outputs.jsonl'))).type, 'noop');
// Real process/time smoke, accelerated only via the module's test seam.
await soak.loop('1', temp, { minuteMs: 30, get: () => ({ status: '200', transport: 0 }), emit: () => {} });
console.log('ok soak input rejection, hosted parity, canary, fake-only blocked route, failure continuation and short smoke');
}
main().catch(error => { console.error(error); process.exitCode = 1; })
.finally(() => fs.rmSync(temp, { recursive: true, force: true }));
- name: Test scheduled pass restart
shell: node {0}
run: |
const assert = require('node:assert/strict');
const fs = require('node:fs');
const { spawnSync } = require('node:child_process');
const pin = fs.readFileSync('.github/workflows/agent-board-pin.yml', 'utf8');
const poll = fs.readFileSync('.github/workflows/poll.yml', 'utf8');
const [header, jobs] = pin.split('\njobs:\n');
const [job, bump] = jobs.split('\n bump:\n');
assert.match(header, /on:\n schedule:/);
assert.doesNotMatch(header, /^concurrency:/m);
assert.match(job, /concurrency:\n group: poll-restart\n cancel-in-progress: false/);
assert.match(bump, /concurrency:\n group: agent-board-pin\n cancel-in-progress: false/);
assert.doesNotMatch(poll, /^ schedule:/m);
assert.match(poll, /^run-name: pass\$\{\{ inputs.apply && ' \(apply\)' \|\| '' \}\}$/m);
assert.match(job, /permissions:\n actions: write\n steps:/);
assert.match(job, /GH_TOKEN: \$\{\{ github.token \}\}/);
assert.doesNotMatch(job, /uses:|secrets\./);
const interval = /^ PASS_INTERVAL_MINUTES: (\d+)$/m.exec(poll)[1];
assert.equal(/^ PASS_INTERVAL_MINUTES: (\d+)$/m.exec(job)[1], interval);
const gate = /^ if: \$\{\{ (.*) \}\}$/m.exec(job)[1];
const repo = 'owner/repo', branch = 'release/trunk';
for (const event_name of ['schedule', 'workflow_dispatch']) for (const PASS_APPLY of ['', 'disabled', 'enabled']) {
for (const ref of [`refs/heads/${branch}`, 'refs/heads/main', `refs/tags/${branch}`]) {
const got = require('node:vm').runInNewContext(gate, { vars: { PASS_APPLY },
github: { ref, event_name, event: { repository: { default_branch: branch } } },
format: (template, value) => template.replace('{0}', value),
});
assert.equal(got, event_name === 'schedule' && PASS_APPLY === 'enabled' && ref === `refs/heads/${branch}`);
}
}
const script = job.split(' shell: node {0}\n run: |\n')[1].replace(/^ /gm, '');
const temp = fs.mkdtempSync(require('node:path').join(require('node:os').tmpdir(), 'poll-restart-'));
try {
const now = Date.parse('2026-11-21T18:00:00Z');
const at = ms => new Date(ms).toISOString();
const cutoff = now - 2 * interval * 60_000;
fs.writeFileSync(`${temp}/clock.cjs`, `Date.now = () => ${now};\n`);
fs.writeFileSync(`${temp}/restart.cjs`, script);
fs.writeFileSync(`${temp}/gh`, `#!${process.execPath}
const fs = require('node:fs');
const assert = require('node:assert/strict');
const { execFileSync } = require('node:child_process');
const args = process.argv.slice(2);
fs.appendFileSync('calls', JSON.stringify(args) + '\\n');
if (args[0] === 'workflow') process.exit(Number(process.env.DISPATCH_EXIT || 0));
const { runs, overrides, attempts } = JSON.parse(fs.readFileSync('fixture', 'utf8'));
let response;
const attempt = new RegExp('^repos/owner/repo/actions/runs/([0-9]+/attempts/[0-9]+)/jobs[?]per_page=1$').exec(args[1]);
const projection = args.at(-1);
if (attempt) {
assert.deepEqual(args, ['api', args[1], '--jq', projection]);
assert.ok(Object.hasOwn(attempts, attempt[1]), args[1]);
response = attempts[attempt[1]];
} else {
const status = args.find(a => a.startsWith('status='));
const created = args.find(a => a.startsWith('created='));
assert.deepEqual(args, ['api', '--method', 'GET', 'repos/owner/repo/actions/workflows/poll.yml/runs',
'-f', 'branch=release/trunk', '-f', 'per_page=100', ...(status ? ['-f', status] : []),
...(created ? ['-f', ${JSON.stringify('created=>=' + at(cutoff).replace('.000Z', 'Z'))}] : []), '--jq', projection]);
const selected = runs.filter(run => (!status || run.status === status.slice(7)) &&
(!created || Date.parse(run.created_at) >= Date.parse(created.slice('created=>='.length))));
response = overrides[status?.slice(7) ?? (created ? 'recent' : 'latest')] ??
{ total_count: selected.length, workflow_runs: selected.slice(0, 100) };
if (process.env.LARGE && !status && !created) assert.ok(Buffer.byteLength(JSON.stringify(response)) > 1024 * 1024);
}
if (response === 'error') process.exit(1);
process.stdout.write(execFileSync('jq', ['-c', projection], { input: JSON.stringify(response) }));
`, { mode: 0o755 });
const run = { id: 42, created_at: at(cutoff - 1000), head_branch: branch,
event: 'workflow_dispatch', display_title: 'pass (apply)', status: 'completed' };
const preview = { ...run, id: 43, created_at: at(now), display_title: 'pass' };
const scheduled = { ...run, id: 41, event: 'schedule', display_title: 'pass' };
const oldPreviews = Array.from({ length: 201 }, (_, i) => ({ ...preview, id: 1000 - i, created_at: at(cutoff - 2000) }));
const dispatch = ['workflow', 'run', 'poll.yml', '--repo', repo, '--ref', branch, '-f', 'apply=true'];
function check(runs, overrides, exit, writes, reason, extra = {}, attempts = {}) {
fs.writeFileSync(`${temp}/calls`, '');
fs.writeFileSync(`${temp}/fixture`, JSON.stringify({ runs, overrides, attempts }));
const got = spawnSync(process.execPath, ['--require', './clock.cjs', 'restart.cjs'], { cwd: temp,
timeout: 10000, encoding: 'utf8', env: { PATH: `${temp}:${process.env.PATH}`, DEFAULT_BRANCH: branch,
GITHUB_REPOSITORY: repo, PASS_INTERVAL_MINUTES: interval, ...extra } });
const calls = fs.readFileSync(`${temp}/calls`, 'utf8').trim().split('\n').filter(Boolean).map(JSON.parse);
assert.equal(got.status, exit, got.error?.message ?? got.stderr);
assert.match(exit ? got.stderr : got.stdout, reason);
assert.deepEqual(calls.filter(args => args[0] === 'workflow'), writes);
return calls;
}
check([preview, run], {}, 0, [dispatch], /dispatch accepted/);
check([{ ...preview, status: 'in_progress' }, { ...scheduled, head_branch: 'other', status: 'queued' }], {}, 0, [dispatch], /dispatch accepted/);
check([...oldPreviews.map(r => ({ ...r, unused: 'x'.repeat(12000) })), run], {}, 0, [dispatch], /dispatch accepted/, { LARGE: '1' });
// Shape from stranded GitHub runs 43388110612 and 39273706807.
const ghost = { ...run, id: 43388110612, display_title: 'poll', status: 'queued', run_attempt: 1,
created_at: '2026-11-13T07:46:07Z', updated_at: '2026-11-13T07:46:07Z' };
const empty = { total_count: 0, jobs: [] };
check([run, ghost], {}, 0, [dispatch], /Ignoring stale queued poll run 43388110612.*has no jobs/, {}, { '43388110612/attempts/1': empty });
check([{ ...ghost, updated_at: at(now), run_attempt: 2 }], {}, 0, [], /run 43388110612 is queued/);
const olderScheduled = { ...ghost, id: scheduled.id, event: 'schedule', run_attempt: 2 };
check([olderScheduled], {}, 0, [], /run 41 is queued/, {}, { '41/attempts/2': { total_count: 2, jobs: [{ id: 55 }] } });
check([olderScheduled], {}, 1, [], /invalid job listing/, {}, { '41/attempts/2': { total_count: 1, jobs: [] } });
const ghosts = Array.from({ length: 9 }, (_, i) => ({ ...ghost, id: ghost.id - i }));
const attempts = Object.fromEntries(ghosts.map(row => [`${row.id}/attempts/1`, empty]));
const lookups = calls => calls.filter(args => args[1]?.includes('/attempts/'));
assert.equal(lookups(check(ghosts.slice(0, 5), {}, 0, [dispatch], /dispatch accepted/, {}, attempts)).length, 5);
assert.equal(lookups(check(ghosts, {}, 1, [], /job listing budget exhausted/, {}, attempts)).length, 8);
const newAttempt = { ...ghost, run_attempt: 2, updated_at: '2026-11-14T07:46:07Z' };
const latest = { total_count: 1, workflow_runs: [newAttempt] };
check([ghost], { latest }, 0, [], /run 43388110612 is queued/, {}, {
...attempts, '43388110612/attempts/2': { total_count: 1, jobs: [{ id: 55 }] },
});
for (const status of ['queued', 'waiting', 'pending', 'requested', 'in_progress']) {
for (const owner of [run, scheduled, { ...run, event: 'future_trigger', display_title: 'future' }]) {
check([run, { ...owner, id: 44, status }], {}, 0, [], new RegExp(`run 44 is ${status}`));
}
}
// A run can finish or be requeued between the independent snapshots.
for (const owner of [run, scheduled]) {
check([run], { recent: { total_count: 1, workflow_runs: [{ ...owner, created_at: at(cutoff) }] } }, 0, [], /was created at or after/);
check([run], { latest: { total_count: 2, workflow_runs: [run, { ...owner, id: 44, status: 'queued' }] } }, 0, [], /run 44 is queued/);
}
const queued = oldPreviews.map(r => ({ ...r, status: 'queued' }));
assert.equal(check(queued, {}, 1, [], /queued poll run listing exceeded/).length, 1);
check(oldPreviews.map(r => ({ ...r, created_at: at(now) })), {}, 1, [], /recent poll run listing exceeded/);
check([], { recent: { total_count: 1, workflow_runs: [] } }, 1, [], /incomplete or invalid/);
check([], { recent: { total_count: 2, workflow_runs: [preview, preview] } }, 1, [], /invalid or repeated/);
check([], { recent: { total_count: 1, workflow_runs: [run] } }, 1, [], /invalid or repeated/);
check([], { in_progress: 'error' }, 1, [], /check failed/);
check([run], {}, 1, [dispatch], /check failed/, { DISPATCH_EXIT: '1' });
} finally { fs.rmSync(temp, { recursive: true, force: true }); }
console.log('ok offline restart gate, legacy and future owners, bounded reads and dispatch');
- name: Test overdue promotion wake
shell: node {0}
run: |
const assert = require('node:assert/strict');
const { execFileSync } = require('node:child_process');
const { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } = require('node:fs');
const { tmpdir } = require('node:os');
const { join } = require('node:path');
const { test } = require('node:test');
const { runInNewContext } = require('node:vm');
const workflow = readFileSync('.github/workflows/poll.yml', 'utf8');
const repo = 'owner/repo';
const branch = 'trunk';
const now = Date.parse('2026-11-21T23:00:00Z');
const states = ['queued', 'waiting', 'pending', 'requested', 'in_progress'];
const runs = (...workflow_runs) => ({ total_count: workflow_runs.length, workflow_runs });
const latest = minutes => runs({ status: 'completed', created_at: new Date(now - minutes * 60_000).toISOString() });
const list = filter => ['api', '--method', 'GET', `repos/${repo}/actions/workflows/promote.yml/runs`, '-f', 'per_page=1', '-f', filter];
const history = list(`branch=${branch}`);
const active = states.map(status => list(`status=${status}`));
const dispatch = ['workflow', 'run', 'promote.yml', '--repo', repo, '--ref', branch];
const enabled = { promote: { publish: true } };
function wakeScript() {
const step = /^ {6}- name: Start promote if overdue\n((?: {8}.*\n)+)/m.exec(workflow)?.[1];
assert.ok(step, 'promote wake step exists');
const next = workflow.slice(workflow.indexOf('\n next:\n'), workflow.indexOf('\n next-fallback:\n'));
assert.ok(next.includes(step), 'only the next job wakes promote');
assert.match(step, /^ {8}continue-on-error: true$/m);
assert.match(step, /^ {8}timeout-minutes: 2$/m);
assert.match(step, /^ {10}GH_TOKEN: \$\{\{ github.token \}\}$/m);
assert.match(step, /^ {8}shell: node \{0\}$/m);
return /^ {8}run: \|\n((?: {10}.*\n)+)/m.exec(step)[1].replace(/^ {10}/gm, '');
}
function wake(config, responses) {
let calls = 0;
try {
runInNewContext(wakeScript(), {
Date: class extends Date { static now() { return now; } },
process: { env: { GITHUB_REPOSITORY: repo, DEFAULT_BRANCH: branch } },
console: { log() {} },
require(module) {
if (module === 'node:fs') return { readFileSync(file) {
assert.equal(file, '.github/pass.json');
return JSON.stringify(config);
} };
assert.equal(module, 'node:child_process');
return { execFileSync(command, args, options) {
assert.equal(command, 'gh');
assert.equal(options.timeout, 10_000);
const expected = responses[calls++];
assert.ok(expected, `unexpected call: ${args.join(' ')}`);
assert.deepEqual([...args], expected[0]);
if (expected[1] instanceof Error) throw expected[1];
return JSON.stringify(expected[1]);
} };
},
});
} finally {
assert.equal(calls, responses.length);
}
}
test('promote wake is off unless the caller enables publication', () => {
for (const config of [{}, { promote: {} }, { promote: { publish: false } }, { promote: { publish: 'true' } }]) wake(config, []);
});
test('promote wakes once when history is absent or the newest run is over 60 minutes old', () => {
for (const entry of [runs(), latest(61)]) wake(enabled, [[history, entry], ...active.map(args => [args, runs()]), [history, entry], [dispatch]]);
for (const age of [0, 59, 60]) wake(enabled, [[history, latest(age)]]);
});
test('any active promote run prevents a wake even when the newest run is old and completed', () => {
for (const [i, status] of states.entries()) {
wake(enabled, [[history, latest(61)], ...active.slice(0, i).map(args => [args, runs()]), [active[i], runs({ status })]]);
}
wake(enabled, [[history, runs({ status: 'in_progress' })]]);
});
test('a cron run queued during the active-run checks prevents dispatch', () => {
const dir = mkdtempSync(join(tmpdir(), 'poll-promote-'));
try {
mkdirSync(join(dir, '.github'));
writeFileSync(join(dir, '.github/pass.json'), JSON.stringify(enabled));
writeFileSync(join(dir, 'wake.cjs'), wakeScript());
writeFileSync(join(dir, 'gh'), `#!${process.execPath}
const fs = require('node:fs');
const args = process.argv.slice(2);
if (args[0] !== 'api') throw new Error('unexpected dispatch');
if (args.includes('status=waiting')) fs.writeFileSync('cron-queued', '');
const cronQueued = fs.existsSync('cron-queued');
const workflow_runs = args.includes('branch=trunk')
? [cronQueued ? { status: 'queued', created_at: new Date().toISOString() }
: { status: 'completed', created_at: '2000-01-01T00:00:00Z' }]
: cronQueued && args.includes('status=queued') ? [{ status: 'queued' }] : [];
console.log(JSON.stringify({ total_count: workflow_runs.length, workflow_runs }));
`, { mode: 0o755 });
execFileSync(process.execPath, ['wake.cjs'], {
cwd: dir, env: { PATH: `${dir}:${process.env.PATH}`, GITHUB_REPOSITORY: repo, DEFAULT_BRANCH: branch },
});
assert.equal(readFileSync(join(dir, 'cron-queued'), 'utf8'), '');
} finally {
rmSync(dir, { recursive: true, force: true });
}
});
test('an unreadable check does not dispatch, and a dispatch failure is not retried', () => {
const apiError = new Error('fixture API failure');
for (const input of [apiError, {}, runs({ status: 'completed', created_at: 'invalid' })]) {
assert.throws(() => wake(enabled, [[history, input]]), /fixture API failure|invalid promote/);
}
assert.throws(() => wake(enabled, [[history, latest(61)], [active[0], apiError]]), apiError);
const checked = [[history, runs()], ...active.map(args => [args, runs()])];
assert.throws(() => wake(enabled, [...checked, [history, apiError]]), apiError);
assert.throws(() => wake(enabled, [...checked, [history, runs()], [dispatch, apiError]]), apiError);
});
# Also executed by just test-supervisor-workflow, with local mock artifacts.
- name: Test supervisor artifact hand-back
shell: node {0}
run: |
const assert = require('node:assert/strict');
const fs = require('node:fs');
const { execFileSync, spawnSync } = require('node:child_process');
const { createHash } = require('node:crypto');
const { runInNewContext } = require('node:vm');
const workflow = fs.readFileSync('.github/workflows/supervisor.yml', 'utf8');
const execute = workflow.split('\n execute:\n')[1];
const gate = / if: >-\n((?: {6}.*\n)+)/.exec(execute)[1];
const input = /research-artifact-only: \$\{\{ (.*?) \}\}/.exec(workflow)[1];
const guard = name => new RegExp(`- name: ${name}\n(?: +id: .*\n)? +if: [$][{][{] (.*?) [}][}]`).exec(execute)[1];
for (const [handback, status, url, commentPath, artifactPath] of [
['', '', 'comment', true, false], ['', 'ready', '', false, false],
['artifact', 'ready', '', false, true], ['artifact', 'unavailable', 'comment', false, false],
['artifact', '', 'comment', false, false],
]) {
for (const mode of ['preview', 'apply']) {
const context = { vars: { SUPERVISOR: mode, SUPERVISOR_HANDBACK: handback },
needs: { agent: { outputs: { 'result-url': url, 'research-status': status } } } };
const evaluate = expression => runInNewContext(expression.replace(/outputs\.([\w-]+)/g, 'outputs["$1"]'), context);
assert.equal(evaluate(input), handback === 'artifact');
assert.equal(evaluate(gate), commentPath || artifactPath);
for (const [name, expected] of [
['Preview requests without applying', commentPath && mode === 'preview'],
['Perform the validated requests', commentPath && mode === 'apply'],
['Verify and stage artifact hand-back', artifactPath],
['Preview artifact requests without applying', artifactPath && mode === 'preview'],
['Perform the validated artifact requests', artifactPath && mode === 'apply'],
]) assert.equal(evaluate(gate) && evaluate(guard(name)), expected, name);
}
}
assert.match(execute, /group: supervisor-execute\n +cancel-in-progress: false/);
assert.match(execute, /shell: bash[^]*?--ledger-out "\$REQUESTS_DIR\/next\/ledger\.json"/);
assert.match(execute, /name: supervisor-executor-ledger\n +path: .*\/next\/ledger\.json/);
const upload = guard('Upload executor ledger').replaceAll('steps.execute-artifact', 'steps["execute-artifact"]');
for (const outcome of ['success', 'failure', 'skipped']) {
assert.equal(runInNewContext(upload, { cancelled: () => false, steps: { 'execute-artifact': { outcome } } }), outcome !== 'skipped');
}
const script = /python3 - <<'PY'\n([^]*?) PY/.exec(execute)[1].replace(/^ {10}/gm, '');
const temp = fs.mkdtempSync(require('node:path').join(require('node:os').tmpdir(), 'supervisor-handback-'));
const repo = 'owner/tracker', api = `repos/${repo}/actions/`;
const makeZip = (name, text) => execFileSync('python3', ['-c',
'import sys, zipfile; z = zipfile.ZipFile(sys.stdout.buffer, "w"); z.writestr(sys.argv[1], sys.argv[2]); z.close()', name, text]);
const requests = '{"type":"add_comment","body":"request data"}\n';
const ledger = JSON.stringify({ schema: 'agent-board/supervisor-ledger/v1', runNumber: 41, blockedUntil: null, entries: [] }) + '\n';
const requestsZip = makeZip('outputs.jsonl', requests), ledgerZip = makeZip('ledger.json', ledger);
const artifact = (id, run, zip) => ({ id, workflow_run: { id: run }, expired: false, digest: 'sha256:' + createHash('sha256').update(zip).digest('hex') });
const original = artifact(90, 42, requestsZip), prior = artifact(89, 41, ledgerZip), older = artifact(88, 40, ledgerZip);
const run = (id, n = id, path = '.github/workflows/supervisor.yml') => ({ id, path, head_repository: { full_name: repo },
head_branch: 'main', event: 'schedule', head_sha: 'fixture', run_number: n, run_attempt: 1 });
const page = (key, entries) => ({ total_count: entries.length, [key]: entries });
const currentJobs = 'runs/42/attempts/1/jobs?per_page=100';
const ledgerList = 'artifacts?name=supervisor-executor-ledger&per_page=100';
const routes = {
'runs/42': run(42), 'runs/41': run(41), 'runs/40': run(40), 'runs/39': run(39, 50, '.github/workflows/other.yml'),
[currentJobs]: page('jobs', [{ id: 100, run_attempt: 1, conclusion: 'success' }]),
'artifacts/90': original, 'artifacts/90/zip': requestsZip.toString('base64'),
[ledgerList]: page('artifacts', [older, artifact(87, 39, ledgerZip), prior]),
'runs/41/attempts/1/jobs?per_page=100': page('jobs', [{ name: 'execute', conclusion: 'failure', steps: [{ name: 'Upload executor ledger', conclusion: 'success' }] }]),
'artifacts/89': prior, 'artifacts/89/zip': ledgerZip.toString('base64'),
};
try {
fs.writeFileSync(`${temp}/gh`, `#!/usr/bin/env node
const fs = require('node:fs');
const url = process.argv[3];
if (process.argv[2] !== 'api' || !url.startsWith(${JSON.stringify(api)})) process.exit(2);
const reply = JSON.parse(fs.readFileSync(process.env.FIXTURE))[url.slice(${api.length})];
if (reply === undefined) throw new Error('Unexpected request: ' + url);
process.stdout.write(typeof reply === 'string' ? Buffer.from(reply, 'base64') : JSON.stringify(reply));
`, { mode: 0o700 });
const probe = (overrides = {}, mode = 'apply', extraEnv = {}) => {
const fixture = `${temp}/fixture.json`, output = `${temp}/output`;
fs.writeFileSync(fixture, JSON.stringify({ ...routes, ...overrides }));
fs.writeFileSync(output, '');
const result = spawnSync('python3', ['-c', script], { encoding: 'utf8', env: {
PATH: `${temp}:${process.env.PATH}`, FIXTURE: fixture, RUNNER_TEMP: temp, GITHUB_OUTPUT: output,
GITHUB_REPOSITORY: repo, GITHUB_RUN_ID: '42', GITHUB_RUN_ATTEMPT: '1', GITHUB_SHA: 'fixture',
GITHUB_RUN_NUMBER: '42', DEFAULT_BRANCH: 'main', NEEDS_LEDGER: String(mode === 'apply'), HANDBACK_REPO: repo, HANDBACK_RUN: '42',
HANDBACK_ATTEMPT: '1', PRODUCER: '100', REQUESTS_ID: '90', REQUESTS_DIGEST: original.digest.slice(7), ...extraEnv,
} });
return { ...result, outputs: Object.fromEntries(fs.readFileSync(output, 'utf8').trim().split('\n').filter(Boolean).map(line => line.split('='))) };
};
const ready = probe();
assert.equal(ready.status, 0, ready.stderr);
assert.equal(ready.outputs['ledger-run'], '41');
assert.equal(fs.readFileSync(`${ready.outputs.directory}/outputs.jsonl`, 'utf8'), requests);
assert.equal(fs.readFileSync(`${ready.outputs.directory}/ledger.json`, 'utf8'), ledger);
assert.ok(fs.statSync(`${ready.outputs.directory}/next`).isDirectory());
// The real shell pipeline must surface a failure even when the
// executor already wrote the ledger and tee succeeds.
const perform = /id: execute-artifact\n[^]*?run: \|\n((?: {10}.*\n)+)/.exec(execute)[1].replace(/^ {10}/gm, '');
fs.mkdirSync(`${temp}/agent-board/bin`, { recursive: true });
fs.writeFileSync(`${temp}/agent-board/bin/agent-board`, `#!/usr/bin/env node
const assert = require('node:assert/strict');
const args = process.argv.slice(2);
const value = key => args[args.indexOf(key) + 1];
assert.deepEqual(args.slice(0, 2), ['supervise', 'execute']);
assert.equal(value('--requests'), process.env.REQUESTS_DIR + '/outputs.jsonl');
assert.equal(value('--ledger'), process.env.REQUESTS_DIR + '/ledger.json');
assert.equal(value('--ledger-run'), '41');
require('node:fs').writeFileSync(value('--ledger-out'), 'reserved');
process.exit(7);
`, { mode: 0o700 });
const failedWrite = spawnSync('bash', ['-e', '-o', 'pipefail', '-c', perform], { encoding: 'utf8', env: {
PATH: process.env.PATH, RUNNER_TEMP: temp, REQUESTS_DIR: ready.outputs.directory, LEDGER_RUN: ready.outputs['ledger-run'],
GITHUB_STEP_SUMMARY: `${temp}/summary`,
} });
assert.equal(failedWrite.status, 7, failedWrite.stderr);
assert.equal(fs.readFileSync(`${ready.outputs.directory}/next/ledger.json`, 'utf8'), 'reserved');
const preview = probe({ [ledgerList]: undefined }, 'preview');
assert.equal(preview.status, 0, preview.stderr);
assert.equal(preview.outputs['ledger-run'], undefined);
assert.notEqual(preview.outputs.directory, ready.outputs.directory);
for (const [changes, error, extra] of [
[{ 'runs/42': { ...run(42), run_attempt: 2 }, 'runs/42/attempts/2/jobs?per_page=100':
page('jobs', [{ id: 99, run_attempt: 2, conclusion: 'success' }]) }, /producer is absent/, { GITHUB_RUN_ATTEMPT: '2', HANDBACK_ATTEMPT: '2' }],
[{ 'runs/42': { ...run(42), run_attempt: 2 } }, /not for the latest attempt/],
[{}, /not this repository, run and attempt/, { HANDBACK_ATTEMPT: '2' }],
[{ 'artifacts/90': artifact(90, 41, requestsZip) }, /metadata does not match/],
[{ 'artifacts/90': artifact(90, 42, ledgerZip) }, /metadata does not match/],
[{ 'artifacts/90/zip': ledgerZip.toString('base64') }, /download digest mismatch/],
[{ [ledgerList]: page('artifacts', []) }, /No prior supervisor executor ledger/],
[{ 'artifacts/89': { ...prior, expired: true } }, /metadata does not match/],
]) {
const result = probe(changes, 'apply', extra);
assert.notEqual(result.status, 0);
assert.match(result.stderr, error);
assert.deepEqual(result.outputs, {});
}
} finally {
fs.rmSync(temp, { recursive: true, force: true });
}
console.log('ok supervisor workflow routing, same-run artifact verification and ledger continuity');
# Also executed by just test-pass-state; keep script growth out of Justfile.
- name: Test pass state export
shell: node {0}
run: |
const assert = require('node:assert/strict');
const fs = require('node:fs');
const { execFileSync, spawnSync } = require('node:child_process');
const poll = fs.readFileSync('.github/workflows/poll.yml', 'utf8');
const source = poll.split(' - name: Validate predecessor\n')[1].split(' run: |\n')[1]
.split('\n - name: Restore pass state\n')[0].replace(/^ /gm, '');
const fixture = { exports: {} };
new Function('require', 'module', source)(require, fixture);
const { publicState, validate, checkCache } = fixture.exports;
const env = { GITHUB_RUN_ID: '42', GITHUB_REPOSITORY: 'owner/tracker', DEFAULT_BRANCH: 'main' };
const prior = { id: 41, run_attempt: 1, workflow_id: 123, path: '.github/workflows/poll.yml', head_branch: 'main',
repository: { full_name: env.GITHUB_REPOSITORY }, head_repository: { full_name: env.GITHUB_REPOSITORY },
event: 'workflow_dispatch', display_title: 'pass (apply)' };
const jobs = { total_count: 2, jobs: [{ name: 'pass', status: 'completed', conclusion: 'success' },
{ name: 'next', status: 'in_progress' }] };
function predecessor(change = {}, jobChange = {}, extra = {}) {
const calls = [];
const id = validate({ ...env, PREVIOUS_RUN_ID: '41', ...extra }, endpoint => {
calls.push(endpoint);
assert.ok(calls.length <= 3);
if (endpoint.endsWith('/workflows/poll.yml')) return { id: 123 };
if (endpoint.includes('/jobs?')) {
const attempt = { ...prior, ...change }.run_attempt;
assert.equal(endpoint, `repos/owner/tracker/actions/runs/41/${attempt == null ? 'jobs?filter=latest&' : `attempts/${attempt}/jobs?`}per_page=100`);
return { ...jobs, ...jobChange };
}
assert.equal(endpoint, 'repos/owner/tracker/actions/runs/41');
return { ...prior, ...change };
});
return { id, calls };
}
const first = { id: '41', key: 'pass-responses-41-1' };
const second = { id: '41', key: 'pass-responses-41-2' };
assert.deepEqual(predecessor().id, first);
assert.deepEqual(predecessor({ run_attempt: 2 }).id, second);
assert.deepEqual(predecessor({ run_attempt: null }).id, { id: '41', key: '' });
assert.deepEqual(predecessor({ event: 'schedule', display_title: 'pass' }).id, first);
assert.deepEqual(predecessor({}, { jobs: [{ ...jobs.jobs[0], conclusion: 'failure' }], total_count: 1 }).id, first);
for (const change of [{ workflow_id: 124 }, { id: 40 }, { path: '.github/workflows/other.yml' },
{ repository: { full_name: 'other/tracker' } }, { head_repository: { full_name: 'fork/tracker' } },
{ head_branch: 'feature' }, { event: 'pull_request' }, { event: 'push' }, { display_title: 'pass' }]) {
assert.equal(predecessor(change).id, null, JSON.stringify(change));
}
for (const change of [{ total_count: 101 }, { jobs: [] }, { jobs: null },
{ jobs: [jobs.jobs[0], jobs.jobs[0]] },
...['in_progress', 'queued'].map(status => ({ total_count: 1, jobs: [{ ...jobs.jobs[0], status }] })),
...['cancelled', 'skipped', null].map(conclusion => ({ total_count: 1, jobs: [{ ...jobs.jobs[0], conclusion }] }))]) {
assert.equal(predecessor({}, change).id, null, JSON.stringify(change));
}
for (const id of ['42', '0', '-1', '../41', '41;exit', '1'.repeat(21)]) {
assert.deepEqual(predecessor({}, {}, { PREVIOUS_RUN_ID: id }), { id: null, calls: [] });
}
// Empty input (schedule or manual bootstrap) discovers, then revalidates,
// exactly the same predecessor that an explicit dispatch would restore.
for (const event of ['schedule', 'workflow_dispatch']) {
const calls = [];
const get = endpoint => {
calls.push(endpoint);
if (endpoint.includes('/runs?')) return { workflow_runs: [
{ ...prior, id: 43 }, { ...prior, id: 40 }, { ...prior, id: 42 }, { ...prior, event },
{ ...prior, id: 44, head_branch: 'other' }, { ...prior, id: 45, display_title: 'pass' }] };
if (endpoint.endsWith('/workflows/poll.yml')) return { id: 123 };
if (endpoint.includes('/jobs?')) return { total_count: 1, jobs: [{ name: 'pass', status: 'completed', conclusion: 'success' }] };
assert.ok(endpoint.endsWith('/runs/41')); return { ...prior, event };
};
assert.deepEqual(validate(env, get), first);
assert.deepEqual(validate({ ...env, PREVIOUS_RUN_ID: '41' }, get), first);
assert.equal(calls.length, 7, 'discovery still runs the three exact provenance checks');
assert.equal(validate(env, endpoint => endpoint.includes('/runs?') ? { workflow_runs: [prior] } :
endpoint.endsWith('/workflows/poll.yml') ? { id: 999 } : prior), null, 'reject discovered untrusted workflow');
}
assert.equal(validate(env, () => ({ workflow_runs: [] })), null);
assert.throws(() => validate(env, () => ({})));
const privateUrl = 'https://api.github.com/repos/owner/private/pulls/1/reviews';
const responses = Object.fromEntries(Array.from({ length: 45 }, (_, i) =>
[`${privateUrl}?page=${i + 1}`, { body: `private review ${i + 1}`, etag: 'fixture-validator', digest: 'b'.repeat(64) }]));
const pass_responses = { [privateUrl]: { body: 'unpublished review', last_modified: 'fixture-timestamp' } };
const response_cache = { key: 'legacy-cache-key', sha256: 'b'.repeat(64) };
const metadata = endpoint => {
if (endpoint.endsWith('/unknown')) throw new Error('API outage');
return { full_name: endpoint.endsWith('/mismatch') ? 'other/repo' : endpoint.slice(6),
private: endpoint.endsWith('/private'), visibility: /private|hidden/.test(endpoint) ? 'private' : 'public' };
};
const state = { schema: 'agent-board/poll-state/v1', interval_seconds: 300, share_cursor: 'owner/public#1',
follow_cursor: 'Owner/Public', authored_cursor: 'owner/private', action_first_cursor: 'owner/unknown',
scan_cursor: 'owner/mismatch', holds_summary_cursor: 'owner/public#2',
operator_cursor: '2026-11-22T00:00:00Z', operator_page: 2,
notify_since: '2026-11-22T00:00:00Z', notify_before: '2026-11-22T00:00:00Z',
intake_waiting: { 'owner/private#2': 'fixture' }, intake_refused: ['owner/private#3/4'],
lock_refused: { 'owner/private#5': 'fixture' }, maintain: { fixture: 'private metadata' }, future_field: 'private metadata',
responses, pass_responses, response_cache, response_scope: 'a'.repeat(64) };
const calls = [];
const handoff = publicState(state, endpoint => { calls.push(endpoint); return metadata(endpoint); });
assert.equal(publicState({ ...state, response_scope: 'owner/private' }, metadata).response_scope, undefined);
assert.deepEqual(handoff, { schema: state.schema, interval_seconds: 300, response_scope: state.response_scope,
share_cursor: state.share_cursor, follow_cursor: state.follow_cursor });
assert.deepEqual(publicState({ ...state, intake_waiting: {} }, metadata), handoff);
assert.equal(publicState({ ...state, scan_cursor: 'owner/hidden' }, metadata).scan_cursor, undefined);
assert.equal(calls.length, 4, 'one metadata check per distinct cursor repository');
const ref = 'refs/heads/main';
const entry = { key: second.key, ref, size_in_bytes: 1024 ** 3 };
const check = result => checkCache({ ...env, RESPONSE_CACHE_KEY: second.key }, endpoint => {
assert.equal(endpoint, `repos/owner/tracker/actions/caches?key=${second.key}&ref=refs%2Fheads%2Fmain&per_page=1`);
return result;
});
const listing = { total_count: 1, actions_caches: [entry] };
assert.equal(check(listing), entry.key, 'permit the exact cap');
for (const variant of [{ key: first.key }, { key: `${entry.key}0` }, { ref: 'refs/pull/1/merge' }, { size_in_bytes: entry.size_in_bytes + 1 },
{ size_in_bytes: '42' }, { size_in_bytes: 0 }, { size_in_bytes: null }]) {
assert.equal(check({ ...listing, actions_caches: [{ ...entry, ...variant }] }), '');
}
for (const result of [{}, { ...listing, total_count: 2 }, { total_count: 0, actions_caches: [] }]) {
assert.equal(check(result), '');
}
assert.equal(checkCache(env, () => assert.fail('unexpected lookup')), '');
const config = JSON.parse(fs.readFileSync('.github/pass.json', 'utf8'));
assert.equal(config.topDown, true); assert.equal(config.state, '.state/pass.json');
assert.equal(Object.hasOwn(config, 'livingStatus'), false, 'hosted poll must not enable living status');
assert.notEqual(config.cleanupHistory, true, 'cleanupHistory waits for reviewed preview candidates');
assert.match(poll, /PREVIOUS_RUN_ID: \$\{\{ inputs.previous_run_id \}\}/);
const restore = poll.split(' - name: Restore pass state\n')[1].split(' - name: One pass\n')[0];
assert.match(restore, /if: steps.predecessor.outputs.run-id != ''/);
assert.match(restore, /run-id: \$\{\{ steps.predecessor.outputs.run-id \}\}/);
assert.match(restore, /name: pass-state\n path: \.state\/handoff/);
assert.match(restore, /continue-on-error: true/);
assert.equal([...poll.matchAll(/vars\.PASS_RESPONSE_CACHE\b/g)].length, 1, 'normalize opt-in once');
assert.match(poll, /PASS_RESPONSE_CACHE_ENABLED: \$\{\{ vars\.PASS_RESPONSE_CACHE == 'enabled' && 'true' \|\| 'false' \}\}/);
assert.match(restore, /if: env\.PASS_RESPONSE_CACHE_ENABLED == 'true' && steps\.restore\.outcome == 'success'/);
assert.match(restore, /RESPONSE_CACHE_KEY: \$\{\{ steps\.predecessor\.outputs\.response-key \}\}/);
assert.match(restore, /if: steps\.cache-check\.outcome == 'success' && steps\.cache-check\.outputs\.key != ''/);
assert.match(restore, /timeout-minutes: 2\n uses: actions\/cache\/restore@[0-9a-f]{40} # v/);
assert.match(restore, /PASS_CACHE_EXTRACT: '1'/);
assert.match(restore, /path: \.state\/pass-responses\.enc\n key: \$\{\{ steps\.cache-check\.outputs\.key \}\}/);
assert.match(restore, /steps\.responses\.outputs\.cache-hit == 'true'/);
assert.match(restore, /PASS_CACHE_KEY: \$\{\{ steps\.responses\.outputs\.cache-hit == 'true' && secrets\.PASS_CACHE_KEY \|\| '' \}\}/);
assert.match(restore, /PASS_RESPONSE_CACHE_PAT: \$\{\{ steps\.responses\.outputs\.cache-hit == 'true' && secrets\.PASS_CACHE_KEY == '' && secrets\.CGWALTERS_BOT_PAT \|\| '' \}\}/);
assert.doesNotMatch(restore, /restore-keys:/);
assert.doesNotMatch(poll, /living-status/);
const [passStep, passCommand] = poll.split(' - name: One pass\n')[1].split(' run: |\n');
assert.doesNotMatch(passStep, /\n if:/);