Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Run unit tests in 34 shards so each fits its time budget with the new weights
garrytan18321331e3eb
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex 37601b0329..cf97913846 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -927,7 +927,7 @@ jobs:strategy:fail-fast: falsematrix:- shard: [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]+ shard: [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]steps:- id: checkoutuses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4@@ -943,8 +943,8 @@ jobs:- name: Install dependencies (bounded, retried once)timeout-minutes: 8run: bun scripts/ci-bun-install.ts --frozen-lockfile- - name: Coverage shard ${{ matrix.shard }}/30- run: scripts/test-shard.sh ${{ matrix.shard }} 30+ - name: Coverage shard ${{ matrix.shard }}/34+ run: scripts/test-shard.sh ${{ matrix.shard }} 34env:COVERAGE_DIR: ${{ runner.temp }}/coverageGBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receipts@@ -1303,7 +1303,7 @@ jobs:bun scripts/merge-lcov.ts \--out-lcov "$RUNNER_TEMP/coverage-full-merged/lcov.info" \--out-json "$RUNNER_TEMP/coverage-full-merged/summary.json" \- --manifest-expect shard-1,shard-2,shard-3,shard-4,shard-5,shard-6,shard-7,shard-8,shard-9,shard-10,shard-11,shard-12,shard-13,shard-14,shard-15,shard-16,shard-17,shard-18,shard-19,shard-20,shard-21,shard-22,shard-23,shard-24,shard-25,shard-26,shard-27,shard-28,shard-29,shard-30,serial,slow,e2e-1,e2e-2,e2e-3,e2e-4 \+ --manifest-expect shard-1,shard-2,shard-3,shard-4,shard-5,shard-6,shard-7,shard-8,shard-9,shard-10,shard-11,shard-12,shard-13,shard-14,shard-15,shard-16,shard-17,shard-18,shard-19,shard-20,shard-21,shard-22,shard-23,shard-24,shard-25,shard-26,shard-27,shard-28,shard-29,shard-30,shard-31,shard-32,shard-33,shard-34,serial,slow,e2e-1,e2e-2,e2e-3,e2e-4 \"$RUNNER_TEMP/coverage-artifacts"- name: Coverage summary → step summaryif: steps.shards.outputs.state == 'complete'diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex 128c2e9745..2b6cc6ebf9 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -1043,10 +1043,11 @@ jobs:# 568 for 18 solo jobs) mined ~12,640s of file time, ~1.4x the solo# weights.#- # 30 shards (UNIT_SHARDS in scripts/sharding.ts): the median of five Test- # nightlies (runs 42180931870 to 42979455461, 2026-11) mined ~16,830s of- # file time, ~561s per shard; at 28 that was ~601s, over the budget. Run- # 40468581224 (2026-10-27) mined ~14,950s, ~534s per shard at 28. A+ # 34 shards (UNIT_SHARDS in scripts/sharding.ts): the median of five Test+ # nightlies (runs 42351236096 to 43385685475, 2026-11-13) mined ~18,000s+ # of file time, ~529s per shard; at 30 that was ~600.03s, over the budget.+ # The 2026-11 nightlies before them (runs 42180931870 to 42979455461)+ # mined ~16,830s, ~561s per shard at 30. A# shard's mined weight must fit this job's 22 minutes twice over, after a# minute of setup, with a minute to spare# (UNIT_SHARD_BUDGET_MS, 600s; test/scripts/unit-shard-budget.test.ts).@@ -1070,7 +1071,7 @@ jobs:strategy:fail-fast: falsematrix:- shards: [[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]]+ shards: [[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]]steps:- id: checkoutuses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4@@ -1113,9 +1114,9 @@ jobs:awk '/^cpu /{print "steal_jiffies", $9}' /proc/statlscpu | grep -m1 'Model name'(while true; do free -m | awk '/^Mem:/{print $3, $7}' >> "$RUNNER_TEMP/mem.log"; sleep 5; done) > /dev/null 2>&1 &- - name: Run test shards ${{ join(matrix.shards, ' and ') }} of 30+ - name: Run test shards ${{ join(matrix.shards, ' and ') }} of 34shell: bash- run: bash scripts/test-shard-pack.sh 30 ${{ join(matrix.shards, ' ') }}+ run: bash scripts/test-shard-pack.sh 34 ${{ join(matrix.shards, ' ') }}env:GBRAIN_SHARD_PACK_DIR: ${{ runner.temp }}/shards- name: Runner diagnostics (after shard)@@ -1182,7 +1183,7 @@ jobs:# ──────────────────────────────────────────────────────────────────────- # coverage-report: merges the PR corpus (30 unit + 4 serial + 2 slow+ # coverage-report: merges the PR corpus (34 unit + 4 serial + 2 slow# lanes) into one honest number, renders it to the step summary, and runs# the diff + baseline gates in report-only mode (COVERAGE_GATE_ENFORCE=0).# ADVISORY during the report-only window: deliberately NOT in test-status's@@ -1235,7 +1236,7 @@ jobs:bun scripts/merge-lcov.ts \--out-lcov "$RUNNER_TEMP/coverage-merged/lcov.info" \--out-json "$RUNNER_TEMP/coverage-merged/summary.json" \- --manifest-expect shard-1,shard-2,shard-3,shard-4,shard-5,shard-6,shard-7,shard-8,shard-9,shard-10,shard-11,shard-12,shard-13,shard-14,shard-15,shard-16,shard-17,shard-18,shard-19,shard-20,shard-21,shard-22,shard-23,shard-24,shard-25,shard-26,shard-27,shard-28,shard-29,shard-30,serial-1,serial-2,serial-3,serial-4,slowperf,slowbrainbench \+ --manifest-expect shard-1,shard-2,shard-3,shard-4,shard-5,shard-6,shard-7,shard-8,shard-9,shard-10,shard-11,shard-12,shard-13,shard-14,shard-15,shard-16,shard-17,shard-18,shard-19,shard-20,shard-21,shard-22,shard-23,shard-24,shard-25,shard-26,shard-27,shard-28,shard-29,shard-30,shard-31,shard-32,shard-33,shard-34,serial-1,serial-2,serial-3,serial-4,slowperf,slowbrainbench \"$RUNNER_TEMP/coverage-artifacts"- name: Coverage summary → step summaryrun: bun scripts/render-coverage-summary.ts --summary "$RUNNER_TEMP/coverage-merged/summary.json" --structural scripts/structural-suites.tsv >> "$GITHUB_STEP_SUMMARY"diff --git a/docs/TESTING.md b/docs/TESTING.mdindex da7c6a974b..391a4c59eb 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -660,7 +660,7 @@ evidence for a change before it merges. `test.yml`'s security matrix,### Keeping CI partitions balanced-Required CI runs 30 weighted unit workers, four serial workers with bounded+Required CI runs 34 weighted unit workers, four serial workers with boundedper-file pools, and up to eight selected E2E workers. E2E selection and exclusionsrun once before setup; the resulting file lists are frozen and executed againstseparate Postgres services. An explicit empty selection launches no tests;@@ -1269,7 +1269,7 @@ there even though they pass on Linux and macOS.### CI vs local: intentionally divergent file sets-- **CI matrix** (`.github/workflows/test.yml`) runs 30 `scripts/test-shard.sh` shards, two per runner, split by weight-aware LPT bin-packing (`scripts/sharding.ts`; unweighted files get the p75 weight) and includes `*.slow.test.ts` files without a dedicated job, plus keyless-allowlisted `evals/**/*.test.ts` (`test/scripts/evals-collection.test.ts`). Shards keep planned file order (`test-shard.sh --dry-run-list <i> 18`) and print their predicted weight (`sharding.ts --sum`). Every Bun job activates the PGLite schema snapshot (built in-runner, cached across jobs; the runner's hash check is authoritative). Serial files run across four `serial-tests` workers via `bun run test:serial`; `verify`, `typecheck` and the BrainBench memory-conformance gate (`scripts/ci-brainbench-gate.sh`, compared against `evals/brainbench/baselines/main.json`) have their own jobs, all aggregated by `test-status`. `e2e.yml` aggregates through `e2e-status`, with jsonb-parity gating Tier 2's token spend; scheduled runs also require the full-corpus lanes. Both aggregates reject failures, cancellations and unexpected skips. Only a master push and the remote gate reuse results: those of a passed full run of the exact tree (`scripts/ci-reuse.ts`). CI is the ground truth for "did everything pass."+- **CI matrix** (`.github/workflows/test.yml`) runs 34 `scripts/test-shard.sh` shards, two per runner, split by weight-aware LPT bin-packing (`scripts/sharding.ts`; unweighted files get the p75 weight) and includes `*.slow.test.ts` files without a dedicated job, plus keyless-allowlisted `evals/**/*.test.ts` (`test/scripts/evals-collection.test.ts`). Shards keep planned file order (`test-shard.sh --dry-run-list <i> 18`) and print their predicted weight (`sharding.ts --sum`). Every Bun job activates the PGLite schema snapshot (built in-runner, cached across jobs; the runner's hash check is authoritative). Serial files run across four `serial-tests` workers via `bun run test:serial`; `verify`, `typecheck` and the BrainBench memory-conformance gate (`scripts/ci-brainbench-gate.sh`, compared against `evals/brainbench/baselines/main.json`) have their own jobs, all aggregated by `test-status`. `e2e.yml` aggregates through `e2e-status`, with jsonb-parity gating Tier 2's token spend; scheduled runs also require the full-corpus lanes. Both aggregates reject failures, cancellations and unexpected skips. Only a master push and the remote gate reuse results: those of a passed full run of the exact tree (`scripts/ci-reuse.ts`). CI is the ground truth for "did everything pass."- **Local fast loop** (`scripts/run-unit-shard.sh` via the parallel wrapper) uses the same weighted partitioner as CI and EXCLUDES `*.slow.test.ts` AND `*.serial.test.ts`. Each shard runs its complete ordered selection with a fresh Bun process per file, without adding workers. Later groups still run after failures; missing summaries or file-completion evidence fail the shard. Local trades coverage for inner-loop speed; CI catches what local skips.`test/scripts/run-unit-shard.test.ts` pins what the local loop includes, and@@ -1301,8 +1301,8 @@ normalizes `COVERAGE_DIR` to an absolute path before moving `HOME`, andcoverage lane). Both names avoid the `GBRAIN_` prefix so the env scrub keepsthem.-**Two corpora.** `prCorpus` is the 36 coverage-collecting lanes in-`test.yml` (30 unit shards, 4 serial partitions, `slow-entity-resolve-perf` and+**Two corpora.** `prCorpus` is the 40 coverage-collecting lanes in+`test.yml` (34 unit shards, 4 serial partitions, `slow-entity-resolve-perf` and`slow-brainbench-e2e`), identical on every PR; the gates run against it.`fullCorpus` is the nightly (or manual `full_corpus=true`) set in `e2e.yml`:`coverage-full-{unit,serial,slow,e2e}` plus `coverage-full-report`, every lane@@ -1362,10 +1362,10 @@ spawned CLI processes undercounts, and `src/cli.ts` carries a permanentrecord; the summary lists those as a count and a sorted list, never apercentage.-**Local smoke** (one shard of 30; this checks the plumbing, not the number):+**Local smoke** (one shard of 34; this checks the plumbing, not the number):```bash-COVERAGE_DIR=$PWD/.coverage bash scripts/test-shard.sh 1 30 \+COVERAGE_DIR=$PWD/.coverage bash scripts/test-shard.sh 1 34 \&& bun scripts/merge-lcov.ts --out-lcov .coverage/merged.lcov --out-json .coverage/summary.json .coverage \&& bun scripts/render-coverage-summary.ts --summary .coverage/summary.json --structural scripts/structural-suites.tsv```diff --git a/scripts/sharding.ts b/scripts/sharding.tsindex 5f33315c73..fba6a27fe9 100644--- a/scripts/sharding.ts+++ b/scripts/sharding.ts@@ -54,7 +54,7 @@ const DEFAULT_WEIGHTS_PATH = resolve(REPO_ROOT, "scripts/test-weights.json");* test.yml's unit matrix size, also e2e.yml's coverage-full-unit matrix;* test/scripts/unit-shard-budget.test.ts pins both workflows to it.*/-export const UNIT_SHARDS = 30;+export const UNIT_SHARDS = 34;/** Unit shards each test.yml `test` job runs at once (scripts/test-shard-pack.sh); test/scripts/ci-gates.test.ts pins the matrix to it. */export const UNIT_SHARDS_PER_JOB = 2;/** test.yml's `test` job `timeout-minutes: 22`: the only bound on a unit shard, its setup steps included. */