Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(scripts): regen-all passes --timeout to every bun test it spawns (#6187)
garrytanbe9ac15d911d
diff --git a/bunfig.toml b/bunfig.tomlindex c2b4af8762..27933f8177 100644--- a/bunfig.toml+++ b/bunfig.toml@@ -3,9 +3,10 @@# Default 5s is too short for those tests' beforeAll hooks. 60s is the# empirical ceiling we observed for the slowest cold-init paths.#-# v0.26.4: scripts/run-unit-parallel.sh and scripts/run-unit-shard.sh-# also pass `--timeout=60000` explicitly so the ceiling is consistent-# whether tests are invoked through the wrapper or directly via bun test.+# Bun (verified on 1.4.2) does not apply this value: a plain `bun test`+# still times out at 5s. Every runner passes `--timeout=60000` itself+# (scripts/run-unit-parallel.sh, scripts/run-unit-shard.sh,+# scripts/regen-all.ts); pass it yourself when running `bun test` directly.timeout = 60_000# v0.37 fix wave: pin gateway defaults to legacy OpenAI/1536 BEFORE anydiff --git a/docs/architecture/key-files/ci-health-and-test-guards.md b/docs/architecture/key-files/ci-health-and-test-guards.mdindex 2c867fd291..bd291ca90a 100644--- a/docs/architecture/key-files/ci-health-and-test-guards.md+++ b/docs/architecture/key-files/ci-health-and-test-guards.md@@ -10,7 +10,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `scripts/lib/ci-run.ts` — one run's failure evidence (`collectEvidence`): jobs, failing jobs' annotations and, for test.yml and e2e.yml, the `ci-manifest` artifact, returned as structured records (job, step, every failing test file and identity) apart from sanitized excerpts; a cancelled job is not run (listed in `cancelled`) unless its annotation says it timed out, and a red run whose only failures are aggregators of cancelled jobs is `ignored`; with `complete`/`problems` (an unreadable page, annotation or manifest is incomplete evidence, never zero failures). `reproduceCommand` builds `bun run test:stress <file> --iterations 10 [--postgres]` from a validated test path only. `exemptionRows` turns failing identities with an exact test name and signature into the stress gate's `<!-- gbrain-stress-exemption -->` records (backend per `stressBackend`, owner `agent on release duty`), written into master-red, flake and nightly-red bodies; `test/fixtures/nightly-watch/stress-exemption-contract.ts` vendors the gate's parser so the tests prove it accepts them.- `scripts/ci-manifest.ts` — the versioned failure and execution manifest (`gbrain-ci-manifest/v1`). The `executed-receipts` job of test.yml and e2e.yml builds it from every lane's receipts (via `scripts/ci-executed-counts.ts`, declared skips from the expected-deltas TSV), binds it to the workflow, event, SHA, run id and attempt, and uploads it as `ci-manifest`; each failure carries the JUnit message (credentials redacted) and the stress gate's `failureSignature` (omitted when the message holds a credential); `checkManifest` refuses a manifest for another run or attempt; `passedFiles` lists files that executed tests and failed none. Docs: `docs/ci-red-runbook.md#ci-failure-manifest`.- `scripts/release-gate.ts` — release.yml's `ci-gate` job. Polls the push-to-master runs of Test and E2E Tests on the release commit and writes `publish`/`sha`: both green publishes; a failed run publishes nothing and fails with the next step; a run cancelled by a newer push is followed to the next master commit with the same VERSION (published there) or marks the version superseded; non-master refs are refused; it fails with the backfill command after 110 minutes. Build, release, `latest-stable` and the publish jobs use the gated commit. Tests: `test/scripts/release-gate.test.ts`. Docs: `docs/RELEASING.md#release-ci-gate`.-- `scripts/regen-all.ts` — one entry point for every generated artifact (`ARTIFACTS`: regen and check command per artifact). `bun run regen:all` regenerates offline and keyless (provider keys and database URLs removed) and lists what changed; a second run changes nothing. `--check` is read-only and runs in `verify` as `check:regen-all`; `--goldens` also regenerates the offline contract goldens. Postgres goldens are named with their own commands, and `llms.txt` regenerates last because it inlines other generated docs. Tests: `test/scripts/regen-all.test.ts`.+- `scripts/regen-all.ts` — one entry point for every generated artifact (`ARTIFACTS`: regen and check command per artifact). `bun run regen:all` regenerates offline and keyless (provider keys and database URLs removed) and lists what changed; a second run changes nothing. `--check` is read-only and runs in `verify` as `check:regen-all`; `--goldens` also regenerates the offline contract goldens. Postgres goldens are named with their own commands, and `llms.txt` regenerates last because it inlines other generated docs. Every `bun test` it spawns (two checks and the goldens) carries `--timeout=60000` through one `BUN_TEST` prefix, because Bun does not apply bunfig.toml's `[test] timeout`. Tests: `test/scripts/regen-all.test.ts`.- `scripts/release-restamp.ts` + `scripts/lib/restamp.ts` — `bun run release:restamp`, run when a PR is next to merge. The CLI refuses a dirty tree, fetches `origin/master`, captures the branch CHANGELOG entry and migration inventory, merges master with a merge commit (version-only stamp hunks, `CHANGELOG.md` and the `GENERATED_PATHS` files resolve mechanically; anything else stops), sets VERSION to master's PATCH + 1, renumbers branch-only migrations from master's latest + 1 (filename, export name and `version:` literal only; `migrationPayloadKey` proves the rest is token-identical and refuses a copy of a published migration or an edited published one), rewrites `STAMPS` (the CLAUDE.md "Version locations" Required rows) plus CHANGELOG and TODOS, runs `DEFAULT_STEPS`, lists branch-added lines that still name an old number (`findLeftoverRefs`, never rewritten), runs `DEFAULT_CHECKS` and commits once. Stops save `.git/gbrain-restamp.json` for `--continue` / `--abort`; `--dry-run` prints the plan, `--no-commit` stages. Generators run through `offlineEnv` (no database URLs, no provider keys). Tests: `test/scripts/release-restamp.test.ts` (fixture repos with the real migration generator; also pins CLAUDE.md table coverage and docs anchors).- `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.diff --git a/scripts/regen-all.ts b/scripts/regen-all.tsindex c16aa45bf7..0fef4ab05c 100644--- a/scripts/regen-all.ts+++ b/scripts/regen-all.ts@@ -29,6 +29,13 @@ if (readFileSync('docs/guides/harness-adapters.md', 'utf8') !== renderHarnessRefprocess.exit(1);}`;+/**+ * Every `bun test` this script spawns. Bun does not apply bunfig.toml's+ * `[test] timeout`, so without the flag a cold PGLite init or a JIT-less+ * runner hits the 5 s default (#6187).+ */+const BUN_TEST = ['bun', 'test', '--timeout=60000'];+export const ARTIFACTS: Artifact[] = [{ name: 'schema (src/schema-embedded)', regen: ['bun', 'run', 'scripts/build-schema.ts'], check: ['bash', 'scripts/check-schema-fresh.sh'] },{ name: 'schema migrations bundle', regen: ['bun', 'run', 'scripts/build-schema-migrations.ts'], check: ['bash', 'scripts/check-schema-migrations-fresh.sh'] },@@ -38,10 +45,10 @@ export const ARTIFACTS: Artifact[] = [{ name: 'MCP tool catalog', regen: ['bun', 'run', 'scripts/generate-tool-catalog.ts'], check: ['bash', 'scripts/check-tool-catalog-fresh.sh'] },{ name: 'skills manifest', regen: ['bun', 'run', 'scripts/generate-skills-manifest.ts'], check: ['bash', 'scripts/check-skills-manifest-fresh.sh'] },{ name: 'eval metric glossary', regen: ['bun', 'run', 'scripts/generate-metric-glossary.ts'], check: ['bash', 'scripts/check-eval-glossary-fresh.sh'] },- { name: 'CLI flag registry', regen: ['bun', 'run', 'scripts/generate-flag-registry.ts'], check: ['bun', 'test', 'test/generate-flag-registry.test.ts'] },+ { name: 'CLI flag registry', regen: ['bun', 'run', 'scripts/generate-flag-registry.ts'], check: [...BUN_TEST, 'test/generate-flag-registry.test.ts'] },{ name: 'plugin tree + persona variants', regen: ['bun', 'run', 'scripts/generate-plugin-tree.ts', '--out', 'plugin', '--variants-out', 'plugin-variants'], check: ['bash', 'scripts/check-plugin-tree.sh'] },{ name: 'structural suites manifest', regen: ['bun', 'scripts/classify-tests.ts'], check: ['bun', 'scripts/classify-tests.ts', '--check'] },- { name: 'llms.txt + llms-full.txt', regen: ['bun', 'run', 'scripts/build-llms.ts'], check: ['bun', 'test', 'test/build-llms.test.ts'] },+ { name: 'llms.txt + llms-full.txt', regen: ['bun', 'run', 'scripts/build-llms.ts'], check: [...BUN_TEST, 'test/build-llms.test.ts'] },];/** Offline contract goldens: regenerated only with --goldens, each a reviewer-visible change to justify. */@@ -58,6 +65,8 @@ export const POSTGRES_GOLDENS = ['GBRAIN_TEST_UPDATE_GOLDENS=1 DATABASE_URL=<test db> bun test --timeout=60000 test/e2e/doctor-json-golden.test.ts',];+export const goldenArgv = (file: string): string[] => [...BUN_TEST, file];+const ROOT = resolve(import.meta.dir, '..');const DOCS = 'docs/RELEASING.md#generated-artifacts';@@ -129,7 +138,7 @@ if (import.meta.main) {const before = dirtyState();const steps = [...ARTIFACTS.map(a => ({ name: a.name, argv: a.regen, env })),- ...(args.includes('--goldens') ? CONTRACT_GOLDENS.map(f => ({ name: `golden ${f}`, argv: ['bun', 'test', f], env: { ...env, GBRAIN_TEST_UPDATE_GOLDENS: '1' } })) : [])];+ ...(args.includes('--goldens') ? CONTRACT_GOLDENS.map(f => ({ name: `golden ${f}`, argv: goldenArgv(f), env: { ...env, GBRAIN_TEST_UPDATE_GOLDENS: '1' } })) : [])];const llms = steps.findIndex(s => s.name.startsWith('llms'));steps.push(...steps.splice(llms, 1));for (const step of steps) {diff --git a/test/scripts/regen-all.test.ts b/test/scripts/regen-all.test.tsindex f124b99f31..53ade8ec0e 100644--- a/test/scripts/regen-all.test.ts+++ b/test/scripts/regen-all.test.ts@@ -7,7 +7,7 @@import { describe, expect, test } from 'bun:test';import { existsSync, readFileSync } from 'node:fs';import { join } from 'node:path';-import { ARTIFACTS, CONTRACT_GOLDENS, POSTGRES_GOLDENS, checkArtifacts, offlineEnv, staleReport, type Artifact } from '../../scripts/regen-all.ts';+import { ARTIFACTS, CONTRACT_GOLDENS, POSTGRES_GOLDENS, checkArtifacts, goldenArgv, offlineEnv, staleReport, type Artifact } from '../../scripts/regen-all.ts';const ROOT = join(import.meta.dir, '../..');@@ -39,6 +39,13 @@ describe('regen:all', () => {for (const c of POSTGRES_GOLDENS) expect(existsSync(join(ROOT, /bun test (?:--timeout=\d+ )?(\S+)/.exec(c)![1]!)), c).toBe(true);});+ test('every bun test it spawns passes an explicit --timeout (bunfig\'s [test] timeout is not applied, #6187)', () => {+ const argvs = [...ARTIFACTS.flatMap(a => [a.regen, a.check]), ...CONTRACT_GOLDENS.map(goldenArgv)];+ const bunTests = argvs.filter(argv => argv[0] === 'bun' && argv[1] === 'test');+ expect(bunTests.length).toBeGreaterThanOrEqual(2 + CONTRACT_GOLDENS.length);+ for (const argv of bunTests) expect(argv.some(x => /^--timeout=\d+$/.test(x)), argv.join(' ')).toBe(true);+ });+test('generators run without provider keys or database URLs', () => {const env = offlineEnv({ PATH: '/bin', OPENAI_API_KEY: 'k', UBICLOUD_API_TOKEN: 't', DATABASE_URL: 'postgres://x', GBRAIN_DATABASE_URL: 'y', HOME: '/h' });expect(env).toEqual({ PATH: '/bin', HOME: '/h' });