Skip to main content

G2a/G2b parallelism canary (nightly, non-required)

Owner: devops-engineer. Issue: #4561, which is stage 1 part (e) of A on #4245 (tracker #4504). Design: #4245 comment 6908523093 §3. Approval: Vaisakh on #4245, comment 6908828532: "with the canary before gating".

What runs​

main-green-nightly.yml job g2-parallelism-canary runs at 04:00 UTC, or on dispatch, against main HEAD. It is a matrix of two arms on the same night:

armgo test GOMAXPROCSgo test -p
strict (control; the queue's value)21
relaxed42

The one reviewed parameter is scripts/g2-parallelism-profiles.json.

Both arms put scripts/g2-nightly/go first on PATH, so their instrumentation is the same. For a non-strict profile that shim rewrites go test only. strict passes every command through byte-for-byte. Every other go command (build, run, vet) is never rewritten, so the process-proof binaries keep their caps.

Each arm runs the orchestrator parts g2a and g2b (#4560). It does not run acquisition-memory, so its two 302 s idles are untouched and are not part of this canary. Producers, argv, arms, mutants and checkers are unchanged.

Each part is checked with check-repo-source-g2-envelope.py --part P --profile <arm>. The go-shim.jsonl log records the original and executed argv of every go command. The artifact is g2-canary-<arm>-<run_id>-<attempt>, kept 30 days.

The queue stays strict​

  • The queue path never puts the shim on PATH. db.yml does not mention it.
  • The ledger and part receipt record profile.
  • The verdict's final checker (check_execution_ledgers) refuses any non-strict ledger.
  • The envelope accepts a non-strict part only when the caller passes --profile, and only the nightly does.
  • The pinned argv literals are unchanged.

Relaxed evidence therefore can never satisfy Migrate Up + Down. Gating on the relaxed profile is out of scope until the week below is green and a separate change is reviewed.

Recording the 7 nights on #4245​

1. Download both artifacts​

Each artifact is about 240 MB (measured on run 44015211231). Use a new, empty directory per night, outside the checkout. RUN is the run id, ATTEMPT its attempt (1 unless re-run). Load the bot token first (gh-token.py).

With gh (it unpacks the zip itself):

gh run download "$RUN" -R upsquad-ai/upsquad-core -n "g2-canary-strict-$RUN-$ATTEMPT" -D strict
gh run download "$RUN" -R upsquad-ai/upsquad-core -n "g2-canary-relaxed-$RUN-$ATTEMPT" -D relaxed

Or through the REST API. The devbox has no unzip, so unpack with Python's zipfile. Artifact content is untrusted data: run Python with -I, and refuse absolute or .. member names.

gh api "repos/upsquad-ai/upsquad-core/actions/runs/$RUN/artifacts" \
--jq '.artifacts[] | select(.name | startswith("g2-canary-")) | [.id, .name] | @tsv'
gh api "repos/upsquad-ai/upsquad-core/actions/artifacts/<strict-id>/zip" > strict.zip
gh api "repos/upsquad-ai/upsquad-core/actions/artifacts/<relaxed-id>/zip" > relaxed.zip
for arm in strict relaxed; do
python3 -I -c 'import sys, zipfile
z = zipfile.ZipFile(sys.argv[1] + ".zip")
assert not [n for n in z.namelist() if n.startswith("/") or ".." in n.split("/")]
z.extractall(sys.argv[1])' "$arm"
done

2. Compare them at the night's SHA​

The comparator reads scripts/g2-parallelism-profiles.json, the orchestrator and the verify scripts from the local checkout it runs from, not from the night's SHA. Run it from a checkout of the main SHA the run tested (the run's head_sha, also the ledgers' commit), for example a detached worktree:

python3 scripts/compare-g2-ledgers.py <night>/strict <night>/relaxed --json <night>/compare.json

The script exits 0 when the two arms are equal and 1 on any mismatch. It exits 2 when an input is missing or unreadable, or when the checkout yields no go test roster for a part. It checks:

  • the profile of each arm;
  • both verdicts are PASS;
  • the ledger IDs and exit codes match;
  • the receipt shapes match (G2a mutant receipts and the G2b mutant receipt);
  • shim coverage: strict ran every go test unchanged, relaxed ran every go test rewritten, and both arms ran the same go test invocations;
  • the shim-coverage floor (#4581).

Where the floor comes from. Shim coverage was measured only from the shim's own log. So a go that bypasses the shim in both arms at once would leave the arms equal. For example, verify-repo-source-g2a.sh prepends $HOME/go/bin to PATH. The floor is a roster derived from the checkout alone (roster() in the comparator):

  • the orchestrator's PARTS;
  • its literal execute(...) argv, read by AST;
  • for a bash <script>.sh producer, that script's literal go test lines.

Each roster entry is keyed by -tags, -run and package. Each arm's go-shim.jsonl must record every entry at least as often as the roster expects. Today the roster is 15 for g2a and 1 for g2b. Both arms of run 44015211231 covered all 16. Dynamic argv is excluded, so this is a floor, not the whole population: the mutant battery's children and -run "$SELECTOR" lines are not in the roster.

What the comparison does not compare (deferred, #4581 item 5). shape() reduces every number to its type, so the exit_code values inside the G2b receipt's compiled[] entries are not compared. narrowed_producer is not in IDENTITY_KEYS, so its value is not compared either. This is acceptable while each arm's status == PASS already covers those results. Change it only as part of a reviewed gating proposal, never during a counted week.

It also prints the per-stage delta (relaxed minus strict) for every ledger command and every G2a phase, including the mutant battery.

Delta caveat: the arms load each other. The matrix has no max-parallel, so both arms run at the same time on hetzner-ci and share CPU, disk and the Docker daemon. A delta is therefore relaxed-beside-strict against strict-beside-relaxed, not either arm alone. Do not serialise the arms during a counted week, because that changes what the week measures. If the deltas look noisy, propose serialising as a separate reviewed change, and restart the count after it lands.

3. Clone-drop p99​

Every template-clone DROP DATABASE writes one cleanup-diagnostics/<database>.json beside its template manifest (internal/testsupport/sourcetemplate). Its duration_ms is the drop time. Take the nearest-rank p99 over every such file in an arm, and compare it with the 60 s window (#4245 comment 6908523093 §4):

python3 -I -c 'import json, pathlib, sys
ms = sorted(json.loads(p.read_text())["duration_ms"] for p in pathlib.Path(sys.argv[1]).rglob("cleanup-diagnostics/*.json"))
print(len(ms), "drops; p99", ms[-(-99 * len(ms) // 100) - 1] / 1000, "s") if ms else print("no drops recorded")' strict

On run 44015211231 this gave 97 drops and p99 21.1 s for strict, and 34 drops and p99 16.3 s for relaxed. Relaxed recorded fewer drops because that arm failed before its mutant battery.

4. Post the night​

Post one comment per night on #4245, headed G2 canary night N/7, with:

  1. the run id, the main SHA, and each arm's job conclusion and duration;
  2. the compare-g2-ledgers.py exit code and its delta table;
  3. any relaxed-only failure, named by the failing test, and whether the strict arm passed the same test that night;
  4. each arm's clone-drop p99 and drop count against the 60 s window.

A night counts only if both arms executed. A cancelled or skipped arm is not a pass, so re-dispatch it.

5. Restart rule​

The count is of consecutive green nights. A red night resets the count to zero. Any of these makes a night red:

  • either arm fails;
  • the comparator exits 1 (mismatch);
  • the comparator exits 2 (input not evidence).

After a fix, night 1 is the first scheduled run at or after the main SHA that carries the fix. A dispatch before that SHA does not count.

Example. On 2026-11-17, run 44015211231 at 1ee9c97c was night 1. The strict arm was green. The relaxed arm failed its proof self-tests because REPO_SOURCE_G2_PROFILE leaked into G2PartsTest (#4574). The fix is #4575 (40be1fc5). The count restarted at zero, and night 1 is the 2026-11-18 scheduled run.

The week is green only on 7 consecutive counted nights with exit 0 and no relaxed-only failure. Only then may a gating proposal be filed. That proposal goes to principal-architect, backend-security and qa-engineer.