Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

heavy: every door and heavy script reports; missing secrets are visible skips

garrytane36e34ac6635
diff --git a/.github/workflows/heavy-tests.yml b/.github/workflows/heavy-tests.yml
index 6c66be9503..1f28be93cb 100644
--- a/.github/workflows/heavy-tests.yml
+++ b/.github/workflows/heavy-tests.yml
@@ -59,7 +59,7 @@ jobs:
ports:
- 5432:5432
options: >-
- --health-cmd pg_isready
+ --health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
@@ -83,19 +83,12 @@ jobs:
GBRAIN_TEST_ALLOW_DATABASE_URL: '1'
run: bun run test:heavy
- # Agent-bootstrap offline Docker e2e [A7] — placeholder registration.
- # The networkless cold-machine container test (interview → render →
- # verify with a fake gh) lands with the bootstrap doors task at
- # tests/docker/bootstrap-e2e.sh. Gated on file existence so this stays
- # a visible no-op until then. It runs at heavy cadence (nightly +
- # `heavy-tests` label) by design — never in the PR shard matrix.
- - name: Bootstrap offline Docker e2e (placeholder)
- run: |
- if [ -f tests/docker/bootstrap-e2e.sh ]; then
- bash tests/docker/bootstrap-e2e.sh
- else
- echo "SKIP: tests/docker/bootstrap-e2e.sh not present yet — placeholder until the bootstrap doors task lands."
- fi
+ # Agent-bootstrap offline Docker e2e [A7]: the networkless cold-machine
+ # container test (interview → render → verify with a fake gh). It runs
+ # at heavy cadence (nightly + `heavy-tests` label) by design, never in
+ # the PR shard matrix. No existence guard: a missing script fails red.
+ - name: Bootstrap offline Docker e2e
+ run: bash tests/docker/bootstrap-e2e.sh
# The heavy runner writes per-script logs to ~/.gbrain/audit/ on every
# run. Upload those + the rss workload JSON on failure for triage
@@ -120,24 +113,29 @@ jobs:
retention-days: 14
if-no-files-found: ignore
- # Real-agent door e2e: drives the ACTUAL `claude` + `codex` + `hermes` +
- # `grok` + `opencode` binaries (no PATH shims) against a real gbrain over
- # MCP. These pay real API
- # cost and need the binaries installed + authed, which a stock GitHub runner
- # does NOT have — so the tests self-SKIP (describe.skipIf on binary/auth) and
- # the job is a clean no-op here. It exists so a self-hosted /
- # manually-provisioned runner WITH authed claude/codex/hermes (and
- # ANTHROPIC/OPENAI creds) actually exercises the real binaries. Heavy cadence
- # only (nightly + `real-agent-e2e` label + dispatch); NEVER the PR shard
- # matrix.
+ # Real-agent door e2e: drives the ACTUAL `claude` + `codex` binaries (plus
+ # `hermes`/`grok`/`opencode` when a provisioned runner has them; their
+ # dedicated jobs below are the owners on stock runners) against a real gbrain
+ # over MCP. bootstrap-real-claude/codex run in no other job.
+ #
+ # Two postures, chosen by the Credential gate step:
+ # - ANTHROPIC_API_KEY and OPENAI_API_KEY secrets set: install the pinned
+ # claude-code and codex builds (same pins as plugin-doors), pass the keys
+ # through the test preload (GBRAIN_TEST_KEEP_PROVIDER_KEYS=1, codex reads
+ # CODEX_API_KEY), and fail unless the live Claude and live Codex door
+ # tests each executed.
+ # - Either secret empty: a visible ::warning:: + step summary saying zero
+ # real-agent tests executed, never a silent green.
+ # Heavy cadence only (nightly + `real-agent-e2e` label + dispatch); NEVER
+ # the PR shard matrix.
real-agent-e2e:
- name: Real-agent door e2e (skips without authed binaries)
+ name: Real-agent door e2e (live claude + codex when keyed)
if: |
github.event_name != 'pull_request' ||
contains(github.event.pull_request.labels.*.name, 'real-agent-e2e') ||
contains(github.event.pull_request.labels.*.name, 'heavy-tests')
runs-on: ubicloud-standard-16-ubuntu-2404
- timeout-minutes: 20
+ timeout-minutes: 30
env:
# Open the hermes/grok opt-in doors here so binary/auth absence — not
# the opt-in var — is what skips (same posture as the claude/codex
@@ -152,6 +150,9 @@ jobs:
GROK_VERSION: "1.0.4"
# Same posture for opencode: a provisioned runner's version pin.
OPENCODE_VERSION: "1.18.18"
+ # Same pins as plugin-doors; update both jobs together.
+ CODEX_NPM_VERSION: "0.147.0"
+ CLAUDE_NPM_VERSION: "2.1.233"
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
@@ -166,36 +167,77 @@ jobs:
restore-keys: bun-cache-${{ runner.os }}-
- run: bun install --frozen-lockfile
- # Reference the door tests; run only the ones present (a door may land
- # in a sibling PR). Missing binary/auth → the file self-skips, so a
- # stock runner reports a green no-op rather than failing.
+ - name: Credential gate (visible skip without provider secrets)
+ id: keys
+ env:
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
+ run: |
+ missing=()
+ [ -n "$ANTHROPIC_API_KEY" ] || missing+=(ANTHROPIC_API_KEY)
+ [ -n "$OPENAI_API_KEY" ] || missing+=(OPENAI_API_KEY)
+ if [ "${#missing[@]}" -eq 0 ]; then
+ echo "keyed=true" >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ echo "keyed=false" >> "$GITHUB_OUTPUT"
+ setcmds=$(printf 'gh secret set %s; ' "${missing[@]}")
+ echo "::warning::Real-agent door e2e executed 0 live claude/codex tests — empty secret(s): ${missing[*]}. Why: only the repo owner can set secrets. Fix (owner-only): ${setcmds% } then re-check with: gh workflow run heavy-tests.yml --ref master (or label a PR real-agent-e2e)." >&2
+ {
+ echo "## Real-agent door e2e: 0 live tests executed"
+ echo "Empty secret(s): ${missing[*]}. bootstrap-real-claude and bootstrap-real-codex run in no other job, so this run is not real-agent coverage."
+ echo ""
+ echo "- Why: only the repo owner can set secrets."
+ echo "- Fix (owner-only): \`${setcmds% }\`"
+ echo "- Re-check: \`gh workflow run heavy-tests.yml --ref master\`, or add the \`real-agent-e2e\` label to a PR."
+ } >> "$GITHUB_STEP_SUMMARY"
+
+ - name: Install codex + claude (pinned npm versions, refuse on drift)
+ if: steps.keys.outputs.keyed == 'true'
+ timeout-minutes: 10
+ run: |
+ npm install -g "@openai/codex@$CODEX_NPM_VERSION" "@anthropic-ai/claude-code@$CLAUDE_NPM_VERSION"
+ codex_v=$(codex --version)
+ printf '%s' "$codex_v" | grep -qF "$CODEX_NPM_VERSION" || { echo "::error::codex version drift — expected $CODEX_NPM_VERSION in: $codex_v (re-pin deliberately)" >&2; exit 1; }
+ claude_v=$(claude --version)
+ printf '%s' "$claude_v" | grep -qF "$CLAUDE_NPM_VERSION" || { echo "::error::claude version drift — expected $CLAUDE_NPM_VERSION in: $claude_v (re-pin deliberately)" >&2; exit 1; }
+
+ # Missing binary/auth → the door files self-skip. Keyed runs then refuse
+ # green unless each live door actually executed.
- name: Run real-agent door tests
+ env:
+ ANTHROPIC_API_KEY: ${{ steps.keys.outputs.keyed == 'true' && secrets.ANTHROPIC_API_KEY || '' }}
+ CODEX_API_KEY: ${{ steps.keys.outputs.keyed == 'true' && secrets.OPENAI_API_KEY || '' }}
+ GBRAIN_TEST_KEEP_PROVIDER_KEYS: ${{ steps.keys.outputs.keyed == 'true' && '1' || '' }}
+ KEYED: ${{ steps.keys.outputs.keyed }}
run: |
- files=()
- for f in \
+ EXIT=0
+ # --timeout: real-agent turns are slow (live claude/codex).
+ bun test --timeout=600000 \
test/e2e/bootstrap-real-claude.serial.test.ts \
test/e2e/bootstrap-real-codex.serial.test.ts \
test/e2e/install-real-hermes.serial.test.ts \
test/e2e/install-real-grok.serial.test.ts \
- test/e2e/install-real-opencode.serial.test.ts; do
- [ -f "$f" ] && files+=("$f")
+ test/e2e/install-real-opencode.serial.test.ts > real-agent-doors.txt 2>&1 || EXIT=$?
+ tail -80 real-agent-doors.txt
+ if [ "$EXIT" -ne 0 ]; then exit "$EXIT"; fi
+ if [ "$KEYED" != "true" ]; then exit 0; fi
+ ok=1
+ for door in 'bootstrap real Claude Code door' 'bootstrap real-codex door'; do
+ if ! grep -qF "(pass) $door" real-agent-doors.txt; then
+ echo "::error::Keyed run executed no passing '$door' test. Why: the secrets are set but the live door self-skipped (binary or auth not detected). Fix: read real-agent-doors.txt above for the skip reason, then gh workflow run heavy-tests.yml --ref <branch>." >&2
+ ok=0
+ fi
done
- if [ "${#files[@]}" -eq 0 ]; then
- echo "SKIP: no real-agent door test files present yet."
- exit 0
- fi
- echo "Running: ${files[*]}"
- # --timeout: real-agent turns are slow (live claude/codex); the door
- # tests self-skip without authed binaries so this is a no-op elsewhere.
- bun test --timeout=600000 "${files[@]}"
+ [ "$ok" -eq 1 ]
# Hermes door e2e: unlike real-agent-e2e above (best-effort, self-skipping),
# this job PROVISIONS the real hermes binary itself — pinned installer digest,
# non-interactive auth + model pin — and then requires the door tests to
# actually execute. It pays real API cost, so it stays label-gated at heavy
# cadence (nightly + `real-agent-e2e`/`heavy-tests` label + dispatch); NEVER
- # the PR shard matrix. Loud-fail throughout: a runner that cannot install or
- # auth hermes fails this job rather than skipping.
+ # the PR shard matrix. Loud-fail on install, payload and version drift; an
+ # empty ANTHROPIC_API_KEY secret is a visible, tracked skip (Preconditions).
hermes-door:
name: Hermes door e2e (credentialed, real binary, loud-fail)
if: |
@@ -300,24 +342,23 @@ jobs:
exit 1
fi
if [ -z "$ANTHROPIC_API_KEY" ]; then
- # Split posture: schedule/dispatch stay LOUD-FAIL — the owner is
- # the audience there and owns the secret. A pull_request run's
- # audience is a PR author who cannot fix repo secrets (fork PRs
- # never receive them at all), and a permanently-red check trains
- # reviewers to ignore this door — so on PRs the missing paid leg
- # is a VISIBLE SKIP (warning + job summary), never a silent green.
- if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
- echo "paid=false" >> "$GITHUB_OUTPUT"
- echo "::warning::hermes door PAID LEG SKIPPED — ANTHROPIC_API_KEY secret is empty (owner-only fix: gh secret set ANTHROPIC_API_KEY). Installer digest + payload + version pins verified; no hermes turn ran." >&2
- {
- echo "## Hermes door: paid leg skipped"
- echo "ANTHROPIC_API_KEY secret is empty — installer digest, payload, and version pins verified, but no hermes turn ran."
- echo "The nightly schedule stays loud-fail until the owner sets the secret."
- } >> "$GITHUB_STEP_SUMMARY"
- exit 0
- fi
- echo "::error::ANTHROPIC_API_KEY secret is empty — this scheduled/dispatched run cannot cover the hermes door without it (owner-only fix: gh secret set ANTHROPIC_API_KEY)" >&2
- exit 1
+ # 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
+ # here would only repeat that fact every night. The skip is never
+ # read as green: "Run hermes door tests" ends `skipped`, which
+ # nightly-watch matches against the `known-skipped` row in
+ # .github/nightly-known-red.tsv and keeps the incident open.
+ echo "paid=false" >> "$GITHUB_OUTPUT"
+ echo "::warning::hermes door PAID LEG SKIPPED — ANTHROPIC_API_KEY secret is empty. Why: only the repo owner can set secrets. Fix (owner-only): gh secret set ANTHROPIC_API_KEY. Installer digest + payload + version pins verified; no hermes turn ran. Tracked as known-skipped in .github/nightly-known-red.tsv." >&2
+ {
+ echo "## Hermes door: paid leg skipped (known-skipped)"
+ echo "ANTHROPIC_API_KEY secret is empty — installer digest, payload, and version pins verified, but no hermes turn ran."
+ echo ""
+ echo "- Why: only the repo owner can set secrets."
+ echo "- Fix (owner-only): \`gh secret set ANTHROPIC_API_KEY\`, then delete the hermes row from \`.github/nightly-known-red.tsv\`."
+ echo "- Tracking: nightly-watch keeps this workflow's incident open while the row matches; this run is not green coverage."
+ } >> "$GITHUB_STEP_SUMMARY"
+ exit 0
fi
echo "paid=true" >> "$GITHUB_OUTPUT"
@@ -719,7 +760,10 @@ jobs:
exit 1
fi
+ # Runs even when the Codex door failed, so one door's red never hides
+ # the other's result.
- name: Claude plugin door (install tier — expected shape enforced)
+ if: ${{ !cancelled() }}
run: |
EXIT=0
bun test --timeout=600000 test/e2e/claude-plugin-install-real.serial.test.ts -t 'VALIDATE' > claude-plugin-door.txt 2>&1 || EXIT=$?
diff --git a/.github/workflows/scale-tier.yml b/.github/workflows/scale-tier.yml
index 92a4cb9fb1..fe9492ace9 100644
--- a/.github/workflows/scale-tier.yml
+++ b/.github/workflows/scale-tier.yml
@@ -142,7 +142,7 @@ jobs:
ports:
- 5432:5432
options: >-
- --health-cmd pg_isready
+ --health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
diff --git a/scripts/run-heavy.sh b/scripts/run-heavy.sh
index d9ff1adce6..200f112d3b 100755
--- a/scripts/run-heavy.sh
+++ b/scripts/run-heavy.sh
@@ -9,6 +9,9 @@
# bash scripts/run-heavy.sh # same
# bash scripts/run-heavy.sh <pattern> # only scripts whose basename matches glob
#
+# Every script runs even after one fails, so one red script never hides
+# another. The summary lists each failing script with its own rerun command.
+#
# Exit codes:
# 0 all scripts passed (or no scripts found — informational)
# N exit code of the first failing script
@@ -53,7 +56,8 @@ echo "[run-heavy] running ${#heavy_files[@]} heavy script(s):"
for f in "${heavy_files[@]}"; do echo " - $f"; done
echo ""
-failed=0
+first_rc=0
+failures=()
for f in "${heavy_files[@]}"; do
echo "[run-heavy] --- $f ---"
start=$(date +%s)
@@ -64,15 +68,19 @@ for f in "${heavy_files[@]}"; do
rc=$?
elapsed=$(( $(date +%s) - start ))
echo "[run-heavy] FAIL ($f exited $rc after ${elapsed}s)" >&2
- failed=$rc
- break
+ [ "$first_rc" -ne 0 ] || first_rc=$rc
+ failures+=("$f|$rc")
fi
echo ""
done
-if [ "$failed" -ne 0 ]; then
- echo "[run-heavy] FAILED — first failing script aborted the run." >&2
- exit "$failed"
+if [ "${#failures[@]}" -ne 0 ]; then
+ echo "[run-heavy] FAILED — ${#failures[@]} of ${#heavy_files[@]} script(s) failed:" >&2
+ for entry in "${failures[@]}"; do
+ f="${entry%|*}"
+ echo " - $f (exit ${entry##*|}); rerun: bash scripts/run-heavy.sh $(basename "$f")" >&2
+ done
+ exit "$first_rc"
fi
echo "[run-heavy] all ${#heavy_files[@]} script(s) passed."
diff --git a/test/e2e/codex-plugin-install-real.serial.test.ts b/test/e2e/codex-plugin-install-real.serial.test.ts
index 0768ca23d5..fe5fdc598d 100644
--- a/test/e2e/codex-plugin-install-real.serial.test.ts
+++ b/test/e2e/codex-plugin-install-real.serial.test.ts
@@ -42,7 +42,7 @@ import {
ensureCompiledGbrain,
} from '../helpers/agent-harness.ts';
import { operations } from '../../src/core/operations.ts';
-import { filterOpsForSurface } from '../../src/mcp/surface.ts';
+import { isCallable, publishGatesFromDisabled } from '../../src/core/ops/callable.ts';
import { codexPluginProvidesName } from '../../src/core/bootstrap/harness.ts';
const REPO_ROOT = resolve(import.meta.dir, '..', '..');
@@ -217,7 +217,8 @@ describe.skipIf(!PLUGIN_CAPABLE)('codex plugin door — INSTALL (no auth needed)
env: probeEnv,
timeoutMs: 120_000,
});
- const expected = filterOpsForSurface(operations, 'starter').map((o) => o.name).sort();
+ const publishGates = publishGatesFromDisabled(operations, new Set());
+ const expected = operations.filter((o) => isCallable(o, { transport: 'stdio', surface: 'starter', scopes: [], publishGates })).map((o) => o.name).sort();
expect(tools.sort()).toEqual(expected);
// (f) cold-home fast-fail: fresh empty GBRAIN_HOME → actionable exit,
@@ -229,9 +230,17 @@ describe.skipIf(!PLUGIN_CAPABLE)('codex plugin door — INSTALL (no auth needed)
env: hermeticChildEnv({ HOME: coldHome, GBRAIN_BIN: gbrainBin, GBRAIN_HOME: coldHome }) as Record<string, string>,
timeout: 60_000,
});
- expect(cold.status).not.toBe(0);
- expect(cold.stderr).toContain('No brain configured');
- expect(cold.stderr).toContain('gbrain init');
+ expect(cold.status).toBe(0);
+ expect(cold.stderr).toContain('STATUS-ONLY');
+ const coldFast = spawnSync(launcher, [...serverArgs, '--fail-fast'], {
+ cwd: snap!,
+ encoding: 'utf8',
+ env: hermeticChildEnv({ HOME: coldHome, GBRAIN_BIN: gbrainBin, GBRAIN_HOME: coldHome }) as Record<string, string>,
+ timeout: 60_000,
+ });
+ expect(coldFast.status).not.toBe(0);
+ expect(coldFast.stderr).toContain('No brain configured');
+ expect(coldFast.stderr).toContain('gbrain init');
// (g) --source-guard: a GENUINELY AMBIGUOUS brain (default + TWO
// non-default sources, so resolution can't land on the unambiguous
diff --git a/test/scripts/heavy-door-workflow.test.ts b/test/scripts/heavy-door-workflow.test.ts
index f2a7b5635b..ad7e5cee1e 100644
--- a/test/scripts/heavy-door-workflow.test.ts
+++ b/test/scripts/heavy-door-workflow.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'bun:test';
-import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+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';
@@ -74,4 +74,67 @@ describe('heavy door supply chain and coverage gates', () => {
expect(result.stdout).not.toContain('paid=true');
}
});
+
+ test('Docker bootstrap e2e has no existence guard that could turn a missing script green', () => {
+ const step = workflow.jobs.heavy.steps.find(s => s.name === 'Bootstrap offline Docker e2e')!;
+ expect(step.run!.trim()).toBe('bash tests/docker/bootstrap-e2e.sh');
+ });
+
+ test('the Claude plugin door reports even when the Codex door failed', () => {
+ const claude = workflow.jobs['plugin-doors'].steps.find(s => s.name?.startsWith('Claude plugin door'))!;
+ expect(claude.if).toBe('${{ !cancelled() }}');
+ });
+
+ test('Hermes with an empty ANTHROPIC_API_KEY is a visible, tracked skip on a scheduled run', () => {
+ const gate = hermes.steps.find(step => step.id === 'paidgate')!;
+ const home = mkdtempSync(join(tmpdir(), 'gbrain-hermes-gate-test-'));
+ try {
+ const bin = join(home, 'bin');
+ mkdirSync(bin);
+ writeFileSync(join(bin, 'hermes'), `#!/bin/sh\necho 'Hermes Agent v${hermes.env.HERMES_VERSION} (2026.8.3)'\n`, { mode: 0o755 });
+ const output = join(home, 'output');
+ const summary = join(home, 'summary');
+ const result = spawnSync('bash', ['-euo', 'pipefail', '-c', gate.run!], {
+ env: {
+ PATH: `${bin}:${process.env.PATH}`, ...hermes.env, ANTHROPIC_API_KEY: '',
+ GITHUB_EVENT_NAME: 'schedule', GITHUB_OUTPUT: output, GITHUB_STEP_SUMMARY: summary,
+ },
+ encoding: 'utf8',
+ });
+ expect(result.status, result.stderr).toBe(0);
+ expect(readFileSync(output, 'utf8')).toContain('paid=false');
+ expect(result.stderr).toContain('Fix (owner-only): gh secret set ANTHROPIC_API_KEY');
+ expect(readFileSync(summary, 'utf8')).toContain('known-skipped');
+ expect(hermes.steps.find(step => step.name === 'Run hermes door tests')!.if).toBe("steps.paidgate.outputs.paid == 'true'");
+ } finally {
+ rmSync(home, { recursive: true, force: true });
+ }
+ });
+
+ test('real-agent e2e without provider secrets warns that 0 live tests ran and names the fix', () => {
+ const job = workflow.jobs['real-agent-e2e'];
+ const gate = job.steps.find(step => step.id === 'keys')!;
+ const home = mkdtempSync(join(tmpdir(), 'gbrain-real-agent-gate-test-'));
+ try {
+ const output = join(home, 'output');
+ const summary = join(home, 'summary');
+ const result = spawnSync('bash', ['-euo', 'pipefail', '-c', gate.run!], {
+ env: { PATH: process.env.PATH, ANTHROPIC_API_KEY: 'set', OPENAI_API_KEY: '', GITHUB_OUTPUT: output, GITHUB_STEP_SUMMARY: summary },
+ encoding: 'utf8',
+ });
+ expect(result.status, result.stderr).toBe(0);
+ expect(readFileSync(output, 'utf8')).toContain('keyed=false');
+ expect(result.stderr).toContain('::warning::Real-agent door e2e executed 0 live claude/codex tests');
+ expect(result.stderr).toContain('gh secret set OPENAI_API_KEY');
+ expect(result.stderr).toContain('gh workflow run heavy-tests.yml');
+ expect(result.stderr).toContain('real-agent-e2e');
+ expect(readFileSync(summary, 'utf8')).toContain('0 live tests executed');
+ } finally {
+ rmSync(home, { recursive: true, force: true });
+ }
+ const run = job.steps.find(step => step.name === 'Run real-agent door tests')!;
+ expect(run.env?.GBRAIN_TEST_KEEP_PROVIDER_KEYS).toContain("'1'");
+ expect(run.env?.CODEX_API_KEY).toContain('secrets.OPENAI_API_KEY');
+ expect(run.run).toContain("'bootstrap real Claude Code door' 'bootstrap real-codex door'");
+ });
});
diff --git a/test/scripts/run-heavy.test.ts b/test/scripts/run-heavy.test.ts
new file mode 100644
index 0000000000..aab10b6c41
--- /dev/null
+++ b/test/scripts/run-heavy.test.ts
@@ -0,0 +1,52 @@
+import { describe, expect, test } from 'bun:test';
+import { spawnSync } from 'node:child_process';
+import { copyFileSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+
+const REPO = resolve(import.meta.dir, '..', '..');
+
+function fixtureTree(scripts: Record<string, string>): string {
+ const root = mkdtempSync(join(tmpdir(), 'gbrain-run-heavy-'));
+ mkdirSync(join(root, 'scripts'));
+ mkdirSync(join(root, 'tests', 'heavy'), { recursive: true });
+ copyFileSync(join(REPO, 'scripts', 'run-heavy.sh'), join(root, 'scripts', 'run-heavy.sh'));
+ writeFileSync(join(root, 'tests', 'heavy', '_db_floor.sh'), '');
+ for (const [name, body] of Object.entries(scripts)) {
+ writeFileSync(join(root, 'tests', 'heavy', name), `#!/usr/bin/env bash\n${body}\n`);
+ }
+ return root;
+}
+
+describe('scripts/run-heavy.sh runs every heavy script', () => {
+ test('a failing script does not hide later scripts; the summary names each failure with its rerun command', () => {
+ const root = fixtureTree({
+ 'a_fails.sh': 'echo a-ran; exit 3',
+ 'b_passes.sh': 'echo b-ran',
+ 'c_fails.sh': 'echo c-ran; exit 5',
+ });
+ try {
+ const result = spawnSync('bash', [join(root, 'scripts', 'run-heavy.sh')], { encoding: 'utf8', timeout: 30_000 });
+ expect(result.status).toBe(3);
+ expect(result.stdout).toContain('a-ran');
+ expect(result.stdout).toContain('b-ran');
+ expect(result.stdout).toContain('c-ran');
+ expect(result.stderr).toContain('2 of 3 script(s) failed');
+ expect(result.stderr).toContain('tests/heavy/a_fails.sh (exit 3); rerun: bash scripts/run-heavy.sh a_fails.sh');
+ expect(result.stderr).toContain('tests/heavy/c_fails.sh (exit 5); rerun: bash scripts/run-heavy.sh c_fails.sh');
+ } finally {
+ rmSync(root, { recursive: true, force: true });
+ }
+ });
+
+ test('all scripts passing exits 0', () => {
+ const root = fixtureTree({ 'a.sh': 'true', 'b.sh': 'true' });
+ try {
+ const result = spawnSync('bash', [join(root, 'scripts', 'run-heavy.sh')], { encoding: 'utf8', timeout: 30_000 });
+ expect(result.status, result.stderr).toBe(0);
+ expect(result.stdout).toContain('all 2 script(s) passed');
+ } finally {
+ rmSync(root, { recursive: true, force: true });
+ }
+ });
+});