Repository navigation
3054 lines (2866 loc) · 175 KB
/
Copy pathci.yml
File metadata and controls
3054 lines (2866 loc) · 175 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
name: CI
on:
push:
branches: [main] # Only run on pushes to main branch
pull_request:
# PRs vs `main`: the fast lanes (plan, workspace, the affected lanes, the package checks
# and the PR-only reports); the merge queue runs everything but viewer parity, which a pull request
# runs when its own diff touches a parity input (VP-1). A draft runs nothing until it is
# marked ready (`ready_for_review`). PRs targeting `production` only (trail PR): skip
# checks — release gate is staging smoke + human merge.
types: [opened, synchronize, reopened, ready_for_review]
branches-ignore:
- production
# The merge queue runs the required checks on the exact commit that will land:
# the PR on top of current `main` and every PR queued ahead of it. A green PR run
# only proves the PR against the `main` its run started from, and required checks
# are not strict, so two individually green PRs could land as a red `main`
# (2026-10-29: #1133 over #1239, incidents/2026-10-29-tau-main-red-revisions-tests).
merge_group:
types: [checks_requested]
env:
pnpm_config_verify_deps_before_run: warn
# Nx remote cache, provisioned by tau-cloud `tau-ci-cache`. The server is set only when a
# token is present (fork and Dependabot runs get none, and Nx fails on a tokenless 403).
# Same-repository pull request jobs granted `id-token: write` swap the read token for a session that
# writes only their own pull request's entries (tau-cloud CP-5b; setup-nx `nx-guard.ts`, item 5).
NX_SELF_HOSTED_REMOTE_CACHE_SERVER: ${{ secrets.NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN != '' && vars.NX_SELF_HOSTED_REMOTE_CACHE_SERVER || '' }}
NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN: ${{ secrets.NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN }}
TAU_API_URL: http://localhost:4000
TAU_WEBSOCKET_URL: ws://localhost:4001
TAU_FRONTEND_URL: http://localhost:3000
# A newer push to a pull request, Dependabot's included, cancels its outdated run;
# different PRs run side by side. Each push to `main` gets a group of its own and is
# never cancelled, so it neither waits for nor cancels another: in one shared group a
# run held the group until its last job ended,
# including a Darwin job waiting hours for a macOS runner, and each newer push was
# cancelled while pending, staging deploy and release commit included (2026-10-11,
# runs 38179340616 and 38183401821).
#
# Staging deploys live in `staging.yml`, not here: this workflow's result is the
# colour of `main` and the gate every release reads (`main-ci-success`), so it holds
# only checks a pull request also runs. Deploy-only failures (Netlify credits, Fly
# registry errors, a missing environment secret) made `main` red for 111 of 214 red
# hours in October 2026 with no code at fault
# (incidents/2026-10-29-tau-main-red-revisions-tests).
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# One affected computation for the lanes that need a project list or a flag: the
# service, browser, formal, GeoSpec, native-host, viewer-parity, end-to-end ratchet and
# package-check lanes, the PR-only reports, and
# `staging.yml` (the `ci-plan` artifact). The `affected-lane` jobs do not wait
# for it: they run their own `nx affected` and read the queue verdict themselves.
# Every selector here is a tag, a target name or a project type — no job in this
# workflow may name a project, except the shell lane's path check below, which names
# `sandbox`, the project whose rows those paths feed (shell split blueprint rows 15, 17).
plan:
name: Plan affected lanes
# A draft pull request runs no CI (the runner pool is the queue's bottleneck,
# 2026-11-10); marking it ready runs this workflow.
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
permissions: # Required for nrwl/nx-set-shas to read workflow runs
contents: 'read'
actions: 'read'
pull-requests: 'read'
outputs:
apps: ${{ steps.plan.outputs.apps }}
api: ${{ steps.plan.outputs.api }}
api-image: ${{ steps.plan.outputs.api-image }}
billing: ${{ steps.plan.outputs.billing }}
cli-e2e: ${{ steps.plan.outputs.cli-e2e }}
size: ${{ steps.plan.outputs.size }}
formal: ${{ steps.plan.outputs.formal }}
formal-nightly: ${{ steps.plan.outputs.formal-nightly }}
formal-nightly-projects: ${{ steps.plan.outputs.formal-nightly-projects }}
geospec-examples: ${{ steps.plan.outputs.geospec-examples }}
browser: ${{ steps.plan.outputs.browser }}
browser-projects: ${{ steps.plan.outputs.browser-projects }}
native-hosts: ${{ steps.plan.outputs.native-hosts }}
native-darwin: ${{ steps.plan.outputs.native-darwin }}
native-darwin-projects: ${{ steps.plan.outputs.native-darwin-projects }}
native-linux: ${{ steps.plan.outputs.native-linux }}
viewer-parity: ${{ steps.plan.outputs.viewer-parity }}
desktop: ${{ steps.plan.outputs.desktop }}
desktop-projects: ${{ steps.plan.outputs.desktop-projects }}
shell: ${{ steps.plan.outputs.shell }}
shell-projects: ${{ steps.plan.outputs.shell-projects }}
windows-unit: ${{ steps.plan.outputs.windows-unit }}
windows-unit-rows: ${{ steps.plan.outputs.windows-unit-rows }}
e2e-queue: ${{ steps.plan.outputs.e2e-queue }}
e2e-queue-suites: ${{ steps.plan.outputs.e2e-queue-suites }}
e2e-queue-early: ${{ steps.plan.outputs.e2e-queue-early }}
e2e-queue-early-suites: ${{ steps.plan.outputs.e2e-queue-early-suites }}
e2e-shadow: ${{ steps.plan.outputs.e2e-shadow }}
e2e-shadow-suites: ${{ steps.plan.outputs.e2e-shadow-suites }}
pkgcheck: ${{ steps.plan.outputs.pkgcheck }}
pkgcheck-shards: ${{ steps.plan.outputs.pkgcheck-shards }}
node-floor: ${{ steps.plan.outputs.node-floor }}
node-floor-shards: ${{ steps.plan.outputs.node-floor-shards }}
compute-qualify: ${{ steps.plan.outputs.compute-qualify }}
burn-in: ${{ steps.burn-in.outputs.burn-in }}
burn-in-units: ${{ steps.burn-in.outputs.burn-in-units }}
reused: ${{ steps.queue.outputs.run-id }}
affected-base: ${{ steps.queue.outputs.affected-base }}
steps:
# A queue run diffs against its first parent (`nx-set-shas` sets NX_BASE to `HEAD^1`
# on `merge_group`), so two commits are enough; pushes and pull requests keep full
# history, which `nx-set-shas` walks to find their base (a push with a merge-group run
# on its commit diffs against `HEAD^1` instead, `queue-verdict`).
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: ${{ github.event_name == 'merge_group' && 2 || 0 }}
# A push to `main` whose identical commit passed the merge queue reuses that
# verdict: no lane runs again. A push whose commit has a merge-group run diffs
# against that run's base (`affected-base`), so this plan selects what the queue did.
- name: Find the merge-queue verdict for this commit
id: queue
uses: ./.github/actions/queue-verdict
with:
github-token: ${{ github.token }}
# Only `workspace` saves a missed pnpm store in pull requests and the queue (a save
# is a 12–15 s post step on the job's end, X10). On a push the plan saves too: it is
# the one job that sets up Nx on every push, and a push that reuses the queue verdict
# skips `workspace`'s setup, while a store saved in the queue is scoped to the queue's
# ref and never reaches `main` or the pull requests that read it.
- name: Setup Nx Environment
uses: ./.github/actions/setup-nx
with:
save-pnpm-store: ${{ github.event_name == 'push' && 'true' || 'false' }}
affected-base: ${{ steps.queue.outputs.affected-base }}
# One `nx show projects --affected` and one graph, and each lane's projects selected
# from them by the tags, targets and project type in LANE_SELECTORS (seven separate
# `nx show projects --affected` calls took 31–50 s). A selector naming a tag or a
# target that no project has fails the step, rather than leaving its lane off.
- name: Compute affected lanes
id: plan
env:
REUSED: ${{ steps.queue.outputs.run-id }}
# Billing contracts: the project that owns them (`api-billing`) or one it depends on changed.
# CLI end-to-end suites: the project that owns them or one it depends on (the CLI) changed.
# API image: the project with the `docker:smoke` target (`api`) or one it depends on
# changed, so a change to another `scope:api` project (an end-to-end suite, `files`)
# does not rebuild the production image.
# Native host rows (`native-hosts.yml`): a `tag:ci:native-hosts` project (Build123d, PicoGK,
# the CLI) or a `test:native-linux` project is affected; the latter are also the linux-x64
# native rows it runs. Its Intel rows run at the desktop candidate gate, never here (INTEL-1).
# Native darwin rows (`native-darwin.yml`): a `test:native-darwin` project (Build123d, PicoGK, the
# CLI) is affected; `native-darwin-projects` names the rows. NATIVE_DARWIN_LANE_PATHS select every
# such project: that workflow and the nuget standalone oracle's sources outside the native closure,
# which its row's last steps read (go-live PRJ-1). Viewer parity (`viewer-parity.yml`, VP-1, operator ruling
# 2026-11-18 "PR-side + release gate"): never in the merge queue (`queue: never`, lockfile or not). A ready pull
# request runs it when its own diff touches a viewer-parity input (`pr: paths`): a path in VIEWER_PARITY_LANE_PATHS
# (the viewer and its capture code, the Three.js and camera packages it renders through, the image plugin, the
# render profile, the capture options, the parity scripts, manifest and committed fixtures, and the workflow), an
# example directory the parity manifest names as a fixture source, or a VIEWER_PARITY_PINS renderer pin in
# `pnpm-workspace.yaml` or its patch. Kernel code is not an input: the viewer and nanoraster draw the same GLB
# bytes, so a kernel change moves both sides alike; kernel tests and the GeoSpec contracts cover the geometry, and
# the release gate runs every fixture on every candidate. A push to `main` the queue did not prove runs it when
# the graph finds `tau-examples` affected; the release gate (`release-gate.yml`) runs it on every candidate.
# Desktop lane: a `tag:ci:desktop` project (the Electron app and, after the split, its services
# host). No job here runs it: the packaged suite runs on every staging candidate instead
# (operator decision D-DS1 (b), `desktop-packaged.yml`), so the lane is informational and
# `lanes.json` records it for the observed desktop lane rate.
# Shell lane: a `tag:ci:shell` project (the sandbox, native-process-core, the shell service, the
# host and the Terminal concern), in the merge queue only; `shell-projects` names the rows' projects.
# SHELL_LANE_PATHS select it too (with `sandbox`): the fixture producers and the workflow the graph
# does not see, checked here rather than as target `inputs`, which would mark `sandbox` and every
# project that depends on it affected in the ordinary lanes (shell split blueprint rows 15, 17).
# Formal nightly lane (`formal-nightly.yml`, CI throughput review Q-4): a project with a `formal:nightly`
# target is affected; the deep formal tiers run per project in the merge queue only, seeded by the commit.
# End-to-end ratchet (`e2e-queue`, operator ruling 2026-11-15): a project with a `test:e2e:queue` target
# is affected. That target's `dependsOn` lists the project's end-to-end suites that passed five consecutive
# e2e-nightly runs (two before 2026-11-17, when merge-queue defect MQ-3 raised the bar); `e2e-queue-suites`
# names one row per suite, and e2e-nightly.yml leaves them out.
# Shadow rows (`e2e-shadow`, operator ruling Q1, CI flake quarantine blueprint FQ-13): a project with a
# `test:e2e:shadow` target is affected. Its `dependsOn` lists the suites on probation for `test:e2e:queue`;
# `e2e-shadow-suites` names one row per suite, in the merge queue and on a push to `main` the queue did not
# prove, never on a pull request, and no row is required. A project whose `test:e2e:shadow` names a
# `metadata.lane` keeps its rows only when that lane is selected or the entry touches the project (DC-27).
# `pr` is a lane's pull-request rule; without it a pull request runs the lane as the queue does.
# "queue": the lane runs in the merge queue only. "touched": a pull request runs the lane only
# for the selected projects that own a file of its own diff (Nx's file-to-project map: the
# deepest project root above the file), never for one that is affected only through a dependency.
# "paths": a pull request runs the lane for every project with its target when its own diff touches one of
# the lane's paths, and not at all otherwise (viewer parity alone has a path list).
# `queue` is a lane's merge-queue rule, read against the entry's own diff (`HEAD^1`), so a change to a
# hub (`agent-host`, `host`) no longer carries every slow lane behind it (merge-queue defects MQ-2).
# "touched": the lane runs for the selected projects that own a file of the diff. "any-touched": the
# lane runs for every selected project when the diff touches one of them, and not at all otherwise.
# "closure": the lane runs for the selected projects whose own dependency closure holds a project the
# diff touches, walked without entering QUEUE_HUBS, so a hub change alone does not select them. "never": the
# lane never runs in the merge queue. The release gate (RG-1, which replaced the formal nightly's schedule) runs
# every `formal:nightly` project, the release gate every viewer-parity fixture, and the candidate gate the full
# shell tier. A diff that touches `pnpm-lock.yaml` applies no `queue` rule but "never".
# Node floor lane (`node-floor`, Brain research/node-26-ci-migration.md R2): an affected published package
# (`type:package`, the release projects) with a `test` target; its suites run again on the `engines.node`
# floor, Node 24, while every other lane runs setup-nx's Node 26 (compatibility policy: package tests and
# universal Wasm instantiation at the declared host floor). A pull request runs the packages its diff touches.
LANE_SELECTORS: >-
{"apps": {"type": "app"},
"api": {"tags": ["scope:api"], "pr": "touched"},
"api-image": {"targets": ["docker:smoke"]},
"billing": {"targets": ["test:billing-foundation"], "pr": "queue"},
"cli-e2e": {"targets": ["test:scenarios"], "pr": "queue"},
"size": {"targets": ["size"]},
"formal": {"targets": ["formal:tla"], "pr": "queue"},
"formal-nightly": {"targets": ["formal:nightly"], "pr": "queue", "queue": "touched"},
"geospec-examples": {"targets": ["test-geospec"], "pr": "queue"},
"browser": {"tags": ["ci:browser"], "targets": ["verify-browser"], "pr": "touched"},
"native-hosts": {"tags": ["ci:native-hosts"], "pr": "queue", "queue": "closure"},
"native-linux": {"targets": ["test:native-linux"], "pr": "queue", "queue": "closure"},
"native-darwin": {"targets": ["test:native-darwin"], "pr": "queue"},
"viewer-parity": {"targets": ["test:viewer-parity"], "pr": "paths", "queue": "never"},
"desktop": {"tags": ["ci:desktop"]},
"shell": {"tags": ["ci:shell"], "pr": "queue", "queue": "any-touched"},
"windows-unit": {"tags": ["ci:windows-unit"], "pr": "touched"},
"e2e-queue": {"targets": ["test:e2e:queue"], "pr": "touched"},
"e2e-shadow": {"targets": ["test:e2e:shadow"], "pr": "queue"},
"compute-qualify": {"targets": ["compute-qualify-ci"]},
"node-floor": {"tags": ["type:package"], "targets": ["test"], "pr": "touched"}}
QUEUE_HUBS: '["agent-host", "host"]'
SHELL_LANE_PATHS: >-
[".github/workflows/shell-conformance.yml",
"apps/desktop/scripts/hosted-linux-bwrap-fixture.mts",
"apps/desktop/scripts/linux-apt-package.mts",
"apps/desktop/scripts/runtime-stage.mts"]
# Compute reuse qualification lane (`compute-qualify`, audit R5): `runtime-e2e:compute-qualify-ci` asserts the
# Replicad reuse-off GLB hashes and work counts of `apps/runtime-e2e/src/compute-baseline`. runtime-e2e stays
# quarantined from the test lanes, and it is affected by most of the workspace, so the selector's project is
# kept only when a project the qualification measures is affected (COMPUTE_QUALIFY_LANE_PROJECTS) or a file it
# reads outside the graph changed (COMPUTE_QUALIFY_LANE_PATHS: the harness and the pinned example models).
COMPUTE_QUALIFY_LANE_PROJECTS: '["replicad", "picovoxel", "runtime", "middleware", "occt-core", "esbuild"]'
COMPUTE_QUALIFY_LANE_PATHS: >-
["apps/runtime-e2e/src/compute-baseline",
"apps/runtime-e2e/project.json",
"libs/tau-examples/src/kernels/replicad/gridfinity-box",
"libs/tau-examples/src/kernels/replicad/six-axis-arm",
"libs/tau-examples/src/kernels/replicad/spur-gearbox",
"libs/tau-examples/src/kernels/picovoxel/sphere-minus-beams",
"libs/tau-examples/src/kernels/picovoxel/lead-screw-stage"]
NATIVE_DARWIN_LANE_PATHS: >-
[".github/workflows/native-darwin.yml",
"scripts/src/check-standalone-project.ts",
"scripts/src/standalone-geometry.ts",
"apps/ui/app/constants/project.constants.ts",
"apps/ui/app/utils/kernel-libraries.ts",
"libs/tau-examples/src/standalone/picogk"]
# A file or a directory each. The manifest's example sources (`libs/tau-examples/src/kernels/<kernel>/<example>`)
# are read from the manifest itself, so a fixture added there is an input with no edit here.
VIEWER_PARITY_LANE_PATHS: >-
[".github/workflows/viewer-parity.yml",
"packages/viewer",
"packages/three",
"packages/camera",
"packages/plugins/image",
"libs/types/src/constants/viewer-render-profile.constants.ts",
"libs/agent-tools/src/capture",
"libs/tau-examples/fixtures/viewer-parity",
"libs/tau-examples/scripts/export-parity-fixtures.mts",
"libs/tau-examples/scripts/viewer-parity.ts",
"libs/tau-examples/scripts/viewer-parity-files.ts",
"libs/tau-examples/scripts/viewer-parity-render.ts",
"libs/tau-examples/scripts/viewer-parity.gate.test.ts",
"libs/tau-examples/scripts/viewer-parity.wasm.browser.test.ts",
"libs/tau-examples/vitest.viewer-parity.config.ts",
"libs/tau-examples/project.json",
"apps/ui/app/routes/convert/gear-8.glb"]
# The renderers both sides run, as package-name patterns: their `pnpm-workspace.yaml` catalog pins (nanoraster and
# its native addons) and three's patch. A changed pin line there, or a patch file of one, selects the lane.
VIEWER_PARITY_PINS: '["three", "nanoraster(-[a-z0-9-]+)?"]'
run: |
# `pipefail` so a failing `nx` call fails the step instead of leaving an empty
# output behind `tail`. `tail -1` keeps the JSON array and drops Nx's log lines.
set -o pipefail
affected=$(pnpm nx show projects --affected --json | tail -1)
pnpm nx graph --file="$RUNNER_TEMP/graph.json" > /dev/null
lanes=$(jq -c --argjson affected "$affected" --argjson selectors "$LANE_SELECTORS" '
.graph.nodes as $nodes
| ([$selectors[] | .tags[]?] - [$nodes[] | .data.tags[]?]) as $unknown_tags
| ([$selectors[] | .targets[]?] - [$nodes[] | .data.targets // {} | keys[]]) as $unknown_targets
| if ($unknown_tags + $unknown_targets) != [] then
error("lane selectors name a tag or target no project has: \($unknown_tags + $unknown_targets | join(", "))")
elif ([$selectors[] | .pr // empty] - ["queue", "touched", "paths"]) != [] then
error("lane selectors name a pull-request rule other than queue, touched or paths")
elif ([$selectors | to_entries[] | select(.value.pr == "paths") | .key] - ["viewer-parity"]) != [] then
error("only the viewer-parity lane has a pull-request path list")
elif ([$selectors[] | .queue // empty] - ["touched", "any-touched", "closure", "never"]) != [] then
error("lane selectors name a merge-queue rule other than touched, any-touched, closure or never")
else . end
| $selectors | map_values(. as $selector
| [$affected[] | . as $name | $nodes[$name] | select(. != null)
| select($selector.type == null or .type == $selector.type)
| select(all($selector.tags[]?; . as $tag | $nodes[$name].data.tags // [] | index([$tag]) != null))
| select(all($selector.targets[]?; . as $target | $nodes[$name].data.targets // {} | has($target)))
| $name] | sort)' "$RUNNER_TEMP/graph.json")
# The project that owns a file, as Nx maps it: the deepest project root above the file, else the workspace.
owner_def='($graph[0].graph.nodes | with_entries({key: (.value.data.root | if . == "" then "." else rtrimstr("/") end), value: .key})) as $roots
| def owner: split("/") as $parts
| [range($parts | length; 0; -1) as $depth | $parts[:$depth] | join("/")] + ["."]
| map($roots[.] // empty) | first // empty;'
# The shell lane's path check: a change to a fixture producer or to the shell workflow selects the
# sandbox rows, whose guests install those fixtures (the reuse and pull-request rules below still apply).
shell_paths=$(git diff --name-only --no-renames "$NX_BASE" "${NX_HEAD:-HEAD}" \
| jq -cRn --argjson paths "$SHELL_LANE_PATHS" '[inputs | select(. as $file | $paths | index([$file]) != null)]')
if [ "$shell_paths" != '[]' ]; then
jq -e '.graph.nodes.sandbox.data.tags // [] | index(["ci:shell"]) != null' "$RUNNER_TEMP/graph.json" > /dev/null \
|| { echo "::error::the shell lane path check names sandbox, which is not a tag:ci:shell project"; exit 1; }
lanes=$(jq -c '.shell |= (. + ["sandbox"] | unique)' <<< "$lanes")
echo "Shell lane paths changed: $shell_paths"
fi
# The native darwin lane's path check: a change to its workflow or to a nuget oracle source outside
# the graph selects every `test:native-darwin` project (a path names a file or a directory).
darwin_paths=$(git diff --name-only --no-renames "$NX_BASE" "${NX_HEAD:-HEAD}" \
| jq -cRn --argjson paths "$NATIVE_DARWIN_LANE_PATHS" \
'[inputs | select(. as $file | any($paths[] as $path | $file == $path or ($file | startswith($path + "/")); .))]')
if [ "$darwin_paths" != '[]' ]; then
lanes=$(jq -c --slurpfile graph "$RUNNER_TEMP/graph.json" \
'."native-darwin" = ([$graph[0].graph.nodes[] | select(.data.targets // {} | has("test:native-darwin")) | .name] | sort)' <<< "$lanes")
echo "Native darwin lane paths changed: $darwin_paths"
fi
# The compute qualification lane's input check: keep its project only when a measured project is affected or a
# qualification path changed (a path names a file or a directory).
if [ "$(jq -c '."compute-qualify"' <<< "$lanes")" != '[]' ]; then
qualify_projects=$(jq -c --argjson projects "$COMPUTE_QUALIFY_LANE_PROJECTS" \
'[.[] | select(. as $name | $projects | index([$name]) != null)]' <<< "$affected")
qualify_paths=$(git diff --name-only --no-renames "$NX_BASE" "${NX_HEAD:-HEAD}" \
| jq -cRn --argjson paths "$COMPUTE_QUALIFY_LANE_PATHS" \
'[inputs | select(. as $file | any($paths[] as $path | $file == $path or ($file | startswith($path + "/")); .))]')
if [ "$qualify_projects" = '[]' ] && [ "$qualify_paths" = '[]' ]; then
lanes=$(jq -c '."compute-qualify" = []' <<< "$lanes")
echo "Compute qualification lane: no measured project affected and no qualification path changed."
else
echo "Compute qualification inputs: projects $qualify_projects, paths $qualify_paths"
fi
fi
# The viewer parity lane's path check, which only the pull-request "paths" rule below reads (`path_lanes`):
# the pull request's own files (the same diff as that rule) against VIEWER_PARITY_LANE_PATHS and the
# manifest's example sources, or a VIEWER_PARITY_PINS pin line of `pnpm-workspace.yaml` or its patch file.
path_lanes='{}'
if test "$GITHUB_EVENT_NAME" = pull_request; then
pr_base=$(git merge-base "$NX_BASE" "${NX_HEAD:-HEAD}")
parity_paths=$(jq -c --argjson paths "$VIEWER_PARITY_LANE_PATHS" \
'$paths + [.fixtures[].source | select(test("^[a-z0-9-]+/[a-z0-9-]+$")) | "libs/tau-examples/src/kernels/" + .]' \
libs/tau-examples/fixtures/viewer-parity/fixtures.json)
parity_files=$(git diff --name-only --no-renames --relative "$pr_base" "${NX_HEAD:-HEAD}" \
| jq -cRn --argjson paths "$parity_paths" --argjson pins "$VIEWER_PARITY_PINS" '[inputs | select(. != "")
| select(. as $file | any($paths[] as $path | $file == $path or ($file | startswith($path + "/")); .)
or any($pins[] as $pin | $file | test("^tools/pnpm/patches/" + $pin + "@"); .))]')
parity_pins=$(git diff --no-renames -U0 "$pr_base" "${NX_HEAD:-HEAD}" -- pnpm-workspace.yaml \
| jq -cRn --argjson pins "$VIEWER_PARITY_PINS" '[inputs | select(test("^[-+][^-+]"))
| select(any($pins[] as $pin | test("^[-+]\\s+" + $pin + "(@[^:]*)?:"); .))]')
if [ "$parity_files" != '[]' ] || [ "$parity_pins" != '[]' ]; then
echo "Viewer parity inputs changed: $parity_files $parity_pins"
path_lanes=$(jq -c '{"viewer-parity": ([.graph.nodes[] | select(.data.targets // {} | has("test:viewer-parity")) | .name] | sort)}' \
"$RUNNER_TEMP/graph.json")
fi
fi
# The merge queue applies each lane's `queue` rule to the entry's own files. A shell lane path counts as
# touching `sandbox`, so the path checks above keep every shell project they selected.
entry_files=$(git diff --name-only --no-renames "$NX_BASE" "${NX_HEAD:-HEAD}")
if [ "$GITHUB_EVENT_NAME" = merge_group ] && grep -qxF pnpm-lock.yaml <<< "$entry_files"; then
echo "The entry changes pnpm-lock.yaml: no merge-queue rule applies."
elif [ "$GITHUB_EVENT_NAME" = merge_group ]; then
lanes=$(printf '%s\n' "$entry_files" \
| jq -cRn --argjson lanes "$lanes" --argjson selectors "$LANE_SELECTORS" --argjson hubs "$QUEUE_HUBS" \
--argjson forced "$(if [ "$shell_paths" != '[]' ]; then echo '["sandbox"]'; else echo '[]'; fi)" \
--slurpfile graph "$RUNNER_TEMP/graph.json" "$owner_def"'
([inputs | select(. != "") | owner] + $forced) as $touched
| ($graph[0].graph.dependencies // {}) as $deps
| def touched: . as $name | $touched | index([$name]) != null;
# The project and every project it depends on, never entering a hub (the project itself may be one).
def closure: {seen: [.], todo: [.]}
| until(.todo == []; .todo[0] as $next | .todo |= .[1:]
| ([$deps[$next][]?.target] | unique) as $targets
| reduce ($targets[] | . as $target | select(($hubs | index([$target])) == null)) as $dep (.;
if (.seen | index([$dep])) == null then .seen += [$dep] | .todo += [$dep] else . end))
| .seen;
$lanes | with_entries(.key as $lane | $selectors[$lane].queue as $rule
| if $rule == "touched" then .value |= map(select(touched))
elif $rule == "any-touched" and (any(.value[]; touched) | not) then .value = []
elif $rule == "closure" then .value |= map(select(any(closure[]; touched)))
else . end)')
jq -r --argjson selectors "$LANE_SELECTORS" \
'to_entries[] | select($selectors[.key].queue != null and $selectors[.key].queue != "never") | "Merge queue (\($selectors[.key].queue)) \(.key): \(.value | tojson)"' <<< "$lanes"
fi
# A "never" lane leaves the merge queue whatever the entry changes, the lockfile included (viewer parity, VP-1:
# the pull request ran it on its own diff, and the release gate runs every fixture).
if [ "$GITHUB_EVENT_NAME" = merge_group ]; then
lanes=$(jq -c --argjson selectors "$LANE_SELECTORS" \
'with_entries(if $selectors[.key].queue == "never" then .value = [] else . end)' <<< "$lanes")
jq -r --argjson selectors "$LANE_SELECTORS" \
'to_entries[] | select($selectors[.key].queue == "never") | "Merge queue (never) \(.key): \(.value | tojson)"' <<< "$lanes"
fi
# A project whose `test:e2e:shadow` or `test:e2e:queue` names a `metadata.lane` (CI decomposition DC-27:
# desktop-e2e, `desktop`) keeps those rows only when that lane selected a project or the entry changes a file
# the project owns, not whenever the project is affected: desktop-e2e depends on ui-e2e, so a `ui` change alone
# affects it. DC-27's desktop rows are selected by `tag:ci:desktop` as shadow rows and once they gate alike.
lanes=$(printf '%s\n' "$entry_files" \
| jq -cRn --argjson lanes "$lanes" --argjson selectors "$LANE_SELECTORS" \
--slurpfile graph "$RUNNER_TEMP/graph.json" "$owner_def"'
([inputs | select(. != "") | owner]) as $touched
| $graph[0].graph.nodes as $nodes
| reduce ({"e2e-queue": "test:e2e:queue", "e2e-shadow": "test:e2e:shadow"} | to_entries[]) as $rows ($lanes;
.[$rows.key] |= map(. as $project
| $nodes[$project].data.targets[$rows.value].metadata.lane as $lane
| if $lane == null then $project
elif ($lane | type) != "string" or $selectors[$lane] == null then
error("\($project):\($rows.value) names lane \($lane | tojson), which is not a lane of this plan")
elif ($lanes[$lane] // []) != [] or ($touched | index([$project])) != null then $project
else empty end))')
jq -r 'to_entries[] | "Affected \(.key): \(.value | tojson)"' <<< "$lanes"
# What `nx affected` selected, for `lanes.json` below.
selected=$lanes
# A push that reuses the merge-queue run on this commit runs no lane again: that run's
# required gate passed, and the gate waits for every lane and fails on any selected lane
# that did not pass. One rule for every lane; this plan diffed against the queue's own
# base, so what it selected is what the queue selected and passed.
if [ -n "$REUSED" ]; then
lanes=$(jq -c 'map_values([])' <<< "$lanes")
echo "Reusing merge-queue run $REUSED: its required gate passed every lane it selected on this commit; no lane runs again."
fi
# A pull request applies each lane's `pr` rule. The "queue" lanes run on the exact commit that
# lands: a PR run of them proved nothing the queue does not prove again, and PR runs held about six
# times the queue's runner minutes when the 60-job pool was the queue's bottleneck (2026-11-10).
# A "touched" lane runs for the projects the diff itself changes, where a deterministic failure
# would otherwise first evict a queue entry and rebuild every entry behind it (F15). The files are
# Nx's own (`git diff --no-renames --relative` from the merge base of NX_BASE and NX_HEAD). A "paths" lane
# runs the projects the lane's path check above found (`path_lanes`), and none when it found none.
if [ "$GITHUB_EVENT_NAME" = pull_request ]; then
head=${NX_HEAD:-HEAD}
lanes=$(git diff --name-only --no-renames --relative "$(git merge-base "$NX_BASE" "$head")" "$head" \
| jq -cRn --argjson lanes "$lanes" --argjson selectors "$LANE_SELECTORS" --argjson matched "$path_lanes" \
--slurpfile graph "$RUNNER_TEMP/graph.json" "$owner_def"'
[inputs | select(. != "") | owner] as $touched
| $lanes | with_entries(.key as $lane | $selectors[$lane].pr as $rule
| if $rule == "queue" then .value = []
elif $rule == "touched" then .value |= map(. as $name | select($touched | index([$name]) != null))
elif $rule == "paths" then .value = ($matched[$lane] // [])
else . end)')
jq -r --argjson selectors "$LANE_SELECTORS" \
'to_entries[] | select($selectors[.key].pr != null) | "Pull request (\($selectors[.key].pr)) \(.key): \(.value | tojson)"' <<< "$lanes"
fi
flag() { jq -r --arg lane "$1" 'if .[$lane] == [] then "false" else "true" end' <<< "$lanes"; }
api=$(flag api)
billing=$(flag billing)
formal=$(flag formal)
formal_nightly=$(flag formal-nightly)
formal_nightly_projects=$(jq -c '."formal-nightly"' <<< "$lanes")
browser=$(flag browser)
geospec_examples=$(flag geospec-examples)
cli_e2e=$(flag cli-e2e)
browser_projects=$(jq -c '.browser' <<< "$lanes")
native_linux=$(jq -r '."native-linux" | join(",")' <<< "$lanes")
native_hosts=$(jq -r 'if .["native-hosts"] == [] and .["native-linux"] == [] then "false" else "true" end' <<< "$lanes")
native_darwin=$(flag native-darwin)
native_darwin_projects=$(jq -r '."native-darwin" | join(",")' <<< "$lanes")
viewer_parity=$(flag viewer-parity)
desktop=$(flag desktop)
desktop_projects=$(jq -c '.desktop' <<< "$lanes")
shell=$(flag shell)
shell_projects=$(jq -c '.shell' <<< "$lanes")
windows_unit=$(flag windows-unit)
# Windows unit rows (`windows-unit`): one per selected project's `test`, a project with `test:shard-<n>`
# targets as one row per shard instead (CI decomposition P-E C, the 240 s rule), so `revisions`, at
# 23.8 min the longest gating job as one row, runs as its three shards. The shards partition its files
# (packages/revisions/test-shards.test.ts). `windows-unit.yml` deals a dispatch or labelled run alike.
windows_unit_rows=$(jq -c --argjson projects "$(jq -c '."windows-unit"' <<< "$lanes")" '
.graph.nodes as $nodes
| [$projects[] as $project
| ([$nodes[$project].data.targets // {} | keys[] | select(test("^test:shard-[1-9][0-9]*$"))]
| sort_by(ltrimstr("test:shard-") | tonumber)) as $shards
| if ($shards | length) > 0
then ($shards | length) as $count | $shards[]
| {task: "\($project):\(.)", label: "\($project) \(ltrimstr("test:shard-"))/\($count)"}
else {task: "\($project):test", label: $project} end]' "$RUNNER_TEMP/graph.json")
echo "Windows unit rows: $windows_unit_rows"
# One row per ratcheted suite of the selected projects: each entry of a project's `test:e2e:queue`
# `dependsOn` is a target of that project, run unsharded (an `e2e-chat-logs` merge of shards is the
# nightly's alone), so anything else fails the plan rather than drop a suite.
e2e_queue_suites=$(jq -c --slurpfile graph "$RUNNER_TEMP/graph.json" '
$graph[0].graph.nodes as $nodes
| [."e2e-queue"[] as $project | $nodes[$project].data.targets as $targets
| $targets["test:e2e:queue"].dependsOn // [] | .[]
| if type != "string" or ($targets[.] == null) then
error("\($project):test:e2e:queue depends on \(tojson), which is not a target of \($project)")
elif ($targets[.].metadata.shards // 1) > 1 then
error("\($project):\(.) declares shards; the e2e-queue lane runs a suite as one job")
else {project: $project, target: ., label: "\($project) \(.)", slug: ("\($project)-\(.)" | gsub(":"; "-"))} end]' <<< "$lanes")
# A suite whose `metadata.queueBuild` is false restores neither bundle `queue-builds` writes (its task graph and
# commands hold no `ui:build` or `ui:build:serve`), so its row runs in `e2e-queue-early`, which starts when this
# plan ends instead of after `queue-builds` (about 3 min later); every other row stays in `e2e-queue`. The two
# lists partition the suites, and `scripts/src/end-to-end-ratchet.test.ts` pins that no early suite builds a bundle.
e2e_queue_early_suites=$(jq -c --slurpfile graph "$RUNNER_TEMP/graph.json" '
$graph[0].graph.nodes as $nodes
| map(select($nodes[.project].data.targets[.target].metadata.queueBuild == false))' <<< "$e2e_queue_suites")
e2e_queue_suites=$(jq -c --slurpfile graph "$RUNNER_TEMP/graph.json" '
$graph[0].graph.nodes as $nodes
| map(select($nodes[.project].data.targets[.target].metadata.queueBuild != false))' <<< "$e2e_queue_suites")
# One row per shadow suite of the selected projects, checked as the ratchet's rows are, and never a suite its
# project also lists in `test:e2e:queue` (a suite gates or is on probation, never both). `browsers` is what the
# row installs: the suite's `metadata.browsers`, else all three, as an `e2e-queue` row.
e2e_shadow_suites=$(jq -c --slurpfile graph "$RUNNER_TEMP/graph.json" '
$graph[0].graph.nodes as $nodes
| [."e2e-shadow"[] as $project | $nodes[$project].data.targets as $targets
| $targets["test:e2e:shadow"].dependsOn // [] | .[]
| if type != "string" or ($targets[.] == null) then
error("\($project):test:e2e:shadow depends on \(tojson), which is not a target of \($project)")
elif (. as $suite | $targets["test:e2e:queue"].dependsOn // [] | index([$suite])) != null then
error("\($project):\(.) is in both test:e2e:shadow and test:e2e:queue")
elif ($targets[.].metadata.shards // 1) > 1 then
error("\($project):\(.) declares shards; the e2e-shadow lane runs a suite as one job")
else {project: $project, target: ., label: "\($project) \(.)", slug: ("\($project)-\(.)" | gsub(":"; "-")),
browsers: ($targets[.].metadata.browsers // ["chromium", "firefox", "webkit"] | join(" "))} end]' <<< "$lanes")
# A project whose rows were all promoted keeps an empty `test:e2e:shadow`: the lane runs only when a row is left,
# since an empty matrix fails the job. The same holds for the ratchet's rows.
e2e_shadow=$(jq -r 'if length > 0 then "true" else "false" end' <<< "$e2e_shadow_suites")
e2e_queue=$(jq -r 'if length > 0 then "true" else "false" end' <<< "$e2e_queue_suites")
e2e_queue_early=$(jq -r 'if length > 0 then "true" else "false" end' <<< "$e2e_queue_early_suites")
# Package checks (`pkgcheck`): every affected project with a `pkgcheck`, `audit-public-surface` or
# `readme-quickstart` target, under no pull-request or merge-queue rule (as the lane ran them before it
# waited for this plan), dealt by measured seconds into one shard per 600 s, at most four. A push that
# reuses the merge-queue run selects none, as every lane.
pkgcheck_projects='[]'
if [ -z "$REUSED" ]; then
pkgcheck_projects=$(jq -c --argjson affected "$affected" '
.graph.nodes as $nodes
| [$affected[] | select($nodes[.].data.targets // {}
| has("pkgcheck") or has("audit-public-surface") or has("readme-quickstart"))] | sort' "$RUNNER_TEMP/graph.json")
fi
pkgcheck_shards=$(echo "$pkgcheck_projects" | node scripts/src/test-shard-dealer.ts --shard all --shards auto \
--max-shards 4 --shard-seconds 600 --durations scripts/src/pkgcheck-shard-durations.json)
echo "Package-check shards: $pkgcheck_shards"
# Node floor shards (`node-floor`): the lane's packages as their `<project>:test` tasks (the snapshot's keys),
# a package with `test:shard-<n>` targets as those tasks instead, as in the test lanes, dealt by measured
# uncached test seconds into one shard per 600 s, at most four, as the package checks are.
node_floor_units=$(jq -c --argjson projects "$(jq -c '."node-floor"' <<< "$lanes")" '
.graph.nodes as $nodes
| [$projects[] as $project
| ([$nodes[$project].data.targets // {} | keys[] | select(test("^test:shard-[1-9][0-9]*$"))]) as $shards
| if ($shards | length) > 0 then $shards[] | "\($project):\(.)" else "\($project):test" end]' "$RUNNER_TEMP/graph.json")
node_floor_shards=$(echo "$node_floor_units" | node scripts/src/test-shard-dealer.ts --shard all --shards auto \
--max-shards 4 --shard-seconds 600 --durations scripts/src/test-shard-durations.json)
echo "Node floor shards: $node_floor_shards"
# `api-image` keeps the PR-only Docker smoke test on the PRs that affect the API image.
api_image=$(flag api-image)
{
echo "apps=$(jq -c '.apps' <<< "$lanes")"
echo "browser-projects=$browser_projects"
echo "api=$api"
echo "api-image=$api_image"
echo "billing=$billing"
echo "cli-e2e=$cli_e2e"
echo "size=$(flag size)"
echo "formal=$formal"
echo "formal-nightly=$formal_nightly"
echo "formal-nightly-projects=$formal_nightly_projects"
echo "browser=$browser"
echo "geospec-examples=$geospec_examples"
echo "native-hosts=$native_hosts"
echo "native-darwin=$native_darwin"
echo "native-darwin-projects=$native_darwin_projects"
echo "native-linux=$native_linux"
echo "viewer-parity=$viewer_parity"
echo "desktop=$desktop"
echo "desktop-projects=$desktop_projects"
echo "shell=$shell"
echo "shell-projects=$shell_projects"
echo "windows-unit=$windows_unit"
echo "windows-unit-rows=$windows_unit_rows"
echo "e2e-queue=$e2e_queue"
echo "e2e-queue-suites=$e2e_queue_suites"
echo "e2e-queue-early=$e2e_queue_early"
echo "e2e-queue-early-suites=$e2e_queue_early_suites"
echo "e2e-shadow=$e2e_shadow"
echo "e2e-shadow-suites=$e2e_shadow_suites"
echo "pkgcheck=$(if [ "$pkgcheck_shards" = '[]' ]; then echo false; else echo true; fi)"
echo "pkgcheck-shards=$pkgcheck_shards"
echo "node-floor=$(if [ "$node_floor_shards" = '[]' ]; then echo false; else echo true; fi)"
echo "node-floor-shards=$node_floor_shards"
echo "compute-qualify=$(flag compute-qualify)"
} >> "$GITHUB_OUTPUT"
# `staging.yml` reads which service lanes `nx affected` selected (`api`, `billing-e2e`,
# keyed by their job), before the reuse and pull-request rules above, and the merge-queue
# run this push reused (`reused-run`): a lane skipped here is acceptable to a deploy only
# when it was not selected, or when the reused run's gate passed it.
# `desktop` and `desktop-projects` record the desktop lane, which no job runs (see above).
mkdir -p out/ci-plan
jq -n --argjson selected "$selected" --arg reused "$REUSED" \
--arg desktop "$desktop" --argjson desktop_projects "$desktop_projects" \
'{api: ($selected.api != [] | tostring), "billing-e2e": ($selected.billing != [] | tostring), "reused-run": $reused, desktop: $desktop, "desktop-projects": $desktop_projects}' \
> out/ci-plan/lanes.json
cat out/ci-plan/lanes.json
# Burn-in of changed tests (Brain research/ci-flake-quarantine-blueprint.md, FQ-10, operator decision O6 B): the
# test files this pull request adds or modifies, mapped to their project's `test` target, the target the test
# lanes run (`scripts/src/burn-in.ts`). None selects no `burn-in` job. Pull requests only: the merge queue and
# pushes never burn in. The files are the pull request's own, as the "touched" rule above reads them.
- name: Plan the burn-in of changed tests
id: burn-in
if: github.event_name == 'pull_request'
run: |
set -o pipefail
head=${NX_HEAD:-HEAD}
git diff --name-only --no-renames --diff-filter=AM --relative "$(git merge-base "$NX_BASE" "$head")" "$head" \
| node scripts/src/burn-in-cli.ts plan --graph "$RUNNER_TEMP/graph.json" --summary "$GITHUB_STEP_SUMMARY"
- name: Upload the lane plan
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ci-plan
path: out/ci-plan/lanes.json
if-no-files-found: error
retention-days: 7
# Every workspace invariant is a `scripts:validate-*` target; `scripts:validate`
# is the wildcard umbrella over all of them (frontmatter, workspace root,
# project names and tags, tsgo runtime references, quickstart budget, license
# partitions, formatting, dead code, license deps, workflows). A new validator
# joins by adding the target — this job never changes.
# A push to `main` whose identical commit passed the merge queue passes on that
# verdict (`queue-verdict`); it still reports, so `staging.yml` reads it.
workspace:
name: Validate workspace
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
# Writes the remote cache on `main` pushes and in `main`'s merge queue, like the affected lanes; pull requests read.
environment: ${{ ((github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'merge_group' && startsWith(github.ref, 'refs/heads/gh-readonly-queue/main/'))) && 'nx-cache-write' || null }}
permissions:
id-token: write # CP-5b: a pull request job trades its OIDC token for its own cache session (setup-nx nx-guard)
contents: read
actions: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Find the merge-queue verdict for this commit
id: queue
uses: ./.github/actions/queue-verdict
with:
github-token: ${{ github.token }}
- name: Setup Nx Environment
if: steps.queue.outputs.run-id == ''
uses: ./.github/actions/setup-nx
- name: Run workspace validators
if: steps.queue.outputs.run-id == ''
run: pnpm nx run scripts:validate
# A change to the PicoGK browser host pin merges only once both dependency hosts, production
# dependencies.tau.new and staging dependencies.taucad.dev, serve every blob it names with its
# pinned digest, so `main` never names a digest either environment does not serve (charter
# picogk-interim-digest-consumer, D9 and I2). It runs in this required check, on the pull
# request and in the merge queue, only when the pin differs from the base.
- name: Prove a changed PicoGK browser host pin is served on both hosts
if: steps.queue.outputs.run-id == '' && (github.event_name == 'pull_request' || github.event_name == 'merge_group')
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
PIN: packages/plugins/picogk/browser-host.pin.json
run: |
set -euo pipefail
git fetch --no-tags --depth=1 origin "$BASE_SHA"
if git diff --quiet "$BASE_SHA" HEAD -- "$PIN"; then
echo "$PIN is unchanged from the base; no blob to prove."
else
node scripts/src/picogk-browser-host-pin.ts check --pin "$PIN"
fi
# A change to the resolved `cadmpeg-ts` version merges only once both dependency hosts serve every
# gzip engine its `cadmpeg-ts/digests` names, with that digest, so `main` never resolves engines
# tau.new or staging cannot load (cadmpeg engine delivery charter, I4). It runs in this required
# check, on the pull request and in the merge queue, and downloads only when the lockfile resolves
# other `cadmpeg-ts` versions than the base. A failure names the dispatch that mirrors the version
# (`dependency-files-publish.yml` with `cadmpeg-version`).
- name: Prove a changed cadmpeg-ts version's engines are served on both hosts
if: steps.queue.outputs.run-id == '' && (github.event_name == 'pull_request' || github.event_name == 'merge_group')
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
run: |
set -euo pipefail
git fetch --no-tags --depth=1 origin "$BASE_SHA"
if git diff --quiet "$BASE_SHA" HEAD -- pnpm-lock.yaml; then
echo "pnpm-lock.yaml is unchanged from the base; no engine to prove."
else
git show "$BASE_SHA:pnpm-lock.yaml" > "$RUNNER_TEMP/base-pnpm-lock.yaml"
node scripts/src/check-cadmpeg-engine-mirror.ts --base-lockfile "$RUNNER_TEMP/base-pnpm-lock.yaml"
fi
# The affected tasks run as parallel lanes on separate standard runners: two lint, two typecheck,
# two build and six test shards, and the package-check shards (`pkgcheck` below). One runner running
# every task in turn took 1 h 40 min on a full graph (run 37221169741, 2026-10-04); the lanes bring
# that down to the longest lane. Each lane keeps `--parallel=1`, which its own 16 GB runner still
# needs (see `Run the lane's tasks`). Lint, typecheck and build each ended past 10 min at p90 as one
# job (13.3, 17.8 and 13.4 min over 60 green queue runs), so each is two shards dealt by measured
# task seconds (Brain research/ci-structural-decomposition-blueprint.md, ST-3).
#
# No `needs: plan`: every lane selects its own projects with `nx affected`, and the only
# thing it read from the plan was the queue verdict, which it now finds itself, as
# `workspace` does. Waiting for the plan put 2.1–3.9 min on every queue run's critical
# path (Brain research/ci-decomposition-blueprint.md, X1). A push to `main` whose commit
# passed the merge queue reuses that run's lanes: every step after the verdict skips, and
# the required `affected` gate passes on the plan's own verdict. A push whose commit has a
# merge-group run that did not pass runs the lanes against the queue's base (`affected-base`).
affected-lane:
name: Affected (${{ matrix.lane }})
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
environment: ${{ ((github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'merge_group' && startsWith(github.ref, 'refs/heads/gh-readonly-queue/main/'))) && 'nx-cache-write' || null }}
permissions: # Required for nrwl/nx-set-shas to read workflow runs
id-token: 'write' # CP-5b: a pull request job trades its OIDC token for its own cache session (setup-nx nx-guard)
contents: 'read'
actions: 'read'
pull-requests: 'read'
strategy:
fail-fast: ${{ github.event_name == 'merge_group' }} # Merge queue: a failed row cancels its siblings (see `fail-fast-*`)
matrix:
lane:
[lint-1, lint-2, typecheck-1, typecheck-2, build-1, build-2, test-1, test-2, test-3, test-4, test-5, test-6]
env:
# The build lanes' targets, in `nx affected` and the deal alike.
BUILD_TARGETS: build size check-desktop-payload check-critical-budget check-static-shells check-server-output check-route-module-patch check-cadmpeg-engine-absence check-serve-ui-layer
steps:
# Two commits in a queue run, full history otherwise (see `plan`).
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: ${{ github.event_name == 'merge_group' && 2 || 0 }}
# A no-op unless this is a push to `main`; on pull requests and in the merge queue
# `run-id` is always empty, so every step below runs.
- name: Find the merge-queue verdict for this commit
id: queue
uses: ./.github/actions/queue-verdict
with:
github-token: ${{ github.token }}
- name: Setup Nx Environment
if: steps.queue.outputs.run-id == ''
uses: ./.github/actions/setup-nx
with:
save-pnpm-store: 'false'
affected-base: ${{ steps.queue.outputs.affected-base }}
- name: Setup Linux sandbox prerequisites
if: startsWith(matrix.lane, 'test-') && steps.queue.outputs.run-id == ''
uses: ./.github/actions/setup-linux-sandbox
# The PR gate documented in docs/policy/release-policy.md: under version plans,
# a touched release project with no plan is an unreleased change. Base and head
# come from NX_BASE/NX_HEAD, which `nrwl/nx-set-shas` exported above. Not run on
# `push`, where the release commit itself touches every manifest after consuming
# the plans.
- name: Check version plans
if: matrix.lane == 'build-1' && github.event_name == 'pull_request'
run: pnpm nx release plan:check
# Pinned third-party downloads come from the Actions cache, so only a pin change asks their
# origin (Brain research/ci-flake-classes.md class 1, R3: during a GitHub Releases outage the
# wasi-sdk of `prepare` and the CPython of `seed` failed 34 lane jobs in two days). The lane's
# task graph, for the same targets as the step below, decides which entries it needs, so a
# lane that runs neither task restores nothing (the kernel seeds are about 350 MB, the
# wasi-sdk archive 125 MB); a shard reads its lane's whole affected graph, as the deal
# happens in the step below (which the lint, typecheck and build shards read too).
# Keys digest the pins themselves (scripts/src/ci-pinned-downloads.ts). The consumers
# re-verify every byte against its pin, and on a miss they download as before;
# `ci-pinned-downloads.yml` saves the entries from `main`, whose cache scope pull requests
# and the merge queue restore from.
- name: Find the lane's pinned downloads
id: pins
if: steps.queue.outputs.run-id == ''
env:
LANE: ${{ matrix.lane }}
run: |
graph="$RUNNER_TEMP/lane-graph.json"
case "$LANE" in
lint-*) pnpm nx affected -t lint --graph="$graph" > /dev/null ;;
typecheck-*) pnpm nx affected -t typecheck --graph="$graph" > /dev/null ;;
# shellcheck disable=SC2086 # BUILD_TARGETS is a word list
build-*) pnpm nx affected -t $BUILD_TARGETS --graph="$graph" > /dev/null ;;
test-*) pnpm nx affected -t test --exclude tag:scope:api,tag:ci:nightly-only --graph="$graph" > /dev/null ;;
*) echo "Unknown lane $LANE" >&2; exit 1 ;;
esac
node scripts/src/ci-pinned-downloads.ts --graph "$graph" >> "$GITHUB_OUTPUT"
- name: Restore the Python kernel seeds
if: steps.queue.outputs.run-id == '' && steps.pins.outputs.kernel-seeds-key != ''
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.pins.outputs.kernel-seeds-path }}
key: ${{ steps.pins.outputs.kernel-seeds-key }}
- name: Restore the wasi-sdk archive
if: steps.queue.outputs.run-id == '' && steps.pins.outputs.wasi-sdk-key != ''
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.pins.outputs.wasi-sdk-path }}
key: ${{ steps.pins.outputs.wasi-sdk-key }}
# Nx Affected runs only tasks affected by the changes in this PR/commit.
# Browser-backed targets are not in this list — they run nightly in
# e2e-nightly.yml, the only workflow that installs Chromium.
# Learn more: https://nx.dev/ci/features/affected
#
# `test` excludes `tag:scope:api`, because these lanes have no services. The API's
# default suite carries the repository store, the git transport and the lifecycle
# jobs (charter W1, W2, W4, W6), which drive real PostgreSQL and real MinIO and
# refuse rather than skip when they are absent. The whole of `test` for that tag
# runs in the `api` lane below, which has both; these lanes stay hermetic.
#
# The lint, typecheck and build shards deal from the graph the step above wrote (one `nx affected` per job,
# ST-4), never from this file: it holds the lane's affected tasks and the project graph without running
# anything (X8). Each shard computes the same deal, so the shards partition the lane's projects and the task
# each project owns runs in exactly one shard (scripts/src/test-shard-dealer.test.ts and
# scripts/src/affected-shard-union.test.ts). They deal projects by measured task seconds with the tasks
# they depend on (`--graph`), so `ui` and the desktop build its payload check needs share a build shard
# instead of building it twice. A task another shard's project also depends on may run in both; Nx caches it.
#
# The six test shards split the affected projects with a `test` target by
# measured uncached seconds of their tests and the tasks those depend on, from the same graph
# (scripts/src/test-shard-dealer.ts --graph and its duration snapshot, CI decomposition global
# review G5). The project list comes from the graph at run time,
# never from this file: one `nx affected -t test --graph=<file>` writes the affected
# `test` tasks and the project graph (each project's tags and targets) without running
# anything, in place of an `nx show projects --affected` and an `nx graph` (X8).
# A project that declares `test:shard-<n>` targets is dealt as those tasks instead of
# its whole `test`: `ui:test`, about 950 s uncached, is six `ui:test:shard-<n>` tasks of
# about 160 s, so it no longer sets one lane's floor (CI throughput review ST-1,
# decomposition rows DC-9/DC-10). Each is cacheable and keyed on its own `--shard`; its
# Vitest config deals the files by measured seconds, and the six run every file once
# (apps/ui/test-shards.test.ts). Locally, `ui:test` still runs every file.
#
# `--parallel=1`: ui:lint and ui:typecheck each peak near 9.5 GB, so any two of
# them (or ui:build) together exhaust the 16 GB hosted runner, which then loses
# its VM ("The runner has received a shutdown signal"). At Nx's default of three
# this happened a few minutes in; at two it still happened once both overlapped.
# `test` needs the same cap: overlapping WASM suites lost the VM the same way
# a few minutes into `test` (tau#306 and tau#299, 2026-10-04).
#
# The build lanes also run `ui:check-desktop-payload`, the desktop renderer ownership
# gate, whenever `ui` is affected: a renderer-only change no longer selects `desktop`,
# so the desktop `package-*` targets that also depend on it never run for it (Brain
# research/desktop-split-blueprint.md, D-DS2). Its `ui:build:desktop` and
# `desktop:build` dependencies stay serial here under the same `--parallel=1`.
#
# They also run `ui:check-critical-budget`, the critical-path budget (progressive loading
# guard G3): each route class's interactive tier in `ui:build`, the one adaptive build (adaptive
# app deployment mode W12), against the `adaptive` entry. Its source guards (G1 lint, G2 graph
# test) run in the lint and test lanes. `ui:check-static-shells` (PL3) renders each static shell through that build's
# server output: neutral and deterministic bytes, the function's own document, its build id
# and headers, no rendered placeholder.
#
# `size` selects `ui:size`, the SSR bundle budget on `ui:build`'s server output, and
# `check-server-output` selects `ui:check-server-output` and `docs:check-server-output`
# (React Router 8 migration RR0, RD8): no server output of the web, desktop, `tau serve`
# or docs build holds a .wasm file, a worker bundle or a client asset. The ui check adds
# `ui:build:serve` to the lane; its other builds are already here.
# `check-route-module-patch` selects `ui:check-route-module-patch` (RR8, RD4): the web,
# desktop and `tau serve` client builds ship React Router's route-module loader with
# Tau's local patch. `check-cadmpeg-engine-absence` selects `ui:check-cadmpeg-engine-absence`
# (cadmpeg engine delivery charter D16, I1): no web, desktop or `tau serve` build holds a file
# whose SHA-256 is an engine digest of the installed `cadmpeg-ts`; its builds are already here.
- name: Run the lane's tasks
if: steps.queue.outputs.run-id == ''
env:
LANE: ${{ matrix.lane }}
run: |
set -o pipefail
graph="$RUNNER_TEMP/lane-graph.json"
case "$LANE" in
lint-* | typecheck-* | build-*)
kind=${LANE%-*}
targets=$kind
if [ "$kind" = build ]; then targets=$(tr ' ' ',' <<< "$BUILD_TARGETS"); fi
projects=$(jq -c --arg targets "$targets" '
($targets | split(",")) as $mine
| [.tasks.tasks[] | select(.target.target | IN($mine[])) | .target.project] | unique' "$graph")
shard=$(echo "$projects" | node scripts/src/test-shard-dealer.ts --shard "${LANE##*-}" --shards 2 \
--durations "scripts/src/$kind-shard-durations.json" --graph "$graph" --targets "$targets")
if [ -z "$shard" ]; then
echo "No affected $kind projects in this shard."
exit 0
fi
echo "Shard projects: $shard"
pnpm nx run-many -t "$targets" --projects "$shard" --parallel=1
;;
test-*)
# GeoSpec suites run here against the published `geospec-engine` prebuild for
# this runner. `ci:nightly-only` projects (runtime-e2e) run only in the nightly
# workflow until their failing tests pass there: https://github.com/taucad/tau/issues/342
pnpm nx affected -t test --exclude tag:scope:api,tag:ci:nightly-only --graph="$RUNNER_TEMP/test-graph.json" > /dev/null
# The task graph also holds the tasks `test` depends on (builds and the like),
# so keep the `test` tasks, and drop an excluded tag again in case another
# project's `test` ever depends on one of theirs.
projects=$(jq -c '
.graph.nodes as $nodes
| [.tasks.tasks[] | select(.target.target == "test") | .target.project] | unique
| map(select($nodes[.].data.tags // [] | any(. == "scope:api" or . == "ci:nightly-only") | not))' "$RUNNER_TEMP/test-graph.json")
# A project with `test:shard-<n>` targets enters the deal as its `<project>:test:shard-<n>`
# tasks, every one of them, in place of the project; the rest enter as projects.
units=$(jq -c --argjson projects "$projects" '
.graph.nodes as $nodes
| [$projects[] as $project
| ([$nodes[$project].data.targets // {} | keys[] | select(test("^test:shard-[1-9][0-9]*$"))]) as $shards
| if ($shards | length) > 0 then $shards[] | "\($project):\(.)" else $project end]' "$RUNNER_TEMP/test-graph.json")
# Every lane deals the same list heaviest first by duration, so the shards partition it and the
# slowest suites land apart. A unit weighs its own task and every task it depends on (`--graph`,
# durations keyed by task), counted once per shard: a lane runs the builds and prepare tasks its
# suites need uncached whenever the build lanes have not cached them yet (`cli:test`'s forty builds
# took 137 s in queue run 45350462131), and units that share them land together.
# `--shards` is the number of `test-<n>` rows in the matrix above.
shard=$(echo "$units" | node scripts/src/test-shard-dealer.ts --shard "${LANE#test-}" --shards 6 \
--graph "$RUNNER_TEMP/test-graph.json" --targets test)
if [ -z "$shard" ]; then
echo "No affected test projects in this shard."
exit 0
fi
echo "Shard projects and tasks: $shard"
projects=$(echo "$shard" | tr ',' '\n' | grep -v ':' | paste -sd, - || true)
tasks=$(echo "$shard" | tr ',' '\n' | grep ':' || true)
: > "$RUNNER_TEMP/affected-test.log"
status=0
# Streamed, not `static`: Nx holds a static task's output until the task ends and then
# prints only its first 64–128 KiB into a pipe, so a long suite lost its Vitest summary and
# every failing test's name (F3; `ui:test` in queue runs 43990460984, 44048796415,
# 44050273147 and 44062740359 stopped mid-run in both the job log and this file).
if [ -n "$projects" ]; then
pnpm nx run-many -t test --projects "$projects" --parallel=1 --outputStyle=stream 2>&1 | tee -a "$RUNNER_TEMP/affected-test.log" || status=1
fi
# A project's dealt shard tasks run in one `run-many`, and every project's run even when
# another failed, so a failed shard hides no other result.
for project in $(echo "$tasks" | cut -d: -f1 | sort -u); do
targets=$(echo "$tasks" | grep "^$project:" | cut -d: -f2- | paste -sd' ' -)
# shellcheck disable=SC2086 # one word per target
pnpm nx run-many -t $targets --projects "$project" --parallel=1 --outputStyle=stream 2>&1 | tee -a "$RUNNER_TEMP/affected-test.log" || status=1
done
exit "$status"
;;
*) echo "Unknown lane $LANE" >&2; exit 1 ;;
esac
# The full log of a full-graph run is far longer than the API's log tail, so a failed
# test phase repeats each failing test's file and name first, then each failing suite's
# report (and the sandbox host facts the native suites depend on), as the job's last output.
# The names come first and alone, so a long report can never push them out of the excerpt.
- name: Summarize failed affected tests
if: failure() && startsWith(matrix.lane, 'test-')
run: |
echo '::group::Sandbox host'
sysctl kernel.apparmor_restrict_unprivileged_userns kernel.unprivileged_userns_clone user.max_user_namespaces 2>&1 || true
sudo grep -Ei 'bwrap|unshare|userns' /sys/kernel/security/apparmor/profiles || echo 'no bwrap, unshare or userns AppArmor profile loaded'
findmnt -no FSTYPE /tmp || true
bwrap --unshare-user --cap-drop ALL --ro-bind / / --dev /dev --unshare-pid --proc /proc -- \
unshare --user --map-root-user --pid --fork --mount-proc true \
&& echo 'nested user namespace: ok' || echo 'nested user namespace: blocked'
echo '::endgroup::'
if [ -f "$RUNNER_TEMP/affected-test.log" ]; then
# Vitest's `FAIL <file> > <suite> > <test>` lines, without colour, Nx's project prefix kept.
failing=$(sed -E 's/\x1b\[[0-9;]*m//g' "$RUNNER_TEMP/affected-test.log" | grep -E '(^|[[:space:]])FAIL[[:space:]]' | sort -u | head -200 || true)
echo 'Failing tests:'
echo "${failing:-No Vitest FAIL line in the test log; see the task output above.}"
awk '/Failed Tests [0-9]+|Failed Suites [0-9]+/ { keep = 1; n = 0 }
keep && n < 300 { print; n++ }
/Test Files / { keep = 0 }' "$RUNNER_TEMP/affected-test.log"
grep -nE 'exited \([0-9]+\)|apply-seccomp|bwrap:|uid_map|ERR_|Unhandled|out of memory|Test timed out' \
"$RUNNER_TEMP/affected-test.log" | head -100
fi
# The M3 verdict helpers left with `geospec` for taucad/geospec, which runs them in its own CI.
- name: Check the affected GeoSpec consumer
if: matrix.lane == 'build-1' && steps.queue.outputs.run-id == ''
run: pnpm nx affected -t check-geospec-test-consumer
- name: Check workspace root hygiene
if: always() && steps.queue.outputs.run-id == ''
run: pnpm nx run scripts:validate-workspace-root
# FQ-1 (CI flake quarantine blueprint): the rows `@taucad/vitest-ci` wrote, one per test execution, for the
# flake ledger. A task replayed from the cache restores its rows with the ids of the run that executed it.
- name: Upload test outcomes
if: always() && startsWith(matrix.lane, 'test-') && steps.queue.outputs.run-id == ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test-outcomes-${{ matrix.lane }}
path: out/test-results/*/*.outcomes.jsonl
if-no-files-found: ignore
retention-days: 30
# The package checks (publint, attw, madge, the public-surface audit and the README quickstart) of the
# affected projects that have one. The plan deals them by measured uncached `pkgcheck` seconds
# (scripts/src/pkgcheck-shard-durations.json, with the test shards' dealer), one shard per 600 s and at most
# four (`pkgcheck-shards`), so a narrow entry runs one job and a root package change four: as three fixed