Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: map the refresh E2E file and regenerate the PGLite upgrade-replay catalog golden

garrytan37d274af3ba6
diff --git a/scripts/e2e-test-map.ts b/scripts/e2e-test-map.ts
index 27c025bb62..6bc1a2e67d 100644
--- a/scripts/e2e-test-map.ts
+++ b/scripts/e2e-test-map.ts
@@ -58,7 +58,9 @@ export const E2E_TEST_MAP: Record<string, string[]> = {
// Fix wave 5 #5401: projection drain CLI and the budgeted resident drain.
"src/commands/projections.ts": ["test/e2e/projection-drain-postgres.test.ts", "test/e2e/fix-wave-5-integration.test.ts"],
"src/core/persistence/consumer.ts": ["test/e2e/projection-drain-postgres.test.ts"],
- "src/core/persistence/journal.ts": ["test/e2e/projection-drain-postgres.test.ts", "test/e2e/withdrawal-followup-writes-postgres.test.ts"],
+ "src/core/persistence/journal.ts": ["test/e2e/projection-drain-postgres.test.ts", "test/e2e/withdrawal-followup-writes-postgres.test.ts", "test/e2e/worktree-refresh-postgres.test.ts"],
+ // F0 `gbrain sources refresh`: the refresh state machine, its admission/claim fence and restart recovery.
+ "src/core/persistence/worktree-refresh.ts": ["test/e2e/worktree-refresh-postgres.test.ts"],
// Fix wave 5 (#5731): the extractor-facts restore and its doctor check.
"src/core/repair/extractor-facts.ts": ["test/e2e/repair-extractor-facts-postgres.test.ts", "test/e2e/fix-wave-5-integration.test.ts"],
"src/core/repair/captured-facts.ts": ["test/e2e/repair-captured-facts-postgres.test.ts"],
@@ -342,7 +344,7 @@ export const E2E_TEST_MAP: Record<string, string[]> = {
"src/core/embed-concurrency.ts": ["test/e2e/embed-stale-pool-default-postgres.test.ts"],
"src/core/embed-stale.ts": ["test/e2e/embed-stale-pool-default-postgres.test.ts"],
"src/core/persistence/effect-git.ts": ["test/e2e/persistence-git-coalescing-5530-postgres.test.ts"],
- "src/core/persistence/effect-journal.ts": ["test/e2e/persistence-git-coalescing-5530-postgres.test.ts"],
+ "src/core/persistence/effect-journal.ts": ["test/e2e/persistence-git-coalescing-5530-postgres.test.ts", "test/e2e/worktree-refresh-postgres.test.ts"],
"src/core/persistence/grandfather.ts": ["test/e2e/persistence-git-coalescing-5530-postgres.test.ts", "test/e2e/grandfather-projection-postgres.test.ts"],
"src/core/timeline-marker.ts": ["test/e2e/timeline-materialize.test.ts"],
"src/commands/source-reconcile.ts": ["test/e2e/reconcile-crash.test.ts", "test/e2e/reconcile-crash-unactivated.test.ts", "test/e2e/reconcile-pgbouncer.test.ts"],
diff --git a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
index 9d2f29e0c0..0c95be5e2f 100644
--- a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
+++ b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
@@ -190,6 +190,9 @@
"persistence_topology_changes.persistence_topology_changes_recovery_bytes_check": "c CHECK ((recovery_bytes >= 0))",
"persistence_topology_changes.persistence_topology_changes_state_check": "c CHECK ((state = ANY (ARRAY['recovering'::text, 'committed'::text, 'failed'::text])))",
"persistence_topology_changes.persistence_topology_changes_terminal_bytes_check": "c CHECK ((terminal_bytes >= 0))",
+ "persistence_worktree_refreshes.persistence_worktree_refreshes_pkey": "p PRIMARY KEY (id)",
+ "persistence_worktree_refreshes.persistence_worktree_refreshes_state_check": "c CHECK ((state = ANY (ARRAY['draining'::text, 'fenced'::text, 'merged'::text, 'syncing'::text, 'completed'::text, 'aborted'::text, 'recovery_required'::text])))",
+ "persistence_worktree_refreshes.persistence_worktree_refreshes_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)",
"persistence_worktrees.persistence_worktrees_pkey": "p PRIMARY KEY (id)",
"persistence_worktrees.persistence_worktrees_state_check": "c CHECK ((state = ANY (ARRAY['active'::text, 'draining'::text, 'recovering'::text, 'retired'::text])))",
"persistence_writer_protocols.persistence_writer_protocols_pkey": "p PRIMARY KEY (worktree_id, host_id)",
@@ -520,6 +523,9 @@
"persistence_topology_changes": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "persistence_worktree_refreshes": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"persistence_worktrees": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -869,6 +875,8 @@
"persistence_topology_changes_pkey": "CREATE UNIQUE INDEX persistence_topology_changes_pkey ON public.persistence_topology_changes USING btree (id)",
"persistence_topology_changes_principal_id_request_id_key": "CREATE UNIQUE INDEX persistence_topology_changes_principal_id_request_id_key ON public.persistence_topology_changes USING btree (principal_id, request_id)",
"persistence_topology_recovering": "CREATE INDEX persistence_topology_recovering ON public.persistence_topology_changes USING btree (created_at) WHERE (state = 'recovering'::text)",
+ "persistence_worktree_refreshes_active": "CREATE UNIQUE INDEX persistence_worktree_refreshes_active ON public.persistence_worktree_refreshes USING btree (worktree_id) WHERE (state = ANY (ARRAY['draining'::text, 'fenced'::text, 'merged'::text, 'syncing'::text, 'recovery_required'::text]))",
+ "persistence_worktree_refreshes_pkey": "CREATE UNIQUE INDEX persistence_worktree_refreshes_pkey ON public.persistence_worktree_refreshes USING btree (id)",
"persistence_worktrees_pkey": "CREATE UNIQUE INDEX persistence_worktrees_pkey ON public.persistence_worktrees USING btree (id)",
"persistence_writer_protocols_pkey": "CREATE UNIQUE INDEX persistence_writer_protocols_pkey ON public.persistence_writer_protocols USING btree (worktree_id, host_id)",
"query_cache_pkey": "CREATE UNIQUE INDEX query_cache_pkey ON public.query_cache USING btree (id)",
@@ -2134,6 +2142,26 @@
],
"flags": "relkind=r rls=false force_rls=false"
},
+ "persistence_worktree_refreshes": {
+ "columns": [
+ "1 id uuid/uuid NOT NULL DEFAULT gen_random_uuid()",
+ "2 worktree_id uuid/uuid NOT NULL",
+ "3 source_ids ARRAY/_text NOT NULL",
+ "4 principal_id uuid/uuid NOT NULL",
+ "5 owner_epoch bigint/int8 NOT NULL",
+ "6 topology_generation bigint/int8 NOT NULL",
+ "7 state text/text NOT NULL",
+ "8 old_head text/text NOT NULL",
+ "9 target_head text/text NOT NULL",
+ "10 upstream_ref text/text NOT NULL",
+ "11 preserved_uncommitted ARRAY/_text NOT NULL DEFAULT '{}'::text[]",
+ "12 outcome jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",
+ "13 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "14 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "15 completed_at timestamp with time zone/timestamptz NULL"
+ ],
+ "flags": "relkind=r rls=false force_rls=false"
+ },
"persistence_worktrees": {
"columns": [
"1 id uuid/uuid NOT NULL DEFAULT gen_random_uuid()",