Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci: GBRAIN_PAID_LANES=0 switches every paid lane off; e2e-status accepts only that skip (#5903)
garrytan3a38db07b835
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex 605e4b17af..b1f7918a3e 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -547,7 +547,14 @@ jobs:# 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.+ # Unset or any other value keeps them on. e2e-status accepts this job as+ # `skipped` only when that exact variable is '0' and says so in the step+ # summary; any other skip, failure or cancellation still fails the aggregate.needs: jsonb-parity+ if: vars.GBRAIN_PAID_LANES != '0'runs-on: ubicloud-standard-4-ubuntu-2404timeout-minutes: 30services:@@ -1081,19 +1088,36 @@ jobs:runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 5steps:+ # The job results come in through env so test/paid-lanes-switch-5903.test.ts+ # can run this exact script under bash with every result combination.- name: Aggregate resultenv:FULL_CORPUS: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.full_corpus) }}+ JSONB: ${{ needs.jsonb-parity.result }}+ TIER1: ${{ needs.tier1.result }}+ BACKEND_MATRIX: ${{ needs.tier1-backend-matrix.result }}+ TIER2: ${{ needs.tier2.result }}+ PREPARE: ${{ needs.prepare-e2e.result }}+ SELECTED: ${{ needs.selected-e2e.result }}+ FULL_UNIT: ${{ needs.coverage-full-unit.result }}+ FULL_SERIAL: ${{ needs.coverage-full-serial.result }}+ FULL_SLOW: ${{ needs.coverage-full-slow.result }}+ FULL_E2E: ${{ needs.coverage-full-e2e.result }}+ EVENT: ${{ github.event_name }}+ # #5903: the one value that authorizes a skipped tier2.+ GBRAIN_PAID_LANES: ${{ vars.GBRAIN_PAID_LANES }}run: |- JSONB="${{ needs.jsonb-parity.result }}"- TIER1="${{ needs.tier1.result }}"- BACKEND_MATRIX="${{ needs.tier1-backend-matrix.result }}"- TIER2="${{ needs.tier2.result }}"- PREPARE="${{ needs.prepare-e2e.result }}"- SELECTED="${{ needs.selected-e2e.result }}"- EVENT="${{ github.event_name }}"echo "event=$EVENT"echo "jsonb-parity=$JSONB tier1=$TIER1 tier1-backend-matrix=$BACKEND_MATRIX tier2=$TIER2 prepare-e2e=$PREPARE selected-e2e=$SELECTED"+ if [ "$TIER2" = "skipped" ] && [ "$GBRAIN_PAID_LANES" = "0" ]; then+ echo "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'"+ {+ echo "## Tier 2 (LLM Skills): skipped, paid lanes disabled"+ echo "The repository variable \`GBRAIN_PAID_LANES\` is \`0\`, so no paid lane ran. This is not green coverage of Tier 2; unset the variable (or set it to \`1\`) to run it."+ } >> "${GITHUB_STEP_SUMMARY:-/dev/null}"+ TIER2="success"+ fifor r in "$JSONB" "$TIER1" "$BACKEND_MATRIX" "$TIER2" "$PREPARE" "$SELECTED"; doif [ "$r" != "success" ]; thenecho "✗ gated e2e job did not succeed (got $r) — E2E fail"@@ -1101,10 +1125,6 @@ jobs:fidoneif [ "$FULL_CORPUS" = "true" ]; then- FULL_UNIT="${{ needs.coverage-full-unit.result }}"- FULL_SERIAL="${{ needs.coverage-full-serial.result }}"- FULL_SLOW="${{ needs.coverage-full-slow.result }}"- FULL_E2E="${{ needs.coverage-full-e2e.result }}"echo "full-unit=$FULL_UNIT full-serial=$FULL_SERIAL full-slow=$FULL_SLOW full-e2e=$FULL_E2E"for r in "$FULL_UNIT" "$FULL_SERIAL" "$FULL_SLOW" "$FULL_E2E"; doif [ "$r" != "success" ]; thendiff --git a/.github/workflows/heavy-tests.yml b/.github/workflows/heavy-tests.ymlindex dcbd66deca..50a8d46618 100644--- a/.github/workflows/heavy-tests.yml+++ b/.github/workflows/heavy-tests.yml@@ -346,6 +346,8 @@ jobs:id: paidgateenv:ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ # #5903: the repository-wide paid-lane switch (see e2e.yml tier2).+ GBRAIN_PAID_LANES: ${{ vars.GBRAIN_PAID_LANES }}run: |if ! command -v hermes >/dev/null 2>&1; thenecho "::error::hermes did not resolve on PATH after install" >&2@@ -359,6 +361,17 @@ jobs:echo "::error::hermes version drift — expected v$HERMES_VERSION in: $version_output" >&2exit 1fi+ if [ "$GBRAIN_PAID_LANES" = "0" ]; then+ # Same visible-skip shape as the missing secret below, with its own+ # line: the operator switched every paid lane off on purpose.+ echo "paid=false" >> "$GITHUB_OUTPUT"+ echo "::warning::hermes door PAID LEG SKIPPED — paid lanes disabled by the repository variable GBRAIN_PAID_LANES='0'. Installer digest + payload + version pins verified; no hermes turn ran." >&2+ {+ echo "## Hermes door: paid leg skipped (paid lanes disabled)"+ echo "The repository variable \`GBRAIN_PAID_LANES\` is \`0\` — installer digest, payload, and version pins verified, but no hermes turn ran. This run is not green coverage of the paid leg; unset the variable (or set it to \`1\`) to run it."+ } >> "$GITHUB_STEP_SUMMARY"+ exit 0+ fiif [ -z "$ANTHROPIC_API_KEY" ]; then# Visible skip on every event: the owner has approved setting the# secret (GBRA-47 D-1) and only the owner can set it, so a red job@@ -817,7 +830,8 @@ jobs:strategy:fail-fast: falsematrix:- lane: ${{ fromJSON((inputs.run_opencode_paid || vars.GBRAIN_OPENCODE_PAID_E2E == '1') && '["keyless","credentialed"]' || '["keyless"]') }}+ # #5903: GBRAIN_PAID_LANES='0' switches the credentialed lane off even when it is requested.+ lane: ${{ fromJSON((inputs.run_opencode_paid || vars.GBRAIN_OPENCODE_PAID_E2E == '1') && vars.GBRAIN_PAID_LANES != '0' && '["keyless","credentialed"]' || '["keyless"]') }}# Measured local door wall-time: full 6-test run 35.8s + one-time# compiled gbrain build (~2-4 min) + npm install (~15s); free-tier +# paid turn budgets 2 x 240s each. 20 min = measured + >50% headroom.@@ -932,7 +946,7 @@ jobs:if: matrix.lane == 'keyless'run: |echo "## OpenCode: keyless coverage only" >> "$GITHUB_STEP_SUMMARY"- echo "No paid turn ran in this lane. Request run_opencode_paid on dispatch or set GBRAIN_OPENCODE_PAID_E2E=1 to enable the separate credentialed lane." >> "$GITHUB_STEP_SUMMARY"+ echo "No paid turn ran in this lane. Request run_opencode_paid on dispatch or set GBRAIN_OPENCODE_PAID_E2E=1 to enable the separate credentialed lane (GBRAIN_PAID_LANES=0 keeps it off either way)." >> "$GITHUB_STEP_SUMMARY"- name: Preconditions (credentialed lane requires secret)if: matrix.lane == 'credentialed'diff --git a/docs/TESTING.md b/docs/TESTING.mdindex 6046db371c..5c9353ab04 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -1260,7 +1260,7 @@ there even though they pass on Linux and macOS.### CI vs local: intentionally divergent file sets-- **CI matrix** (`.github/workflows/test.yml`) runs `scripts/test-shard.sh` across 8 shards partitioned 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 (`eval-longmemeval-e2e.slow.test.ts` runs inside the shards; entity-resolve-perf, entity-card-perf, export-scale and brainbench-e2e have dedicated jobs, and the `reconcile-crash-*.slow.test.ts` files runs only in persistence-validation) plus keyless-allowlisted `evals/**/*.test.ts` (`test/scripts/evals-collection.test.ts`). Shards keep planned file order (`test-shard.sh --dry-run-list <i> 8`). Every Bun job activates the PGLite schema snapshot (built in-runner, cached across jobs with the runner's hash check authoritative). Serial files run across four `serial-tests` workers via `bun run test:serial`; `verify` 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, and successful test results are never reused. CI is the ground truth for "did everything pass."+- **CI matrix** (`.github/workflows/test.yml`) runs `scripts/test-shard.sh` across 8 shards partitioned 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 (`eval-longmemeval-e2e.slow.test.ts` runs inside the shards; entity-resolve-perf, entity-card-perf, export-scale and brainbench-e2e have dedicated jobs, and the `reconcile-crash-*.slow.test.ts` files runs only in persistence-validation) plus keyless-allowlisted `evals/**/*.test.ts` (`test/scripts/evals-collection.test.ts`). Shards keep planned file order (`test-shard.sh --dry-run-list <i> 8`). Every Bun job activates the PGLite schema snapshot (built in-runner, cached across jobs with the runner's hash check authoritative). Serial files run across four `serial-tests` workers via `bun run test:serial`; `verify` 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, and successful test results are never reused. The repository variable `GBRAIN_PAID_LANES=0` switches every paid lane off (Tier 2, the hermes door's paid leg and the OpenCode credentialed lane in `heavy-tests.yml`) for forks and spend freezes; `e2e-status` then accepts Tier 2 as skipped, says so in the step summary, and still rejects every other skip, failure or cancellation (#5903, `test/paid-lanes-switch-5903.test.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.This divergence is intentional; the two scripts solve different problems.diff --git a/test/paid-lanes-switch-5903.test.ts b/test/paid-lanes-switch-5903.test.tsnew file mode 100644index 0000000000..80c2268b60--- /dev/null+++ b/test/paid-lanes-switch-5903.test.ts@@ -0,0 +1,132 @@+/**+ * #5903: the repository variable GBRAIN_PAID_LANES='0' switches every paid CI+ * lane off (tier2 in e2e.yml, the hermes door paid leg and the OpenCode+ * credentialed lane in heavy-tests.yml), and e2e-status accepts a skipped+ * tier2 only when exactly that variable authorized it ([R21]).+ *+ * The aggregate step reads every job result from env, so this test runs the+ * step's real script under bash with each result combination.+ */+import { describe, expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { load } from 'js-yaml';++const ROOT = join(import.meta.dir, '..');+const E2E = readFileSync(join(ROOT, '.github/workflows/e2e.yml'), 'utf8');+const HEAVY = readFileSync(join(ROOT, '.github/workflows/heavy-tests.yml'), 'utf8');++type Step = { name?: string; id?: string; env?: Record<string, string>; run?: string; if?: string };+type Job = { if?: string; needs?: string[]; steps: Step[]; strategy?: { matrix?: Record<string, string> } };+const e2eJobs = (load(E2E) as { jobs: Record<string, Job> }).jobs;+const heavyJobs = (load(HEAVY) as { jobs: Record<string, Job> }).jobs;++const aggregate = e2eJobs['e2e-status'].steps.find((s) => s.name === 'Aggregate result');+if (!aggregate?.run || !aggregate.env) throw new Error('e2e-status has no "Aggregate result" step with env + run');++const GREEN = {+ JSONB: 'success',+ TIER1: 'success',+ BACKEND_MATRIX: 'success',+ TIER2: 'success',+ PREPARE: 'success',+ SELECTED: 'success',+ FULL_UNIT: 'success',+ FULL_SERIAL: 'success',+ FULL_SLOW: 'success',+ FULL_E2E: 'success',+ FULL_CORPUS: 'false',+ EVENT: 'pull_request',+ GBRAIN_PAID_LANES: '',+};++function runAggregate(overrides: Partial<typeof GREEN>) {+ const dir = mkdtempSync(join(tmpdir(), 'paid-lanes-5903-'));+ const summary = join(dir, 'summary.md');+ try {+ const proc = spawnSync('bash', ['-e', '-c', aggregate!.run!], {+ env: { PATH: process.env.PATH ?? '/usr/bin:/bin', ...GREEN, ...overrides, GITHUB_STEP_SUMMARY: summary },+ encoding: 'utf8',+ });+ let summaryText = '';+ try {+ summaryText = readFileSync(summary, 'utf8');+ } catch {}+ return { status: proc.status, stdout: proc.stdout, stderr: proc.stderr, summary: summaryText };+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+}++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("vars.GBRAIN_PAID_LANES != '0'");+ 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');+ });++ test('hermes paidgate honours the variable before the secret check', () => {+ const gate = heavyJobs['hermes-door'].steps.find((s) => s.id === 'paidgate');+ expect(gate?.env?.GBRAIN_PAID_LANES).toBe('${{ vars.GBRAIN_PAID_LANES }}');+ const run = gate!.run!;+ const switchOff = run.indexOf('if [ "$GBRAIN_PAID_LANES" = "0" ]; then');+ const secretCheck = run.indexOf('if [ -z "$ANTHROPIC_API_KEY" ]; then');+ expect(switchOff).toBeGreaterThan(-1);+ expect(switchOff).toBeLessThan(secretCheck);+ expect(run.slice(switchOff, secretCheck)).toContain('echo "paid=false" >> "$GITHUB_OUTPUT"');+ expect(run.slice(switchOff, secretCheck)).toContain('exit 0');+ });++ test('OpenCode credentialed lane stays keyless-only when the variable is 0', () => {+ const lane = heavyJobs['opencode-door'].strategy?.matrix?.lane ?? '';+ expect(lane).toContain("vars.GBRAIN_PAID_LANES != '0' && '[\"keyless\",\"credentialed\"]'");+ });+});++describe('#5903 e2e-status accepts a skipped tier2 only under GBRAIN_PAID_LANES=0', () => {+ test('all green passes', () => {+ expect(runAggregate({}).status).toBe(0);+ });++ test('tier2 skipped with the variable unset fails', () => {+ const r = runAggregate({ TIER2: 'skipped' });+ 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 with the variable at '0' passes and says it is not coverage", () => {+ const r = runAggregate({ TIER2: 'skipped', GBRAIN_PAID_LANES: '0' });+ expect(r.status).toBe(0);+ expect(r.stdout).toContain("paid lanes disabled by the repository variable GBRAIN_PAID_LANES='0'");+ expect(r.stdout).toContain('✓ all required e2e jobs succeeded');+ expect(r.summary).toContain('not green coverage of Tier 2');+ });++ 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', 'PREPARE', 'SELECTED'] as const) {+ const r = runAggregate({ [key]: 'skipped', GBRAIN_PAID_LANES: '0' });+ expect(r.status).toBe(1);+ expect(r.stdout).toContain('got skipped');+ }+ });++ test('full-corpus jobs are still required when FULL_CORPUS=true', () => {+ expect(runAggregate({ FULL_CORPUS: 'true' }).status).toBe(0);+ const r = runAggregate({ FULL_CORPUS: 'true', FULL_SLOW: 'skipped', GBRAIN_PAID_LANES: '0' });+ expect(r.status).toBe(1);+ expect(r.stdout).toContain('full-corpus job did not succeed (got skipped)');+ });+});