Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
ci: shard the C-suite legs, prove cross-shard coverage, warm compiler caches
Martin Vogeld7ce789e8ff7
diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.ymlindex 01d10150d..f7885fac1 100644--- a/.github/workflows/_test.yml+++ b/.github/workflows/_test.yml@@ -12,6 +12,10 @@ on:description: 'Test the broad platform matrix (older glibc + extra OS versions) instead of the core set'type: booleandefault: false+ shard_suites:+ description: 'Split each C-suite leg across parallel shard jobs (ubuntu x3, windows x2); off = one job per leg, byte-identical to the pre-shard topology'+ type: boolean+ default: falsepermissions:contents: read@@ -31,6 +35,7 @@ jobs:id: setenv:BROAD: ${{ inputs.broad_platforms }}+ SHARDS: ${{ inputs.shard_suites }}run: |CORE_UNIX='[{"os":"ubuntu-latest","cc":"gcc","cxx":"g++"},@@ -63,6 +68,25 @@ jobs:UNIX=$(jq -cn --argjson a "$CORE_UNIX" '$a')WIN=$(jq -cn --argjson a "$CORE_WIN" '$a')fi+ # Suite sharding (opt-in via the shard_suites input): each platform's+ # C-suite run is split across N runner jobs. CBM_TEST_SHARD="i/N"+ # slices deterministically inside run-tests-parallel.sh; each+ # shard's union guard proves it ran exactly its slice; shards are+ # minted HERE from one expansion so a missing shard cannot be+ # configured silently; and the shard-completeness job re-proves the+ # cross-shard union at runtime. Ubuntu runners are plentiful (3+ # shards); Windows gets 2 (every extra shard re-pays ~5 min of+ # MSYS2 setup); macOS stays at 1 — mac legs are not the critical+ # path and mac runner concurrency ceilings are the tightest.+ if [ "$SHARDS" = "true" ]; then+ UNIX=$(jq -c '[.[] | . as $e+ | (if ($e.os | startswith("ubuntu")) then 3 else 1 end) as $n+ | range(1; $n + 1) as $i+ | $e + {shard: "\($i)/\($n)"}]' <<< "$UNIX")+ WIN=$(jq -c '[.[] | . as $e+ | range(1; 3) as $i+ | $e + {shard: "\($i)/2"}]' <<< "$WIN")+ fiecho "unix={\"include\":$UNIX}" >> "$GITHUB_OUTPUT"echo "windows={\"include\":$WIN}" >> "$GITHUB_OUTPUT"@@ -91,24 +115,54 @@ jobs:# on the compiler-binary CONTENT plus the fully preprocessed input, so a# hit is provably the identical compilation — a stale or foreign cache# can only miss, never return wrong output (see scripts/env.sh).- # Keys embed github.ref on top of GitHub's own branch scoping: caches are- # STRICTLY per-ref by policy — no base-branch fallback, a new PR builds- # cold once and only its own pushes warm it.- - name: Compiler cache (content-verified)- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ # Keys embed github.ref; the final ref-less restore key falls back to+ # the newest cache GitHub's scoping permits (a PR can only ever see its+ # own ref and the base branch, and base-branch caches are written only+ # by base-branch runs), so a fresh PR starts from main's warm cache+ # instead of building cold. Content verification is what makes that+ # safe; the fallback buys ~8-12 minutes on every first-of-ref build.+ - name: Compiler cache (content-verified, restore)+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: ${{ github.workspace }}/.ccachekey: ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-${{ github.sha }}+ # The cross-ref fallback is what keeps fresh PRs warm: without it a+ # new PR always started from a cold cache (observed 0% hit legs).+ # ccache verifies content hashes itself, so a stale cache can only+ # miss, never mis-compile.restore-keys: |ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-+ ccache-test-${{ matrix.os }}-${{ matrix.cc }}-- name: Testrun: scripts/test.sh CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}env:+ CBM_TEST_SHARD: ${{ matrix.shard }}+ CBM_TEST_LEG: ${{ matrix.os }}-${{ matrix.cc }}CBM_SKIP_PERF: ${{ inputs.skip_perf && '1' || '' }}CCACHE_DIR: ${{ github.workspace }}/.ccacheCCACHE_MAXSIZE: 1500M+ # Every shard of a leg builds the identical runner, so one shard's+ # cache carries the complete object set: shard 1 (or the unsharded+ # job) saves, the rest only restore — same save volume as before+ # sharding, no quota thrash, no same-key save races. Saving on failure+ # too keeps red iterations warm.+ - name: Shard manifest (completeness proof)+ if: always()+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: shard-manifest-${{ matrix.os }}-${{ matrix.cc }}-${{ strategy.job-index }}+ path: build/c/test-logs/shard-manifest.txt+ if-no-files-found: error++ - name: Compiler cache (save)+ if: always() && (matrix.shard == null || startsWith(matrix.shard, '1/'))+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ path: ${{ github.workspace }}/.ccache+ key: ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-${{ github.sha }}+- name: ccache statsif: always()run: ccache -s || true@@ -152,6 +206,7 @@ jobs:key: ccache-tsan-${{ matrix.os }}-${{ github.ref }}-${{ github.sha }}restore-keys: |ccache-tsan-${{ matrix.os }}-${{ github.ref }}-+ ccache-tsan-${{ matrix.os }}-- name: ThreadSanitizer tests# Calls make directly (no env.sh), so route the compilers through@@ -225,14 +280,28 @@ jobs:$acl.AddAccessRule($rule) | Out-NullSet-Acl -LiteralPath $root -AclObject $acl"CBM_CI_TEMP_ROOT=$root" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8+ # Pre-create the build directory with the same protected DACL so+ # every build product inherits it. The workspace drive root grants+ # Authenticated Users Modify by inheritance — a shape real user+ # checkouts (under the profile) do not have — and the activation+ # transaction's source-directory policy correctly refuses it, which+ # would fail the install-flow tests on the environment, not the code.+ $build = Join-Path $env:GITHUB_WORKSPACE "build\c"+ New-Item -ItemType Directory -Path $build -Force | Out-Null+ $bacl = [System.Security.AccessControl.DirectorySecurity]::new()+ $bacl.SetOwner($sid)+ $bacl.SetAccessRuleProtection($true, $false)+ $bacl.AddAccessRule($rule) | Out-Null+ Set-Acl -LiteralPath $build -AclObject $bacl- name: Compiler cache (content-verified)- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: ${{ github.workspace }}/.ccachekey: ccache-test-${{ matrix.os }}-${{ matrix.msystem }}-${{ github.ref }}-${{ github.sha }}restore-keys: |ccache-test-${{ matrix.os }}-${{ matrix.msystem }}-${{ github.ref }}-+ ccache-test-${{ matrix.os }}-${{ matrix.msystem }}-- name: Testshell: msys2 {0}@@ -256,6 +325,8 @@ jobs:export TMPDIR="$(cygpath -u "$CBM_CI_TEMP_ROOT")"scripts/test.sh CC=clang CXX=clang++ ${{ matrix.os == 'windows-11-arm' && 'SANITIZE=-fsanitize=undefined -fsanitize-trap=undefined -fstack-protector-strong -fno-omit-frame-pointer' || '' }}env:+ CBM_TEST_SHARD: ${{ matrix.shard }}+ CBM_TEST_LEG: ${{ matrix.os }}-${{ matrix.msystem }}CBM_SKIP_PERF: ${{ inputs.skip_perf && '1' || '' }}CCACHE_DIR: ${{ github.workspace }}/.ccacheCCACHE_MAXSIZE: 1500M@@ -267,6 +338,82 @@ jobs:env:CCACHE_DIR: ${{ github.workspace }}/.ccache+ - name: Shard manifest (completeness proof)+ if: always()+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: shard-manifest-${{ matrix.os }}-${{ matrix.msystem }}-${{ strategy.job-index }}+ path: build/c/test-logs/shard-manifest.txt+ if-no-files-found: error++ # Shard 1 (or the unsharded job) saves the compiler cache; every shard+ # builds the identical runner, so one cache carries the full object set.+ - name: Compiler cache (save)+ if: always() && (matrix.shard == null || startsWith(matrix.shard, '1/'))+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ path: ${{ github.workspace }}/.ccache+ key: ccache-test-${{ matrix.os }}-${{ matrix.msystem }}-${{ github.ref }}-${{ github.sha }}++ # Cross-shard completeness: re-proves at runtime that each leg's shards+ # agreed on the full suite list and that the union of their slices IS that+ # list. This is the guard the per-shard union checks cannot provide: a+ # mis-plumbed CBM_TEST_SHARD (two jobs running the same slice) passes every+ # per-shard guard while a slice runs nowhere — only a cross-shard view+ # catches it. Runs and gates on unsharded topologies too (every leg then+ # contributes one 1/1 manifest whose slice must equal the full list).+ shard-completeness:+ needs: [test-unix, test-windows]+ if: always()+ runs-on: ubuntu-latest+ timeout-minutes: 10+ steps:+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ pattern: shard-manifest-*+ path: manifests++ - name: Verify cross-shard union per leg+ run: |+ set -eu+ files=$(find manifests -name shard-manifest.txt | sort)+ if [ -z "$files" ]; then+ echo "FAIL: no shard manifests were uploaded" >&2+ exit 1+ fi+ rc=0+ for leg in $(grep -h '^leg=' $files | sort -u | sed 's/^leg=//'); do+ leg_files=$(grep -l "^leg=$leg\$" $files)+ n=$(grep -h '^shard=' $leg_files | sed 's|.*/||' | sort -u)+ if [ "$(printf '%s\n' "$n" | wc -l)" -ne 1 ]; then+ echo "FAIL: $leg shards disagree on shard count: $n" >&2+ rc=1+ continue+ fi+ indices=$(grep -h '^shard=' $leg_files | sed 's/^shard=//;s|/.*||' | sort -n)+ if [ "$indices" != "$(seq 1 "$n")" ]; then+ echo "FAIL: $leg shard indices [$indices] != 1..$n" >&2+ rc=1+ continue+ fi+ list_sha=$(grep -h '^list_sha256=' $leg_files | sed 's/^list_sha256=//' | sort -u)+ if [ "$(printf '%s\n' "$list_sha" | wc -l)" -ne 1 ]; then+ echo "FAIL: $leg shards saw different suite lists" >&2+ rc=1+ continue+ fi+ union_sha=$(for f in $leg_files; do+ sed -n '/^--- slice ---$/,$p' "$f" | tail -n +2+ done | sort | sha256sum | awk '{print $1}')+ if [ "$union_sha" != "$list_sha" ]; then+ echo "FAIL: $leg union of shard slices != full suite list (GATE-QUALITY LOSS)" >&2+ rc=1+ continue+ fi+ echo "OK: $leg — $n shard(s), union of slices == full suite list"+ done+ exit "$rc"+# Windows product-surface regression guards. Distinct from test-windows above# (the sanitizer C suite): these drive a real product binary + embedded HTTP UI# over stdio / CLI / HTTP and fail if a Windows bug already fixed on main comes@@ -307,6 +454,7 @@ jobs:key: ccache-guards-${{ github.ref }}-${{ github.sha }}restore-keys: |ccache-guards-${{ github.ref }}-+ ccache-guards-- name: Build product binary with embedded UIshell: msys2 {0}diff --git a/.github/workflows/cache-warm.yml b/.github/workflows/cache-warm.ymlnew file mode 100644index 000000000..65a6d02d5--- /dev/null+++ b/.github/workflows/cache-warm.yml@@ -0,0 +1,123 @@+# Nightly compiler-cache warming for main's scope. GitHub cache isolation+# lets a PR restore only caches written by its own ref or the base branch —+# and nothing used to write test caches in main's scope (the test workflow+# runs on pull_request and workflow_dispatch only), so the cross-ref+# fallback restore keys in _test.yml had no warm source and every fresh PR+# built cold. This build-only job (no tests) keeps main-scoped caches at+# most a day stale; CCACHE_COMPILERCHECK=content turns staleness into+# partial misses, never wrong output. The build commands and ccache+# environment mirror scripts/test.sh's build phase exactly — a warm entry+# only hits when flags and compiler content match, so fidelity here is what+# makes the cache useful.+name: Cache warm++on:+ schedule:+ - cron: '17 2 * * *'+ workflow_dispatch: {}++permissions:+ contents: read++jobs:+ warm-unix:+ strategy:+ fail-fast: false+ matrix:+ include:+ - { os: ubuntu-latest, cc: gcc, cxx: g++ }+ - { os: ubuntu-24.04-arm, cc: gcc, cxx: g++ }+ - { os: macos-14, cc: cc, cxx: c++ }+ - { os: macos-15-intel, cc: cc, cxx: c++ }+ runs-on: ${{ matrix.os }}+ timeout-minutes: 60+ steps:+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0++ - name: Install deps (Ubuntu)+ if: startsWith(matrix.os, 'ubuntu')+ run: sudo apt-get update && sudo apt-get install -y zlib1g-dev ccache++ - name: Install ccache (macOS)+ if: startsWith(matrix.os, 'macos')+ run: command -v ccache >/dev/null 2>&1 || brew install ccache++ - name: Compiler cache (restore)+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ path: ${{ github.workspace }}/.ccache+ key: ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-${{ github.sha }}+ restore-keys: |+ ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-+ ccache-test-${{ matrix.os }}-${{ matrix.cc }}-++ - name: Build (test runner + product, no tests)+ run: |+ source scripts/env.sh+ make -j"$(getconf _NPROCESSORS_ONLN)" -f Makefile.cbm \+ build/c/test-runner cbm CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}+ env:+ CCACHE_DIR: ${{ github.workspace }}/.ccache+ CCACHE_MAXSIZE: 1500M++ - name: ccache stats+ run: ccache -sv || ccache -s+ env:+ CCACHE_DIR: ${{ github.workspace }}/.ccache++ - name: Compiler cache (save)+ if: always()+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ path: ${{ github.workspace }}/.ccache+ key: ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-${{ github.sha }}++ warm-windows:+ runs-on: windows-latest+ timeout-minutes: 90+ defaults:+ run:+ shell: msys2 {0}+ steps:+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0++ - uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2+ with:+ msystem: CLANG64+ path-type: inherit+ install: >-+ mingw-w64-clang-x86_64-clang+ mingw-w64-clang-x86_64-compiler-rt+ mingw-w64-clang-x86_64-zlib+ mingw-w64-clang-x86_64-ccache+ make+ git++ - name: Compiler cache (restore)+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ path: ${{ github.workspace }}/.ccache+ key: ccache-test-windows-latest-CLANG64-${{ github.ref }}-${{ github.sha }}+ restore-keys: |+ ccache-test-windows-latest-CLANG64-${{ github.ref }}-+ ccache-test-windows-latest-CLANG64-++ - name: Build (test runner + product, no tests)+ run: |+ source scripts/env.sh+ make -j"$(nproc)" -f Makefile.cbm build/c/test-runner cbm CC=clang CXX=clang+++ env:+ CCACHE_DIR: ${{ github.workspace }}/.ccache+ CCACHE_MAXSIZE: 1500M++ - name: ccache stats+ run: ccache -sv || ccache -s+ env:+ CCACHE_DIR: ${{ github.workspace }}/.ccache++ - name: Compiler cache (save)+ if: always()+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ path: ${{ github.workspace }}/.ccache+ key: ccache-test-windows-latest-CLANG64-${{ github.ref }}-${{ github.sha }}diff --git a/scripts/run-tests-parallel.sh b/scripts/run-tests-parallel.shindex eab4607ed..05a223722 100644--- a/scripts/run-tests-parallel.sh+++ b/scripts/run-tests-parallel.sh@@ -52,6 +52,55 @@ if [ "$NSUITES" -lt 1 ] || grep -qvE '^[a-z0-9_]+$' "$SUITES_FILE"; thenecho "FAIL: suite list empty or malformed (runner too old for --list-suites?)" >&2exit 1fi++# CBM_TEST_SHARD="i/N" runs this invocation's deterministic slice of the+# suite list so CI can spread one platform's suites across N runner jobs.+# Unset (or "1/1") selects everything — the sharding path is inert unless a+# workflow opts in. The slice is a pure function of (--list-suites, i, N):+# every shard recomputes the same assignment, so N jobs with indices 1..N+# cover the full list by construction, and each job's union guard below+# proves it ran exactly its slice.+SHARD_INDEX=1+SHARD_TOTAL=1+if [ -n "${CBM_TEST_SHARD:-}" ]; then+ if ! printf '%s' "$CBM_TEST_SHARD" | grep -qE '^[0-9]+/[0-9]+$'; then+ echo "FAIL: CBM_TEST_SHARD must be i/N, got '$CBM_TEST_SHARD'" >&2+ exit 1+ fi+ SHARD_INDEX="${CBM_TEST_SHARD%%/*}"+ SHARD_TOTAL="${CBM_TEST_SHARD##*/}"+ if [ "$SHARD_TOTAL" -lt 1 ] || [ "$SHARD_INDEX" -lt 1 ] ||+ [ "$SHARD_INDEX" -gt "$SHARD_TOTAL" ]; then+ echo "FAIL: CBM_TEST_SHARD out of range: $CBM_TEST_SHARD" >&2+ exit 1+ fi+fi++# Deal the known-heavy suites round-robin FIRST so no shard receives a+# second heavy suite before every shard holds one — shard wall time is+# bounded by its heaviest member, and naive modulo can stack store_arch and+# daemon_runtime (the two slowest sanitized suites) onto one job.+shard_filter() {+ awk -v idx="$SHARD_INDEX" -v total="$SHARD_TOTAL" '+ BEGIN {+ nh = split("store_arch daemon_runtime incremental cli extraction " \+ "watcher daemon_ipc subprocess httpd py_lsp_stress " \+ "grammar_regression mcp daemon_frontend pipeline", h, " ")+ }+ { present[$0] = NR; lines[NR] = $0 }+ END {+ # Deal heavies in WEIGHT order (the static list above), not file+ # order: the point is that the two slowest suites land on+ # different shards, which file-order dealing does not guarantee.+ n = 0+ for (i = 1; i <= nh; i++)+ if (h[i] in present) { order[++n] = h[i]; taken[h[i]] = 1 }+ for (i = 1; i <= NR; i++)+ if (!(lines[i] in taken)) order[++n] = lines[i]+ for (i = 1; i <= n; i++) if ((i - 1) % total == idx - 1) print order[i]+ }+ '+}# Timing-sensitive suites run SEQUENTIALLY after the parallel wave: they# spawn subprocesses / watch the filesystem / bind ports with fixed# deadlines, and a saturated 4-core CI runner starves those deadlines into@@ -87,7 +136,16 @@ while IFS= read -r sname; doecho "$sname" >> "$PAR_FILE"fidone < "$SUITES_FILE"-echo "=== parallel test run: $NSUITES suites ($(wc -l < "$SER_FILE" | tr -d ' ') serial-tail), $JOBS jobs ==="++# The parallel wave and the serial tail are sharded separately: every shard+# keeps its own quiet tail for the deadline-sensitive suites (its runner is+# a whole machine, so the tail is at least as quiet as before sharding).+shard_filter < "$PAR_FILE" > "$PAR_FILE.shard" && mv "$PAR_FILE.shard" "$PAR_FILE"+shard_filter < "$SER_FILE" > "$SER_FILE.shard" && mv "$SER_FILE.shard" "$SER_FILE"+SHARD_EXPECT="$LOGDIR/suites-shard.txt"+cat "$PAR_FILE" "$SER_FILE" > "$SHARD_EXPECT"+NSHARD=$(wc -l < "$SHARD_EXPECT" | tr -d ' ')+echo "=== parallel test run: $NSHARD of $NSUITES suites (shard ${SHARD_INDEX}/${SHARD_TOTAL}, $(wc -l < "$SER_FILE" | tr -d ' ') serial-tail), $JOBS jobs ==="export RUNNER LOGDIR RESULTS_FILErun_one() {@@ -96,11 +154,14 @@ run_one() {# Per-suite wall-clock ceiling so a wedged suite fails LOUDLY instead of# blocking the run (and the single local build slot) indefinitely. The# `incremental` suite legitimately re-indexes large fixtures (minutes) so- # it gets a wider ceiling until the template-DB fixture refactor lands.+ # it gets a wider ceiling until the template-DB fixture refactor lands;+ # `daemon_runtime` measures ~610s SOLO on arm64 under ASan (10-round+ # loop), so on an overloaded 4-job CI runner the 900s default is a+ # slowness kill, not a hang detector — it joins the slow tier.# Uses `timeout` where available (always in the Linux container / CI); on a# host without it the suite runs uncapped (no regression vs before).case "$s" in- incremental | store_arch) st="${CBM_SUITE_TIMEOUT_SLOW:-3600}" ;;+ incremental | store_arch | daemon_runtime) st="${CBM_SUITE_TIMEOUT_SLOW:-3600}" ;;*) st="${CBM_SUITE_TIMEOUT:-900}" ;;esacif command -v timeout >/dev/null 2>&1; then@@ -130,12 +191,30 @@ while IFS= read -r sname; dorun_one "$sname"done < "$SER_FILE"-# ── Union guard: every listed suite produced exactly one result ──-MISSING=$(comm -23 <(sort "$SUITES_FILE") <(awk '{print $1}' "$RESULTS_FILE" | sort -u))+# Machine-checkable manifest for CI's cross-shard completeness job: it+# proves at runtime that the shards of one leg agree on N and on the full+# suite list, and that the union of their slices IS that list — the guard+# against a mis-plumbed CBM_TEST_SHARD (two jobs running the same slice+# passes every per-shard check but silently drops a slice; only a+# cross-shard view catches it).+{+ echo "leg=${CBM_TEST_LEG:-local}"+ echo "shard=${SHARD_INDEX}/${SHARD_TOTAL}"+ echo "list_sha256=$(sort "$SUITES_FILE" | { sha256sum 2>/dev/null || shasum -a 256; } | awk '{print $1}')"+ echo "--- slice ---"+ cat "$SHARD_EXPECT"+} > "$LOGDIR/shard-manifest.txt"++# ── Union guard: every suite in this shard's slice produced exactly one+# result. The slice is deterministic, so N green shard jobs = full coverage;+# a shard that ran anything more, less, or twice fails here. ──+MISSING=$(comm -23 <(sort "$SHARD_EXPECT") <(awk '{print $1}' "$RESULTS_FILE" | sort -u))+EXTRA=$(comm -13 <(sort "$SHARD_EXPECT") <(awk '{print $1}' "$RESULTS_FILE" | sort -u))DUPES=$(awk '{print $1}' "$RESULTS_FILE" | sort | uniq -d)-if [ -n "$MISSING" ] || [ -n "$DUPES" ]; then- echo "FAIL: shard union does not match --list-suites (GATE-QUALITY LOSS)" >&2+if [ -n "$MISSING" ] || [ -n "$EXTRA" ] || [ -n "$DUPES" ]; then+ echo "FAIL: shard union does not match its --list-suites slice (GATE-QUALITY LOSS)" >&2[ -n "$MISSING" ] && echo " never ran: $MISSING" >&2+ [ -n "$EXTRA" ] && echo " outside slice: $EXTRA" >&2[ -n "$DUPES" ] && echo " ran twice: $DUPES" >&2exit 1fi