Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
large pages switch-on: projection batch seam fires before the batch is read; writer-gate test raises the floor past any placeholder
garrytana184c472241e
diff --git a/src/core/page-body/ingest.ts b/src/core/page-body/ingest.tsindex 97981d28ef..9268ac9014 100644--- a/src/core/page-body/ingest.ts+++ b/src/core/page-body/ingest.ts@@ -396,6 +396,7 @@ export async function stageOccurrenceChunks(engine: BrainEngine, input: { pageIdwhile (end < input.occurrences.length && (end === start || bytes + input.occurrences[end]!.byteLen <= batchBytes)) bytes += input.occurrences[end++]!.byteLen;const batch = input.occurrences.slice(start, end);start = end;+ if (input.guarded) await faultPoint('segmented:projection_batch', { sourceId: input.sourceId, slug: input.slug });const texts = await engine.readSegmentTexts(input.sourceId, batch.map(row => row.sha256));ledger ??= await readBodyLedger(engine, input.sourceId, input.slug);const segments = [];@@ -423,7 +424,6 @@ export async function stageOccurrenceChunks(engine: BrainEngine, input: { pageIdif (input.hold) input.hold.push(...chunks);else if (chunks.length && !input.guarded) indexes.push(...await engine.stageSegmentChunks(input.pageId, input.generation, chunks));let moved = false, lost = false;- if (chunks.length && input.guarded) await faultPoint('segmented:projection_batch', { sourceId: input.sourceId, slug: input.slug });if (chunks.length && input.guarded) rows -= chunks.length - await engine.transaction(async tx => {await tx.lockPageKeys([{ sourceId: input.sourceId, slug: input.slug }]);const [page] = await tx.executeRaw<{ body_generation: number | string }>('SELECT body_generation FROM pages WHERE id=$1', [input.pageId]);diff --git a/src/core/persistence/fault-points.ts b/src/core/persistence/fault-points.tsindex f3dbb3529c..bb90315c74 100644--- a/src/core/persistence/fault-points.ts+++ b/src/core/persistence/fault-points.ts@@ -43,8 +43,8 @@ export type FaultPoint = `publication:${PublicationBoundary}` | `effect:${Effect// bytes are written (before their journal step), after a --keep disk write is abandoned (its journal step written), and after recoverPublication returns.| 'stuck_recovery:backed_up' | 'stuck_recovery:written' | 'stuck_recovery:abandoned' | 'stuck_recovery:recovered'// Wave B segmented writes (spec 3.4 crash windows): after the texts, the staged manifest rows and the staged chunks of a- // preparation, after the generation flip (inside the publication transaction), before each chunk batch a projection inserts (its- // claim renewal and insert), and after a projection staged its chunks (before its seal).+ // preparation, after the generation flip (inside the publication transaction), before each chunk batch a projection reads (its segment+ // texts, then its claim renewal and insert), and after a projection staged its chunks (before its seal).| 'segmented:texts_staged' | 'segmented:manifest_staged' | 'segmented:chunks_staged' | 'segmented:flipped' | 'segmented:projection_batch'| 'segmented:projection_staged'// A prior file over the single-string ceiling copied to its before stage (large-file.ts `stageBeforeCopy`): after the copy isdiff --git a/test/large-pages/segmented-switch.test.ts b/test/large-pages/segmented-switch.test.tsindex d7fa7eb98d..f507b924cb 100644--- a/test/large-pages/segmented-switch.test.ts+++ b/test/large-pages/segmented-switch.test.ts@@ -179,7 +179,7 @@ for (const kind of testBackends()) {await heartbeat('marked-nonce', SEGMENTED_WRITER_FLOOR, true);expect(await seen()).toEqual([]);expect(await segmentedNow()).toBe(true);- const raised = '0.60.291.0';+ const raised = '99.0.0.0';expect(compareWriterVersions(SEGMENTED_WRITER_FLOOR, raised)).toBeLessThan(0);expect(await seen(raised)).toEqual([['importer', SEGMENTED_WRITER_FLOOR, true], ['resident', SEGMENTED_WRITER_FLOOR, true]]);