Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Give the Postgres-arm lane a 22nd shard so new arm files fit its per-worker budget (GST-2692)
garrytan48bfca4feead
diff --git a/.github/workflows/persistence-validation.yml b/.github/workflows/persistence-validation.ymlindex 2bd35fdb7f..1c1d2382b0 100644--- a/.github/workflows/persistence-validation.yml+++ b/.github/workflows/persistence-validation.yml@@ -201,14 +201,14 @@ 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 twenty-one shards (ARM_SHARDS in scripts/postgres-unit-arms.ts) are+ # file. The twenty-two shards (ARM_SHARDS in scripts/postgres-unit-arms.ts) are# balanced by measured runtime (scripts/postgres-arm-weights.json, mined# from this job's ARM_FILE lines). Each job runs two files at a time, each# worker against its own PostgreSQL service; a shard's two-worker makespan,# doubled for a slow runner, must end a minute inside the step's 20 minutes- # (ARM_SHARD_BUDGET_MS, 570 s). On master 505204a9 (2026-11-12) the largest- # shard planned at 554.6 s with 19 shards; 21 shards bring it to 502.3 s, room- # for about 70 more arm files at the p75 weight. The job runs both arms of+ # (ARM_SHARD_BUDGET_MS, 570 s). On 2026-11-14 (gbrain#9342) the list filled+ # 21 shards to the budget, so one more arm file put 19 shards over; 22 shards+ # bring the largest to 545.6 s. The job runs both arms of# every listed file: the unit shards skip *.slow.test.ts, so this lane is the# only GitHub lane that runs the PGLite side of the listed slow# testBackends() suites.@@ -216,14 +216,14 @@ jobs:# pull request (cheap tier) runs only the crash robot and convergence here. The# full-ci dispatch on its head, every push and the nightly run this lane.unit-postgres-arms:- name: Unit-lane PostgreSQL arms ${{ matrix.shard }}/21 / Bun ${{ matrix.bun }}+ name: Unit-lane PostgreSQL arms ${{ matrix.shard }}/22 / Bun ${{ matrix.bun }}if: ${{ github.event_name != 'pull_request' }}runs-on: ubicloud-standard-4-ubuntu-2404timeout-minutes: 30strategy: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]+ shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]bun: ['1.4.4']# Event parity: every event, pull requests and merge-queue runs# included, runs every supported Bun version (docs/TESTING.md#event-parity).@@ -278,7 +278,7 @@ jobs:GBRAIN_TEST_ALLOW_DATABASE_URL: '1'GBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receiptsGBRAIN_TEST_RECEIPT_LANE: pg-arms-bun-${{ matrix.bun }}- run: bun scripts/postgres-unit-arms.ts run ${{ matrix.shard }} 21+ run: bun scripts/postgres-unit-arms.ts run ${{ matrix.shard }} 22- name: Upload receiptsif: always()uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4diff --git a/docs/architecture/key-files/ci-health-and-test-guards.md b/docs/architecture/key-files/ci-health-and-test-guards.mdindex 063f2c551d..4bd34ce625 100644--- a/docs/architecture/key-files/ci-health-and-test-guards.md+++ b/docs/architecture/key-files/ci-health-and-test-guards.md@@ -29,7 +29,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `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`.- `scripts/check-item-allowlist-catches.ts` + `scripts/item-allowlist-catches-baseline.tsv` — `check:item-allowlist-catches` (in `verify`). TypeScript-AST scan of `src/**/*.ts` (no `*.generated.ts`, `.d.ts`) for catch clauses in a per-item loop (a for/for-of/for-in/while/do-while body, or a `.forEach`/`.map` callback, up to the nearest function boundary) whose block tests the caught error's code against a set, list or literal (direct, cast, aliased or destructured) and rethrows the caught error. Per-file counts only shrink: growth, a new file, a count under its row, a row with no sites or no file, and malformed, duplicate or unsorted rows fail, pointing at `classifyItemFailure` / `ItemRun` (`src/core/item-failure.ts`) and `test/pathological/`. `--update` rewrites the baseline after a shrink. `findAllowlistCatches` and `compareBaseline` are exported for `test/scripts/check-item-allowlist-catches.test.ts`; self-test fixtures under `test/fixtures/guards/check-item-allowlist-catches.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` = 19 shards, `shard <n> <m>`: LPT over the mined per-file weights, p75 fallback; `run <n> <m> [--postgres-only]`: `ARM_WORKERS` = 2 files at a time, one Bun process per file, each worker on its own URL from `GBRAIN_ARM_DATABASE_URLS`, output buffered per file and printed in queue order in `::group::` blocks ending in an `ARM_FILE … ms=…` line, one receipt triple per file; `--postgres-only` (a manual mode; CI runs both arms) sets `GBRAIN_TEST_BACKEND=postgres` and reads `ARM_WEIGHTS_POSTGRES_ONLY` when it exists; each shard's two-worker makespan at most `ARM_SHARD_BUDGET_MS`, 570 s, so twice that still ends a minute inside the 20-minute `ARM_STEP_TIMEOUT_MS` step; no machine-exclusive serial file may be listed), the scheduled race hunt and the lane guard. `mine [--postgres-only] <job.log>…` rewrites the cell's weights from a green run's `ARM_FILE` lines (older 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` = 22 shards, `shard <n> <m>`: LPT over the mined per-file weights, p75 fallback; `run <n> <m> [--postgres-only]`: `ARM_WORKERS` = 2 files at a time, one Bun process per file, each worker on its own URL from `GBRAIN_ARM_DATABASE_URLS`, output buffered per file and printed in queue order in `::group::` blocks ending in an `ARM_FILE … ms=…` line, one receipt triple per file; `--postgres-only` (a manual mode; CI runs both arms) sets `GBRAIN_TEST_BACKEND=postgres` and reads `ARM_WEIGHTS_POSTGRES_ONLY` when it exists; each shard's two-worker makespan at most `ARM_SHARD_BUDGET_MS`, 570 s, so twice that still ends a minute inside the 20-minute `ARM_STEP_TIMEOUT_MS` step; no machine-exclusive serial file may be listed), the scheduled race hunt and the lane guard. `mine [--postgres-only] <job.log>…` rewrites the cell's weights from a green run's `ARM_FILE` lines (older 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.tsindex 433211968b..e710b2fcf2 100644--- a/scripts/postgres-unit-arms.ts+++ b/scripts/postgres-unit-arms.ts@@ -44,7 +44,7 @@ export const ARMS_LIST = 'test/postgres-unit-arms.txt';export const ARM_WEIGHTS = 'scripts/postgres-arm-weights.json';export const ARM_WEIGHTS_POSTGRES_ONLY = 'scripts/postgres-arm-weights-postgres-only.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 = 21;+export const ARM_SHARDS = 22;/** Files run at once per job, each against its own PostgreSQL service; the workflow lists one URL per worker. */export const ARM_WORKERS = 2;/** The workflow step's `timeout-minutes: 20`: a shard whose files run longer is cut off mid-list. */diff --git a/scripts/ubicloud/README.md b/scripts/ubicloud/README.mdindex cc669f82ee..c22955a6c3 100644--- a/scripts/ubicloud/README.md+++ b/scripts/ubicloud/README.md@@ -169,7 +169,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'sown empty `gbrain_arms_test` database. The summary takes the two-worker makespan of its-measured durations over that job's `ARM_SHARDS` partition (21 shards, `ARM_WORKERS` = 2+measured durations over that job's `ARM_SHARDS` partition (22 shards, `ARM_WORKERS` = 2files at a time), and a shard over the step's 20-minute timeoutfails the run, since GitHub would cut that shard off mid-list. The committedweights must also fit each shard twice over with a minute to spare