Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci: GBRA-135 audit 2 wave: 14 Selected E2E workers, Tier 1 graduation shards, keyed Tier 2 nightly with an all-ran check, E2E shard-time guard
garrytan5f6050ce5232
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex 08f1e69605..2ea0733b67 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -216,7 +216,7 @@ jobs:strategy:fail-fast: falsematrix: ${{ fromJSON(needs.prepare-e2e.outputs.matrix) }}- # 2 vCPUs, up to 8 shards (C1): run-e2e.sh runs one bun process at a time,+ # 2 vCPUs, up to 14 shards (C1; 14 since GBRA-135 L2): run-e2e.sh runs one bun process at a time,# and a 25-file sample took 442s on 2 cores vs 455s on 4.if: ${{ needs.prepare-e2e.outputs.reuse != 'true' }}runs-on: ubicloud-standard-2-ubuntu-2404@@ -395,23 +395,6 @@ jobs:DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gbrain_testGBRAIN_TEST_ALLOW_DATABASE_URL: '1'GBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receipts- - name: Run engine graduation suites (direct Postgres and PgBouncer)- # PGLite -> Postgres graduation (docs/guides/move-to-postgres.md): the- # agent flow, stale clients and respawned serves, SIGKILL at every- # custody boundary, faults, and the legacy copier. Every PR, with the- # transaction-mode pooler as a second target route (pooledUrl).- # Excluded from the selected matrix (scripts/e2e-matrix.ts) so they- # run once. Named files only, no glob.- shell: bash- run: bash scripts/run-e2e.sh test/e2e/graduation-cli.test.ts test/e2e/graduation-cli-topologies.test.ts test/e2e/graduation-cli-history.test.ts test/e2e/graduation-cli-zero-mutation-1.test.ts test/e2e/graduation-cli-zero-mutation-2.test.ts test/e2e/graduation-cli-zero-mutation-3.test.ts test/e2e/graduation-clients.test.ts test/e2e/graduation-clients-serve.test.ts test/e2e/graduation-crash-run-1.test.ts test/e2e/graduation-crash-run-2.test.ts test/e2e/graduation-crash-run-3.test.ts test/e2e/graduation-crash-rollback-1.test.ts test/e2e/graduation-crash-rollback-2.test.ts test/e2e/graduation-faults.test.ts test/e2e/graduation-legacy-copy.test.ts- env:- DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gbrain_test- GBRAIN_PGBOUNCER_URL: postgresql://postgres:postgres@localhost:55433/gbrain_test?prepare=false- GBRAIN_TEST_ALLOW_DATABASE_URL: '1'- GBRAIN_TEST_DB: '1'- E2E_FILE_TIMEOUT_SECS: '900'- GBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receipts- GBRAIN_TEST_RECEIPT_LANE: tier1- name: Run multi-agent serve suite# cathedral-6 (T7): multi-agent continuity + isolation over a real# `gbrain serve --http`. Own invocation line (engine-parity@@ -473,6 +456,101 @@ jobs:if-no-files-found: warnoverwrite: true+ # PGLite -> Postgres graduation (docs/guides/move-to-postgres.md), split+ # from Tier 1 (GBRA-135 L2): the files run one at a time, so the step took+ # about 891 s on 16 vCPUs and set the E2E critical path. On 8 vCPUs it took+ # 712-958 s whole (GBRA-135 pilot), so two weighted shards on 8 vCPUs halve+ # it. Same 15 named files, same direct Postgres and PgBouncer targets, same+ # receipt lane (tier1).+ tier1-graduation:+ name: Tier 1 graduation (direct + PgBouncer) ${{ matrix.shard }}/2+ needs: [prepare-e2e]+ if: ${{ needs.prepare-e2e.outputs.reuse != 'true' }}+ runs-on: ubicloud-standard-8-ubuntu-2404+ strategy:+ fail-fast: false+ matrix:+ shard: [1, 2]+ timeout-minutes: 45+ services:+ postgres:+ image: pgvector/pgvector:pg16+ env:+ POSTGRES_USER: postgres+ POSTGRES_PASSWORD: postgres+ POSTGRES_DB: gbrain_test+ ports:+ - 5432:5432+ options: >-+ --shm-size=1g+ --health-cmd pg_isready+ --health-interval 10s+ --health-timeout 5s+ --health-retries 5+ pgbouncer:+ image: edoburu/pgbouncer:latest+ env:+ DB_HOST: postgres+ DB_PORT: '5432'+ DB_USER: postgres+ DB_PASSWORD: postgres+ POOL_MODE: transaction+ AUTH_TYPE: plain+ MAX_CLIENT_CONN: '200'+ DEFAULT_POOL_SIZE: '10'+ IGNORE_STARTUP_PARAMETERS: extra_float_digits,statement_timeout,idle_in_transaction_session_timeout,search_path+ ports:+ - 55433:5432+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2+ with:+ bun-version: 1.4.4+ - uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3+ with:+ path: ~/.bun/install/cache+ key: bun-cache-${{ runner.os }}-${{ hashFiles('bun.lock') }}+ restore-keys: bun-cache-${{ runner.os }}-+ # PGLite snapshot (restore-only; test.yml's serial-tests job saves).+ # run-e2e.sh builds it when absent/stale — this just avoids paying the+ # build once per job. KEY: byte-identical with the homes in test.yml.+ - uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3+ with:+ path: |+ test/fixtures/pglite-snapshot.tar+ test/fixtures/pglite-snapshot.version+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}+ - name: Install dependencies (bounded, retried once)+ timeout-minutes: 8+ run: bun scripts/ci-bun-install.ts --frozen-lockfile+ - name: Run engine graduation suites (direct Postgres and PgBouncer)+ # The agent flow, stale clients and respawned serves, SIGKILL at every+ # custody boundary, faults, and the legacy copier. Every PR, with the+ # transaction-mode pooler as a second target route (pooledUrl).+ # Excluded from the selected matrix (scripts/e2e-matrix.ts) so they+ # run once. Named files only, no glob; run-e2e.sh splits them by+ # weight (SHARD).+ shell: bash+ run: bash scripts/run-e2e.sh test/e2e/graduation-cli.test.ts test/e2e/graduation-cli-topologies.test.ts test/e2e/graduation-cli-history.test.ts test/e2e/graduation-cli-zero-mutation-1.test.ts test/e2e/graduation-cli-zero-mutation-2.test.ts test/e2e/graduation-cli-zero-mutation-3.test.ts test/e2e/graduation-clients.test.ts test/e2e/graduation-clients-serve.test.ts test/e2e/graduation-crash-run-1.test.ts test/e2e/graduation-crash-run-2.test.ts test/e2e/graduation-crash-run-3.test.ts test/e2e/graduation-crash-rollback-1.test.ts test/e2e/graduation-crash-rollback-2.test.ts test/e2e/graduation-faults.test.ts test/e2e/graduation-legacy-copy.test.ts+ env:+ DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gbrain_test+ GBRAIN_PGBOUNCER_URL: postgresql://postgres:postgres@localhost:55433/gbrain_test?prepare=false+ GBRAIN_TEST_ALLOW_DATABASE_URL: '1'+ GBRAIN_TEST_DB: '1'+ E2E_FILE_TIMEOUT_SECS: '900'+ GBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receipts+ GBRAIN_TEST_RECEIPT_LANE: tier1+ SHARD: ${{ matrix.shard }}/2+ - name: Upload receipts+ if: always()+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4+ with:+ name: receipts-tier1-graduation-${{ matrix.shard }}+ path: ${{ runner.temp }}/receipts+ retention-days: 14+ if-no-files-found: warn+ overwrite: true+# The backend matrix (scripts/e2e-backend-matrix.txt) runs each file on# direct Postgres and again through transaction-mode PgBouncer, one file at# a time, so it needs no more than 4 vCPUs (C5). Split from Tier 1, which@@ -651,12 +729,14 @@ jobs:tier2:name: Tier 2 (LLM Skills)- # Runs on every push/PR (promoted from schedule-only in v0.19.0), in- # PARALLEL with tier1 (own postgres service — the old `needs: tier1`- # serialized ~2min for no shared state). The jsonb-parity gate (~40s)- # stays in front as the broken-build SPEND gate: this job burns real- # OpenAI/Anthropic tokens and must not fire when the build- # can't even pass the cheapest DB guard.+ # Named exception: keyed, on the nightly E2E schedule (or a full_corpus+ # dispatch) only (docs/TESTING.md#event-parity). Its three tests need the+ # provider keys, which other events withhold; a keyless run skipped all of+ # them and still went green (GBRA-237), so other events skip the job and+ # e2e-status says Tier 2 did not run. Runs in PARALLEL with tier1 (own+ # postgres service). The jsonb-parity gate (~40s) stays in front as the+ # broken-build SPEND gate: this job burns real OpenAI/Anthropic tokens+ # and must not fire when the build can't even pass the cheapest DB guard.# #5903: the repository variable GBRAIN_PAID_LANES='0' switches every# paid lane off (this job, the hermes door's paid leg and the OpenCode# credentialed lane in heavy-tests.yml) for forks and spend freezes.@@ -667,7 +747,7 @@ jobs:# GitHub's `!=` coerces null and '0' both to the number 0, which would skip# this job on every repository that never set the variable.needs: jsonb-parity- if: format('{0}', vars.GBRAIN_PAID_LANES) != '0'+ if: format('{0}', vars.GBRAIN_PAID_LANES) != '0' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.full_corpus))runs-on: ubicloud-standard-4-ubuntu-2404timeout-minutes: 30services:@@ -754,7 +834,13 @@ jobs:GBRAIN_TEST_ALLOW_DATABASE_URL: '1'OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ # Keyed by decision (GBRA-108: Tier 2 keyed nightly, about $2 a week).+ GBRAIN_TEST_KEEP_PROVIDER_KEYS: '1'GBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receipts+ # bun test exits 0 when every test skips (an empty secret, a missing+ # openclaw agent), so a keyless or all-skip run fails here instead.+ - name: Require every Tier 2 test to run+ run: bun scripts/require-executed-tests.ts "$RUNNER_TEMP/receipts" tier2- name: Upload receiptsif: always()uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4@@ -764,14 +850,14 @@ jobs:retention-days: 14if-no-files-found: warnoverwrite: true- # Tier 2 runs keyless by decision (no paid spend): its bare `bun test`- # step does not set GBRAIN_TEST_KEEP_PROVIDER_KEYS, so the test preload- # strips the keys and this notice names the skip.+ # The test step passes the keys (GBRAIN_TEST_KEEP_PROVIDER_KEYS=1); this+ # notice names an empty secret when there is one.- name: Provider-key coverage noticeif: ${{ !cancelled() }}env:OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ GBRAIN_TEST_KEEP_PROVIDER_KEYS: '1'run: bash scripts/e2e-provider-key-notice.sh# ──────────────────────────────────────────────────────────────────────@@ -1153,7 +1239,7 @@ jobs:# in e2e-status; baseline comparisons run locally with# bun scripts/ci-executed-counts.ts --base-run <id> --head-run <id>executed-receipts:- needs: [prepare-e2e, jsonb-parity, tier1, tier1-backend-matrix, tier2, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-e2e]+ needs: [prepare-e2e, jsonb-parity, tier1, tier1-graduation, tier1-backend-matrix, tier2, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-e2e]if: ${{ needs.prepare-e2e.outputs.reuse != 'true' && always() }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 10@@ -1209,9 +1295,11 @@ jobs:# The stable aggregate includes full-profile execution lanes when requested.# Coverage reporting itself remains advisory; failed tests never do.# Named exception (docs/TESTING.md#event-parity): FULL_CORPUS adds the- # full-corpus lanes to the aggregate on the nightly schedule only.+ # full-corpus lanes to the aggregate on the nightly schedule only, and+ # Tier 2 (keyed) is required there; other events accept its skip with a+ # "not run: keys withheld" notice.e2e-status:- needs: [jsonb-parity, tier1, tier1-backend-matrix, postgres15-compat, tier2, prepare-e2e, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-slow, coverage-full-e2e]+ needs: [jsonb-parity, tier1, tier1-graduation, tier1-backend-matrix, postgres15-compat, tier2, prepare-e2e, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-slow, coverage-full-e2e]if: ${{ needs.prepare-e2e.outputs.reuse != 'true' && always() }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 5@@ -1223,6 +1311,7 @@ jobs:FULL_CORPUS: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.full_corpus) }}JSONB: ${{ needs.jsonb-parity.result }}TIER1: ${{ needs.tier1.result }}+ GRADUATION: ${{ needs.tier1-graduation.result }}BACKEND_MATRIX: ${{ needs.tier1-backend-matrix.result }}POSTGRES15: ${{ needs.postgres15-compat.result }}TIER2: ${{ needs.tier2.result }}@@ -1237,7 +1326,7 @@ jobs:GBRAIN_PAID_LANES: ${{ vars.GBRAIN_PAID_LANES }}run: |echo "event=$EVENT"- echo "jsonb-parity=$JSONB tier1=$TIER1 tier1-backend-matrix=$BACKEND_MATRIX postgres15-compat=$POSTGRES15 tier2=$TIER2 prepare-e2e=$PREPARE selected-e2e=$SELECTED"+ echo "jsonb-parity=$JSONB tier1=$TIER1 tier1-graduation=$GRADUATION tier1-backend-matrix=$BACKEND_MATRIX postgres15-compat=$POSTGRES15 tier2=$TIER2 prepare-e2e=$PREPARE selected-e2e=$SELECTED"if [ "$TIER2" = "skipped" ] && [ "$GBRAIN_PAID_LANES" = "0" ]; thenecho "tier2 skipped: paid lanes disabled by the repository variable GBRAIN_PAID_LANES='0' (not green coverage of Tier 2)"echo "::notice::Tier 2 (LLM Skills) skipped: paid lanes disabled by GBRAIN_PAID_LANES='0'"@@ -1247,7 +1336,16 @@ jobs:} >> "${GITHUB_STEP_SUMMARY:-/dev/null}"TIER2="success"fi- for r in "$JSONB" "$TIER1" "$BACKEND_MATRIX" "$POSTGRES15" "$TIER2" "$PREPARE" "$SELECTED"; do+ if [ "$TIER2" = "skipped" ] && [ "$FULL_CORPUS" != "true" ]; then+ echo "tier2 not run: provider keys are withheld outside the nightly E2E schedule (not green coverage of Tier 2)"+ echo "::notice::Tier 2 (LLM Skills) not run: keys withheld; it runs keyed on the nightly E2E schedule"+ {+ echo "## Tier 2 (LLM Skills): not run, keys withheld"+ echo "Tier 2 runs keyed on the nightly E2E schedule and on a \`full_corpus\` dispatch only. This is not green coverage of Tier 2."+ } >> "${GITHUB_STEP_SUMMARY:-/dev/null}"+ TIER2="success"+ fi+ for r in "$JSONB" "$TIER1" "$GRADUATION" "$BACKEND_MATRIX" "$POSTGRES15" "$TIER2" "$PREPARE" "$SELECTED"; doif [ "$r" != "success" ]; thenecho "✗ gated e2e job did not succeed (got $r) — E2E fail"exit 1diff --git a/docs/TESTING.md b/docs/TESTING.mdindex a02cce0ea2..217044a2dd 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -50,7 +50,7 @@ not grant access. No Ubicloud API token is passed to workflow jobs.| Workload | Runner | Capacity || --- | --- | --- || Unit shards, slow and eval jobs, BrainBench, admin browser, shared-skills compatibility, persistence soak, reconciliation crashes and read latency, native Linux cells, OpenClaw startup, JSONB parity, PR serial pool, E2E backend matrix, Tier 2, coverage reports and Semgrep | `ubicloud-standard-4-ubuntu-2404` | 4 vCPU, 16 GB RAM |-| Nightly coverage serial pool, `verify`, PgBouncer/RLS deployment matrix | `ubicloud-standard-8-ubuntu-2404` | 8 vCPU, 32 GB RAM |+| Nightly coverage serial pool, `verify`, PgBouncer/RLS deployment matrix, E2E graduation shards | `ubicloud-standard-8-ubuntu-2404` | 8 vCPU, 32 GB RAM || E2E Tier 1 (its CLI `init` spawns exceed their timeouts on 4 vCPUs), label-gated and nightly heavy-tests jobs | `ubicloud-standard-16-ubuntu-2404` | 16 vCPU, 64 GB RAM || Label-gated heavy test suite | `ubicloud-standard-30-ubuntu-2404` | 30 vCPU, 120 GB RAM || Native ARM64 glibc and musl tests | `ubicloud-standard-4-arm-ubuntu-2404` | 4 vCPU |@@ -70,9 +70,9 @@ VMs a unit shard takes the same time on 4, 8 and 16 vCPUs; the serial pool and`verify` take the same time on 8 and 16 vCPUs (serial shard 2: 222s and 224s;277s on 4); the 2,500-write PGLite soak averages 1.3-1.8 busy cores and takes523s on 4 vCPUs and 500s on 16. Selected E2E workers run one file at a time and-fit on 2 vCPUs. Re-measure with `scripts/ubicloud/ubi-runner.sh run -s standard-N`-before resizing a runner: more CPU does not shorten a single-process job, and-the decision rule is critical path first, vCPU-minutes second.+fit on 2 vCPUs. Re-measure (`ubi-runner.sh run -s standard-N`) before resizing a+runner: more CPU does not shorten a single-process job; critical path+comes first, vCPU-minutes second.`test/scripts/ci-runner-routing.test.ts` pins capacity and platform routing;`.github/actionlint.yaml` declares the exact custom runner labels.diff --git a/docs/architecture/key-files/ci-health-and-test-guards.md b/docs/architecture/key-files/ci-health-and-test-guards.mdindex 83b4e01261..4513339598 100644--- a/docs/architecture/key-files/ci-health-and-test-guards.md+++ b/docs/architecture/key-files/ci-health-and-test-guards.md@@ -16,6 +16,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `scripts/ci-convergence-scope.sh` — #6712 PR 0: classifies a pull request's changed files (stdin) for the managed-sync convergence gate (`persistence-validation.yml` `convergence`): `run` for persistence, sync commands and sync core, page projections and storage, `bun.lock` and `vendor/postgres/`, the harness (`test/sync-convergence.serial.test.ts`, `test/fixtures/convergence-fault-kill.ts`), this script and its workflows (`persistence-validation.yml`, `convergence-nightly.yml`); `skip` otherwise, and never selected by `package.json` alone, so a release-stamp PR does not run it; an empty list runs. test.yml `changes` calls it for pull requests only (step `convergence`, passed as the `convergence` input). Tests: `test/scripts/ci-pr-scope.test.ts`.- `scripts/ci-manifest-diff.sh` — parsed-JSON classification of manifest diffs for CI scoping: `version-only` (only the top-level `version` differs), `dependency-change` (any dependency field differs), `dependency-scope` (whether a changed-file list touches lockfiles, `patches/` or dependency fields) and `drop-version-only` (filters version-only `package.json` and `openclaw.plugin.json` entries out of a changed-file list, so a release bump does not widen the native scope). Used by test.yml's `changes` job (before `scripts/ci-native-scope.sh`) and its dependency-audit scope step. Tests: `test/scripts/ci-manifest-diff.test.ts`.- `scripts/ci-dependency-audit.sh` — runs `bun audit` for the root and `admin/` lockfiles. It blocks (`BLOCKING=true`) on pushes, schedules and dispatches, on lockfile, `patches/` or dependency-field changes, with the `dependency-audit` label, or when the diff cannot be read; elsewhere an advisory is a `::warning::` naming why the run does not block.+- `scripts/require-executed-tests.ts` — fails a lane whose receipts show zero passed tests, any skipped, todo or failed test, a missing or truncated JUnit report, or no receipt at all (GBRA-135 L6). The keyed Tier 2 nightly (`e2e.yml` `tier2`) runs it after its test step, because `bun test` exits 0 when every key-gated test self-skips. `executedProblems(dir, lane)` reads receipts through `loadReceiptDir` (`scripts/ci-executed-counts.ts`). Test: `test/scripts/require-executed-tests.test.ts` (includes the real keyless `test/e2e/skills.test.ts` run).- `scripts/ci-install-openclaw.sh` — e2e.yml's Tier 2 `Install OpenClaw` step. Each `npm install -g openclaw@<pin>` attempt is bounded (`timeout 120`); a failure whose npm log carries `code ETARGET` or `E404` is a registry race (a dependency version published but not yet visible for every package of its release, the 2026-10-12 master Tier 2 red on `@aws-sdk/credential-provider-node@^3.972.86`) and is retried up to 4 attempts 20/40/80 s apart; any other failure keeps the 3 attempts 10 s apart. Nothing else is retried, and the last attempt fails the step with npm's own log. Knobs (`OPENCLAW_SPEC`, `OPENCLAW_INSTALL_ATTEMPT_S`, `OPENCLAW_INSTALL_RETRY_SLEEP_S`, `OPENCLAW_INSTALL_RACE_SLEEPS_S`) exist for the test: `test/scripts/ci-install-openclaw.test.ts` installs a one-file package from a loopback registry (`test/helpers/npm-stub-registry.ts`) that answers ETARGET or E404 to the first three packument requests, forever, or publishes for an impossible `os` (`EBADPLATFORM`, the generic path). The lockfile route (a committed `package-lock.json` per pin) was weighed and not taken: two pins live in the workflows (`e2e.yml` 2026.4.9, `native-locks.yml` 2026.9.4), every bump would regenerate a multi-hundred-kilobyte lockfile, and the race the retry waits out is a propagation delay of minutes.- `scripts/e2e-provider-key-notice.sh` — e2e.yml's visible-skip step: when `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` is empty, prints a `::warning::` and step-summary line naming the empty secret and the owner-only fix, so a green keyless run is never read as keyed coverage. Exits 0 always.- `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`.diff --git a/docs/ci-event-parity.md b/docs/ci-event-parity.mdindex 3c02c4abf7..09579a54c6 100644--- a/docs/ci-event-parity.md+++ b/docs/ci-event-parity.md@@ -37,6 +37,7 @@ checks ([below](#full-ci-on-pull-requests)), never per-cell matrix names.| `native-locks.yml` | `inputs.scope` (OpenClaw, musl, Windows probes, cross-target cells) | Named exception | Every push to master and the nightly Test schedule (`full`) || `e2e.yml` | Doc-only merge-queue entry selects no E2E file | Named exception | Every push to master (whole corpus) and the nightly E2E schedule || `e2e.yml` | Full-corpus coverage lanes and their `e2e-status` checks | Named exception | Nightly E2E schedule (or a `full_corpus` dispatch) |+| `e2e.yml` | Tier 2 (LLM Skills) runs keyed on the nightly only; other events skip it, and `e2e-status` prints "not run: keys withheld" instead of counting it green | Named exception | Nightly E2E schedule (or a `full_corpus` dispatch), keyed; `scripts/require-executed-tests.ts` fails the job when any test skipped or none ran || `heavy-tests.yml` | Label-gated jobs on pull requests | Named exception | Nightly Heavy Tests schedule || `heavy-tests.yml` | `grok-door` (label or input only) | Recorded decision: no scheduled run until the `XAI_API_KEY` secret exists | None yet, by decision || `heavy-tests.yml` | `opencode-door-canary` | Named exception: schedule-only, non-gating canary | Itself |diff --git a/docs/ci-red-runbook.md b/docs/ci-red-runbook.mdindex fdac6139c7..c27a23d3b8 100644--- a/docs/ci-red-runbook.md+++ b/docs/ci-red-runbook.md@@ -94,7 +94,7 @@ The nightly E2E workflow's `order-hunt` job (also `gh workflow run e2e.yml -f or## Paid lanes switch-The repository variable `GBRAIN_PAID_LANES=0` switches every paid lane off: Tier 2 (LLM Skills) in `e2e.yml`, the hermes door's paid leg and the OpenCode credentialed lane in `heavy-tests.yml` (#5903). Use it on a fork or during a spend freeze; unset (or any other value) keeps the lanes on. Each lane writes a visible "paid lanes disabled" step summary, and `e2e-status` accepts Tier 2 as `skipped` only under that exact value, saying so in its own summary; any other skip, failure or cancellation still fails the aggregate (`test/paid-lanes-switch-5903.test.ts` runs the aggregate script with every combination). A run with the variable set is not green coverage of the paid lanes.+The repository variable `GBRAIN_PAID_LANES=0` switches every paid lane off: Tier 2 (LLM Skills) in `e2e.yml`, the hermes door's paid leg and the OpenCode credentialed lane in `heavy-tests.yml` (#5903). Use it on a fork or during a spend freeze; unset (or any other value) keeps the lanes on. Each lane writes a visible "paid lanes disabled" step summary, and `e2e-status` accepts Tier 2 as `skipped` only under that exact value, saying so in its own summary; any other skip, failure or cancellation still fails the aggregate (`test/paid-lanes-switch-5903.test.ts` runs the aggregate script with every combination). A run with the variable set is not green coverage of the paid lanes. Tier 2 runs keyed only on the nightly E2E schedule (and a `full_corpus` dispatch); elsewhere `e2e-status` accepts its skip with a "not run: keys withheld" notice, and a nightly run in which any Tier 2 test skipped fails (`scripts/require-executed-tests.ts`).## CI failure manifestdiff --git a/scripts/e2e-matrix.ts b/scripts/e2e-matrix.tsindex 2a2a0a0ec7..99d3dbc56c 100644--- a/scripts/e2e-matrix.ts+++ b/scripts/e2e-matrix.ts@@ -26,7 +26,7 @@ export function exclusionNotice(file: string): string {if (BACKEND_MATRIX_OWNED.has(file)) return `excluded: ${file} (owned by the Tier 1 backend matrix, scripts/e2e-backend-matrix.txt)`;return `excluded (named-job / live-key lane): ${file}`;}-export const MAX_E2E_WORKERS = 8;+export const MAX_E2E_WORKERS = 14;export const E2E_EXCLUSIONS = new Set(['test/e2e/op-checkpoint-jsonb-parity.test.ts','test/e2e/jsonb-roundtrip.test.ts',@@ -41,7 +41,7 @@ export const E2E_EXCLUSIONS = new Set(['test/e2e/skills.test.ts','test/e2e/voyage-rerank-live.test.ts','test/e2e/voyage-multimodal.test.ts',- // Engine graduation: run once by tier1's graduation step (direct Postgres + PgBouncer).+ // Engine graduation: run once by the tier1-graduation job (direct Postgres + PgBouncer).'test/e2e/graduation-cli.test.ts','test/e2e/graduation-cli-topologies.test.ts','test/e2e/graduation-cli-history.test.ts',diff --git a/scripts/e2e-provider-key-notice.sh b/scripts/e2e-provider-key-notice.shindex d4df375b4f..7a05e73dab 100755--- a/scripts/e2e-provider-key-notice.sh+++ b/scripts/e2e-provider-key-notice.sh@@ -5,8 +5,8 @@# key-gated jobs; when a secret is empty, the key-gated tests self-skip and# the job still goes green. The test preload (test/helpers/provider-keys-preload.ts)# also strips both keys from every test process unless the step that ran the-# tests set GBRAIN_TEST_KEEP_PROVIDER_KEYS=1 (scripts/run-e2e.sh sets it; a-# bare `bun test` step such as Tier 2 does not). The workflow passes this step+# tests set GBRAIN_TEST_KEEP_PROVIDER_KEYS=1 (scripts/run-e2e.sh sets it, and+# so does the keyed Tier 2 nightly step). The workflow passes this step# the value the test step had, so a run whose keys were stripped is never# reported as keyed. This step says what happened in the log (::warning::) and# the step summary. Exit 0 always: it reports, it does not gate.diff --git a/scripts/require-executed-tests.ts b/scripts/require-executed-tests.tsnew file mode 100644index 0000000000..b991683df8--- /dev/null+++ b/scripts/require-executed-tests.ts@@ -0,0 +1,49 @@+#!/usr/bin/env bun+/**+ * Require that a lane's tests all ran and passed (GBRA-135 L6).+ *+ * A key-gated test file self-skips when its provider keys or tools are+ * missing, and `bun test` exits 0 on an all-skip run, so a job that ran+ * nothing reads green. The keyed Tier 2 nightly (e2e.yml `tier2`) runs this+ * after its test step: a keyless run, an all-skip run, a partial skip or a+ * missing JUnit report fails the job instead of passing as coverage.+ *+ * Reads the receipts scripts/run-with-receipt.sh writes+ * (docs/TESTING.md#executed-test-receipts).+ *+ * Usage: bun scripts/require-executed-tests.ts <receipt-dir> <lane>+ * Exit: 0 at least one test ran and every test passed; 1 otherwise; 2 usage.+ */+import { existsSync } from 'node:fs';+import { loadReceiptDir } from './ci-executed-counts.ts';++export function executedProblems(dir: string, lane: string): string[] {+ const receipts = existsSync(dir) ? loadReceiptDir(dir).filter(r => r.lane === lane) : [];+ if (!receipts.length) return [`no ${lane} receipt in ${dir}: the test step did not run`];+ const problems: string[] = [];+ let passed = 0;+ for (const receipt of receipts) {+ if (receipt.junit !== 'ok') problems.push(`${receipt.id}: JUnit report ${receipt.junit}${receipt.junitError ? ` (${receipt.junitError})` : ''}`);+ for (const c of receipt.cases) {+ if (c.status === 'pass') passed++;+ else problems.push(`${c.status}: ${c.file} > ${c.test}`);+ }+ }+ if (passed === 0) problems.unshift(`${lane} ran 0 tests`);+ return problems;+}++if (import.meta.main) {+ const [dir, lane] = process.argv.slice(2);+ if (!dir || !lane) {+ console.error('usage: bun scripts/require-executed-tests.ts <receipt-dir> <lane>');+ process.exit(2);+ }+ const problems = executedProblems(dir, lane);+ if (problems.length) {+ console.error(`::error::${lane}: not every test ran and passed, so this run is not coverage`);+ for (const p of problems) console.error(` ${p}`);+ process.exit(1);+ }+ console.log(`${lane}: every test ran and passed`);+}diff --git a/test/paid-lanes-switch-5903.test.ts b/test/paid-lanes-switch-5903.test.tsindex b398d06da2..e3a904b56f 100644--- a/test/paid-lanes-switch-5903.test.ts+++ b/test/paid-lanes-switch-5903.test.ts@@ -29,6 +29,7 @@ if (!aggregate?.run || !aggregate.env) throw new Error('e2e-status has no "Aggreconst GREEN = {JSONB: 'success',TIER1: 'success',+ GRADUATION: 'success',BACKEND_MATRIX: 'success',POSTGRES15: 'success',TIER2: 'success',@@ -63,7 +64,7 @@ function runAggregate(overrides: Partial<typeof GREEN>) {describe('#5903 GBRAIN_PAID_LANES switches every paid lane off', () => {test('tier2 is gated on the variable and e2e-status reads it from env', () => {- expect(e2eJobs.tier2.if).toBe("format('{0}', vars.GBRAIN_PAID_LANES) != '0'");+ expect(e2eJobs.tier2.if).toBe("format('{0}', vars.GBRAIN_PAID_LANES) != '0' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.full_corpus))");expect(aggregate!.env!.GBRAIN_PAID_LANES).toBe('${{ vars.GBRAIN_PAID_LANES }}');expect(aggregate!.env!.TIER2).toBe('${{ needs.tier2.result }}');expect(e2eJobs['e2e-status'].needs).toContain('tier2');@@ -118,15 +119,15 @@ describe('#5903 e2e-status accepts a skipped tier2 only under GBRAIN_PAID_LANES=expect(runAggregate({}).status).toBe(0);});- test('tier2 skipped with the variable unset fails', () => {- const r = runAggregate({ TIER2: 'skipped' });+ test('tier2 skipped on the nightly with the variable unset fails', () => {+ const r = runAggregate({ TIER2: 'skipped', FULL_CORPUS: 'true' });expect(r.status).toBe(1);expect(r.stdout).toContain('gated e2e job did not succeed (got skipped)');});- test("tier2 skipped with the variable at '1' or 'false' fails", () => {- expect(runAggregate({ TIER2: 'skipped', GBRAIN_PAID_LANES: '1' }).status).toBe(1);- expect(runAggregate({ TIER2: 'skipped', GBRAIN_PAID_LANES: 'false' }).status).toBe(1);+ test("tier2 skipped on the nightly with the variable at '1' or 'false' fails", () => {+ expect(runAggregate({ TIER2: 'skipped', FULL_CORPUS: 'true', GBRAIN_PAID_LANES: '1' }).status).toBe(1);+ expect(runAggregate({ TIER2: 'skipped', FULL_CORPUS: 'true', GBRAIN_PAID_LANES: 'false' }).status).toBe(1);});test("tier2 skipped with the variable at '0' passes and says it is not coverage", () => {@@ -137,13 +138,28 @@ describe('#5903 e2e-status accepts a skipped tier2 only under GBRAIN_PAID_LANES=expect(r.summary).toContain('not green coverage of Tier 2');});+ test("tier2 skipped outside the nightly passes and says keys were withheld (GBRA-135 L6)", () => {+ for (const EVENT of ['workflow_dispatch', 'push', 'merge_group']) {+ const r = runAggregate({ TIER2: 'skipped', EVENT });+ expect(r.status).toBe(0);+ expect(r.stdout).toContain('tier2 not run: provider keys are withheld outside the nightly E2E schedule');+ expect(r.stdout).toContain('::notice::Tier 2 (LLM Skills) not run: keys withheld');+ expect(r.summary).toContain('not green coverage of Tier 2');+ }+ });++ test('outside the nightly a failed or cancelled tier2 still fails', () => {+ expect(runAggregate({ TIER2: 'failure' }).status).toBe(1);+ expect(runAggregate({ TIER2: 'cancelled' }).status).toBe(1);+ });+test("the variable at '0' does not excuse a failed or cancelled tier2", () => {expect(runAggregate({ TIER2: 'failure', GBRAIN_PAID_LANES: '0' }).status).toBe(1);expect(runAggregate({ TIER2: 'cancelled', GBRAIN_PAID_LANES: '0' }).status).toBe(1);});test("the variable at '0' does not excuse any other skipped lane", () => {- for (const key of ['JSONB', 'TIER1', 'BACKEND_MATRIX', 'POSTGRES15', 'PREPARE', 'SELECTED'] as const) {+ for (const key of ['JSONB', 'TIER1', 'GRADUATION', 'BACKEND_MATRIX', 'POSTGRES15', 'PREPARE', 'SELECTED'] as const) {const r = runAggregate({ [key]: 'skipped', GBRAIN_PAID_LANES: '0' });expect(r.status).toBe(1);expect(r.stdout).toContain('got skipped');diff --git a/test/scripts/ci-gates.test.ts b/test/scripts/ci-gates.test.tsindex d357215cdf..ff8c64f7f7 100644--- a/test/scripts/ci-gates.test.ts+++ b/test/scripts/ci-gates.test.ts@@ -46,8 +46,9 @@ describe('CI execution evidence', () => {expect(unit.jobs[name].if).toBe("${{ github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base) }}");}expect(e2e.jobs.tier2.needs).toBe('jsonb-parity');- // No event gating: the only condition is the repository-wide paid-lane switch (#5903).- expect(e2e.jobs.tier2.if).toBe("format('{0}', vars.GBRAIN_PAID_LANES) != '0'");+ // Keyed Tier 2 runs on the nightly (and a full_corpus dispatch) only, under the+ // repository-wide paid-lane switch (#5903; GBRA-135 L6).+ expect(e2e.jobs.tier2.if).toBe("format('{0}', vars.GBRAIN_PAID_LANES) != '0' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.full_corpus))");});test('the verify job runs `bun run verify`, which dispatches through run-verify-parallel.sh', () => {@@ -114,7 +115,7 @@ describe('CI execution evidence', () => {expect(e2e.jobs['e2e-status'].if).toBe("${{ needs.prepare-e2e.outputs.reuse != 'true' && always() }}");const needs = e2e.jobs['e2e-status'].needs as string[];const nightly = ['coverage-full-unit', 'coverage-full-serial', 'coverage-full-slow', 'coverage-full-e2e'];- expect(needs).toEqual(['jsonb-parity', 'tier1', 'tier1-backend-matrix', 'postgres15-compat', 'tier2', 'prepare-e2e', 'selected-e2e', ...nightly]);+ expect(needs).toEqual(['jsonb-parity', 'tier1', 'tier1-graduation', 'tier1-backend-matrix', 'postgres15-compat', 'tier2', 'prepare-e2e', 'selected-e2e', ...nightly]);for (const event of ['pull_request', 'push', 'workflow_dispatch']) {expect(aggregate(e2e, 'e2e-status', event, Object.fromEntries(nightly.map(job => [job, 'skipped'])))).toBe(0);}diff --git a/test/scripts/ci-runner-routing.test.ts b/test/scripts/ci-runner-routing.test.tsindex 4efe157aa8..e239f72248 100644--- a/test/scripts/ci-runner-routing.test.ts+++ b/test/scripts/ci-runner-routing.test.ts@@ -48,6 +48,8 @@ describe('CI runner routing', () => {}expect(load('e2e.yml').jobs.tier1['runs-on']).toBe(normal);expect(load('e2e.yml').jobs['coverage-full-serial']['runs-on']).toBe(pooled);+ // Graduation files run one at a time: 712-958 s whole on 8 vCPUs vs 751-770 s on 16 (GBRA-135 pilot).+ expect(load('e2e.yml').jobs['tier1-graduation']['runs-on']).toBe(pooled);expect(load('persistence-validation.yml').jobs['read-performance']['runs-on']).toBe(single);expect(load('persistence-validation.yml').jobs.invariants['runs-on']).toBe(single);expect(load('persistence-validation.yml').jobs.reconciliation['runs-on']).toBe(single);diff --git a/test/scripts/e2e-matrix.test.ts b/test/scripts/e2e-matrix.test.tsindex 783efc7077..1156019a06 100644--- a/test/scripts/e2e-matrix.test.ts+++ b/test/scripts/e2e-matrix.test.ts@@ -6,8 +6,8 @@ import { spawnSync } from 'node:child_process';import { BACKEND_MATRIX_OWNED, E2E_EXCLUSIONS, MAX_E2E_WORKERS, prepareMatrix, validateRow } from '../../scripts/e2e-matrix.ts';const repo = join(import.meta.dir, '../..');-const paths = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'].map(n => `test/e2e/${n}.test.ts`);-const weights = new Map(paths.map((f, i) => [f, 100 - i * 10]));+const paths = 'abcdefghijklmnop'.split('').map(n => `test/e2e/${n}.test.ts`);+const weights = new Map(paths.map((f, i) => [f, 200 - i * 10]));function fixture(fn: (root: string) => void) {const root = mkdtempSync(join(tmpdir(), 'gbrain-e2e-matrix-'));try {@@ -23,10 +23,10 @@ function worker(root: string, row: unknown) {});}describe('frozen E2E matrix', () => {- test('partitions the exact selection once, with deterministic weights and at most eight workers', () => {+ test('partitions the exact selection once, with deterministic weights and at most fourteen workers', () => {const matrix = prepareMatrix(paths, weights);- expect(MAX_E2E_WORKERS).toBe(8);- expect(matrix.include).toHaveLength(8);+ expect(MAX_E2E_WORKERS).toBe(14);+ expect(matrix.include).toHaveLength(14);expect(matrix.include.flatMap(r => r.files).sort()).toEqual(paths);expect(prepareMatrix(paths, weights)).toEqual(matrix);expect(prepareMatrix(paths.slice(0, 2), weights).include).toHaveLength(2);diff --git a/test/scripts/e2e-shard-budget.test.ts b/test/scripts/e2e-shard-budget.test.tsnew file mode 100644index 0000000000..5656e4709e--- /dev/null+++ b/test/scripts/e2e-shard-budget.test.ts@@ -0,0 +1,56 @@+/**+ * E2E shard-time guard (GBRA-135 L7). Selected E2E and the Tier 1 graduation+ * shards run their files one at a time inside a job timeout, so a shard's+ * predicted time times the measured actual/predicted factor, plus setup and a+ * minute to spare, must fit that timeout. scripts/e2e-weights.json predicted+ * 4,945 s for E2E files that took 9,969 s on full run 40798858961 (factor+ * 2.02) without anything noticing; this test keeps that factor in the budget,+ * so a bigger corpus or fewer workers fails here instead of at a job timeout.+ * Re-mine the weights (scripts/mine-shard-weights.ts) and measure the factor+ * again before lowering it.+ */+import { describe, expect, test } from 'bun:test';+import { readFileSync } from 'node:fs';+import { join } from 'node:path';+import { spawnSync } from 'node:child_process';+import { load } from 'js-yaml';+import { E2E_EXCLUSIONS, MAX_E2E_WORKERS, prepareMatrix } from '../../scripts/e2e-matrix.ts';+import { loadWeights, partition, predictedWeight, type WeightMap } from '../../scripts/sharding.ts';++const REPO = join(import.meta.dir, '..', '..');+const ACTUAL_OVER_PREDICTED = 2.02;+const SETUP_ALLOWANCE_MS = 2 * 60_000;+const SPARE_MS = 60_000;+type Job = { 'timeout-minutes': number };+const jobs = (load(readFileSync(join(REPO, '.github/workflows/e2e.yml'), 'utf8')) as { jobs: Record<string, Job> }).jobs;+const weights = loadWeights(join(REPO, 'scripts/e2e-weights.json'));++function overBudget(shards: string[][], w: WeightMap, timeoutMinutes: number) {+ const budget = timeoutMinutes * 60_000 - SETUP_ALLOWANCE_MS - SPARE_MS;+ return shards+ .map((files, i) => ({ shard: i + 1, expectedMs: Math.round(predictedWeight(files, w).totalMs * ACTUAL_OVER_PREDICTED) }))+ .filter(s => s.expectedMs > budget);+}++describe('E2E shard-time budget', () => {+ test('every Selected E2E shard of the full corpus fits the job timeout at the measured factor', () => {+ const selected = spawnSync(process.execPath, [join(REPO, 'scripts/select-e2e.ts'), '--changed-files', '/dev/null'], { cwd: REPO, encoding: 'utf8' });+ expect(selected.status, selected.stderr).toBe(0);+ const files = selected.stdout.trim().split('\n').filter(Boolean);+ expect(files.length).toBeGreaterThan(100);+ const matrix = prepareMatrix(files, weights);+ expect(matrix.include).toHaveLength(MAX_E2E_WORKERS);+ expect(overBudget(matrix.include.map(r => r.files), weights, jobs['selected-e2e']['timeout-minutes'])).toEqual([]);+ });++ test('both Tier 1 graduation shards fit the job timeout at the measured factor', () => {+ const graduation = [...E2E_EXCLUSIONS].filter(f => f.startsWith('test/e2e/graduation-'));+ expect(graduation).toHaveLength(15);+ expect(overBudget(partition(graduation, weights, 2), weights, jobs['tier1-graduation']['timeout-minutes'])).toEqual([]);+ });++ test('a shard whose predicted time times the factor passes the timeout is reported', () => {+ const w: WeightMap = new Map([['test/e2e/a.test.ts', 20 * 60_000], ['test/e2e/b.test.ts', 10 * 60_000]]);+ expect(overBudget([['test/e2e/a.test.ts'], ['test/e2e/b.test.ts']], w, 30)).toEqual([{ shard: 1, expectedMs: 2_424_000 }]);+ });+});diff --git a/test/scripts/e2e-wiring.test.ts b/test/scripts/e2e-wiring.test.tsindex 8d9665ded3..0a405c6e80 100644--- a/test/scripts/e2e-wiring.test.ts+++ b/test/scripts/e2e-wiring.test.ts@@ -191,3 +191,27 @@ describe('e2e file ownership', () => {expect(jobBlock('e2e-status')).toContain('needs.tier1-backend-matrix.result');});});++describe('tier1-graduation job (GBRA-135 L2)', () => {+ const GRADUATION = [...E2E_EXCLUSIONS].filter(f => f.startsWith('test/e2e/graduation-'));++ test('runs every excluded graduation file once, in two weighted shards, on direct Postgres and PgBouncer', () => {+ const job = jobBlock('tier1-graduation');+ expect(GRADUATION).toHaveLength(15);+ const run = job.split('\n').find(l => l.includes('run: bash scripts/run-e2e.sh '))!;+ expect(run.trim().replace('run: bash scripts/run-e2e.sh ', '').split(' ').sort()).toEqual([...GRADUATION].sort());+ expect(job).toContain('shard: [1, 2]');+ expect(job).toContain('SHARD: ${{ matrix.shard }}/2');+ expect(job).toContain('GBRAIN_PGBOUNCER_URL: postgresql://postgres:postgres@localhost:55433/gbrain_test?prepare=false');+ expect(job).toContain('GBRAIN_TEST_RECEIPT_LANE: tier1');+ expect(job).toContain('name: receipts-tier1-graduation-${{ matrix.shard }}');+ for (const file of GRADUATION) expect(jobBlock('tier1')).not.toContain(file);+ });++ test('e2e-status requires the job and checks its result', () => {+ const status = jobBlock('e2e-status');+ expect(status).toContain('tier1-graduation');+ expect(status).toContain('GRADUATION: ${{ needs.tier1-graduation.result }}');+ expect(status).toContain('"$GRADUATION"');+ });+});diff --git a/test/scripts/full-ci-workflow.test.ts b/test/scripts/full-ci-workflow.test.tsindex b448a2008c..953acb006f 100644--- a/test/scripts/full-ci-workflow.test.ts+++ b/test/scripts/full-ci-workflow.test.ts@@ -190,7 +190,7 @@ describe('master-push reuse of a passed full-suite run', () => {const e2eReused = runs(e2e, { event: 'push', outputs: { reuse: 'true' } });expect(e2eReused).toContain('reused-full-suite');- for (const job of ['jsonb-parity', 'tier1', 'tier1-backend-matrix', 'selected-e2e', 'executed-receipts', 'e2e-status', 'e2e-full-suite']) {+ for (const job of ['jsonb-parity', 'tier1', 'tier1-graduation', 'tier1-backend-matrix', 'selected-e2e', 'executed-receipts', 'e2e-status', 'e2e-full-suite']) {expect(e2eReused, job).not.toContain(job);expect(runs(e2e, { event: 'push' }), job).toContain(job);}diff --git a/test/scripts/require-executed-tests.test.ts b/test/scripts/require-executed-tests.test.tsnew file mode 100644index 0000000000..844d31e1ee--- /dev/null+++ b/test/scripts/require-executed-tests.test.ts@@ -0,0 +1,92 @@+/**+ * GBRA-135 L6: the keyed Tier 2 nightly fails when its tests did not all run.+ * A keyless or all-skip `bun test` exits 0, so scripts/require-executed-tests.ts+ * reads the run's receipts and refuses zero passes, any skip and any failure.+ */+import { describe, expect, test } from 'bun:test';+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { spawnSync } from 'node:child_process';+import { load } from 'js-yaml';+import { executedProblems } from '../../scripts/require-executed-tests.ts';++const REPO = join(import.meta.dir, '../..');++function receiptsFor(body: string) {+ const root = mkdtempSync(join(tmpdir(), 'gbrain-require-executed-'));+ mkdirSync(join(root, 'test'));+ writeFileSync(join(root, 'test/t2.test.ts'), `import { describe, test, expect } from 'bun:test';\n${body}`);+ const receipts = join(root, 'receipts');+ const run = spawnSync('bash', [join(REPO, 'scripts/run-with-receipt.sh'), 'tier2', 'skills', '--', 'bun', 'test', '--timeout=60000', join(root, 'test/t2.test.ts')], {+ cwd: REPO, encoding: 'utf8', env: { ...process.env, GBRAIN_NO_SNAPSHOT: '1', GBRAIN_TEST_RECEIPT_DIR: receipts },+ });+ return { root, receipts, run };+}++const guard = (dir: string, lane = 'tier2') =>+ spawnSync('bun', [join(REPO, 'scripts/require-executed-tests.ts'), dir, lane], { cwd: REPO, encoding: 'utf8' });++describe('require-executed-tests', () => {+ test('the keyless Tier 2 file skips everything with exit 0, and the guard fails it', () => {+ const receipts = mkdtempSync(join(tmpdir(), 'gbrain-require-executed-t2-'));+ try {+ const env: Record<string, string | undefined> = { ...process.env, GBRAIN_NO_SNAPSHOT: '1', GBRAIN_TEST_RECEIPT_DIR: receipts };+ delete env.GBRAIN_TEST_KEEP_PROVIDER_KEYS;+ delete env.DATABASE_URL;+ const run = spawnSync('bash', ['scripts/run-with-receipt.sh', 'tier2', 'skills', '--', 'bun', 'test', '--timeout=60000', 'test/e2e/skills.test.ts'], { cwd: REPO, encoding: 'utf8', env });+ expect(run.status, run.stdout + run.stderr).toBe(0);+ const g = guard(receipts);+ expect(g.status).toBe(1);+ expect(g.stderr).toContain('tier2 ran 0 tests');+ expect(g.stderr).toContain('skip: test/e2e/skills.test.ts > E2E Tier 2: Health Skill > health skill reports brain status');+ } finally { rmSync(receipts, { recursive: true, force: true }); }+ });++ test('passes only when at least one test ran and every test passed', () => {+ const { root, receipts, run } = receiptsFor(`describe('t2', () => { test('a', () => expect(1).toBe(1)); test('b', () => {}); });`);+ try {+ expect(run.status, run.stdout + run.stderr).toBe(0);+ expect(executedProblems(receipts, 'tier2')).toEqual([]);+ const g = guard(receipts);+ expect(g.status, g.stderr).toBe(0);+ expect(g.stdout).toContain('tier2: every test ran and passed');+ } finally { rmSync(root, { recursive: true, force: true }); }+ });++ test('a partial skip fails even when other tests passed', () => {+ const { root, receipts } = receiptsFor(`describe('t2', () => { test('a', () => {}); test.skip('keyed', () => {}); });`);+ try {+ const problems = executedProblems(receipts, 'tier2');+ expect(problems).toHaveLength(1);+ expect(problems[0]).toMatch(/^skip: .*t2\.test\.ts > t2 > keyed$/);+ expect(guard(receipts).status).toBe(1);+ } finally { rmSync(root, { recursive: true, force: true }); }+ });++ test('a failed test, a missing receipt and another lane all fail', () => {+ const { root, receipts, run } = receiptsFor(`test('broken', () => expect(1).toBe(2));`);+ try {+ expect(run.status).not.toBe(0);+ expect(executedProblems(receipts, 'tier2')).toEqual(['tier2 ran 0 tests', expect.stringMatching(/^fail: .*t2\.test\.ts > broken$/)]);+ expect(executedProblems(receipts, 'tier1')).toEqual([`no tier1 receipt in ${receipts}: the test step did not run`]);+ expect(executedProblems(join(root, 'absent'), 'tier2')[0]).toContain('the test step did not run');+ expect(guard(join(root, 'absent')).status).toBe(1);+ expect(guard('').status).toBe(2);+ } finally { rmSync(root, { recursive: true, force: true }); }+ });++ test('e2e.yml runs Tier 2 keyed and gates it on the guard', () => {+ type Step = { name?: string; run?: string; env?: Record<string, string>; if?: string };+ const tier2 = (load(readFileSync(join(REPO, '.github/workflows/e2e.yml'), 'utf8')) as { jobs: Record<string, { steps: Step[] }> }).jobs.tier2!;+ const names = tier2.steps.map(s => s.name);+ const run = tier2.steps.find(s => s.name === 'Run Tier 2 skill tests')!;+ expect(run.env!.GBRAIN_TEST_KEEP_PROVIDER_KEYS).toBe('1');+ expect(run.run).toContain('scripts/run-with-receipt.sh tier2 ');+ const check = tier2.steps.find(s => s.name === 'Require every Tier 2 test to run')!;+ expect(check.run).toBe('bun scripts/require-executed-tests.ts "$RUNNER_TEMP/receipts" tier2');+ expect(check.if).toBeUndefined();+ expect(names.indexOf('Require every Tier 2 test to run')).toBe(names.indexOf('Run Tier 2 skill tests') + 1);+ expect(tier2.steps.find(s => s.name === 'Provider-key coverage notice')!.env!.GBRAIN_TEST_KEEP_PROVIDER_KEYS).toBe('1');+ });+});