Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(GST-1209): the segment-GC fixture publishes generations that tile; the seal-bounded flip allowlist names the tiling guard
garrytan36b5be027604
diff --git a/test/helpers/segment-gc-cases.ts b/test/helpers/segment-gc-cases.tsindex 10022704d9..57ad931a9f 100644--- a/test/helpers/segment-gc-cases.ts+++ b/test/helpers/segment-gc-cases.ts@@ -178,12 +178,12 @@ export function defineSegmentGcCases(opts: { getEngine: () => BrainEngine; concuVALUES ($1, NULL, NULL, '{}'::jsonb, 'segmented', 1, 10, 'h1')`, [page.pageId]);const v2 = [segmentText('# Two\nsecond, edited\n')];const s2 = await stageGeneration(engine, { pageId: page.pageId, slug: `notes/gc-versions-${sourceId}`, genFrom: 2, texts: v2, sourceId, chunkTexts: true });- await engine.executeRaw('UPDATE page_body_manifest SET seq = 1 WHERE staging_id = $1::uuid', [s2.stagingId]);- await engine.flipBodyGeneration(flipInput(page.pageId, 1, s2.stagingId, v2, { closeOccurrences: [page.occurrences[1]!], retireChunkOccurrences: [page.occurrences[1]!] }));+ await engine.executeRaw('UPDATE page_body_manifest SET seq = 1, byte_start = $2 WHERE staging_id = $1::uuid', [s2.stagingId, v1[0]!.body.byteLength]);+ await engine.flipBodyGeneration(flipInput(page.pageId, 1, s2.stagingId, [v1[0]!, ...v2], { closeOccurrences: [page.occurrences[1]!], retireChunkOccurrences: [page.occurrences[1]!] }));const v3 = [segmentText('# Two\nsecond, edited again\n')];const s3 = await stageGeneration(engine, { pageId: page.pageId, slug: `notes/gc-versions-${sourceId}`, genFrom: 3, texts: v3, sourceId, chunkTexts: true });- await engine.executeRaw('UPDATE page_body_manifest SET seq = 1 WHERE staging_id = $1::uuid', [s3.stagingId]);- await engine.flipBodyGeneration(flipInput(page.pageId, 2, s3.stagingId, v3, { closeOccurrences: s2.occurrences, retireChunkOccurrences: s2.occurrences }));+ await engine.executeRaw('UPDATE page_body_manifest SET seq = 1, byte_start = $2 WHERE staging_id = $1::uuid', [s3.stagingId, v1[0]!.body.byteLength]);+ await engine.flipBodyGeneration(flipInput(page.pageId, 2, s3.stagingId, [v1[0]!, ...v3], { closeOccurrences: s2.occurrences, retireChunkOccurrences: s2.occurrences }));await ageTexts(engine, sourceId);const chunkOccurrences = async () => (await engine.executeRaw<{ occurrence_id: number }>('SELECT DISTINCT occurrence_id::int AS occurrence_id FROM content_chunks WHERE page_id = $1 ORDER BY 1', [page.pageId])).map(r => r.occurrence_id);diff --git a/test/large-pages/publication-seal-bounded.test.ts b/test/large-pages/publication-seal-bounded.test.tsindex cf23adf673..412c65905e 100644--- a/test/large-pages/publication-seal-bounded.test.ts+++ b/test/large-pages/publication-seal-bounded.test.ts@@ -57,8 +57,9 @@ interface Statement { sql: string; rows?: number; nodes?: string[]; subplan?: boconst TABLES = /content_chunks|page_body_manifest/;const DELTA_DELETE = /^DELETE FROM content_chunks WHERE page_id=\$1 AND body_generation=\$2 AND NOT \(chunk_index = ANY\(\$3::int\[\]\)\)$/;-/** The generation flip's statements on the two tables (engine-sql/page-body.ts flipBodyGeneration). */+/** The generation flip's statements on the two tables (engine-sql/page-body.ts flipBodyGeneration), its tiling guard included (GST-1209: the live generation's manifest rows, never chunk rows). */const FLIP = [+ /^SELECT t\.n, t\.covered, t\.gapless FROM pages p CROSS JOIN LATERAL \(SELECT count\(\*\)::bigint AS n, COALESCE\(sum\(r\.byte_len\), 0\)::bigint AS covered, .* FROM page_body_manifest m WHERE m\.page_id = p\.id /,/^SELECT count\(\*\)::bigint AS n FROM content_chunks c WHERE c\.page_id = \$1 AND \(/,/^UPDATE page_body_manifest SET gen_to = \$1::bigint WHERE page_id = \$2 AND gen_to IS NULL AND staging_id IS NULL AND occurrence_id = ANY\(/,/^DELETE FROM content_chunks c WHERE c\.page_id = \$1 AND \(/,