Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

ci: run unit-lane PostgreSQL arms in 14 shards

garrytandf51f7fd3b1a
diff --git a/.github/workflows/persistence-validation.yml b/.github/workflows/persistence-validation.yml
index 93be06b304..ed45f8a13e 100644
--- a/.github/workflows/persistence-validation.yml
+++ b/.github/workflows/persistence-validation.yml
@@ -178,18 +178,18 @@ jobs:
# file; the PGLite arm also runs in the unit lane). The list is test/postgres-unit-arms.txt;
# scripts/check-postgres-lane-coverage.ts fails a new DATABASE_URL-gated arm
# until it is listed there or wrapped in a test/e2e registerPostgresTests
- # file. The twelve shards (ARM_SHARDS in scripts/postgres-unit-arms.ts) are
+ # file. The fourteen shards (ARM_SHARDS in scripts/postgres-unit-arms.ts) are
# balanced by measured runtime (scripts/postgres-arm-weights.json, mined from
# this job's logs); each shard's measured sum, doubled for a slow runner, must
# end a minute inside the step's 20 minutes (ARM_SHARD_BUDGET_MS).
unit-postgres-arms:
- name: Unit-lane PostgreSQL arms ${{ matrix.shard }}/12 / Bun ${{ matrix.bun }}
+ name: Unit-lane PostgreSQL arms ${{ matrix.shard }}/14 / Bun ${{ matrix.bun }}
runs-on: ubicloud-standard-4-ubuntu-2404
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
- shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
+ shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
bun: ['1.4.0', '1.4.3']
# Event parity: every event, pull requests and merge-queue runs
# included, runs both supported Bun versions (docs/TESTING.md#event-parity).
@@ -230,11 +230,11 @@ jobs:
receipts_init pg-arms || exit 2
# The list lives in test/postgres-unit-arms.txt (one path per line);
# shards balance by measured runtime (scripts/postgres-arm-weights.json).
- selected=$(bun scripts/postgres-unit-arms.ts shard "$SHARD" 12)
+ selected=$(bun scripts/postgres-unit-arms.ts shard "$SHARD" 14)
files=()
while IFS= read -r file; do [ -n "$file" ] && files+=("$file"); done <<< "$selected"
if [ "${#files[@]}" -eq 0 ]; then
- echo "::error::shard $SHARD/8 selected no files from test/postgres-unit-arms.txt. Why: an empty shard would pass without running any PostgreSQL arm. Fix: run 'bun scripts/postgres-unit-arms.ts shard $SHARD 12' locally and correct the list. Docs: docs/TESTING.md#postgres-arm-lanes" >&2
+ echo "::error::shard $SHARD/14 selected no files from test/postgres-unit-arms.txt. Why: an empty shard would pass without running any PostgreSQL arm. Fix: run 'bun scripts/postgres-unit-arms.ts shard $SHARD 14' locally and correct the list. Docs: docs/TESTING.md#postgres-arm-lanes" >&2
exit 1
fi
# One bun process per file: *.serial.test.ts files require their own
diff --git a/docs/architecture/key-files/ci-health-and-test-guards.md b/docs/architecture/key-files/ci-health-and-test-guards.md
index 3845cc5c4e..02ffd36f37 100644
--- a/docs/architecture/key-files/ci-health-and-test-guards.md
+++ b/docs/architecture/key-files/ci-health-and-test-guards.md
@@ -20,7 +20,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL
- `scripts/scale/watchdog.ts` — out-of-process phase watchdog for the scale harness. `scripts/scale/run.ts` re-runs itself as a child; the supervisor times the `import`, `extract`, `vectors` and `budgets` phases from the child's `[scale] phase <name> start` lines and kills the child's process group at 1.5x the phase's gate ceiling (`scripts/scale/gates.ts` `phaseLimitsMs`), names the phase, elapsed time and last progress line, then removes the brain home and scale database. `GBRAIN_SCALE_PHASE_LIMIT_MS_<PHASE>` overrides one limit; `GBRAIN_SCALE_SUPERVISED` is the internal handshake. Tests: `test/scripts/scale-watchdog.test.ts`.
- `scripts/check-test-env-opt-ins.ts` + `test/helpers/operator-env-policy.ts` — the opt-in naming rule. The policy (`STRIP_PREFIX`, `KEEP_EXACT`, `KEEP_PREFIX`, `RENAMED`, `isStripped`) is shared by `test/helpers/operator-env-preload.ts`, which deletes stripped `GBRAIN_*` names before any test loads and stops the run with the rename command when an old opt-in name is set, and by the guard (`check:test-env-opt-ins`, in `verify`), which parses test files and fails on a test that gates execution on a stripped name. Test opt-ins are `GBRAIN_TEST_<AREA>_<WHAT>`, paid ones `GBRAIN_TEST_LIVE_<WHAT>`. The same guard fails `test_env_snapshot_module_scope`: a `delete` of or assignment to `process.env.GBRAIN_PGLITE_SNAPSHOT` outside every function body in a file the unit matrix loads (`*.serial.test.ts`, `test/e2e/` and `*-preload.ts` are exempt: own process, or process-wide by design). `scripts/test-shard.sh` runs a whole shard in one bun process, so such a change persists for every later file and each of their PGLite engines cold-boots (~3 s); the accepted shape is save+delete in `beforeAll`, restore in `afterAll`, or `test/helpers/with-snapshot.ts` per test. Tests: `test/scripts/test-env-opt-ins-guard.test.ts`, `test/operator-env-preload.test.ts`.
- `scripts/check-postgres-lane-coverage.ts` — `check:postgres-lanes` (in `verify`). TypeScript-AST scan of every `test/` file outside `test/e2e/` and `test/fixtures/` for a `DATABASE_URL`-gated PostgreSQL arm (zero-argument `testBackends()`, or a `DATABASE_URL` read used as a condition, connection argument or `database_url` value; `withEnv`-supplied URLs excluded) and a lane that runs it (a workflow step with `DATABASE_URL` naming the file, a `test/e2e/` importer, a `tests/heavy/` script, or a `scripts/e2e-backend-matrix.txt` row). `ALLOWLIST` rows name a reason and TODO; stale rows fail. A `test/postgres-unit-arms.txt` row is a lane; a malformed, duplicate, unsorted, missing-file or arm-less row fails (`postgres_arm_list_invalid`, `postgres_arm_list_stale`). `postgresArm`, `postgresLanes` and `armedFiles` are exported for the stress runner. Tests: `test/scripts/postgres-lane-coverage.test.ts`.
-- `test/postgres-unit-arms.txt` + `scripts/postgres-unit-arms.ts` + `scripts/postgres-arm-weights.json` — the one list of unit-lane files whose PostgreSQL arm has no other owner (sorted, one path per line, `#` comments). Read by persistence-validation.yml's `unit-postgres-arms` job (`ARM_SHARDS` = 12 shards, `shard <n> <m>`: LPT over the mined per-file weights, p75 fallback; one Bun process per file; each shard's weighted sum at most `ARM_SHARD_BUDGET_MS`, 570 s, so twice that still ends a minute inside the 20-minute `ARM_STEP_TIMEOUT_MS` step), the scheduled race hunt and the lane guard. `mine <job.log>…` rewrites the weights from a green run's shard logs (`##[group]<file>` to the next group or endgroup). Tests: `test/scripts/postgres-unit-arms.test.ts`.
+- `test/postgres-unit-arms.txt` + `scripts/postgres-unit-arms.ts` + `scripts/postgres-arm-weights.json` — the one list of unit-lane files whose PostgreSQL arm has no other owner (sorted, one path per line, `#` comments). Read by persistence-validation.yml's `unit-postgres-arms` job (`ARM_SHARDS` = 14 shards, `shard <n> <m>`: LPT over the mined per-file weights, p75 fallback; one Bun process per file; each shard's weighted sum at most `ARM_SHARD_BUDGET_MS`, 570 s, so twice that still ends a minute inside the 20-minute `ARM_STEP_TIMEOUT_MS` step), the scheduled race hunt and the lane guard. `mine <job.log>…` rewrites the weights from a green run's shard logs (`##[group]<file>` to the next group or endgroup). Tests: `test/scripts/postgres-unit-arms.test.ts`.
- `scripts/serial-files.tsv` + `scripts/lib/serial-manifest.ts` — the serial manifest: every `*.serial.test.ts` outside `test/e2e/` with its class (`R1`, `R2`, `global-state`, `exclusive`) and a reason. `checkSerialManifest` (pure) requires the manifest to match the tree exactly, classes to match what the file does (env mutation, `mock.module`, `EXCLUSIVE_FILES`) and reasons to be specific; each failure prints Why/Fix/Docs with `bash scripts/check-test-isolation.sh --as-parallel <file>` as the first step. Tests: `test/scripts/serial-files.test.ts`.
- `test/helpers/brain-template.ts` — disk-backed PGLite brains cloned from one initialized template per process and embedding shape. The template is captured right after `initSchema` with no source, writer or physical-root reservation (asserted); only the data directory is copied; each clone regenerates `brain_id`, the default source incarnation and the shared-skill token secret and serving epoch. Used by `test/helpers/connector-fixture.ts`. Tests: `test/helpers/brain-template.test.ts`.
- `scripts/test-agent-voice.sh` — `bun run test:agent-voice`: the agent-voice recipe's vitest unit suite (`recipes/agent-voice/tests/unit`), with pinned vitest and ws installed into a temporary prefix linked as the recipe's `node_modules`. Needs node, npm and registry access; CI runs it in test.yml's verify job.
diff --git a/scripts/postgres-unit-arms.ts b/scripts/postgres-unit-arms.ts
index 5a75fe67aa..01a962b146 100644
--- a/scripts/postgres-unit-arms.ts
+++ b/scripts/postgres-unit-arms.ts
@@ -24,7 +24,7 @@ import { loadWeights, partition } from './sharding.ts';
export const ARMS_LIST = 'test/postgres-unit-arms.txt';
export const ARM_WEIGHTS = 'scripts/postgres-arm-weights.json';
/** persistence-validation's unit-postgres-arms matrix size; test/scripts/postgres-unit-arms.test.ts pins the workflow to it. */
-export const ARM_SHARDS = 12;
+export const ARM_SHARDS = 14;
/** The workflow step's `timeout-minutes: 20`: a shard whose files run longer is cut off mid-list. */
export const ARM_STEP_TIMEOUT_MS = 20 * 60 * 1000;
/**
diff --git a/scripts/ubicloud/README.md b/scripts/ubicloud/README.md
index ace76d3bf9..63dcef1590 100644
--- a/scripts/ubicloud/README.md
+++ b/scripts/ubicloud/README.md
@@ -110,7 +110,7 @@ runs every file in `test/postgres-unit-arms.txt` the way persistence-validation'
`unit-postgres-arms` step does (`bun --no-env-file test --timeout=120000`,
`GBRAIN_TEST_ALLOW_DATABASE_URL=1`, no timeout multiplier) against the slot's
own empty `gbrain_arms_test` database. The summary sums its measured durations over
-that job's `ARM_SHARDS` partition (12 shards), and a shard over the step's 20-minute timeout
+that job's `ARM_SHARDS` partition (14 shards), and a shard over the step's 20-minute timeout
fails the run, since GitHub would cut that shard off mid-list. The committed
weights must also fit each shard twice over with a minute to spare
(`ARM_SHARD_BUDGET_MS`, 570 s), because a slow runner ran the files 1.3-2x
diff --git a/test/scripts/postgres-unit-arms.test.ts b/test/scripts/postgres-unit-arms.test.ts
index 183baea5d7..8a3e14cdf1 100644
--- a/test/scripts/postgres-unit-arms.test.ts
+++ b/test/scripts/postgres-unit-arms.test.ts
@@ -36,6 +36,8 @@ describe('postgres-unit-arms list', () => {
expect(job).toContain(`shard: [${shards.join(', ')}]`);
expect(job).toContain(`Unit-lane PostgreSQL arms \${{ matrix.shard }}/${ARM_SHARDS}`);
expect(job).toContain(`postgres-unit-arms.ts shard "$SHARD" ${ARM_SHARDS})`);
+ expect(job).toContain(`shard $SHARD/${ARM_SHARDS} selected no files`);
+ expect(job).toContain(`postgres-unit-arms.ts shard $SHARD ${ARM_SHARDS}' locally`);
expect(job).toMatch(new RegExp(`- name: Require PostgreSQL arms of unit-lane suites\\n\\s+timeout-minutes: ${ARM_STEP_TIMEOUT_MS / 60_000}\\n`));
});