Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: #5984 round-trip diet — reviewed writer inventory, export goldens, apply(tx, preimage) wiring pins

garrytan79e57320d407
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsv
index 764f72e6d3..8d94d1e751 100644
--- a/docs/architecture/canonical-writers.tsv
+++ b/docs/architecture/canonical-writers.tsv
@@ -55,7 +55,7 @@ src/core/embedding-invalidation.ts 2 projection Derived vector invalidation; sig
src/core/embedding-migration.ts 1 projection Derived indexing, retrieval telemetry, or source settings; canonical fields remain guarded by SQL triggers.
src/core/engine-constants.ts 1 contract Engine contract or explanatory SQL references; execution is in guarded engine implementations.
src/core/engine-sql/bootstrap.ts 1 schema Schema installation and forward-reference DDL; coordinated activation quiesces canonical writers.
-src/core/engine-sql/chunks.ts 1 projection Derived indexing: setPageEmbeddingSignature stamps pages.embedding_signature; chunk rows are derived index state and canonical fields remain guarded by SQL triggers.
+src/core/engine-sql/chunks.ts 2 projection Derived indexing: setPageEmbeddingSignature stamps pages.embedding_signature, and a complete chunk replacement (upsertChunks sealChunkerVersion, #5984) stamps pages.chunker_version in the caller's transaction; chunk rows are derived index state and canonical fields remain guarded by SQL triggers.
src/core/engine-sql/facts.ts 11 engine_guard Canonical table SQL trigger requires coordinator capability; legacy calls fail before canonical DB publication.
src/core/engine-sql/pages.ts 16 engine_guard Canonical table SQL trigger requires coordinator capability; legacy calls fail before canonical DB publication. #5761: markPagesAttendanceBlocked writes only the derived attendance-marker columns, which the managed guard does not track.
src/core/engine-sql/salience.ts 1 projection Derived indexing, retrieval telemetry, or source settings; canonical fields remain guarded by SQL triggers.
diff --git a/test/fact-withdrawal-prepare-wiring.test.ts b/test/fact-withdrawal-prepare-wiring.test.ts
index ab8586c2ad..83406c6d20 100644
--- a/test/fact-withdrawal-prepare-wiring.test.ts
+++ b/test/fact-withdrawal-prepare-wiring.test.ts
@@ -23,7 +23,8 @@ test.each([
['page-prepare.ts', 1],
] as const)('%s validates every prepared content import it applies', (file, applied) => {
const text = source(file);
- expect(count(text, 'await ready.apply(tx)') + count(text, 'await applied.apply(tx)')).toBe(applied);
+ // #5984: apply may also receive the publisher's preimage (`apply(tx, preimage)`).
+ expect(count(text, 'await ready.apply(tx)') + count(text, 'await ready.apply(tx,') + count(text, 'await applied.apply(tx)') + count(text, 'await applied.apply(tx,')).toBe(applied);
expect(count(text, 'await ready.validate(tx)') + count(text, 'validate: ready.validate')).toBe(applied);
});
@@ -31,7 +32,7 @@ test('a managed rename validates the import it re-prepares at the new slug befor
const text = source('sync-prepare.ts');
const validated = text.indexOf('await movedImport.validate(tx); applied = movedImport;');
expect(validated).toBeGreaterThan(0);
- expect(validated).toBeLessThan(text.indexOf('await applied.apply(tx)'));
+ expect(validated).toBeLessThan(text.indexOf('await applied.apply(tx,'));
});
test('the coordinator validates prepared mutations before publication boundaries and file writes', () => {
diff --git a/test/fixtures/goldens/exports/runtime.json b/test/fixtures/goldens/exports/runtime.json
index 829c615c1b..c69944ea45 100644
--- a/test/fixtures/goldens/exports/runtime.json
+++ b/test/fixtures/goldens/exports/runtime.json
@@ -611,6 +611,7 @@
"isImageFilePath",
"pLimit",
"slugConflictHoldMessage",
+ "verifyPageReadable",
"withImportTransaction"
],
"./ingestion": [
diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.json
index fb4aa5732c..890a4eb7bb 100644
--- a/test/fixtures/goldens/exports/types.json
+++ b/test/fixtures/goldens/exports/types.json
@@ -68,7 +68,7 @@
"countStalePagesForExtraction: (opts?: { sourceId?: string; versionTs?: string; attendance?: \"exclude\" | \"blocked\"; }) => Promise<number>",
"countStaleTakes: (opts?: StaleTakeOpts) => Promise<number>",
"countUnconsolidatedFacts: (source_id: string) => Promise<number>",
- "createVersion: (slug: string, opts?: { sourceId?: string; }) => Promise<PageVersion>",
+ "createVersion: (slug: string, opts?: { sourceId?: string; preimage?: PageSnapshot; }) => Promise<PageVersion>",
"deleteChunks: (slug: string, opts?: { sourceId?: string; }) => Promise<void>",
"deleteCodeEdgesForChunks: (chunkIds: number[]) => Promise<void>",
"deleteEvalCandidatesBefore: (date: Date) => Promise<number>",
@@ -214,7 +214,7 @@
"updateSourceConfig: (sourceId: string, patch: Record<string, unknown>) => Promise<boolean>",
"updateTake: (pageId: number, rowNum: number, fields: { weight?: number; since_date?: string; source?: string; }) => Promise<void>",
"updateTakeEmbeddings: (rows: TakeEmbeddingInput[], opts?: BatchOpts) => Promise<number>",
- "upsertChunks: (slug: string, chunks: ChunkInput[], opts?: { sourceId?: string; embeddingColumn?: ResolvedColumn; expectedRevision?: string; } & BatchOpts) => Promise<void>",
+ "upsertChunks: (slug: string, chunks: ChunkInput[], opts?: { sourceId?: string; embeddingColumn?: ResolvedColumn; expectedRevision?: string; sealChunkerVersion?: number; } & BatchOpts) => Promise<void>",
"upsertEventProjection: (opts: { depthSlug: string; eventSlug: string; date: string; summary: string; detail?: string; sourceId?: string; }) => Promise<{ projected: boolean; }>",
"upsertFile: (spec: FileSpec) => Promise<{ id: number; created: boolean; }>",
"withReservedConnection: <T>(fn: (conn: ReservedConnection) => Promise<T>, opts?: { route?: \"ordinary\"; }) => Promise<T>",
@@ -971,7 +971,7 @@
"countStalePagesForExtraction: (opts?: { sourceId?: string; versionTs?: string; attendance?: \"exclude\" | \"blocked\"; }) => Promise<number>",
"countStaleTakes: (opts?: StaleTakeOpts) => Promise<number>",
"countUnconsolidatedFacts: (source_id: string) => Promise<number>",
- "createVersion: (slug: string, opts?: { sourceId?: string; }) => Promise<PageVersion>",
+ "createVersion: (slug: string, opts?: { sourceId?: string; preimage?: PageSnapshot; }) => Promise<PageVersion>",
"deleteChunks: (slug: string, opts?: { sourceId?: string; }) => Promise<void>",
"deleteCodeEdgesForChunks: (chunkIds: number[]) => Promise<void>",
"deleteEvalCandidatesBefore: (date: Date) => Promise<number>",
@@ -1154,7 +1154,7 @@
"updateSourceConfig: (sourceId: string, patch: Record<string, unknown>) => Promise<boolean>",
"updateTake: (pageId: number, rowNum: number, fields: { weight?: number; since_date?: string; source?: string; }) => Promise<void>",
"updateTakeEmbeddings: (rowsIn: TakeEmbeddingInput[], opts?: BatchOpts) => Promise<number>",
- "upsertChunks: (slug: string, chunks: ChunkInput[], opts?: { sourceId?: string; embeddingColumn?: ResolvedColumn; expectedRevision?: string; } & BatchOpts) => Promise<void>",
+ "upsertChunks: (slug: string, chunks: ChunkInput[], opts?: { sourceId?: string; embeddingColumn?: ResolvedColumn; expectedRevision?: string; sealChunkerVersion?: number; } & BatchOpts) => Promise<void>",
"upsertEventProjection: (opts: { depthSlug: string; eventSlug: string; date: string; summary: string; detail?: string; sourceId?: string; }) => Promise<{ projected: boolean; }>",
"upsertFile: (spec: FileSpec) => Promise<{ id: number; created: boolean; }>",
"withReservedConnection: <T>(fn: (conn: ReservedConnection) => Promise<T>, opts?: { route?: \"ordinary\"; }) => Promise<T>",
@@ -3053,7 +3053,7 @@
"countStalePagesForExtraction: (opts?: { sourceId?: string; versionTs?: string; attendance?: \"exclude\" | \"blocked\"; }) => Promise<number>",
"countStaleTakes: (opts?: StaleTakeOpts) => Promise<number>",
"countUnconsolidatedFacts: (source_id: string) => Promise<number>",
- "createVersion: (slug: string, opts?: { sourceId?: string; }) => Promise<PageVersion>",
+ "createVersion: (slug: string, opts?: { sourceId?: string; preimage?: PageSnapshot; }) => Promise<PageVersion>",
"deleteChunks: (slug: string, opts?: { sourceId?: string; }) => Promise<void>",
"deleteCodeEdgesForChunks: (chunkIds: number[]) => Promise<void>",
"deleteEvalCandidatesBefore: (date: Date) => Promise<number>",
@@ -3199,7 +3199,7 @@
"updateSourceConfig: (sourceId: string, patch: Record<string, unknown>) => Promise<boolean>",
"updateTake: (pageId: number, rowNum: number, fields: { weight?: number; since_date?: string; source?: string; }) => Promise<void>",
"updateTakeEmbeddings: (rows: TakeEmbeddingInput[], opts?: BatchOpts) => Promise<number>",
- "upsertChunks: (slug: string, chunks: ChunkInput[], opts?: { sourceId?: string; embeddingColumn?: ResolvedColumn; expectedRevision?: string; } & BatchOpts) => Promise<void>",
+ "upsertChunks: (slug: string, chunks: ChunkInput[], opts?: { sourceId?: string; embeddingColumn?: ResolvedColumn; expectedRevision?: string; sealChunkerVersion?: number; } & BatchOpts) => Promise<void>",
"upsertEventProjection: (opts: { depthSlug: string; eventSlug: string; date: string; summary: string; detail?: string; sourceId?: string; }) => Promise<{ projected: boolean; }>",
"upsertFile: (spec: FileSpec) => Promise<{ id: number; created: boolean; }>",
"withReservedConnection: <T>(fn: (conn: ReservedConnection) => Promise<T>, opts?: { route?: \"ordinary\"; }) => Promise<T>",
@@ -4279,7 +4279,7 @@
"kind": "function",
"name": "importFromContent",
"signature": [
- "(engine: BrainEngine, slug: string, content: string, opts?: { prepare?: (prepared: PreparedContentImport) => Promise<ImportResult>; prepareFrontmatter?: (page: ParsedPage) => void; noEmbed?: boolean; sourceId?: string; filename?: string; sourcePath?: string; sourceRoot?: string; fileTimes?: { birthtime?: Date; mtime?: Date; firstCommit?: Date; }; forceRechunk?: boolean; activePack?: ParseOpts[\"activePack\"]; source_kind?: string | null; source_uri?: string | null; ingested_via?: string | null; remote?: boolean; allowEmptyOverwrite?: boolean; beforeCommit?: (tx: BrainEngine, slug: string) => Promise<void>; onPostCommitEmbedding?: (complete: () => Promise<ImportEmbeddingResult>) => void; }) => Promise<ImportResult>"
+ "(engine: BrainEngine, slug: string, content: string, opts?: { prepare?: (prepared: PreparedContentImport) => Promise<ImportResult>; coordinated?: boolean; prepareFrontmatter?: (page: ParsedPage) => void; noEmbed?: boolean; sourceId?: string; filename?: string; sourcePath?: string; sourceRoot?: string; fileTimes?: { birthtime?: Date; mtime?: Date; firstCommit?: Date; }; forceRechunk?: boolean; activePack?: ParseOpts[\"activePack\"]; source_kind?: string | null; source_uri?: string | null; ingested_via?: string | null; remote?: boolean; allowEmptyOverwrite?: boolean; beforeCommit?: (tx: BrainEngine, slug: string) => Promise<void>; onPostCommitEmbedding?: (complete: () => Promise<ImportEmbeddingResult>) => void; }) => Promise<ImportResult>"
]
},
{
@@ -4317,6 +4317,13 @@
"(relativePath: string, expectedSlug: string) => string"
]
},
+ {
+ "kind": "function",
+ "name": "verifyPageReadable",
+ "signature": [
+ "(engine: BrainEngine, slug: string, expectedHash: string, sourceId: string | undefined, caller: string, read?: Pick<Page, \"content_hash\"> | null) => Promise<void>"
+ ]
+ },
{
"kind": "function",
"name": "withImportTransaction",
@@ -5840,7 +5847,7 @@
"countStalePagesForExtraction: (opts?: { sourceId?: string; versionTs?: string; attendance?: \"exclude\" | \"blocked\"; }) => Promise<number>",
"countStaleTakes: (opts?: StaleTakeOpts) => Promise<number>",
"countUnconsolidatedFacts: (source_id: string) => Promise<number>",
- "createVersion: (slug: string, opts?: { sourceId?: string; }) => Promise<PageVersion>",
+ "createVersion: (slug: string, opts?: { sourceId?: string; preimage?: PageSnapshot; }) => Promise<PageVersion>",
"db: PGlite",
"deleteChunks: (slug: string, opts?: { sourceId?: string; }) => Promise<void>",
"deleteCodeEdgesForChunks: (chunkIds: number[]) => Promise<void>",
@@ -6017,7 +6024,7 @@
"updateSourceConfig: (sourceId: string, patch: Record<string, unknown>) => Promise<boolean>",
"updateTake: (pageId: number, rowNum: number, fields: { weight?: number; since_date?: string; source?: string; }) => Promise<void>",
"updateTakeEmbeddings: (rowsIn: TakeEmbeddingInput[], opts?: BatchOpts) => Promise<number>",
- "upsertChunks: (slug: string, chunks: ChunkInput[], opts?: { sourceId?: string; embeddingColumn?: ResolvedColumn; expectedRevision?: string; } & BatchOpts) => Promise<void>",
+ "upsertChunks: (slug: string, chunks: ChunkInput[], opts?: { sourceId?: string; embeddingColumn?: ResolvedColumn; expectedRevision?: string; sealChunkerVersion?: number; } & BatchOpts) => Promise<void>",
"upsertEventProjection: (opts: { depthSlug: string; eventSlug: string; date: string; summary: string; detail?: string; sourceId?: string; }) => Promise<{ projected: boolean; }>",
"upsertFile: (spec: FileSpec) => Promise<{ id: number; created: boolean; }>",
"walRepairReceipt: WalRepairReceipt | null",