Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript
38.2 KB
Raw Blame

Key files: CI Health And Test Guards

Subsystem index. Read only the entries relevant to your change. Current behavior and load-bearing invariants; history belongs in Git and CHANGELOG.

  • .github/workflows/nightly-watch.yml + scripts/nightly-issue.ts — nightly-red and master-red incidents. workflow_run fires only for master-branch completions; the resolve job admits scheduled runs and push-to-master runs of Test and E2E Tests from this repository (head repository checked) plus dispatch, and nightly-issue.ts --resolve turns every entry path into the target workflow id and track (schedule, push; a replay writes push); watch queues on one group per repository + workflow + track. nightly-issue.ts --run-id <id> [--replay-issue <n>] [--dry-run] routes the run (routeRun: pull-request, fork, other-branch and non-allowlisted push runs are refused with a next step). Scheduled runs keep one Nightly red: <workflow> issue (label nightly-red): open on red with job/step pairs, every failing test file with its reproduce line, sanitized error excerpts, the first red run, the last green SHA and compare link, a "Next step for the agent" and a JSON block; update while red; reopen on a flap; close only on a later green scheduled run with complete evidence where every previously failing job executed. Rows in .github/nightly-known-red.tsv (at most 3; race-hunt jobs refused) keep a matching incident open under known-red. A scheduled Test or E2E Tests run also feeds that workflow's open master-red issue. Push runs go to scripts/lib/master-red.ts. A ratchet test fails when a scheduled workflow is not watched. Tests: test/scripts/nightly-issue.test.ts. Process: docs/RELEASING.md#nightly-red-issues, docs/ci-red-runbook.md.

  • .github/workflows/upgrade-matrix.yml + scripts/upgrade-matrix.ts (modules in scripts/upgrade-matrix/) — upgrade-from-N matrix (GBRA-224 W2). plan resolves the candidate and from-versions (N-1, N-10, N-50, 30 days, stable, and stable-window: versions.ts stableWindow over the stable-v* record tags, the newest 8 plus one per older month back 183 days) from release tags; cell installs a from-version with bun install -g github:garrytan/gbrain in an isolated HOME, seeds a brain, runs that release's gbrain upgrade against github-fixture.ts (per-cell bare mirror via git insteadOf, loopback tarball API, TLS fixture behind HTTPS_PROXY; every other host refused), then checks install identity, one build across a running serve, apply-migrations, schema head, doctor, canonical preservation (snapshot.ts), writes, keyed vector query on the mock provider and the old binary on the upgraded brain; summarize judges red/hold/green (verdict.ts, known-exceptions.json, the W4 SWITCH POINT for doctor --alert); issue keeps one upgrade-break issue with marker.ts's ISSUE_MARKER and a red-from line naming the failing from-versions. Tests: test/scripts/upgrade-matrix.test.ts. Docs: docs/ci-upgrade-matrix.md.

  • scripts/lib/gh-issue.ts — the GitHub seam shared by the CI watchers. inert() makes run-derived text (job, step and test names, error text) safe to show an agent: control characters stripped, length capped, backticks and pipes replaced, mentions and links neutralized; redactCredentials() strips user:password from database URLs. GitHubClient is the one interface the watchers call (restClient() uses GH_TOKEN/GITHUB_TOKEN in Actions or the authenticated gh api locally; download() reads artifact archives without forwarding the token to blob storage). findIssueByTitle finds an issue by label and exact title, open first, else the most recently updated closed one; listLabeled, getIssue and linkedPulls (PRs cross-referencing an issue) back master-red and CI health; fetchArtifactJson + readZipEntry read one JSON file from a run artifact and return a reason instead of throwing. createIssue adds AGENT_FILED_LABEL (agent-filed) to every issue it opens, so CONTRIBUTING.md's community-issues search can leave automation's issues out; test/scripts/gh-issue-agent-filed.test.ts fails if a script or workflow opens an issue any other way.

  • .github/workflows/ci-health.yml + scripts/ci-health-report.ts — CI health report. Reads one window (--days, default 7, or --since/--until, also dispatch inputs) of same-repository pull-request and push-to-master runs of test.yml and e2e.yml (runs, jobs, check-run annotations, issues; never logs, fork runs or fork artifacts), paging the whole window (listRuns splits a query over the 1000-result search cap). It reports first-attempt pass rates (firstAttempt()), the exit criteria (master >= 95%, PR >= 90%; met, missed or indeterminate when the window cannot be read in full), stress-gate failures, failure classes, cancellation and completion coverage, master-red time to first response, the nightly-watch residual, the test files with the most failure annotations, shard spread and the count of fork runs it did not read; an explicit window with a missed target opens a follow-up issue. Tests: test/scripts/ci-health-report.test.ts. Docs: docs/ci-red-runbook.md#ci-health-report.

  • scripts/lib/master-red.ts — master-red reconciliation for push-to-master runs of Test and E2E Tests (PUSH_ALLOWLIST). Each watch evaluates every completed push run above the high-water mark (evaluated: run number, then attempt) stored in the newest Master red: <workflow> issue's master-red:json block (applyRun folds runs; cancelled runs change nothing); a missing or malformed block is rebuilt from the actions API (pendingRuns). It opens on red with the suspect range (suspectRange: compare plus commit-to-PR lookups), updates while red, closes when every previously failing job (E2E Tests: every failing file, from the manifest) ran and passed with complete evidence, records an incident that opened and closed between watches, and keeps a not-run-since failure open with the manual-close step. A newest issue closed by hand while its block is red ends that incident (closed_by_hand): later runs are recorded on it as green, and only a new red run opens a new issue. externalPass lets a scheduled run or an issue-bound E2E replay clear failures. Closing without a merged linked repair PR opens flake issues (flakeFor, flake:json); closeFlakes closes one after its repair PR merged and a later complete run passed its file and arm. Writes re-read the issue first and re-plan when it moved; a create race closes the newer duplicate. Tests: test/scripts/nightly-issue.test.ts. Docs: docs/ci-red-runbook.md.

  • 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). A push run with a succeeded reused-full-suite job is judged by the run its reuse.json names (checkRecord from scripts/ci-reuse.ts, recorded attempt, identical commit tree): that run's succeeded jobs and complete ci-manifest stand in for the push, and any gap is incomplete. 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 cancelled or skipped run publishes nothing and fails with gh run rerun <id> (master push runs are keyed by sha, and between releases many commits share one VERSION, so it never follows to a later commit); non-master refs are refused; a workflow_dispatch (--event) gates only the release commit (the first-parent commit that last changed VERSION) and refuses a later master HEAD with the re-run of that commit's push Release run; 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.

  • .github/workflows/promote-stable.yml + scripts/promote-stable.ts — stable channel promotion (workflow_dispatch: version, soak_run_url, matrix_run_url, scoreboard_url, rollback, reason, withdraw, not_promotable, not_promotable_reason, not_promotable_fixed_in, not_promotable_remove; concurrency group promote-stable). promote() refuses unless the actor's role_name is admin or maintain (authorize(); the one exception is PromoteDeps.scheduled, set by scheduleAuthorized() only for a schedule event of stable-daily.yml on the default branch, which also requires the release commit on master and records promoted_by: schedule (.github/workflows/stable-daily.yml)), v<VERSION> exists with a VERSION file naming it and a published (non-draft) GitHub release, the soak run URL names a completed, successful run of this repository's STABLE_SOAK_WORKFLOW workflow (repository variable; bare file name or path), the run's head commit has the release tag's exact tree (fetched when missing), checkMatrix() accepts the named upgrade matrix run only through scripts/stable-matrix.ts judgeMatrixRun() (a completed schedule or dispatch run of master's harness, full profile, no fault, whose upgrade-matrix-receipt names the release's tag, commit and tree and the run's own harness, and green; a scheduled promotion must name one, a maintainer may not and the record says matrix_run: null), and the version is newer than the current stable (the highest v* tag on refs/tags/stable^{commit}), or older with rollback and a reason. Re-promoting the current stable (no rollback) moves no tag: recordCurrentStable() writes stable.json from the stable tag's message (parseTagMessage(), which must name the same commit, tree and soak run) when the published record does not name that release, leasing stable unchanged and the record branch, and refuses as a no-op otherwise (GBRA-346 backfill for releases promoted before the record existed). It creates the immutable annotated stable-v<VERSION> record (refused when it exists, except on a rollback re-promotion of the same commit) and moves the annotated stable tag, both with renderTagMessage()'s key: value body, commits the evidence record (renderRecord(), stable.json, known_bad carried forward and merged with withdraw by mergeKnownBad(), not_promotable carried forward, added to and removed from by mergeNotPromotable(), which caps a reason at 500 characters; a record over STABLE_RECORD_MAX_BYTES, the client's RECORD_MAX_BYTES, is refused before the push) on the stable-record branch, then pushes all three in one --atomic push (stable and stable-record leased on the values it read, so a failed push changes nothing) and writes the step summary. Side effects come in through PromoteDeps. Tests: test/scripts/promote-stable.test.ts. Docs: docs/RELEASING.md#stable-channel-promotion.

  • .github/workflows/stable-daily.yml + scripts/stable-daily.ts — the daily stable check (05:17 and 13:17 UTC; dispatch defaults to dry_run, and dry_run=false needs admin or maintain; concurrency group promote-stable). Off when STABLE_AUTO_PROMOTE is off, paused while the stable record says rollback: true. Acts only on a reason: a merged stable:important PR released but not in stable (found through GitHub's search, so the workflow needs pull-requests: read; each run logs the labelled-PR count, and a search that sees no merged PR at all is a refusal naming that permission), or stable older than WEEKLY_FLOOR_DAYS (7) with a newer release. Promotes, through promote(), the newest release on master newer than stable whose exact tree passed a full SOAK_SHAPE STABLE_SOAK_WORKFLOW run with every INTEGRITY_GATES gate passing in every cell (on the important-only path it must contain the fix), skipping a release with a stable-v<version> tag (stable before, then rolled back) or on stable.json's known_bad (#8792) or not_promotable list; the soaked candidate also needs a green upgrade matrix gate run on its exact tag and tree (judgeMatrixRun), and with none it dispatches upgrade-matrix.yml on master with candidate=v<version> (not while a matrix run is active); a red or foreign run returns held. While the matrix's own break issue is open (findBreakIssue: ISSUE_MARKER, not the label alone) it returns held unless a released fix's changelog.d fragment says important: security or data-loss (BREAK_PASS_CLASSES) and the candidate's run fails only on from-versions the issue's red-from line names. Otherwise dispatches one soak (and the matrix, when it has no run) on the newest release's tag, never while a soak runs or after a soak on a newer release failed to qualify. Tests: test/scripts/stable-daily.test.ts. Docs: docs/RELEASING.md#daily-stable-check.

  • scripts/check-install-ref.ts (bun run check:install-ref, in verify) — every install pin, bootstrap runbook fetch and setup-helper fetch in tracked files (not CHANGELOG.md or test/) names INSTALL_REF from src/core/install-ref.ts; exact v<version> and commit pins are left alone; TypeScript must import the constant; --write rewrites the text surfaces. scripts/check-bootstrap-tag.sh reads its sanctioned ref from the same constant. Tests: test/install-ref.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/build-behavior-changes.ts — writes (or --checks) src/core/behavior-changes.generated.ts from behavior-changes.d/<id>.md and the <!-- behavior-change: <id> --> markers in released CHANGELOG sections (and in changelog.d fragments while VERSION is newer than the top heading, i.e. inside a release PR): RELEASED_BEHAVIOR_CHANGES rows dated by their section, BEHAVIOR_CHANGE_RELEASES for releasedIn(id) rows. Refuses unmarked files, dangling markers, duplicate ids, bad names, texts over 2,000 characters and a changelog.d fragment whose bump: is not patch. The release PR's release_tool; in regen:all. Tests: test/scripts/build-behavior-changes.test.ts.

  • scripts/check-behavior-since.ts — refuses a literal since: 'TBD' row under merge: "direct"; --stamped (release.yml ci-gate) also refuses an unfolded changelog.d fragment, a stale behavior-change table and a missing or unparsable .gstack/ship-policy.json. Tests: test/scripts/check-behavior-since.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). Modes for releases per batch (docs/RELEASING.md#releases-per-batch): --stamp-only <version> (the release PR's restamp_command: every STAMPS row plus the plugin, variant and template stamp lines; no fetch, merge or commit), --unstamp (bun run release:unstamp: merge master, stamps back to master's version, the entry to changelog.d/<branch-slug>.md, appended plain-text notice rows to behavior-changes.d/; refuses multi-entry branches, released-section edits and rows it cannot move) and --renumber (bun run migrations:renumber); plain restamp refuses when master's policy says merge: "direct". 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-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, and each tier1-graduation shard runs it on lane tier1, because those files skip without DATABASE_URL and run-e2e.sh exits 0 (#8003).

  • scripts/ci-openclaw-mcp.sh, scripts/ci-mcp-tap.sh, scripts/mcp-tap-calls.ts — Tier 2's gbrain MCP wiring (#8002). The first saves gbrain under mcp.servers in ~/.openclaw/openclaw.json with openclaw mcp set (serving the starter surface, so the agent's request stays under OpenAI's 128-tool cap) and fails unless openclaw mcp show reads it back; the server runs behind the tap, which logs every JSON-RPC request to GBRAIN_TEST_TIER2_MCP_TAP_LOG; test/e2e/skills.test.ts reads that log with tapToolCalls and fails a test in which the agent made no gbrain tool call. 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.

  • scripts/check-test-env-opt-ins.ts + test/helpers/operator-env-policy.ts — the opt-in naming rule. The policy (STRIP_PREFIX, KEEP_EXACT, KEEP_PREFIX, RENAMED, isStripped) is shared by test/helpers/operator-env-preload.ts, which deletes stripped GBRAIN_* names before any test loads and stops the run with the rename command when an old opt-in name is set, and by the guard (check:test-env-opt-ins, in verify), which parses test files and fails on a test that gates execution on a stripped name. Test opt-ins are GBRAIN_TEST_<AREA>_<WHAT>, paid ones GBRAIN_TEST_LIVE_<WHAT>. The same guard fails test_env_snapshot_module_scope: a delete of or assignment to process.env.GBRAIN_PGLITE_SNAPSHOT outside every function body in a file the unit matrix loads (*.serial.test.ts, test/e2e/ and *-preload.ts are exempt: own process, or process-wide by design). scripts/test-shard.sh runs a whole shard in one bun process, so such a change persists for every later file and each of their PGLite engines cold-boots (~3 s); the accepted shape is save+delete in beforeAll, restore in afterAll, or test/helpers/with-snapshot.ts per test. Tests: test/scripts/test-env-opt-ins-guard.test.ts, test/operator-env-preload.test.ts.

  • scripts/check-postgres-lane-coverage.ts — check:postgres-lanes (in verify). TypeScript-AST scan of every test/ file outside test/e2e/ and test/fixtures/ for a DATABASE_URL-gated PostgreSQL arm (zero-argument testBackends(), or a DATABASE_URL read used as a condition, connection argument or database_url value; withEnv-supplied URLs excluded) and a lane that runs it (a workflow step with DATABASE_URL naming the file, a test/e2e/ importer, a tests/heavy/ script, or a scripts/e2e-backend-matrix.txt row). ALLOWLIST rows name a reason and TODO; stale rows fail. A test/postgres-unit-arms.txt row is a lane; a malformed, duplicate, unsorted, missing-file or arm-less row fails (postgres_arm_list_invalid, postgres_arm_list_stale). postgresArm, postgresLanes and armedFiles are exported for the stress runner. Tests: test/scripts/postgres-lane-coverage.test.ts.

  • scripts/check-item-allowlist-catches.ts + scripts/item-allowlist-catches-baseline.tsv — check:item-allowlist-catches (in verify). TypeScript-AST scan of src/**/*.ts (no *.generated.ts, .d.ts) for catch clauses in a per-item loop (a for/for-of/for-in/while/do-while body, or a .forEach/.map callback, up to the nearest function boundary) whose block tests the caught error's code against a set, list or literal (direct, cast, aliased or destructured) and rethrows the caught error. Per-file counts only shrink: growth, a new file, a count under its row, a row with no sites or no file, and malformed, duplicate or unsorted rows fail, pointing at classifyItemFailure / ItemRun (src/core/item-failure.ts) and test/pathological/. --update rewrites the baseline after a shrink. findAllowlistCatches and compareBaseline are exported for test/scripts/check-item-allowlist-catches.test.ts; self-test fixtures under test/fixtures/guards/check-item-allowlist-catches.ts/.

  • test/postgres-unit-arms.txt + scripts/postgres-unit-arms.ts + scripts/postgres-arm-weights.json — the one list of unit-lane files whose PostgreSQL arm has no other owner (sorted, one path per line, # comments). Read by persistence-validation.yml's unit-postgres-arms job (ARM_SHARDS = 24 shards, shard <n> <m>: LPT over the mined per-file weights, p75 fallback; run <n> <m> [--postgres-only]: ARM_WORKERS = 2 files at a time, one Bun process per file, each worker on its own URL from GBRAIN_ARM_DATABASE_URLS, output buffered per file and printed in queue order in ::group:: blocks ending in an ARM_FILE … ms=… line, one receipt triple per file; --postgres-only (a manual mode; CI runs both arms) sets GBRAIN_TEST_BACKEND=postgres and reads ARM_WEIGHTS_POSTGRES_ONLY when it exists; each shard's two-worker makespan at most ARM_SHARD_BUDGET_MS, 570 s, so twice that still ends a minute inside the 20-minute ARM_STEP_TIMEOUT_MS step; no machine-exclusive serial file may be listed), the scheduled race hunt and the lane guard. mine [--postgres-only] <job.log>… rewrites the cell's weights from a green run's ARM_FILE lines (older logs: ##[group]<file> to the next group or endgroup). Tests: test/scripts/postgres-unit-arms.test.ts.

  • scripts/serial-files.tsv + scripts/lib/serial-manifest.ts — the serial manifest: every *.serial.test.ts outside test/e2e/ with its class (R1, R2, global-state, exclusive) and a reason. checkSerialManifest (pure) requires the manifest to match the tree exactly, classes to match what the file does (env mutation, mock.module, EXCLUSIVE_FILES) and reasons to be specific; each failure prints Why/Fix/Docs with bash scripts/check-test-isolation.sh --as-parallel <file> as the first step. Tests: test/scripts/serial-files.test.ts.

  • test/helpers/brain-template.ts — disk-backed PGLite brains cloned from one initialized template per process and embedding shape. The template is captured right after initSchema with no source, writer or physical-root reservation (asserted); only the data directory is copied; each clone regenerates brain_id, the default source incarnation and the shared-skill token secret and serving epoch. Used by test/helpers/connector-fixture.ts. Tests: test/helpers/brain-template.test.ts.

  • scripts/test-agent-voice.sh — bun run test:agent-voice: the agent-voice recipe's vitest unit suite (recipes/agent-voice/tests/unit), with pinned vitest and ws installed into a temporary prefix linked as the recipe's node_modules. Needs node, npm and registry access; CI runs it in test.yml's verify job.

  • scripts/check-image-decoders-embedded.sh — check:image-decoders (in verify): compiles a smoke binary and proves HEIC and AVIF decode inside a bun --compile artifact; a failure prints the bun build error with Why/Fix.

  • scripts/contributor-audit.ts + scripts/contributor-audit-fixture.ts — bun run audit:contributors <base>..<head> [--prs <manifest>] [--json]. Per first-parent commit in the range and per pinned PR head trial-merged onto <head>: green baseline of the change's test files (one Bun process per file), reverse only its product hunks (non-test, non-doc) with git apply -R in an isolated worktree of <head> (falling back to the merge commit when the hunks no longer apply), classify (discriminates, does_not_discriminate, vacuous_failure, setup_failed, conflict, not_audited with a reason), restore, verify the tree is identical and green again. Untrusted install and tests run under env -i with sandboxEnv()'s allowlist (temporary HOME/GBRAIN_HOME, empty DATABASE_URL/GBRAIN_DATABASE_URL unless --postgres names a test-shaped database). Runs the trusted wave-security-scan.sh and check-postgres-lane-coverage.ts (GBRAIN_GUARD_ROOT = audited tree). State, logs and prs.pinned.json live in <git-dir>/contributor-audit/<base>-<head>/; --resume refuses on changed refs or pins (preview_changed). Human verdicts come only from the verdicts file. Exit 0 clean, 1 review, 2 refusal envelope, 130 interrupted. The fixture builds the offline demo range. Tests: test/scripts/contributor-audit.test.ts. Docs: docs/TESTING.md#contributor-audit.

  • .github/workflows/fix-wave-gate.yml + scripts/fix-wave-gate.ts — the contributor gate. pull_request_target on master (opened, edited, reopened, synchronize, labeled, unlabeled); sparse-checks-out only the script from the default branch and never PR code. decide() (pure) passes a head repository equal to TRUSTED_HEAD_REPO with the base repository's id, or a present maintainer-override label whose latest labeled timeline event was made by a User on MAINTAINERS (no [bot] login); a null head repository, a missing label or any other labeler fails. Overrides print a notice and step-summary line naming the actor, time and event id. --comment (the welcome-comment job, pull-requests: write, opened only) posts gateMessage() once per PR, keyed by COMMENT_MARKER. The script imports only node: modules. Tests: test/scripts/fix-wave-gate.test.ts (fixture payloads in test/fixtures/fix-wave-gate/). Process and the required-check settings step: docs/RELEASING.md#fix-wave-gate.

  • .github/workflows/fix-wave-closeout.yml + scripts/fix-wave-closeout.ts — closes what a merged fix wave superseded. pull_request_target on master (closed); the job runs only when the PR merged and its head repository is garrytan/gbrain, and sparse-checks-out only the script from the default branch. supersededNumbers() (pure) reads the PR numbers listed right after a line-leading Supersedes keyword; runCloseout() skips non-PRs and closed PRs, posts closeoutMessage() once per PR (keyed by COMMENT_MARKER, crediting the contributor only when the wave body says Contributed by @handle), closes it, caps a run at MAX_CLOSES, and turns a failed close into a warning. --dry-run reads without writing. Tests: test/scripts/fix-wave-closeout.test.ts. Process: docs/RELEASING.md#fix-wave-closeout.

  • .github/workflows/harness-check.yml — the advisory keyless harness check (GBRA-156, non-required). On pull requests to master from this repository: clones the private harness-evals at HARNESS_EVALS_PIN with the read-only HARNESS_EVALS_READ_TOKEN, builds the gbrain sidecar image for the head commit, runs scripts/gbrain-check.ts --no-build and fails only on a non-zero cross-scope page count (or an unreadable check.json or a missing scoped probe); other failed assertions are warnings. The first step (id: gate, output run) refuses a fork head, then skips the job with a ::notice:: and a job-summary line when the secret is missing; every later step is gated on steps.gate.outputs.run == 'true'. Runner ubicloud-standard-4-ubuntu-2404, 45 minutes. Docs: docs/ci-event-parity.md#harness-check. Guards: test/scripts/ci-pr-scope.test.ts (event-parity classification) and test/scripts/ci-runner-routing.test.ts (Ubicloud routing).

  • scripts/check-skill-refs.mjs + scripts/portable-skill-links.ts + scripts/skills-commit-gate.sh — skills-tree integrity gate (bun run check:skill-refs, in verify and the skills commit gate). Fails on dangling backtick skills/ refs, .//../ links, composes: and RESOLVER dispatcher slugs; donor-workspace paths outside the shrink-only allowlist; any gbrain <cmd> in a fenced line or inline code span (command position only: line/span start, after a shell separator, nohup/env prefixes) that is not a real command (union of --tools-json, CLI_FLAG_REGISTRY, src/cli.ts dispatch, the command table and op cliHints), plus curated known-bad subcommands (embed refresh); and a relative link that resolves outside the skills root, in skills/ and in the generated plugin/skills and plugin-variants/*/skills trees (skills/migrations/** exempt). W4.7: a tools-json load failure FAILS the CLI lane (--no-cli-refs skips it deliberately); links are read in every form (](./x), bare ](x.md) unless a placeholder, ](<x>), titled, [id]: x definitions); a [paid-consent] lane, migrations included, fails a paid gbrain command carrying --yes/--max-usd/--max-cost[-usd] with no ask/agree/approve/consent/confirm/permission wording on its line or the 8 before. portable-skill-links.ts is that rule's fix: it points docs/protocol/AGENT_OPERATOR_v1.md links at the bundled skills/conventions/agent-operator-protocol.md and other repo files at absolute blob URLs derived from LLMS_REPO_BASE (raw.githubusercontent base → github.com blob base; default garrytan/gbrain/blob/master; a non-https or credentialed value throws via repoBaseOrThrow, as in scripts/llms-config.ts), retargeting default-base links for forks; --check reports pending rewrites. Tests: test/check-skill-refs.test.ts, test/skills-portable-links.test.ts (scaffold --all into a tmp host: 0 broken local links).

  • scripts/check-file-url-pathname.sh — check:file-url-pathname (in verify, #6845): no .pathname of a file URL (import.meta.url).pathname, pathToFileURL(...).pathname) in test/, which keeps %20 and breaks a checkout under a path with a space; use fileURLToPath or import.meta.dir. Self-tested via GBRAIN_GUARD_ROOT fixtures; skips test/fixtures/guards/.

  • scripts/check-dynamic-ci.ts — check:dynamic-ci (in verify): wiring guard for the Trunk Dynamic CI filter (dynamic-ci job in test.yml and scale-tier.yml; rules in docs/ci-event-parity.md). checkWorkflow() (pure, over parsed YAML) flags a filter job that can run on an event other than pull_request, sits in a workflow without that trigger, is not SHA-pinned, lacks continue-on-error: true or a step timeout below the job's, or whose job-keys differ from its outputs; a gated job whose if does not start !cancelled() && needs.<filter>.outputs.<key> != 'false' &&, lacks needs.<other>.result == 'success' for another need, or has a top-level || after the prefix; and a gated merge or release aggregate. scripts/ci-cheap-tier.sh accepts a gated lane that skipped only on an exact false verdict. Self-tested via GBRAIN_GUARD_ROOT fixtures in test/fixtures/guards/check-dynamic-ci.ts/ (good, bad, bad-every-event, bad-other-needs, bad-top-level-or).

  • spec/tla/ + scripts/spec/{tlc.sh,tla-jar.sh,tla-tools.env,mutants.ts} + .github/workflows/tla-spec.yml — TLA+ models checked exhaustively by TLC within small bounds; spec/tla/drain-lease models the managed-sync drain lease (sync-lease.ts over db-lock.ts, plus the pass stamp's fences in sync-pass-fold.ts and sync-prepare.ts). spec/tla/refresh-barrier models the refresh write barrier and its deferred-write queue (admission, claim, replay, expiry and restore in journal.ts, refresh-barrier.ts, worktree-refresh.ts, shared-skills/restore.ts and the v292 triggers, with Postgres row locks and a deadlock invariant), plus #8705/#8708 behind constants. tlc.sh runs every config on a private copy and fails TLC_VIOLATION, TLC_TIMEOUT or TLC_ERROR; tla-jar.sh fetches the pinned tla2tools.jar and refuses a sha256 mismatch. mutants.ts checks mutants.json: each guard mutant's model edit must break its named property, and its code edits (every engine branch), applied in a scratch copy of the tree, must fail each named test on its own assertions; assumption mutants document what liveness rests on, survivors stay defense in depth. bun run test:tla runs both; the workflow runs them nightly and on changes to anything a mutant names (test/spec-drain-lease-constants.test.ts and test/spec-refresh-barrier.test.ts pin that path filter; the first also pins the drain-lease configs' timing to the code's constants). Guard tests: test/drain-lease-guards.test.ts, test/drain-lease-stamp-fence.test.ts (Postgres twins in test/e2e/), test/e2e/drain-lease-fence-postgres.test.ts. Docs: spec/tla/README.md.