Garry's Opinionated OpenClaw/Hermes Agent Brain
Test audit — LANE=e2e (test/e2e)
Read-only discovery. Checkout at 2ede415 (v0.59.11.0). The tree was left clean after every probe (git status --short came back empty). Method: the openclaw test-audit skill, AGENTS.md/CLAUDE.md, and TESTING.md §"Coverage responsibilities before consolidation". Costs come from scripts/ubicloud/weights.json (e2e:<path> ms per file). 16 newer files have no weight entry.
CI routing facts that shape every verdict
- Unit shards exclude
test/e2e/*(scripts/test-shard.sh:93). A PGLite-only e2e file executes only in the e2e lanes. - The e2e lanes:
- PR/push
selected-e2e: diff-selected viaselect-e2e.ts. Escape-hatch paths (operations.ts,src/core/ops/,skills/, workflows,package.json, …) select ALL files, minusE2E_EXCLUSIONS. Runs sequentially per shard throughrun-e2e.shwithDATABASE_URL. No provider keys are passed. - Named jobs:
jsonb-parity,tier1, andtier2(skills.test.ts, with keys). - Nightly
coverage-full-e2e: the wholetest/e2e/*.test.tsglob, 4 shards, with coverage, plus OPENAI/ANTHROPIC keys (no VOYAGE/OPENROUTER/GOOGLE).
- PR/push
run-e2e.shscrubsGBRAIN_REAL_*/HERMES_/GROK_/OPENCODE_, so the real-agent door files structurally skip in every e2e lane. Their venue isheavy-tests.yml.persistence-validation.ymlisworkflow_called fromtest.ymlon every PR. By name it runstest/e2e/reconcile-crash*.test.ts(postgres × Bun 1.3.11/1.3.13),reconcile-pgbouncer,extract-atoms-page-state, andscripts/persistence/matrix.ts.- No PgBouncer service in
e2e.yml, so files gated onGBRAIN_PGBOUNCER_URLare skip-only in GitHub e2e. They execute only underci:local/ci:ubicloud.
Category counts (312 files, 71,361 LOC, 2,877 s)
| Category | Files | LOC | ms (weights) | Verdict |
|---|---|---|---|---|
| Real Postgres (setupDB / PostgresEngine / engine loops / fixtures) | 165 | 36,930 | 1,449,559 | Postgres owner; keep by default |
Postgres wrappers of shared scenarios (registerPostgresTests / import '../x.test.ts') |
22 | 78 | 491,686 | Parity arms, NOT duplicates. Exception: 3 attendance wrappers re-run the PGLite arm (Candidate 2) |
| PGLite-only or pure (never touch Postgres) | 113 | 30,538 | 927,437 | Lane-misplaced. They hold the Postgres runner sequentially and run on PRs only when selected. Move-lane candidates, not deletions. Inventory: pglite-files.txt |
| Skip-only in every e2e lane (door binaries / never-provided keys) | 12 | 3,815 | 8,151 | Doors owned by heavy-tests; 4 live files never execute in any CI |
Key-gated behaviour: on PR selected-e2e, every OPENAI/ANTHROPIC-gated describe skips (no secrets are passed). Nightly executes them. VOYAGE/OPENROUTER-gated tests execute nowhere in CI.
Top candidates (full evidence)
1. test/e2e/mcp.test.ts: delete (HIGH confidence)
- Tests: "E2E: MCP Tool Generation > operations generate valid MCP tool definitions" and "> MCP server module can be imported".
- What it can detect: only that
operationshas at least 30 entries with truthy name/description and contains 9 names, plus thatserver.tsexports two functions. The first test re-implements the ParamDef→JSON-Schema mapping inline. Its copy has already drifted: it lacks thedefaultkey and recursiveitemsthat the realsrc/mcp/tool-defs.ts:paramDefToSchemaemits. So it asserts properties of its own copy. - Mutation probe: I set
buildToolDefsto emitrequired: []and madeparamDefToSchemadropdescription.bun test test/e2e/mcp.test.ts→ 2 pass, 0 fail (detects nothing).- The owner
test/mcp-tool-defs.test.ts→ 4 fail: "output equals pre-extraction inline mapping byte-for-byte", "put_page warns…", "strictParams… real dry_run", "paramDefToSchema preserves description on nested items".
- Non-test callers of the seam: none needed. It reads the public
operationsarray andserver.tsexports. - Surviving owners:
test/mcp-tool-defs.test.ts:buildToolDefsbyte-equality, "preserves operation count", "every def has object inputSchema with properties + required array".test/mcp-stdio-gate-list.test.ts: the live stdio tools/list.- Op-name presence: e.g.
test/operations-trust-boundary.test.ts(find_orphans etc.). - Module import is exercised by
test/mcp-stdio-source-preflight.test.tsandtest/checkpoint-harvest.serial.test.ts(handleToolCall). - All of these are the same boundary: pure/in-process.
- History: added in a86f99588 (v0.3.0, 2026-04-08), before
tool-defs.tswas extracted as the single source (v0.34). Last touched 9c2c91188. - Deletion unlocks: 70 test LOC. Plus edits to the
tier1run line ine2e.yml,E2E_EXCLUSIONSinscripts/e2e-matrix.ts:12, the map entrysrc/mcp/**inscripts/e2e-test-map.ts:346(still covered by http-transport + mcp-search-transport-matrix), and thetest/select-e2e.test.ts:32fixture list. No production seam. - Cost: 1,201 ms. It also runs inside a required job.
- Risk: low. Validation:
bun test test/mcp-tool-defs.test.ts test/select-e2e.test.ts test/scripts/*e2e*.
2. Attendance wrappers re-run the PGLite arm already run by the unit lane: rewrite at the wrapper (HIGH confidence)
- Files:
test/e2e/attendance-retrieval-postgres.test.ts,test/e2e/attendance-repair-postgres.test.ts,test/e2e/extract-timeline-attendance-postgres.test.ts. Each is one line,import '../X.test.ts'. - Mechanism: the imported scenarios use
for (const kind of ['pglite', ...(process.env.DATABASE_URL ? ['postgres'] : [])]). They don't usetestBackends(), so under the e2eDATABASE_URLthey register both arms. The unit lane (URL stripped) already runs the PGLite arm. All 19 other wrappers useregisterPostgresTests+testBackends()/connector-fixture, which honourGBRAIN_TEST_BACKEND=postgres. - Measured against local pgvector pg16:
attendance-retrieval-postgres: 387 tests, 183 PGLite (20.1 s) + 183 Postgres (21.9 s).attendance-repair-postgres: 173 tests, 86 PGLite (22.7 s) + 87 Postgres (24.4 s).extract-timeline-attendance-postgres: 22 tests, 11(pglite)+ 11(postgres)describes.
- Surviving owner of the PGLite arm: the unit-lane runs of
test/attendance-retrieval.test.ts(unit weight 26.6 s),test/attendance-repair.test.ts(24.2 s) andtest/extract-timeline-attendance.test.ts(3.0 s). Same contract, same PGLite boundary. The Postgres arm stays in e2e. - History: a610db7b7 (v0.58.0.0, 2026-09-25, #5458), a recent wave predating/omitting the
testBackendsconvention. - Action: switch the three scenario loops to
testBackends()and the wrappers toregisterPostgresTests(() => import(...)). The shape is identical tomanaged-maintenance.test.ts. This removes only the duplicated PGLite execution. - Saves: ~45 s per execution (PGLite arms 20.1 + 22.7 + ~2.5 s). Net LOC ~0. No production seam.
- Cost now: 47,886 + 49,195 + 4,675 ms. Risk: low.
- Validation: run each wrapper with
DATABASE_URLand confirm only(postgres)describes; unit files unchanged.
3. test/e2e/v030_1-integration-pglite.test.ts: delete, keeping 2 registry assertions in a unit file (HIGH confidence)
- Tests: 14 tests across Lanes B/C/D/E + "Cross-lane integration".
- Why slow:
beforeEachdoes a coldinitSchema(the file deletesGBRAIN_PGLITE_SNAPSHOT). Every test, including pure checkpoint helpers, pays about 2 s. Measured locally: 14 pass, each test 1.97–2.68 s, 30.3 s wall. - Mutation probe: I made
validateCheckpointreturnresumeAt: 'pull'. The e2e file fails 1 test; the ownertest/upgrade-checkpoint.serial.test.tsfails "partial completion → resumeAt = next un-completed step" in 0.42 ms. - Per-lane surviving owners (same PGLite/pure boundary):
- Lane E (round-trip, resumeAt, brain_mismatch, all_complete):
upgrade-checkpoint.serial.test.ts"writes and reads a complete checkpoint", "partial completion…", "X2: brain mismatch…", "all steps complete…". - Lane D:
test/vector-index-lifecycle.test.ts"checkActiveBuild > PGLite returns active: false" and "dropZombieIndexes > PGLite: no-op returns dropped: []". Samekind==='pglite'branch. - Lane B:
test/bootstrap.test.ts"fresh install regression: initSchema on empty DB produces LATEST" (cold path, snapshot deleted).test/schema-bootstrap-coverage.test.tspinspages.emotional_weight_recomputed_at. - "connectionManager in engine" and "schema_version optional": no product contract. The first asserts that a property is absent; the second accepts undefined or '1'.
- Only unique assertions: "listBackfills returns the canonical registry entries" and "embedding_voyage is declared-only". No other test imports
backfill-registry;src/commands/backfill.tsandsrc/core/cycle/patterns.tsconsume it. Move these two intotest/backfill-base.test.ts(no engine needed). The empty-brainrunBackfillchecks are low value; optional.
- Lane E (round-trip, resumeAt, brain_mismatch, all_complete):
- History: dffb607ef (v0.30.1, #750). Last touched aa820c7f9 (snapshot opt-out).
- Deletion unlocks: ~200 test LOC; entries in
test/fixtures/e2e-unmapped-baseline.txt. No production seam. - Saves: ~26 s (weight 26,038 ms). Risk: low.
4. test/e2e/v0_30_3-fix-wave.test.ts: delete (MEDIUM confidence), dominated by schema-bootstrap-coverage
- Tests: "pre-v39 brain…", "pre-v40 brain…", "pre-v41 PGLite brain…", "pre-v34 brain (compounded…)". Each rewinds a LATEST PGLite brain by dropping columns and re-runs
initSchema. - Mutation A (dropped the
effective_dateALTER fromapplyForwardReferenceBootstrap,src/core/pglite-engine.ts):- v0_30_3 fails 2 of 4.
test/schema-bootstrap-coverage.test.tsfails 3: "covers every forward reference declared in REQUIRED_BOOTSTRAP_COVERAGE", "after bootstrap, PGLITE_SCHEMA_SQL replays…", "every ALTER TABLE ADD COLUMN in MIGRATIONS is covered…".test/bootstrap.test.ts: 0 fail.
- Mutation B (dropped the
modalityALTER):- v0_30_3: 4 pass, so its "pre-v39 (missing modality…)" test does not detect the loss of the column it names.
- schema-bootstrap-coverage fails 1.
- Surviving owners:
schema-bootstrap-coverage.test.ts(every column v0_30_3 names is inREQUIRED_BOOTSTRAP_COVERAGE, lines ~90–118). Full-initSchema-from-old-shape is covered generically bybootstrap.test.ts"full path: pre-v0.18 brain reaches LATEST_VERSION via initSchema" and "pre-v121 timeline shape reaches LATEST through full initSchema". All PGLite. - Why MEDIUM: v0_30_3 is the only test running this exact set of rewinds through the full
initSchema+ migration chain. Its unique value is the "compounded pre-v34" arc. Consider merging that one case intobootstrap.test.ts. - History: ff53a4c9b (v0.31.1.1 fix-wave, #776).
- Unlocks: 201 LOC. Saves: 13,153 ms. Risk: low–med.
- Sibling:
test/e2e/v0_28_5-fix-wave.test.ts(15,254 ms, 292 LOC) is the same pattern. Its A4 tests duplicatetest/embedding-dim-check.test.ts"Postgres branch inlines all four recipe steps…" and "…skips HNSW recreate when requested dims exceed pgvector cap". Cluster A overlaps schema-bootstrap-coverage. Cluster B (dim templating at 768 / >2000) needs an owner check before removal. Not probed; secondary candidate.
5. test/e2e/reconcile-crash.test.ts + reconcile-crash-unactivated.test.ts: add to E2E_EXCLUSIONS (HIGH confidence, lane dedupe, no test deletion)
- Tests: "Postgres reconciliation survives SIGKILL/, activation=true|false" over
CRASH_BOUNDARIES. - Duplicate execution:
persistence-validation.yml(called fromtest.ymlon every PR) already runs exactly these two files, by name, on postgres × Bun {1.3.11, 1.3.13} with pg16, and uploads crash manifests. The step is "Require all reconciliation crash boundaries before and after activation". Theselected-e2erun is Bun 1.3.13 + pg16, which is the same contract on the same boundary as the persistence-validation postgres/1.3.13 arm. They are selected on any escape-hatch PR and throughe2e-test-map.ts:229,235,238. - Action: add both files to
E2E_EXCLUSIONS(the "named-job lane" mechanism). That removes only the PRselected-e2eduplicate. Nightlycoverage-full-e2estill runs them, so coverage artifacts and cadence are unchanged, per TESTING.md. - History: b272cf234 (#5361, 2026-09-22) added the files and the persistence-validation step together.
- Saves: ~203 s per PR where selected (102,209 + 101,348 ms). Risk: low.
- Validation:
bun test test/scripts/*e2e-matrix*(if pinned) andbun scripts/select-e2e.ts | bun scripts/e2e-matrix.ts prepare.
6. test/e2e/minions-field-report-repro.test.ts: keep, rewrite for a smaller workload (HIGH confidence it is the sole owner)
- Test: "v0.41 field-report repro > subagent batch under lease pressure completes; zero dead-from-lease-pressure".
- Mutation probe: I set
isLeaseFull = false && …insrc/core/minions/worker.ts:1659, which breaks the worker's lease-full routing.- This file fails.
test/minions-lease-full-retry.test.ts(7 pass),test/e2e/minions-controller-bounce-only.test.ts(2 pass),test/job-isolation-protocol.test.ts(22 pass) andtest/child-job-runner.test.ts(15 pass) all still pass.- So this is the only worker-boundary owner. Retained.
- Waste: a fixed
await new Promise(r => setTimeout(r, 25_000))with 12 jobs. - Action: poll until all jobs settle (with a timeout), or use 2–3 jobs. Move to the unit/slow lane; it is PGLite-only.
- Saves: ~20+ s of 27,667 ms. Risk: low.
7. Never-executing live files: exclude from the e2e glob (MEDIUM; opt-in dev tools, not CI coverage)
- Files:
openrouter-anthropic-subagent-replay.live.test.ts(1,464 ms / 168 LOC)openrouter-deepseek-subagent-replay.live.test.ts(1,913 / 168)voyage-rerank-live.test.ts(297 / 132)voyage-multimodal.test.ts(270 / 44)
- Evidence: no workflow provides
OPENROUTER_API_KEYorVOYAGE_API_KEY(the only secrets are ANTHROPIC, OPENAI, XAI, TEMPLATE_REPO_PAT). The openrouter files still boot PGLite inbeforeAllbefore skipping every test. The voyage files are excluded fromselected-e2ebut still hit by the nightly glob. - TESTING.md says "a missing key … is not live-provider evidence". Keep them as documented opt-in commands, but rename or exclude them from
run-e2e.sh's glob so they stop counting as discovered coverage. - Saves: ~3.9 s nightly. Risk: low.
- The 7 real-agent door files (≈3.9 s) are skip-only in e2e lanes by design (env scrub) and owned by
heavy-tests.yml. Excluding them from the glob is optional.
Category-level opportunity: lane misplacement (not deletions)
113 files / 30.5K LOC / 927 s never touch Postgres. Examples: claw-test 82 s, mounts-routing-pglite 45 s, qm-provisioning 40 s, pglite-cli-exit.serial 39 s, init-fresh-pglite 36 s, fresh-install-pglite 29 s, remote-privacy-journeys 24 s, serve-stdio-roundtrip 23 s, plus ~39 *-pglite* files.
In the e2e lane they occupy a Postgres-provisioned runner, execute strictly sequentially (run-e2e.sh), and run on PRs only when selected. Moving them to unit/serial/slow lanes (by suffix) would increase PR coverage and cut Postgres-lane wall time. Their tests are the sole owners in most cases, so this is re-homing, not reduction.
TODOS.md:6806 ("Non-tier-1 e2e files run in no required CI lane") is the same finding, and partly stale now that selected-e2e exists. Exceptions that must stay put:
sync-delegation-under-serve.serialanddream-synthesize-pglite: dedicated tier1 steps.db-guard.test.ts: fine to move, but keep it.
Retained false positives
- 22 Postgres wrappers (491 s, 78 LOC; e.g.
persistence-embedding-effects,managed-connector-retry,projection-recovery-parity,google-attachments-postgres). Tiny files, but each is the Postgres arm of a shared scenario gated byrequirePostgresTestDatabase+GBRAIN_TEST_BACKEND=postgres. A PGLite pass doesn't establish JSONB, locking or pool behaviour (TESTING.md). Only the 3 attendance wrappers double-run (Candidate 2). db-guard.test.ts(332 ms): a pure unit test sitting in e2e, but the only direct truth table forassertSafeE2eDatabaseUrl, the destructive-DB safety guard.db-guard-coverage.test.tstests the scanner, not the predicate. Security contract. Keep; lane-move it.persistence-runtime-matrix.test.ts(45 s weight): skip-only in GitHub e2e (no PgBouncer). Underci:local/ci:ubicloudit is the local stand-in for persistence-validation's "Execute all 24 deployment cases", which ci:local does not otherwise run.minions-field-report-repro: the probe showed it is the sole worker-routing owner (shrink it, don't delete).minions-controller-bounce-only: coverscontrollerTickover populated audit/dead-job SQL windows.lease-cap-controller.test.tscovers the purenextLeaseCapand only the empty-brain tick.claw-test(82 s): drives the real harness subprocess, oracles, phase-timeout kill and charset guard.claw-test-cli.test.tscovers only the registry, detection and argv. Process boundary. Keep (slow-lane candidate).sync-delegation-under-serve.serial(155 s),serve-http-multi-agent,postgres-bootstrap: process/IPC/SIGKILL/bootstrap boundaries with dedicated jobs.- Tier1 named files are also in the nightly glob, so they run twice nightly. That is deliberate, for coverage LCOV, so no action.
Est. savings if candidates 1–7 land
| # | Action | Test LOC removed | ms saved per run where it executes |
|---|---|---|---|
| 1 | delete mcp.test.ts | 70 | 1,201 |
| 2 | attendance wrappers → Postgres-only | ~0 | ~45,000 |
| 3 | delete v030_1 (move 2 asserts) | ~200 | ~26,000 |
| 4 | delete v0_30_3 (+ v0_28_5 follow-up) | 201 (+~292) | 13,153 (+15,254) |
| 5 | reconcile-crash → E2E_EXCLUSIONS | 0 | ~203,000 per selected PR |
| 6 | field-report poll instead of 25 s sleep | ~0 | ~20,000 |
| 7 | exclude never-run live files | 0 (rename) | ~3,900 nightly |
| Total (1–7, excl. v0_28_5) | ~470 | ~312 s (≈11% of e2e compute) |
Plus the category move of 927 s from the sequential Postgres lane to parallel unit/serial lanes.
Probes run (all reverted; git status clean): tool-defs mutation, worker lease-full routing, PGLite bootstrap effective_date / modality, upgrade-checkpoint resumeAt. Attendance arm timings came from a local pgvector/pgvector:pg16 container, since removed. No full-suite runs.