Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci(robot): full-scope Postgres crash-robot ceiling 880 s after dead-owner effect-claim release
garrytand99a05c72b19
diff --git a/.github/workflows/persistence-validation.yml b/.github/workflows/persistence-validation.ymlindex 4f7a15a3f7..d96a7612d0 100644--- a/.github/workflows/persistence-validation.yml+++ b/.github/workflows/persistence-validation.yml@@ -377,7 +377,7 @@ jobs:# from ubicloud-standard-4 measurements (docs/ci-event-parity.md#crash-robot-ceilings):# 820 s PGLite and 620 s Postgres on pull requests and merge-queue runs (named exception,# docs/TESTING.md#event-parity: scope pr skips the Postgres lease-bound seams),- # 1200 s PGLite and 1800 s Postgres elsewhere. The nightly Test schedule adds that+ # 1200 s PGLite and 880 s Postgres elsewhere. The nightly Test schedule adds that# day's exploration seeds. Each cell writes its share of the ceiling to the job summary.- name: Crash every reachable seam of the generated sequencesenv:@@ -385,7 +385,7 @@ jobs:DATABASE_URL: postgres://[email protected]:5432/gbrain_testGBRAIN_PGBOUNCER_URL: postgres://[email protected]:55433/gbrain_testROBOT_SCOPE: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && 'pr' || 'full' }}- ROBOT_SECONDS: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && (matrix.engine == 'postgres' && '620' || '820') || (matrix.engine == 'postgres' && '1800' || '1200') }}+ ROBOT_SECONDS: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && (matrix.engine == 'postgres' && '620' || '820') || (matrix.engine == 'postgres' && '880' || '1200') }}ROBOT_EXPLORE: ${{ github.event_name == 'schedule' && 'nightly' || '' }}run: >-bun --no-env-file scripts/persistence/validate.ts --engine=${{ matrix.engine }}diff --git a/docs/architecture/key-files/tooling-and-tests.md b/docs/architecture/key-files/tooling-and-tests.mdindex adfe0c043e..b33fe2c457 100644--- a/docs/architecture/key-files/tooling-and-tests.md+++ b/docs/architecture/key-files/tooling-and-tests.md@@ -63,7 +63,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `scripts/persistence/{harness,schedules,worker,validate,failure-diagnostics}.ts` — executable concurrency gate using real journal/coordinator APIs: 1,000 seeded schedules per engine, eight actual process-kill publication boundaries, and 10,000 writes from four producer processes. Each phase owns a temporary disk PGLite datastore or a fresh test Postgres database. Independent accounting queries verify conservation; every soak receipt is compared to its canonical snapshot and file. JSON manifests separate actual counts and latency measurements from the configured Linux/Bun CI matrix. Failed runs preserve private fixtures and collect bounded, allowlisted request/queue/owner diagnostics without changing deadlines or hiding the original error. Cleanup commands read the existing test URL from the environment. The PGLite loopback endpoint is a fixture transport, not production authentication coverage. Contract and commands: `scripts/persistence/README.md`; smoke entries: `test/persistence-chaos.slow.test.ts`, `test/e2e/persistence-chaos.test.ts`; diagnostic/retention contracts: `test/persistence-failure-diagnostics.test.ts`.-- `scripts/persistence/{ops,generator,model,crash-robot,robot-driver,shrink,lock-order,history-fixture,would-have-caught}.ts` — the crash robot, a phase of `validate.ts` (`--robot-seconds` ceiling, default 1200 PGLite, 1800 Postgres; `--robot-scope=pr|full`, `--explore-day`; CI: `persistence-validation.yml`). `ops.ts` is the JSON op-descriptor protocol between driver and workers: each descriptor names an op kind (put/edit/delete/restore page, remember/forget, takes add/supersede, timeline add, sync, connector publish, revoke access), an actor (the local CLI or a remote agent `verifyAccessToken` resolves), a source, a fixed request id and arguments whose `{ $ref }` values come from earlier observations; workers run each op through its registered handler. Its `retryingRead` retries the robot's reads only across a session drop the `SessionDrops` ledger shows it injected; any other closed connection fails the run. `generator.ts` builds seeded schedules: the fixed cross-boundary sequences (`crossBoundarySequences`: withdrawal then republication, overlapping slugs, competing writers, caller-bound replay, revoked authority, sync/connector races) plus random sequences with concurrent groups. `model.ts` is the temporal oracle: receipts and revisions at the observation point, legal later transitions, late receipts against page history, withdrawal permanence on recall/get_page/facts, source isolation, caller-bound replay, takes/facts fence projections, attribution, orphans, drain and wedge bounds; `EFFECT_SEAMS` maps every `EffectKind` to its trigger op and seam (typecheck-exhaustive). `crash-robot.ts` runs a schedule in-process or as a worker role (`count`, `run` frozen at a `fault-points.ts` seam and SIGKILLed by the driver, `recover`), plus process faults (stale `index.lock`, a hung git commit holding it, Postgres session drops, the owner killed after a `facts-absorb` extraction commits, then the job re-run). `robot-driver.ts` runs one fixed list on every event (a passed run is reusable): each seam the fixed sequences reach (all of them on full PGLite), `ROBOT_RANDOM_SEEDS`, nightly `explorationSeeds(day)`; `over_budget` fails it past the ceiling. Postgres connects through `GBRAIN_PGBOUNCER_URL` when set and, in the `pr` scope, skips the seams and the pooler disconnect fault that can wait out a dead owner's claim lease (`effect:*`, `consumer:prepared`, three publication seams), listed in the manifest as `lease_bound_seams_skipped` and `lease_bound_faults_skipped`. `shrink.ts` is dependency-preserving ddmin accepted on 3/3 reproduction; `--replay`/`--shrink` re-run a manifest's failing runs. `lock-order.ts` traces each transaction's row locks (worktrees before sources, sources by id, no exclusive brain lock in a publication). `history-fixture.ts` exports `buildHistoryFixture(engine, { pages, seed, sources, worktrees })` (real persistence history up to 10k pages; engine graduation, attribution backfill) and `prepareTopology`. `would-have-caught.ts` reverts each fix in `would-have-caught.json` in a scratch worktree and runs the pre-robot gate and robot on it. Tests: `test/persistence-crash-robot.test.ts`, `test/persistence-crash-robot.slow.test.ts` (shrunk regressions in `test/fixtures/crash-robot/`), `test/persistence-history-fixture.test.ts`.+- `scripts/persistence/{ops,generator,model,crash-robot,robot-driver,shrink,lock-order,history-fixture,would-have-caught}.ts` — the crash robot, a phase of `validate.ts` (`--robot-seconds` ceiling, default 1200 PGLite, 880 Postgres; `--robot-scope=pr|full`, `--explore-day`; CI: `persistence-validation.yml`). `ops.ts` is the JSON op-descriptor protocol between driver and workers: each descriptor names an op kind (put/edit/delete/restore page, remember/forget, takes add/supersede, timeline add, sync, connector publish, revoke access), an actor (the local CLI or a remote agent `verifyAccessToken` resolves), a source, a fixed request id and arguments whose `{ $ref }` values come from earlier observations; workers run each op through its registered handler. Its `retryingRead` retries the robot's reads only across a session drop the `SessionDrops` ledger shows it injected; any other closed connection fails the run. `generator.ts` builds seeded schedules: the fixed cross-boundary sequences (`crossBoundarySequences`: withdrawal then republication, overlapping slugs, competing writers, caller-bound replay, revoked authority, sync/connector races) plus random sequences with concurrent groups. `model.ts` is the temporal oracle: receipts and revisions at the observation point, legal later transitions, late receipts against page history, withdrawal permanence on recall/get_page/facts, source isolation, caller-bound replay, takes/facts fence projections, attribution, orphans, drain and wedge bounds; `EFFECT_SEAMS` maps every `EffectKind` to its trigger op and seam (typecheck-exhaustive). `crash-robot.ts` runs a schedule in-process or as a worker role (`count`, `run` frozen at a `fault-points.ts` seam and SIGKILLed by the driver, `recover`), plus process faults (stale `index.lock`, a hung git commit holding it, Postgres session drops, the owner killed after a `facts-absorb` extraction commits, then the job re-run). `robot-driver.ts` runs one fixed list on every event (a passed run is reusable): each seam the fixed sequences reach (all of them on full PGLite), `ROBOT_RANDOM_SEEDS`, nightly `explorationSeeds(day)`; `over_budget` fails it past the ceiling. Postgres connects through `GBRAIN_PGBOUNCER_URL` when set and, in the `pr` scope, skips the seams and the pooler disconnect fault that can wait out a dead owner's claim lease (`effect:*`, `consumer:prepared`, three publication seams), listed in the manifest as `lease_bound_seams_skipped` and `lease_bound_faults_skipped`. `shrink.ts` is dependency-preserving ddmin accepted on 3/3 reproduction; `--replay`/`--shrink` re-run a manifest's failing runs. `lock-order.ts` traces each transaction's row locks (worktrees before sources, sources by id, no exclusive brain lock in a publication). `history-fixture.ts` exports `buildHistoryFixture(engine, { pages, seed, sources, worktrees })` (real persistence history up to 10k pages; engine graduation, attribution backfill) and `prepareTopology`. `would-have-caught.ts` reverts each fix in `would-have-caught.json` in a scratch worktree and runs the pre-robot gate and robot on it. Tests: `test/persistence-crash-robot.test.ts`, `test/persistence-crash-robot.slow.test.ts` (shrunk regressions in `test/fixtures/crash-robot/`), `test/persistence-history-fixture.test.ts`.- `scripts/persistence/{graduation-fixture,graduation-process,graduation-ttv}.ts` — engine graduation test inputs and measurements. `graduation-fixture.ts` builds the 1k/10k history brains (`buildHistoryFixture` plus deterministic chunk vectors) or the hand-built legacy brain (`test/fixtures/graduation/`) in a keyless child process, caches each as a tarball keyed by its source files, schema version, seed and size, and re-homes a restore (database paths, managed-root records, owner stamps re-stamped with the new inode and birth time; sources marked synced). Its report lists bytes, chunks, versions, requests, effects and embeddings. `graduation-process.ts` spawns the real CLI or an older release with an isolated home and no provider keys, with optional boundary hooks, plus MCP stdio/HTTP clients and the JSON contract accessors. `graduation-ttv.ts` times plan to green doctor (five-minute gate at 1k pages; exit 1 under `--enforce`, 3 on a harness crash). Owners: `test/scripts/graduation-fixture.test.ts`, `test/graduation-legacy-fixture.test.ts`, `test/e2e/graduation-{crash,faults,clients,cli}.test.ts`, `tests/heavy/graduation_10k.sh`.diff --git a/docs/ci-event-parity.md b/docs/ci-event-parity.mdindex 3bd75632dc..18dd78adf4 100644--- a/docs/ci-event-parity.md+++ b/docs/ci-event-parity.md@@ -33,7 +33,7 @@ checks ([below](#full-ci-on-pull-requests)), never per-cell matrix names.| `persistence-validation.yml` | `convergence` selected on pull requests by `scripts/ci-convergence-scope.sh` (test.yml `changes`; never by `package.json` alone) | Named exception | Every merge-queue run and every push to master; the nightly cell runs in `convergence-nightly.yml` || `convergence-nightly.yml` | The convergence gate's nightly cell (2,000 pages, 50 ms, 20 kills, run-id seed): schedule and dispatch only, outside `test-status`; the PR cell (200 pages, 10 ms, 6 kills, seed 6650) runs in `persistence-validation.yml` | Named exception | Itself (nightly Convergence schedule) || `persistence-validation.yml` | `SOAK_OPERATIONS` 2,500 vs 10,000 | Named exception | Every push to master and the nightly Test schedule |-| `persistence-validation.yml` | Crash robot `--robot-scope=pr` (Postgres lease-bound seams skipped, 820 s PGLite and 620 s Postgres ceilings) vs `full` (1200 s PGLite, 1800 s Postgres; [ceilings](#crash-robot-ceilings)); the nightly adds that day's exploration seeds | Named exception | The full-ci dispatch, every push to master (same fixed list, so it may reuse that run) and the nightly Test schedule |+| `persistence-validation.yml` | Crash robot `--robot-scope=pr` (Postgres lease-bound seams skipped, 820 s PGLite and 620 s Postgres ceilings) vs `full` (1200 s PGLite, 880 s Postgres; [ceilings](#crash-robot-ceilings)); the nightly adds that day's exploration seeds | Named exception | The full-ci dispatch, every push to master (same fixed list, so it may reuse that run) and the nightly Test schedule || `native-locks.yml` | `inputs.scope` (OpenClaw, musl, Windows probes, Bun 1.4.0 and cross-target cells) | Named exception | Every push to master and the nightly Test schedule (`full`) || `e2e.yml` | Doc-only merge-queue entry selects no E2E file | Named exception | Every push to master (whole corpus) and the nightly E2E schedule || `e2e.yml` | Full-corpus coverage lanes and their `e2e-status` checks | Named exception | Nightly E2E schedule (or a `full_corpus` dispatch) |@@ -131,9 +131,19 @@ Measured on ubicloud-standard-4, full scope, run 39996381819:- **PGLite, 1200 s.** The slowest cell ran 880 s. The nightly's two exploration seedsadd about 45 s, and the slower cells in the previous week's manifests project toabout 985 s. 1200 s is that projection plus about 20%.-- **Postgres, 1800 s.** The slowest cell ran 1,290 s, including one 128 s wait for a- dead owner's effect-claim lease on a random seed. A nightly with two such waits- lands near 1,550 s, and 1800 s is that plus about 15%.+- **Postgres, 880 s.** Before #7454 the slowest cell ran 1,290 s, including one 128 s wait+ for a dead owner's effect-claim lease, under an 1800 s ceiling. Since #7454 releases that+ claim early, measured on master with a full-scope dispatch (run 40062601017):++ | Cell | Wall | Cross-boundary crashes | Process faults | 8 random seeds |+ |---|---|---|---|---|+ | postgres / Bun 1.4.0 | 391 s | 27 runs | 4 runs | no lease wait |+ | postgres / Bun 1.4.4 | 679 s | 27 runs | 4 runs, one 127 s | no lease wait |++ The 679 s cell includes one 127 s `pooler_disconnect` process fault on+ `overlapping_slugs_two_sources` (2.4 s in the other cell). 880 s is the slowest cell plus+ about 30%; the nightly's two exploration seeds (about 15–20 s each on Postgres) fit inside+ that margin.- **Pull requests, 820 s PGLite and 620 s Postgres.** Scope `pr` crashes each seam onceand skips the Postgres lease-bound seams. PGLite measured 510 s and 427 s (run40003479271), then 529 s and 474 s (run 40018836178); 820 s is the slowest plus about 30%.diff --git a/scripts/persistence/validate.ts b/scripts/persistence/validate.tsindex d00d956040..5155fcc835 100644--- a/scripts/persistence/validate.ts+++ b/scripts/persistence/validate.ts@@ -14,7 +14,7 @@ import { shrinkRun } from './shrink.ts';export interface ValidationOptions {engine: 'pglite' | 'postgres'; schedules?: number; operations?: number; seed?: number;crashes?: boolean; databaseUrl?: string; manifest?: string;- /** Crash-robot ceiling in seconds: a run past it fails; omitted or 0 skips the phase (the CLI defaults to 1200 on PGLite, 1800 on Postgres). */+ /** Crash-robot ceiling in seconds: a run past it fails; omitted or 0 skips the phase (the CLI defaults to 1200 on PGLite, 880 on Postgres). */robotSeconds?: number;/** `pr` skips the Postgres lease-bound seams; `full` (default) crashes every seam. */robotScope?: RobotScope;@@ -291,7 +291,7 @@ if (import.meta.main) {assert(['pr', 'full'].includes(args.get('robot-scope') ?? 'full'), '--robot-scope is pr or full');const result = await runValidation({ engine, schedules: Number(args.get('schedules') ?? 1000), operations: Number(args.get('operations') ?? 10_000),seed: Number(args.get('seed') ?? 5105), crashes: !args.has('no-crashes'), databaseUrl: process.env.DATABASE_URL,- robotSeconds: Number(args.get('robot-seconds') ?? (engine === 'postgres' ? 1800 : 1200)),+ robotSeconds: Number(args.get('robot-seconds') ?? (engine === 'postgres' ? 880 : 1200)),robotScope: (args.get('robot-scope') ?? 'full') as RobotScope, exploreDay: args.has('explore-day') ? Number(args.get('explore-day')) : undefined, replay: args.get('replay') || undefined, shrink: args.get('shrink') || undefined,manifest: args.get('manifest') ?? `.context/persistence-${engine}-manifest.json` });process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);diff --git a/test/scripts/data-safety-native-workflow.test.ts b/test/scripts/data-safety-native-workflow.test.tsindex b3b294cc27..094f019664 100644--- a/test/scripts/data-safety-native-workflow.test.ts+++ b/test/scripts/data-safety-native-workflow.test.ts@@ -324,7 +324,7 @@ describe('data-safety native CI coverage', () => {}});- test('the crash robot runs a fixed list beside the soak: scope pr under 820/620 s on pull requests, full under 1200/1800 s elsewhere, exploration nightly, Postgres through PgBouncer', () => {+ test('the crash robot runs a fixed list beside the soak: scope pr under 820/620 s on pull requests, full under 1200/880 s elsewhere, exploration nightly, Postgres through PgBouncer', () => {const persistence = load(readFileSync(join(import.meta.dir, '../../.github/workflows/persistence-validation.yml'), 'utf8')) as {jobs: { 'crash-robot': { steps: Step[]; services: Record<string, { env?: Record<string, string> }> } };};@@ -332,7 +332,7 @@ describe('data-safety native CI coverage', () => {expect(job.services.pgbouncer?.env?.POOL_MODE).toBe('transaction');const step = job.steps.find(entry => entry.run?.includes('scripts/persistence/validate.ts'));expect(step?.env?.ROBOT_SCOPE).toBe("${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && 'pr' || 'full' }}");- expect(step?.env?.ROBOT_SECONDS).toBe("${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && (matrix.engine == 'postgres' && '620' || '820') || (matrix.engine == 'postgres' && '1800' || '1200') }}");+ expect(step?.env?.ROBOT_SECONDS).toBe("${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && (matrix.engine == 'postgres' && '620' || '820') || (matrix.engine == 'postgres' && '880' || '1200') }}");expect(step?.env?.ROBOT_EXPLORE).toBe("${{ github.event_name == 'schedule' && 'nightly' || '' }}");expect(step?.env?.GBRAIN_PGBOUNCER_URL).toContain(':55433/');const argv = (env: Record<string, string>) => Bun.spawnSync(['bash', '-e', '-o', 'pipefail', '-c', `@@ -342,8 +342,8 @@ describe('data-safety native CI coverage', () => {const head = ['--no-env-file', 'scripts/persistence/validate.ts', '--engine=postgres', '--schedules=0', '--operations=0', '--no-crashes'];expect(argv({ ROBOT_SCOPE: 'pr', ROBOT_SECONDS: '820', ROBOT_EXPLORE: '' })).toEqual([...head, '--robot-scope=pr', '--robot-seconds=820','--manifest=.context/persistence-robot.json']);- const nightly = argv({ ROBOT_SCOPE: 'full', ROBOT_SECONDS: '1800', ROBOT_EXPLORE: 'nightly' });- expect(nightly.slice(0, -2)).toEqual([...head, '--robot-scope=full', '--robot-seconds=1800']);+ const nightly = argv({ ROBOT_SCOPE: 'full', ROBOT_SECONDS: '880', ROBOT_EXPLORE: 'nightly' });+ expect(nightly.slice(0, -2)).toEqual([...head, '--robot-scope=full', '--robot-seconds=880']);expect(nightly.at(-2)).toBe(`--explore-day=${Math.floor(Date.now() / 86_400_000)}`);expect(nightly.at(-1)).toBe('--manifest=.context/persistence-robot.json');});