Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

graduation(G3): merge G4; wire graduation E2E (tier1 step with PgBouncer, matrix exclusions, test map, weights), heavy 10k fixture cache + timeout, stub-aware GRADUATION_LANDED, accessor fixes (fix.plan_hash, run doctor shape), run doc state

garrytan18c4506f78a9
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index a78c308938..da437155b0 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -314,6 +314,21 @@ jobs:
GBRAIN_CI_REQUIRE_PGBOUNCER: '1'
GBRAIN_TEST_DB: '1'
GBRAIN_TEST_ALLOW_DATABASE_URL: '1'
+ - name: Run engine graduation suites (direct Postgres and PgBouncer)
+ # PGLite -> Postgres graduation (docs/guides/move-to-postgres.md): the
+ # agent flow, stale clients and respawned serves, SIGKILL at every
+ # custody boundary, faults, and the legacy copier. Every PR, with the
+ # transaction-mode pooler as a second target route (pooledUrl).
+ # Excluded from the selected matrix (scripts/e2e-matrix.ts) so they
+ # run once. Named files only, no glob.
+ shell: bash
+ run: bash scripts/run-e2e.sh test/e2e/graduation-cli.test.ts test/e2e/graduation-clients.test.ts test/e2e/graduation-crash.test.ts test/e2e/graduation-faults.test.ts test/e2e/graduation-legacy-copy.test.ts
+ env:
+ DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gbrain_test
+ GBRAIN_PGBOUNCER_URL: postgresql://postgres:postgres@localhost:55433/gbrain_test?prepare=false
+ GBRAIN_TEST_ALLOW_DATABASE_URL: '1'
+ GBRAIN_TEST_DB: '1'
+ E2E_FILE_TIMEOUT_SECS: '900'
- name: Run multi-agent serve suite
# cathedral-6 (T7): multi-agent continuity + isolation over a real
# `gbrain serve --http`. Own invocation line (engine-parity
diff --git a/.github/workflows/heavy-tests.yml b/.github/workflows/heavy-tests.yml
index 6c66be9503..32aa324537 100644
--- a/.github/workflows/heavy-tests.yml
+++ b/.github/workflows/heavy-tests.yml
@@ -48,7 +48,9 @@ jobs:
github.event_name != 'pull_request' ||
contains(github.event.pull_request.labels.*.name, 'heavy-tests')
runs-on: ubicloud-standard-30-ubuntu-2404
- timeout-minutes: 30
+ # 75: tests/heavy/graduation_10k.sh builds the 10k-page history fixture
+ # on a cold cache (~18 min) before graduating it.
+ timeout-minutes: 75
services:
postgres:
image: pgvector/pgvector:pg16
@@ -74,6 +76,14 @@ jobs:
key: bun-cache-${{ runner.os }}-${{ hashFiles('bun.lock') }}
restore-keys: bun-cache-${{ runner.os }}-
- run: bun install --frozen-lockfile
+ # The 10k graduation fixture is cached as a PGLite data-dir tarball keyed
+ # by the fixture sources (scripts/persistence/graduation-fixture.ts
+ # verifies its own key; a stale entry is rebuilt, never reused).
+ - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
+ with:
+ path: ~/.cache/gbrain-graduation-fixtures
+ key: graduation-fixtures-${{ runner.os }}-${{ hashFiles('scripts/persistence/graduation-fixture.ts', 'scripts/persistence/history-fixture.ts', 'src/core/schema-migrations/**') }}
+ restore-keys: graduation-fixtures-${{ runner.os }}-
- name: Run heavy tests
env:
diff --git a/scripts/e2e-matrix.ts b/scripts/e2e-matrix.ts
index 4b47ff04a7..703da6166d 100644
--- a/scripts/e2e-matrix.ts
+++ b/scripts/e2e-matrix.ts
@@ -31,6 +31,12 @@ export const E2E_EXCLUSIONS = new Set([
'test/e2e/skills.test.ts',
'test/e2e/voyage-rerank-live.test.ts',
'test/e2e/voyage-multimodal.test.ts',
+ // Engine graduation: run once by tier1's graduation step (direct Postgres + PgBouncer).
+ 'test/e2e/graduation-cli.test.ts',
+ 'test/e2e/graduation-clients.test.ts',
+ 'test/e2e/graduation-crash.test.ts',
+ 'test/e2e/graduation-faults.test.ts',
+ 'test/e2e/graduation-legacy-copy.test.ts',
...PERSISTENCE_VALIDATION_OWNED,
]);
export interface E2ERow { shard: number; files: string[]; empty: boolean }
diff --git a/scripts/e2e-test-map.ts b/scripts/e2e-test-map.ts
index 722f3dd6f3..dd784712ab 100644
--- a/scripts/e2e-test-map.ts
+++ b/scripts/e2e-test-map.ts
@@ -23,6 +23,14 @@ const MIGRATION_WAVE_TESTS = [
"test/e2e/migration-wave-provider-outcomes.test.ts",
];
+const GRADUATION_E2E_TESTS = [
+ "test/e2e/graduation-cli.test.ts",
+ "test/e2e/graduation-clients.test.ts",
+ "test/e2e/graduation-crash.test.ts",
+ "test/e2e/graduation-faults.test.ts",
+ "test/e2e/graduation-legacy-copy.test.ts",
+];
+
export const E2E_TEST_MAP: Record<string, string[]> = {
// #5984: the env-gated wire-level SQL trace for the managed-sync catch-up bench.
"src/core/sql-trace.ts": ["test/e2e/sql-trace-postgres.test.ts"],
@@ -259,7 +267,19 @@ export const E2E_TEST_MAP: Record<string, string[]> = {
"src/commands/migrate-engine.ts": [
"test/e2e/multi-source-bug-class.test.ts",
"test/e2e/migrate-engine-pglite-to-postgres.test.ts",
+ "test/e2e/graduation-legacy-copy.test.ts",
],
+ // Engine graduation (PGLite -> Postgres): the CLI, the orchestrator modules and the serve guard.
+ "src/commands/migrate-graduation.ts": GRADUATION_E2E_TESTS,
+ "src/core/persistence/engine-graduation*.ts": GRADUATION_E2E_TESTS,
+ "src/core/persistence/graduation-*.ts": GRADUATION_E2E_TESTS,
+ "src/core/persistence/graduation-copy.ts": ["test/e2e/graduation-copy.test.ts"],
+ "src/core/persistence/graduation-target.ts": ["test/e2e/graduation-copy.test.ts"],
+ "test/helpers/graduation-copy-harness.ts": ["test/e2e/graduation-copy.test.ts"],
+ "src/commands/doctor/checks/engine-graduation.ts": ["test/e2e/graduation-clients.test.ts"],
+ "scripts/persistence/graduation-*.ts": GRADUATION_E2E_TESTS,
+ "test/helpers/graduation-*.ts": GRADUATION_E2E_TESTS,
+ "test/fixtures/graduation/**": GRADUATION_E2E_TESTS,
// Any minions queue/worker/handler change exercises all minion E2E.
"src/core/minions/**": [
"test/e2e/minions-legacy-coalesce-postgres.test.ts",
diff --git a/scripts/e2e-weights.json b/scripts/e2e-weights.json
index db9cc5e34b..1124eec63c 100644
--- a/scripts/e2e-weights.json
+++ b/scripts/e2e-weights.json
@@ -91,6 +91,12 @@
"test/e2e/facts-worker-config.test.ts": 2420,
"test/e2e/frontmatter-migration.test.ts": 3490,
"test/e2e/global-basename-pglite.test.ts": 2890,
+ "test/e2e/graduation-cli.test.ts": 240000,
+ "test/e2e/graduation-clients.test.ts": 180000,
+ "test/e2e/graduation-copy.test.ts": 60000,
+ "test/e2e/graduation-crash.test.ts": 300000,
+ "test/e2e/graduation-faults.test.ts": 150000,
+ "test/e2e/graduation-legacy-copy.test.ts": 30000,
"test/e2e/grandfather-projection-postgres.test.ts": 5350,
"test/e2e/graph-quality.test.ts": 3420,
"test/e2e/graph-signals-engine.test.ts": 1201,
diff --git a/scripts/persistence/graduation-process.ts b/scripts/persistence/graduation-process.ts
index 5ebeeb6d84..4558d4e4e6 100644
--- a/scripts/persistence/graduation-process.ts
+++ b/scripts/persistence/graduation-process.ts
@@ -80,7 +80,7 @@ export async function gbrain(argv: string[], opts: GbrainOpts): Promise<GbrainRe
// ── Contract accessors (one place to fix if the CLI's JSON names move) ───────
export const planHashOf = (doc: Record<string, any> | null): string | undefined =>
- doc?.plan_hash ?? doc?.planHash ?? doc?.plan?.plan_hash ?? doc?.plan?.planHash ?? doc?.data?.plan_hash;
+ doc?.plan_hash ?? doc?.planHash ?? doc?.plan?.plan_hash ?? doc?.plan?.planHash ?? doc?.fix?.plan_hash ?? doc?.data?.plan_hash;
export const codeOf = (doc: Record<string, any> | null): string | undefined => doc?.code ?? doc?.error?.code ?? doc?.error;
export const fixOf = (doc: Record<string, any> | null): Record<string, any> | undefined => doc?.fix ?? doc?.error?.fix;
export const stateOf = (doc: Record<string, any> | null): string | undefined =>
diff --git a/scripts/ubicloud/weights.json b/scripts/ubicloud/weights.json
index e446287924..fdedb56073 100644
--- a/scripts/ubicloud/weights.json
+++ b/scripts/ubicloud/weights.json
@@ -95,6 +95,12 @@
"e2e:test/e2e/fixture-reset-postgres.test.ts": 4246,
"e2e:test/e2e/frontmatter-migration.test.ts": 3738,
"e2e:test/e2e/global-basename-pglite.test.ts": 3967,
+ "e2e:test/e2e/graduation-cli.test.ts": 240000,
+ "e2e:test/e2e/graduation-clients.test.ts": 180000,
+ "e2e:test/e2e/graduation-copy.test.ts": 60000,
+ "e2e:test/e2e/graduation-crash.test.ts": 300000,
+ "e2e:test/e2e/graduation-faults.test.ts": 150000,
+ "e2e:test/e2e/graduation-legacy-copy.test.ts": 30000,
"e2e:test/e2e/grandfather-projection-postgres.test.ts": 4645,
"e2e:test/e2e/graph-quality.test.ts": 4440,
"e2e:test/e2e/graph-signals-engine.test.ts": 1793,
diff --git a/src/commands/migrate-graduation.ts b/src/commands/migrate-graduation.ts
index 1a2772df6c..b2ab04b4ed 100644
--- a/src/commands/migrate-graduation.ts
+++ b/src/commands/migrate-graduation.ts
@@ -276,6 +276,7 @@ function successDoc(receipt: GraduationReceipt) {
return {
schema_version: 1 as const,
status: 'graduated' as const,
+ state: 'graduated' as const,
run_id: receipt.runId,
target: receipt.targetDisplayUrl ?? null,
retained_path: receipt.retainedPath ?? null,
diff --git a/test/helpers/graduation-e2e.ts b/test/helpers/graduation-e2e.ts
index b7670749a6..5fd79c2e08 100644
--- a/test/helpers/graduation-e2e.ts
+++ b/test/helpers/graduation-e2e.ts
@@ -26,7 +26,9 @@ export * from '../../scripts/persistence/graduation-process.ts';
* (visible in every report, never silently skipped). Infrastructure checks
* that need only Postgres run either way.
*/
-export const GRADUATION_LANDED = existsSync(join(REPO, 'src', 'core', 'persistence', 'engine-graduation.ts'));
+const ORCHESTRATOR = join(REPO, 'src', 'core', 'persistence', 'engine-graduation.ts');
+/** The CLI lane ships a throwing stub at this path until the orchestrator merges; the stub does not count as landed. */
+export const GRADUATION_LANDED = existsSync(ORCHESTRATOR) && !readFileSync(ORCHESTRATOR, 'utf8').includes('STUB (G3 CLI lane)');
export const graduationTest: typeof test = GRADUATION_LANDED ? test : (test.todo as unknown as typeof test);
/** `graduationTest` with an extra visible skip condition (e.g. Docker unavailable). */
export function graduationTestIf(skip: boolean): typeof test {
diff --git a/test/helpers/graduation-scenarios.ts b/test/helpers/graduation-scenarios.ts
index c9d2ac5fbf..e0e7aa233e 100644
--- a/test/helpers/graduation-scenarios.ts
+++ b/test/helpers/graduation-scenarios.ts
@@ -102,6 +102,8 @@ export async function expectAtMostOneWriter(c: Case, label: string): Promise<voi
}
export function failingChecks(doc: Record<string, any> | null): string[] {
+ // The run document's `doctor` is { source, target } lists of failing check names; doctor --json has `checks`.
+ if (Array.isArray(doc?.target)) return doc.target as string[];
return ((doc?.checks ?? []) as { name: string; status: string }[]).filter(c => c.status === 'fail').map(c => c.name);
}