Garry's Opinionated OpenClaw/Hermes Agent Brain
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_runfires only for master-branch completions; theresolvejob admits scheduled runs and push-to-master runs of Test and E2E Tests from this repository (head repository checked) plus dispatch, andnightly-issue.ts --resolveturns every entry path into the target workflow id and track (schedule,push; a replay writespush);watchqueues 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 oneNightly red: <workflow>issue (labelnightly-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 underknown-red. A scheduled Test or E2E Tests run also feeds that workflow's open master-red issue. Push runs go toscripts/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 inscripts/upgrade-matrix/) — upgrade-from-N matrix (GBRA-224 W2).planresolves the candidate and from-versions (N-1, N-10, N-50, 30 days, stable, andstable-window:versions.tsstableWindowover thestable-v*record tags, the newest 8 plus one per older month back 183 days) from release tags;cellinstalls a from-version withbun install -g github:garrytan/gbrainin an isolated HOME, seeds a brain, runs that release'sgbrain upgradeagainstgithub-fixture.ts(per-cell bare mirror via gitinsteadOf, loopback tarball API, TLS fixture behindHTTPS_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;summarizejudges red/hold/green (verdict.ts,known-exceptions.json, theW4 SWITCH POINTfordoctor --alert);issuekeeps oneupgrade-breakissue withmarker.ts'sISSUE_MARKERand ared-fromline 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.GitHubClientis the one interface the watchers call (restClient()usesGH_TOKEN/GITHUB_TOKENin Actions or the authenticatedgh apilocally;download()reads artifact archives without forwarding the token to blob storage).findIssueByTitlefinds an issue by label and exact title, open first, else the most recently updated closed one;listLabeled,getIssueandlinkedPulls(PRs cross-referencing an issue) back master-red and CI health;fetchArtifactJson+readZipEntryread one JSON file from a run artifact and return a reason instead of throwing.createIssueaddsAGENT_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.tsfails 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 (listRunssplits 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 newestMaster red: <workflow>issue'smaster-red:jsonblock (applyRunfolds 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.externalPasslets a scheduled run or an issue-bound E2E replay clear failures. Closing without a merged linked repair PR opensflakeissues (flakeFor,flake:json);closeFlakescloses 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, theci-manifestartifact, returned as structured records (job, step, every failing test file and identity) apart from sanitized excerpts; a cancelled job is not run (listed incancelled) unless its annotation says it timed out, and a red run whose only failures are aggregators of cancelled jobs isignored; withcomplete/problems(an unreadable page, annotation or manifest is incomplete evidence, never zero failures). A push run with a succeededreused-full-suitejob is judged by the run itsreuse.jsonnames (checkRecordfromscripts/ci-reuse.ts, recorded attempt, identical commit tree): that run's succeeded jobs and completeci-manifeststand in for the push, and any gap is incomplete.reproduceCommandbuildsbun run test:stress <file> --iterations 10 [--postgres]from a validated test path only.exemptionRowsturns failing identities with an exact test name and signature into the stress gate's<!-- gbrain-stress-exemption -->records (backend perstressBackend, owneragent on release duty), written into master-red, flake and nightly-red bodies;test/fixtures/nightly-watch/stress-exemption-contract.tsvendors 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). Theexecuted-receiptsjob of test.yml and e2e.yml builds it from every lane's receipts (viascripts/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 asci-manifest; each failure carries the JUnit message (credentials redacted) and the stress gate'sfailureSignature(omitted when the message holds a credential);checkManifestrefuses a manifest for another run or attempt;passedFileslists files that executed tests and failed none. Docs:docs/ci-red-runbook.md#ci-failure-manifest.scripts/release-gate.ts— release.yml'sci-gatejob. Polls the push-to-master runs of Test and E2E Tests on the release commit and writespublish/sha: both green publishes; a failed run publishes nothing and fails with the next step; a cancelled or skipped run publishes nothing and fails withgh 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; aworkflow_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-stableand 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 grouppromote-stable).promote()refuses unless the actor'srole_nameis admin or maintain (authorize(); the one exception isPromoteDeps.scheduled, set byscheduleAuthorized()only for a schedule event ofstable-daily.ymlon the default branch, which also requires the release commit on master and recordspromoted_by: schedule (.github/workflows/stable-daily.yml)),v<VERSION>exists with aVERSIONfile naming it and a published (non-draft) GitHub release, the soak run URL names a completed, successful run of this repository'sSTABLE_SOAK_WORKFLOWworkflow (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 throughscripts/stable-matrix.tsjudgeMatrixRun()(a completed schedule or dispatch run of master's harness, full profile, no fault, whoseupgrade-matrix-receiptnames 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 saysmatrix_run: null), and the version is newer than the current stable (the highestv*tag onrefs/tags/stable^{commit}), or older withrollbackand a reason. Re-promoting the current stable (no rollback) moves no tag:recordCurrentStable()writesstable.jsonfrom 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, leasingstableunchanged 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 annotatedstable-v<VERSION>record (refused when it exists, except on a rollback re-promotion of the same commit) and moves the annotatedstabletag, both withrenderTagMessage()'skey: valuebody, commits the evidence record (renderRecord(),stable.json,known_badcarried forward and merged withwithdrawbymergeKnownBad(),not_promotablecarried forward, added to and removed from bymergeNotPromotable(), which caps a reason at 500 characters; a record overSTABLE_RECORD_MAX_BYTES, the client'sRECORD_MAX_BYTES, is refused before the push) on thestable-recordbranch, then pushes all three in one--atomicpush (stableandstable-recordleased on the values it read, so a failed push changes nothing) and writes the step summary. Side effects come in throughPromoteDeps. 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 todry_run, anddry_run=falseneeds admin or maintain; concurrency grouppromote-stable). Off whenSTABLE_AUTO_PROMOTEisoff, paused while the stable record saysrollback: true. Acts only on a reason: a mergedstable:importantPR released but not in stable (found through GitHub's search, so the workflow needspull-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 thanWEEKLY_FLOOR_DAYS(7) with a newer release. Promotes, throughpromote(), the newest release on master newer than stable whose exact tree passed a fullSOAK_SHAPESTABLE_SOAK_WORKFLOWrun with everyINTEGRITY_GATESgate passing in every cell (on the important-only path it must contain the fix), skipping a release with astable-v<version>tag (stable before, then rolled back) or on stable.json'sknown_bad(#8792) ornot_promotablelist; the soaked candidate also needs a green upgrade matrix gate run on its exact tag and tree (judgeMatrixRun), and with none it dispatchesupgrade-matrix.ymlon master withcandidate=v<version>(not while a matrix run is active); a red or foreign run returnsheld. While the matrix's own break issue is open (findBreakIssue:ISSUE_MARKER, not the label alone) it returnsheldunless a released fix'schangelog.dfragment saysimportant: securityordata-loss(BREAK_PASS_CLASSES) and the candidate's run fails only on from-versions the issue'sred-fromline 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/) namesINSTALL_REFfromsrc/core/install-ref.ts; exactv<version>and commit pins are left alone; TypeScript must import the constant;--writerewrites the text surfaces.scripts/check-bootstrap-tag.shreads 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:allregenerates offline and keyless (provider keys and database URLs removed) and lists what changed; a second run changes nothing.--checkis read-only and runs inverifyascheck:regen-all;--goldensalso regenerates the offline contract goldens. Postgres goldens are named with their own commands, andllms.txtregenerates last because it inlines other generated docs. Everybun testit spawns (two checks and the goldens) carries--timeout=60000through oneBUN_TESTprefix, 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.tsfrombehavior-changes.d/<id>.mdand the<!-- behavior-change: <id> -->markers in released CHANGELOG sections (and inchangelog.dfragments while VERSION is newer than the top heading, i.e. inside a release PR):RELEASED_BEHAVIOR_CHANGESrows dated by their section,BEHAVIOR_CHANGE_RELEASESforreleasedIn(id)rows. Refuses unmarked files, dangling markers, duplicate ids, bad names, texts over 2,000 characters and achangelog.dfragment whosebump:is notpatch. The release PR'srelease_tool; inregen:all. Tests:test/scripts/build-behavior-changes.test.ts.scripts/check-behavior-since.ts— refuses a literalsince: 'TBD'row undermerge: "direct";--stamped(release.yml ci-gate) also refuses an unfoldedchangelog.dfragment, 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, fetchesorigin/master, captures the branch CHANGELOG entry and migration inventory, merges master with a merge commit (version-only stamp hunks,CHANGELOG.mdand theGENERATED_PATHSfiles resolve mechanically; anything else stops), sets VERSION to master's PATCH + 1, renumbers branch-only migrations from master's latest + 1 (filename, export name andversion:literal only;migrationPayloadKeyproves the rest is token-identical and refuses a copy of a published migration or an edited published one), rewritesSTAMPS(the CLAUDE.md "Version locations" Required rows) plus CHANGELOG and TODOS, runsDEFAULT_STEPS, lists branch-added lines that still name an old number (findLeftoverRefs, never rewritten), runsDEFAULT_CHECKSand commits once. Stops save.git/gbrain-restamp.jsonfor--continue/--abort;--dry-runprints the plan,--no-commitstages. Generators run throughofflineEnv(no database URLs, no provider keys). Modes for releases per batch (docs/RELEASING.md#releases-per-batch):--stamp-only <version>(the release PR'srestamp_command: everySTAMPSrow 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 tochangelog.d/<branch-slug>.md, appended plain-text notice rows tobehavior-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 saysmerge: "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.ymlconvergence):runfor persistence, sync commands and sync core, page projections and storage,bun.lockandvendor/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);skipotherwise, and never selected bypackage.jsonalone, so a release-stamp PR does not run it; an empty list runs. test.ymlchangescalls it for pull requests only (stepconvergence, passed as theconvergenceinput). 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-levelversiondiffers),dependency-change(any dependency field differs),dependency-scope(whether a changed-file list touches lockfiles,patches/or dependency fields) anddrop-version-only(filters version-onlypackage.jsonandopenclaw.plugin.jsonentries out of a changed-file list, so a release bump does not widen the native scope). Used by test.yml'schangesjob (beforescripts/ci-native-scope.sh) and its dependency-audit scope step. Tests:test/scripts/ci-manifest-diff.test.ts.scripts/ci-dependency-audit.sh— runsbun auditfor the root andadmin/lockfiles. It blocks (BLOCKING=true) on pushes, schedules and dispatches, on lockfile,patches/or dependency-field changes, with thedependency-auditlabel, 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.ymltier2) runs it after its test step, becausebun testexits 0 when every key-gated test self-skips, and eachtier1-graduationshard runs it on lanetier1, because those files skip withoutDATABASE_URLandrun-e2e.shexits 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 undermcp.serversin~/.openclaw/openclaw.jsonwithopenclaw mcp set(serving the starter surface, so the agent's request stays under OpenAI's 128-tool cap) and fails unlessopenclaw mcp showreads it back; the server runs behind the tap, which logs every JSON-RPC request toGBRAIN_TEST_TIER2_MCP_TAP_LOG;test/e2e/skills.test.tsreads that log withtapToolCallsand fails a test in which the agent made no gbrain tool call.executedProblems(dir, lane)reads receipts throughloadReceiptDir(scripts/ci-executed-counts.ts). Test:test/scripts/require-executed-tests.test.ts(includes the real keylesstest/e2e/skills.test.tsrun).scripts/ci-install-openclaw.sh— e2e.yml's Tier 2Install OpenClawstep. Eachnpm install -g openclaw@<pin>attempt is bounded (timeout 120); a failure whose npm log carriescode ETARGETorE404is 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.tsinstalls 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 impossibleos(EBADPLATFORM, the generic path). The lockfile route (a committedpackage-lock.jsonper pin) was weighed and not taken: two pins live in the workflows (e2e.yml2026.4.9,native-locks.yml2026.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: whenOPENAI_API_KEYorANTHROPIC_API_KEYis 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.tsre-runs itself as a child; the supervisor times theimport,extract,vectorsandbudgetsphases from the child's[scale] phase <name> startlines and kills the child's process group at 1.5x the phase's gate ceiling (scripts/scale/gates.tsphaseLimitsMs), 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_SUPERVISEDis 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 bytest/helpers/operator-env-preload.ts, which deletes strippedGBRAIN_*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, inverify), which parses test files and fails on a test that gates execution on a stripped name. Test opt-ins areGBRAIN_TEST_<AREA>_<WHAT>, paid onesGBRAIN_TEST_LIVE_<WHAT>. The same guard failstest_env_snapshot_module_scope: adeleteof or assignment toprocess.env.GBRAIN_PGLITE_SNAPSHOToutside every function body in a file the unit matrix loads (*.serial.test.ts,test/e2e/and*-preload.tsare exempt: own process, or process-wide by design).scripts/test-shard.shruns 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 inbeforeAll, restore inafterAll, ortest/helpers/with-snapshot.tsper 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(inverify). TypeScript-AST scan of everytest/file outsidetest/e2e/andtest/fixtures/for aDATABASE_URL-gated PostgreSQL arm (zero-argumenttestBackends(), or aDATABASE_URLread used as a condition, connection argument ordatabase_urlvalue;withEnv-supplied URLs excluded) and a lane that runs it (a workflow step withDATABASE_URLnaming the file, atest/e2e/importer, atests/heavy/script, or ascripts/e2e-backend-matrix.txtrow).ALLOWLISTrows name a reason and TODO; stale rows fail. Atest/postgres-unit-arms.txtrow is a lane; a malformed, duplicate, unsorted, missing-file or arm-less row fails (postgres_arm_list_invalid,postgres_arm_list_stale).postgresArm,postgresLanesandarmedFilesare 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(inverify). TypeScript-AST scan ofsrc/**/*.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/.mapcallback, 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 atclassifyItemFailure/ItemRun(src/core/item-failure.ts) andtest/pathological/.--updaterewrites the baseline after a shrink.findAllowlistCatchesandcompareBaselineare exported fortest/scripts/check-item-allowlist-catches.test.ts; self-test fixtures undertest/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'sunit-postgres-armsjob (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 fromGBRAIN_ARM_DATABASE_URLS, output buffered per file and printed in queue order in::group::blocks ending in anARM_FILE … ms=…line, one receipt triple per file;--postgres-only(a manual mode; CI runs both arms) setsGBRAIN_TEST_BACKEND=postgresand readsARM_WEIGHTS_POSTGRES_ONLYwhen it exists; each shard's two-worker makespan at mostARM_SHARD_BUDGET_MS, 570 s, so twice that still ends a minute inside the 20-minuteARM_STEP_TIMEOUT_MSstep; 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'sARM_FILElines (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.tsoutsidetest/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 withbash 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 afterinitSchemawith no source, writer or physical-root reservation (asserted); only the data directory is copied; each clone regeneratesbrain_id, the default source incarnation and the shared-skill token secret and serving epoch. Used bytest/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'snode_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(inverify): compiles a smoke binary and proves HEIC and AVIF decode inside abun --compileartifact; 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) withgit apply -Rin 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_auditedwith a reason), restore, verify the tree is identical and green again. Untrusted install and tests run underenv -iwithsandboxEnv()'s allowlist (temporaryHOME/GBRAIN_HOME, emptyDATABASE_URL/GBRAIN_DATABASE_URLunless--postgresnames a test-shaped database). Runs the trustedwave-security-scan.shandcheck-postgres-lane-coverage.ts(GBRAIN_GUARD_ROOT= audited tree). State, logs andprs.pinned.jsonlive in<git-dir>/contributor-audit/<base>-<head>/;--resumerefuses 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_targeton 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 toTRUSTED_HEAD_REPOwith the base repository's id, or a presentmaintainer-overridelabel whose latestlabeledtimeline event was made by aUseronMAINTAINERS(no[bot]login); a null head repository, a missing label or any other labeler fails. Overrides print anoticeand step-summary line naming the actor, time and event id.--comment(thewelcome-commentjob,pull-requests: write,openedonly) postsgateMessage()once per PR, keyed byCOMMENT_MARKER. The script imports onlynode:modules. Tests:test/scripts/fix-wave-gate.test.ts(fixture payloads intest/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_targeton master (closed); the job runs only when the PR merged and its head repository isgarrytan/gbrain, and sparse-checks-out only the script from the default branch.supersededNumbers()(pure) reads the PR numbers listed right after a line-leadingSupersedeskeyword;runCloseout()skips non-PRs and closed PRs, postscloseoutMessage()once per PR (keyed byCOMMENT_MARKER, crediting the contributor only when the wave body saysContributed by @handle), closes it, caps a run atMAX_CLOSES, and turns a failed close into a warning.--dry-runreads 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 atHARNESS_EVALS_PINwith the read-onlyHARNESS_EVALS_READ_TOKEN, builds the gbrain sidecar image for the head commit, runsscripts/gbrain-check.ts --no-buildand fails only on a non-zero cross-scope page count (or an unreadablecheck.jsonor a missing scoped probe); other failed assertions are warnings. The first step (id: gate, outputrun) 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 onsteps.gate.outputs.run == 'true'. Runnerubicloud-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) andtest/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 backtickskills/refs,.//../links,composes:and RESOLVER dispatcher slugs; donor-workspace paths outside the shrink-only allowlist; anygbrain <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.tsdispatch, the command table and opcliHints), plus curated known-bad subcommands (embed refresh); and a relative link that resolves outside the skills root, inskills/and in the generatedplugin/skillsandplugin-variants/*/skillstrees (skills/migrations/**exempt). W4.7: a tools-json load failure FAILS the CLI lane (--no-cli-refsskips it deliberately); links are read in every form (](./x), bare](x.md)unless a placeholder,](<x>), titled,[id]: xdefinitions); a[paid-consent]lane, migrations included, fails a paidgbraincommand 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.tsis that rule's fix: it pointsdocs/protocol/AGENT_OPERATOR_v1.mdlinks at the bundledskills/conventions/agent-operator-protocol.mdand other repo files at absolute blob URLs derived fromLLMS_REPO_BASE(raw.githubusercontent base → github.com blob base; defaultgarrytan/gbrain/blob/master; a non-https or credentialed value throws viarepoBaseOrThrow, as inscripts/llms-config.ts), retargeting default-base links for forks;--checkreports pending rewrites. Tests:test/check-skill-refs.test.ts,test/skills-portable-links.test.ts(scaffold--allinto a tmp host: 0 broken local links).scripts/check-file-url-pathname.sh—check:file-url-pathname(in verify, #6845): no.pathnameof a file URL (import.meta.url).pathname,pathToFileURL(...).pathname) in test/, which keeps%20and breaks a checkout under a path with a space; usefileURLToPathorimport.meta.dir. Self-tested viaGBRAIN_GUARD_ROOTfixtures; skipstest/fixtures/guards/.scripts/check-dynamic-ci.ts—check:dynamic-ci(in verify): wiring guard for the Trunk Dynamic CI filter (dynamic-cijob intest.ymlandscale-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 thanpull_request, sits in a workflow without that trigger, is not SHA-pinned, lackscontinue-on-error: trueor a step timeout below the job's, or whosejob-keysdiffer from itsoutputs; a gated job whoseifdoes not start!cancelled() && needs.<filter>.outputs.<key> != 'false' &&, lacksneeds.<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.shaccepts a gated lane that skipped only on an exactfalseverdict. Self-tested viaGBRAIN_GUARD_ROOTfixtures intest/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-leasemodels the managed-sync drain lease (sync-lease.tsoverdb-lock.ts, plus the pass stamp's fences insync-pass-fold.tsandsync-prepare.ts).spec/tla/refresh-barriermodels the refresh write barrier and its deferred-write queue (admission, claim, replay, expiry and restore injournal.ts,refresh-barrier.ts,worktree-refresh.ts,shared-skills/restore.tsand the v292 triggers, with Postgres row locks and a deadlock invariant), plus #8705/#8708 behind constants.tlc.shruns every config on a private copy and failsTLC_VIOLATION,TLC_TIMEOUTorTLC_ERROR;tla-jar.shfetches the pinned tla2tools.jar and refuses a sha256 mismatch.mutants.tschecksmutants.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:tlaruns both; the workflow runs them nightly and on changes to anything a mutant names (test/spec-drain-lease-constants.test.tsandtest/spec-refresh-barrier.test.tspin 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 intest/e2e/),test/e2e/drain-lease-fence-postgres.test.ts. Docs:spec/tla/README.md.