Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(conversation-facts): split the incremental and property arms into per-engine files that fit the e2e budget
garrytan514351c58155
diff --git a/scripts/stress/iteration-weights.json b/scripts/stress/iteration-weights.jsonindex 7abd6775cf..8a11cad77a 100644--- a/scripts/stress/iteration-weights.json+++ b/scripts/stress/iteration-weights.json@@ -24,7 +24,6 @@"test/doctor-slow-pass-6712.test.ts": 1900,"test/drift-watch.test.ts": 2700,"test/e2e/agent-journey-postgres.test.ts": 16400,- "test/e2e/conversation-facts-incremental-postgres.test.ts": 124750,"test/e2e/derivation-equivalence-postgres.test.ts": 33650,"test/e2e/derivation-purge-postgres.test.ts": 38500,"test/e2e/doctor-hot-checks-golden.test.ts": 13900,@@ -101,7 +100,6 @@"test/large-pages/append-cost.test.ts": 45200,"test/large-pages/append-mention-links.test.ts": 13750,"test/large-pages/contextual-reembed-segmented.test.ts": 7550,- "test/large-pages/conversation-facts-incremental.test.ts": 69550,"test/large-pages/derivation-equivalence.test.ts": 38550,"test/large-pages/derivation-purge.test.ts": 82050,"test/large-pages/edit-segmented.test.ts": 21100,diff --git a/test/e2e/conversation-facts-incremental-postgres.test.ts b/test/e2e/conversation-facts-incremental-core-postgres.test.tssimilarity index 55%rename from test/e2e/conversation-facts-incremental-postgres.test.tsrename to test/e2e/conversation-facts-incremental-core-postgres.test.tsindex 380fceba0a..706d28c16f 100644--- a/test/e2e/conversation-facts-incremental-postgres.test.ts+++ b/test/e2e/conversation-facts-incremental-core-postgres.test.ts@@ -1,18 +1,19 @@/**- * Incremental conversation facts on a segmented page, Postgres arm (wave-b spec 8.2, PR 4 lane 4b), including the- * facts.source_window double-encoding check (jsonb_typeof = 'object') PGLite can't catch. Cases:- * test/helpers/conversation-facts-incremental-cases.ts. PGLite arm: test/large-pages/conversation-facts-incremental.test.ts.+ * Incremental conversation facts on a segmented page, Postgres arm: append, retirement, cap, spend and unpriced-model+ * cases (wave-b spec 8.2, PR 4 lane 4b), including the facts.source_window double-encoding check (jsonb_typeof =+ * 'object') PGLite can't catch. Cases: test/helpers/conversation-facts-incremental-cases.ts,+ * test/helpers/derivation-spend-cases.ts, test/helpers/derivation-unpriced-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-incremental-core.test.ts. One of eight files per engine, split by topic so each+ * fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.*/import { afterAll, beforeAll, describe } from 'bun:test';import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsIncrementalCases, defineSegmentReceiptDoctorCases, defineSegmentedAtomsCases, defineSegmentedBackstopCases } from '../helpers/conversation-facts-incremental-cases.ts';import { defineDerivationSpendCases } from '../helpers/derivation-spend-cases.ts';-import { defineConversationFactsRecoveryCases } from '../helpers/conversation-facts-recovery-cases.ts';-import { defineConversationFactsInvariantCases } from '../helpers/conversation-facts-invariant-cases.ts';import { defineDerivationUnpricedCases } from '../helpers/derivation-unpriced-cases.ts';-import { defineConversationFactsIncrementalCases, defineSegmentedAtomsCases, defineSegmentedBackstopCases, defineSegmentReceiptDoctorCases } from '../helpers/conversation-facts-incremental-cases.ts';import { hasDatabase } from './helpers.ts';-(hasDatabase() ? describe : describe.skip)('conversation facts incremental [postgres]', () => {+(hasDatabase() ? describe : describe.skip)('conversation facts incremental, core [postgres]', () => {let brain: AppendBrain;beforeAll(async () => { brain = await openAppendBrain('postgres'); }, 120_000);afterAll(async () => { await brain.close(); }, 120_000);@@ -21,7 +22,5 @@ import { hasDatabase } from './helpers.ts';defineSegmentedAtomsCases({ getBrain: () => brain });defineSegmentReceiptDoctorCases({ getBrain: () => brain });defineDerivationSpendCases({ getBrain: () => brain });- defineConversationFactsRecoveryCases({ getBrain: () => brain });- defineConversationFactsInvariantCases({ getBrain: () => brain });defineDerivationUnpricedCases({ getBrain: () => brain });});diff --git a/test/e2e/conversation-facts-incremental-deletion-postgres.test.ts b/test/e2e/conversation-facts-incremental-deletion-postgres.test.tsnew file mode 100644index 0000000000..86fd5ce537--- /dev/null+++ b/test/e2e/conversation-facts-incremental-deletion-postgres.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, Postgres arm: the deletion invariant (F1, F2, F6, F9, N2) (wave-b+ * spec 8.2, PR 4 lane 4b), including the facts.source_window double-encoding check (jsonb_typeof = 'object') PGLite+ * can't catch. Cases: test/helpers/conversation-facts-invariant-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-incremental-deletion.test.ts. One of eight files per engine, split by topic so+ * each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsDeletionCases } from '../helpers/conversation-facts-invariant-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts incremental, deletion [postgres]', () => {+ let brain: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); }, 120_000);+ defineConversationFactsDeletionCases({ getBrain: () => brain });+});diff --git a/test/e2e/conversation-facts-incremental-grammar-choice-postgres.test.ts b/test/e2e/conversation-facts-incremental-grammar-choice-postgres.test.tsnew file mode 100644index 0000000000..2032aac77b--- /dev/null+++ b/test/e2e/conversation-facts-incremental-grammar-choice-postgres.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, Postgres arm: how long a --grammar choice lasts (wave-b spec 8.2,+ * PR 4 lane 4b), including the facts.source_window double-encoding check (jsonb_typeof = 'object') PGLite can't catch.+ * Cases: test/helpers/conversation-facts-invariant-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-incremental-grammar-choice.test.ts. One of eight files per engine, split by topic+ * so each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsGrammarChoiceCases } from '../helpers/conversation-facts-invariant-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts incremental, grammar-choice [postgres]', () => {+ let brain: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); }, 120_000);+ defineConversationFactsGrammarChoiceCases({ getBrain: () => brain });+});diff --git a/test/e2e/conversation-facts-incremental-grammar-flag-postgres.test.ts b/test/e2e/conversation-facts-incremental-grammar-flag-postgres.test.tsnew file mode 100644index 0000000000..ae688c7b61--- /dev/null+++ b/test/e2e/conversation-facts-incremental-grammar-flag-postgres.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, Postgres arm: the operator's --grammar (wave-b spec 8.2, PR 4+ * lane 4b), including the facts.source_window double-encoding check (jsonb_typeof = 'object') PGLite can't catch.+ * Cases: test/helpers/conversation-facts-invariant-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-incremental-grammar-flag.test.ts. One of eight files per engine, split by topic+ * so each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsGrammarFlagCases } from '../helpers/conversation-facts-invariant-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts incremental, grammar-flag [postgres]', () => {+ let brain: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); }, 120_000);+ defineConversationFactsGrammarFlagCases({ getBrain: () => brain });+});diff --git a/test/e2e/conversation-facts-incremental-grammar-postgres.test.ts b/test/e2e/conversation-facts-incremental-grammar-postgres.test.tsnew file mode 100644index 0000000000..f35466655b--- /dev/null+++ b/test/e2e/conversation-facts-incremental-grammar-postgres.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, Postgres arm: which grammar a run reads (F3, G1, p7, R3) (wave-b+ * spec 8.2, PR 4 lane 4b), including the facts.source_window double-encoding check (jsonb_typeof = 'object') PGLite+ * can't catch. Cases: test/helpers/conversation-facts-invariant-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-incremental-grammar.test.ts. One of eight files per engine, split by topic so+ * each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsGrammarCases } from '../helpers/conversation-facts-invariant-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts incremental, grammar [postgres]', () => {+ let brain: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); }, 120_000);+ defineConversationFactsGrammarCases({ getBrain: () => brain });+});diff --git a/test/e2e/conversation-facts-incremental-held-postgres.test.ts b/test/e2e/conversation-facts-incremental-held-postgres.test.tsnew file mode 100644index 0000000000..cad9a2b6d2--- /dev/null+++ b/test/e2e/conversation-facts-incremental-held-postgres.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, Postgres arm: held transcripts (N1, R4) (wave-b spec 8.2, PR 4+ * lane 4b), including the facts.source_window double-encoding check (jsonb_typeof = 'object') PGLite can't catch.+ * Cases: test/helpers/conversation-facts-invariant-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-incremental-held.test.ts. One of eight files per engine, split by topic so each+ * fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsHeldCases } from '../helpers/conversation-facts-invariant-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts incremental, held [postgres]', () => {+ let brain: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); }, 120_000);+ defineConversationFactsHeldCases({ getBrain: () => brain });+});diff --git a/test/e2e/conversation-facts-incremental-page-change-postgres.test.ts b/test/e2e/conversation-facts-incremental-page-change-postgres.test.tsnew file mode 100644index 0000000000..d6f3615734--- /dev/null+++ b/test/e2e/conversation-facts-incremental-page-change-postgres.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, Postgres arm: pages that change shape (wave-b spec 8.2, PR 4 lane+ * 4b), including the facts.source_window double-encoding check (jsonb_typeof = 'object') PGLite can't catch. Cases:+ * test/helpers/conversation-facts-recovery-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-incremental-page-change.test.ts. One of eight files per engine, split by topic so+ * each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPageChangeCases } from '../helpers/conversation-facts-recovery-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts incremental, page-change [postgres]', () => {+ let brain: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); }, 120_000);+ defineConversationFactsPageChangeCases({ getBrain: () => brain });+});diff --git a/test/e2e/conversation-facts-incremental-recovery-postgres.test.ts b/test/e2e/conversation-facts-incremental-recovery-postgres.test.tsnew file mode 100644index 0000000000..b74026b137--- /dev/null+++ b/test/e2e/conversation-facts-incremental-recovery-postgres.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, Postgres arm: partial runs, failed checkpoint writes and failing+ * windows (wave-b spec 8.2, PR 4 lane 4b), including the facts.source_window double-encoding check (jsonb_typeof =+ * 'object') PGLite can't catch. Cases: test/helpers/conversation-facts-recovery-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-incremental-recovery.test.ts. One of eight files per engine, split by topic so+ * each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsRecoveryCases } from '../helpers/conversation-facts-recovery-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts incremental, recovery [postgres]', () => {+ let brain: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); }, 120_000);+ defineConversationFactsRecoveryCases({ getBrain: () => brain });+});diff --git a/test/e2e/conversation-facts-property-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-01-03-postgres.test.tssimilarity index 71%rename from test/e2e/conversation-facts-property-postgres.test.tsrename to test/e2e/conversation-facts-property-seeds-01-03-postgres.test.tsindex 1833800c15..a0e5cb2ff9 100644--- a/test/e2e/conversation-facts-property-postgres.test.ts+++ b/test/e2e/conversation-facts-property-seeds-01-03-postgres.test.ts@@ -1,16 +1,17 @@/**- * Seeded property test of the conversation facts deletion invariant, Postgres arm (PR 4 lane 4b round 5). Cases:- * test/helpers/conversation-facts-property-cases.ts. PGLite arm: test/large-pages/conversation-facts-property.test.ts.+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 1 to 3 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-01-03.test.ts.*/import { afterAll, beforeAll, describe } from 'bun:test';import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';import { hasDatabase } from './helpers.ts';-(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant [postgres]', () => {+(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 1 to 3 [postgres]', () => {let brain: AppendBrain;let fresh: AppendBrain;beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);- defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh });+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 1 });});diff --git a/test/e2e/conversation-facts-property-seeds-04-06-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-04-06-postgres.test.tsnew file mode 100644index 0000000000..83add52a23--- /dev/null+++ b/test/e2e/conversation-facts-property-seeds-04-06-postgres.test.ts@@ -0,0 +1,17 @@+/**+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 4 to 6 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-04-06.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 4 to 6 [postgres]', () => {+ let brain: AppendBrain;+ let fresh: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 4 });+});diff --git a/test/e2e/conversation-facts-property-seeds-07-09-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-07-09-postgres.test.tsnew file mode 100644index 0000000000..aba3a3ef9a--- /dev/null+++ b/test/e2e/conversation-facts-property-seeds-07-09-postgres.test.ts@@ -0,0 +1,17 @@+/**+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 7 to 9 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-07-09.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 7 to 9 [postgres]', () => {+ let brain: AppendBrain;+ let fresh: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 7 });+});diff --git a/test/e2e/conversation-facts-property-seeds-10-12-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-10-12-postgres.test.tsnew file mode 100644index 0000000000..6d855feecd--- /dev/null+++ b/test/e2e/conversation-facts-property-seeds-10-12-postgres.test.ts@@ -0,0 +1,17 @@+/**+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 10 to 12 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-10-12.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 10 to 12 [postgres]', () => {+ let brain: AppendBrain;+ let fresh: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 10 });+});diff --git a/test/e2e/conversation-facts-property-seeds-13-15-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-13-15-postgres.test.tsnew file mode 100644index 0000000000..1bb1b03577--- /dev/null+++ b/test/e2e/conversation-facts-property-seeds-13-15-postgres.test.ts@@ -0,0 +1,17 @@+/**+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 13 to 15 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-13-15.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 13 to 15 [postgres]', () => {+ let brain: AppendBrain;+ let fresh: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 13 });+});diff --git a/test/e2e/conversation-facts-property-seeds-16-18-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-16-18-postgres.test.tsnew file mode 100644index 0000000000..de78852b98--- /dev/null+++ b/test/e2e/conversation-facts-property-seeds-16-18-postgres.test.ts@@ -0,0 +1,17 @@+/**+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 16 to 18 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-16-18.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 16 to 18 [postgres]', () => {+ let brain: AppendBrain;+ let fresh: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 16 });+});diff --git a/test/e2e/conversation-facts-property-seeds-19-21-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-19-21-postgres.test.tsnew file mode 100644index 0000000000..e13a140944--- /dev/null+++ b/test/e2e/conversation-facts-property-seeds-19-21-postgres.test.ts@@ -0,0 +1,17 @@+/**+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 19 to 21 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-19-21.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 19 to 21 [postgres]', () => {+ let brain: AppendBrain;+ let fresh: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 19 });+});diff --git a/test/e2e/conversation-facts-property-seeds-22-24-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-22-24-postgres.test.tsnew file mode 100644index 0000000000..e6c5417a06--- /dev/null+++ b/test/e2e/conversation-facts-property-seeds-22-24-postgres.test.ts@@ -0,0 +1,17 @@+/**+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 22 to 24 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-22-24.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 22 to 24 [postgres]', () => {+ let brain: AppendBrain;+ let fresh: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 22 });+});diff --git a/test/e2e/conversation-facts-property-seeds-25-27-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-25-27-postgres.test.tsnew file mode 100644index 0000000000..a70a58a7a7--- /dev/null+++ b/test/e2e/conversation-facts-property-seeds-25-27-postgres.test.ts@@ -0,0 +1,17 @@+/**+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 25 to 27 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-25-27.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 25 to 27 [postgres]', () => {+ let brain: AppendBrain;+ let fresh: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 25 });+});diff --git a/test/e2e/conversation-facts-property-seeds-28-30-postgres.test.ts b/test/e2e/conversation-facts-property-seeds-28-30-postgres.test.tsnew file mode 100644index 0000000000..2c85bcd2af--- /dev/null+++ b/test/e2e/conversation-facts-property-seeds-28-30-postgres.test.ts@@ -0,0 +1,17 @@+/**+ * Seeded property test of the conversation facts deletion invariant, Postgres arm, seeds 28 to 30 (PR 4 lane 4b round+ * 5). Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. PGLite arm:+ * test/large-pages/conversation-facts-property-seeds-28-30.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';+import { hasDatabase } from './helpers.ts';++(hasDatabase() ? describe : describe.skip)('conversation facts deletion invariant, seeds 28 to 30 [postgres]', () => {+ let brain: AppendBrain;+ let fresh: AppendBrain;+ beforeAll(async () => { brain = await openAppendBrain('postgres'); fresh = await openAppendBrain('postgres'); }, 120_000);+ afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 28 });+});diff --git a/test/helpers/conversation-facts-incremental-cases.ts b/test/helpers/conversation-facts-incremental-cases.tsindex c2626ddf5f..00ff02ff81 100644--- a/test/helpers/conversation-facts-incremental-cases.ts+++ b/test/helpers/conversation-facts-incremental-cases.ts@@ -1,7 +1,7 @@/*** Incremental conversation facts on a segmented page (wave-b spec 8.2 "Conversation facts", PR 4 lane 4b), shared by- * the PGLite arm (test/large-pages/conversation-facts-incremental.test.ts) and the Postgres arm- * (test/e2e/conversation-facts-incremental-postgres.test.ts). A fake extractor counts calls by window text; no model+ * the PGLite arm (test/large-pages/conversation-facts-incremental-core.test.ts) and the Postgres arm+ * (test/e2e/conversation-facts-incremental-core-postgres.test.ts). A fake extractor counts calls by window text; no model* is called. Spend is metered (meterPaidCall, the facts ledger); the cap case's fake extractor calls the gateway, whose* fake transport reports token usage on a priced model, so its windows cost what that usage costs.*diff --git a/test/helpers/conversation-facts-invariant-cases.ts b/test/helpers/conversation-facts-invariant-cases.tsindex be367128ba..5954fe49d5 100644--- a/test/helpers/conversation-facts-invariant-cases.ts+++ b/test/helpers/conversation-facts-invariant-cases.ts@@ -1,7 +1,7 @@/*** Conversation facts deletion invariant on a segmented page (wave-b spec 8.2; PR 4 lane 4b round 5), shared by the PGLite- * arm (test/large-pages/conversation-facts-incremental.test.ts) and the Postgres arm- * (test/e2e/conversation-facts-incremental-postgres.test.ts). Fake extractors only; appends go through the remote+ * arms (test/large-pages/conversation-facts-incremental-{deletion,held,grammar,grammar-flag,grammar-choice}.test.ts) and+ * the Postgres arms (test/e2e/conversation-facts-incremental-<same>-postgres.test.ts). Fake extractors only; appends go through the remote* append_page operation (remote=true).** 1. Protects: a partial run only adds and replaces facts per window key, and a row claims exactly the facts it holds:@@ -55,7 +55,60 @@ const sparseTranscript = (count: number, notes: number) => Array.from({ length:...Array.from({ length: notes }, (_, j) => `note ${j} of item ${t} on the roadmap review`)].join('\n')).join('\n\n');const references = (count: number) => Array.from({ length: count }, (_, i) => `Reference ${i}: the roadmap review moved to next quarter and the budget stays flat.`).join('\n\n');-export function defineConversationFactsInvariantCases(opts: { getBrain: () => AppendBrain }): void {+/** Three runs (two plain, one --force) on a page whose grammar is no longer detected: what each reported and left. */+const lostGrammarRuns = async (brain: AppendBrain, slug: string) => {+ const out: Array<Record<string, unknown>> = [];+ for (const force of [false, false, true]) {+ const { calls, result } = await extract(brain.engine, slug, { force });+ const rows = await derivations(brain.engine, slug);+ out.push({ calls: calls.length, failed: result.pages_failed, held: result.pages_detection_ambiguous ?? 0, nonExtractable: result.pages_marked_non_extractable,+ facts: (await factsOf(brain.engine, slug)).length, windows: rows.keys.length, mismatches: (await claimMismatches(brain.engine, slug)).length });+ }+ return out;+};+const undetected = async (brain: AppendBrain, slug: string) => {+ const page = (await brain.engine.getPage(slug, { sourceId: 'default' }))!;+ return parser.parseConversation((await brain.body(slug)).truth, { page }).matched_pattern_id ?? null;+};+/** A held run: no call, no failure, nothing added or removed. */+const heldRun = (facts: number, windows: number) => ({ calls: 0, failed: 0, held: 1, nonExtractable: 0, facts, windows, mismatches: 0 });+/** Every conversation_facts row of the page, as it stands. */+const rowState = async (brain: AppendBrain, slug: string) => JSON.stringify((await derivations(brain.engine, slug)).rows.map(row => [row.occurrenceId, row.output, row.state, row.receipt]));+/** What doctor reports: the held pages with each format's count, and whether extraction_input_truncated (the spend-cap remedy) names anything. */+const heldPages = async (brain: AppendBrain) => {+ const checks = await extractionInputTruncatedEntry.run({ engine: brain.engine } as unknown as DoctorContext) as Check[];+ const held = checks.find(c => c.name === 'conversation_detection_ambiguous')!;+ return { status: held.status, samples: ((held.details as { samples?: Array<{ page: string; grammars: Record<string, number> }> } | undefined)?.samples ?? []),+ fix: held.fix?.argv ?? null, truncated: JSON.stringify(checks.find(c => c.name === 'extraction_input_truncated')?.details ?? {}) };+};++/**+ * A page whose rows record two formats, with none detected over it (round-8 review P1 and P2): a bold-name transcript+ * extracted in full, then a plain-role one extracted one window (its rows record plain-role, the rest bold-name), then+ * reference prose, the plain-role transcript and a section quoting `quotes` short bold-name turns under a new title.+ */+const mixedFormats = async (brain: AppendBrain, slug: string, quotes: number) => {+ await caps(brain.engine, 'off');+ const old = Array.from({ length: 100 }, (_, i) => `**${i % 2 ? 'Bob Example' : 'Alice Example'}:** old turn ${i} ${'detail '.repeat(1600)}`).join('\n');+ await brain.seed(slug, chatPage('Old transcript', old));+ await extract(brain.engine, slug);+ const current = Array.from({ length: 200 }, (_, i) => `${i % 2 ? 'Assistant' : 'User'}: current turn ${i} ${'present '.repeat(700)}`).join('\n');+ await brain.seed(slug, chatPage('Current transcript', current));+ await extract(brain.engine, slug, { segmentLimit: 1 });+ expect(await recordedGrammars(brain, slug)).toEqual(['bold-name-no-time', 'plain-role-no-time']);+ const quoted = Array.from({ length: quotes }, (_, i) => `**${i % 2 ? 'Bob Example' : 'Alice Example'}:** quoted historical turn ${i}.`).join('\n');+ const prose = Array.from({ length: 12_000 }, (_, i) => `Reference paragraph ${i} explains the migration.`).join('\n');+ await brain.seed(slug, chatPage('Combined transcript archive', `${prose}\n${current}\n## Quoted historical transcript\n${quoted}`));+ expect(await undetected(brain, slug)).toBeNull();+ return { prose, current, quoted };+};+const recordedGrammars = async (brain: AppendBrain, slug: string) =>+ [...new Set((await derivations(brain.engine, slug)).rows.map(row => (row.output as { pattern?: string | null }).pattern ?? null))].sort();+/** The plain-role turns the run's windows carry. */+const turnsIn = (calls: string[]) => new Set(calls.flatMap(text => [...text.matchAll(/current turn (\d+) /g)].map(m => m[1]))).size;++/** Deletion only by exact-key replacement or a settled collection: F1, F2, F6, F9 and N2. */+export function defineConversationFactsDeletionCases(opts: { getBrain: () => AppendBrain }): void {test('F1: two interrupted runs after an append lose no fact and leave every row claiming exactly the facts it holds', async () => {const brain = opts.getBrain();const slug = `notes/interrupted-moves-${randomUUID().slice(0, 8)}`;@@ -141,49 +194,46 @@ export function defineConversationFactsInvariantCases(opts: { getBrain: () => Ap.toEqual({ calls: 1, facts: before.length + 1, lost: 0, cleaned: 0 });}, 600_000);- test('F3: the grammar is the whole page\'s, not its head\'s; the detection read is counted once, and a run on a pinned grammar reads none', async () => {- const brain = opts.getBrain();- const slug = `notes/preamble-${randomUUID().slice(0, 8)}`;- await caps(brain.engine, 'off');- const preamble = Array.from({ length: 4000 }, (_, i) => (i % 4 === 3 ? 'User: a line of the preamble' : `Notes line ${i} about the roadmap review.`)).join('\n');- await brain.seed(slug, chatPage('Preamble', `${preamble}\n\n${chatDays(4200, 100, 35)}`));- const page = (await brain.engine.getPage(slug, { sourceId: 'default' }))!;- const truth = (await brain.body(slug)).truth;- expect(parser.parseConversation(truth.slice(0, 64 * 1024), { page }).matched_pattern_id).toBe('plain-role-no-time');- expect(parser.parseConversation(truth, { page }).matched_pattern_id).toBe('bold-paren-time-12h');- const expected = splitIntoSegments(parser.parseConversation(truth, { page }).messages, { pageTitle: 'Preamble' }).map(seg => renderSegmentForExtraction('Preamble', seg));- const detected = conversationDetectionWork.bytes;- const { calls } = await extract(brain.engine, slug, { segmentLimit: 5 });- const read = conversationDetectionWork.bytes - detected;- const rest = await extract(brain.engine, slug);- const all = [...calls, ...rest.calls];- expect({ read, again: conversationDetectionWork.bytes - detected - read, same: [...all].sort().join('\n') === [...expected].sort().join('\n') })- .toEqual({ read: Buffer.byteLength(truth), again: 0, same: true });- }, 600_000);-- test('a page that reads as a transcript yet parses no message changes nothing and leaves a no_messages receipt doctor lists', async () => {+ test('N2: an append_page that commits right after the old version check (before the publication locks the page) leaves the run unsettled with its facts kept; the next run settles it', async () => {const brain = opts.getBrain();- const slug = `notes/parser-fault-${randomUUID().slice(0, 8)}`;+ const slug = `notes/concurrent-append-${randomUUID().slice(0, 8)}`;await caps(brain.engine, 'off');- await brain.seed(slug, chatPage('Parser fault', chatDays(4300, 100, 36)));+ await brain.seed(slug, chatPage('Concurrent append', chatDays(4400, 100, 37)));await extract(brain.engine, slug);+ // Two new days: one or two new windows, fewer than a checkpoint, so the only publication after them is the final one.+ expect(await brain.call('append_page', { slug, text: chatDays(4500, 2, 37), request_id: randomUUID() }, { remote: true })).toMatchObject({ isError: false });const before = (await factsOf(brain.engine, slug)).map(f => f.id);- await brain.seed(slug, chatPage('Parser fault', Array.from({ length: 8000 }, (_, i) => `Paragraph ${i} of the notes: the roadmap review moved to next quarter and the budget stays flat.`).join('\n\n')));- // A detector fault: it reports a transcript format the page's text does not hold.- const spy = spyOn(parser, 'createPatternDetector').mockImplementation(() => ({ push() {}, finish: () => 'bold-paren-time-12h' }));+ let armed = false;+ let injected = 0;+ const transaction = brain.engine.transaction;+ // The outermost transaction the publication opens (a transaction engine inherits the spy; its nested calls are skipped).+ const spy = spyOn(brain.engine, 'transaction').mockImplementation((async function (this: BrainEngine, ...args: Parameters<BrainEngine['transaction']>) {+ if (armed && this === brain.engine && (new Error().stack ?? '').includes('maintenanceTransaction')) {+ armed = false;+ injected++;+ expect(await brain.call('append_page', { slug, text: chatDays(4502, 1, 37), request_id: randomUUID() }, { remote: true })).toMatchObject({ isError: false });+ }+ return transaction.apply(this, args);+ }) as typeof brain.engine.transaction);+ let run: Awaited<ReturnType<typeof extract>>;try {- const { calls, result } = await extract(brain.engine, slug);- expect({ calls: calls.length, failed: result.pages_failed, nonExtractable: result.pages_marked_non_extractable, cleaned: result.orphan_facts_cleaned,- facts: (await factsOf(brain.engine, slug)).map(f => f.id) }).toEqual({ calls: 0, failed: 1, nonExtractable: 0, cleaned: 0, facts: before });+ run = await extract(brain.engine, slug, { failOn: () => { armed = true; return false; } });} finally {spy.mockRestore();}- const check = (await extractionInputTruncatedEntry.run({ engine: brain.engine } as unknown as DoctorContext) as Check[]).find(c => c.name === 'extraction_input_truncated')!;- const groups = (check.details as { groups: Array<{ pipeline: string; kind: string; samples: string[]; remedy: string | null }> }).groups;- const group = groups.find(g => g.pipeline === 'conversation_facts' && g.kind === 'no_messages');- expect({ listed: group?.samples.includes(`default:${slug}`), fault: group?.remedy?.includes('parser fault') }).toEqual({ listed: true, fault: true });+ const kept = await factsOf(brain.engine, slug);+ expect({ injected, calls: run.calls.length > 0, failed: run.result.pages_failed, processed: run.result.pages_processed, cleaned: run.result.orphan_facts_cleaned,+ lost: before.filter(id => !kept.some(f => f.id === id)).length, reason: run.result.failed_pages[0]?.error ?? null })+ .toEqual({ injected: 1, calls: true, failed: 1, processed: 0, cleaned: 0, lost: 0, reason: 'the page changed during extraction; left unfinished for replay' });+ const next = await extract(brain.engine, slug);+ const rows = await derivations(brain.engine, slug);+ expect({ calls: next.calls.length > 0, processed: next.result.pages_processed, mismatches: await claimMismatches(brain.engine, slug), states: [...new Set(rows.states)],+ facts: (await factsOf(brain.engine, slug)).length }).toEqual({ calls: true, processed: 1, mismatches: [], states: ['done'], facts: rows.keys.length });}, 600_000);+}+/** A transcript whose format the whole page no longer shows is held while a message still parses: N1, R4 and the held-page reuse. */+export function defineConversationFactsHeldCases(opts: { getBrain: () => AppendBrain }): void {test('N1: a transcript whose format the whole page no longer shows (references added, title changed) is held: no call, every fact and row kept, --force too, and doctor lists it with its format\'s count', async () => {const brain = opts.getBrain();const slug = `notes/grammar-lost-${randomUUID().slice(0, 8)}`;@@ -208,33 +258,6 @@ export function defineConversationFactsInvariantCases(opts: { getBrain: () => Ap.toEqual({ runs: [run, run], status: 'warn', listed: { 'bold-name-no-time': 3000 }, truncated: false });}, 600_000);- /** Three runs (two plain, one --force) on a page whose grammar is no longer detected: what each reported and left. */- const lostGrammarRuns = async (brain: AppendBrain, slug: string) => {- const out: Array<Record<string, unknown>> = [];- for (const force of [false, false, true]) {- const { calls, result } = await extract(brain.engine, slug, { force });- const rows = await derivations(brain.engine, slug);- out.push({ calls: calls.length, failed: result.pages_failed, held: result.pages_detection_ambiguous ?? 0, nonExtractable: result.pages_marked_non_extractable,- facts: (await factsOf(brain.engine, slug)).length, windows: rows.keys.length, mismatches: (await claimMismatches(brain.engine, slug)).length });- }- return out;- };- const undetected = async (brain: AppendBrain, slug: string) => {- const page = (await brain.engine.getPage(slug, { sourceId: 'default' }))!;- return parser.parseConversation((await brain.body(slug)).truth, { page }).matched_pattern_id ?? null;- };- /** A held run: no call, no failure, nothing added or removed. */- const heldRun = (facts: number, windows: number) => ({ calls: 0, failed: 0, held: 1, nonExtractable: 0, facts, windows, mismatches: 0 });- /** Every conversation_facts row of the page, as it stands. */- const rowState = async (brain: AppendBrain, slug: string) => JSON.stringify((await derivations(brain.engine, slug)).rows.map(row => [row.occurrenceId, row.output, row.state, row.receipt]));- /** What doctor reports: the held pages with each format's count, and whether extraction_input_truncated (the spend-cap remedy) names anything. */- const heldPages = async (brain: AppendBrain) => {- const checks = await extractionInputTruncatedEntry.run({ engine: brain.engine } as unknown as DoctorContext) as Check[];- const held = checks.find(c => c.name === 'conversation_detection_ambiguous')!;- return { status: held.status, samples: ((held.details as { samples?: Array<{ page: string; grammars: Record<string, number> }> } | undefined)?.samples ?? []),- fix: held.fix?.argv ?? null, truncated: JSON.stringify(checks.find(c => c.name === 'extraction_input_truncated')?.details ?? {}) };- };-test('R4 (case A): a transcript rewritten to prose that keeps one or three quoted message lines is held every run, --force too: its facts wait for the operator\'s call', async () => {const brain = opts.getBrain();const out: Record<string, unknown> = {};@@ -300,31 +323,52 @@ export function defineConversationFactsInvariantCases(opts: { getBrain: () => Apconst held = [heldRun(facts, windows), heldRun(facts, windows), heldRun(facts, windows)];expect({ added, heading }).toEqual({ added: held, heading: held });}, 600_000);+}- /**- * A page whose rows record two formats, with none detected over it (round-8 review P1 and P2): a bold-name transcript- * extracted in full, then a plain-role one extracted one window (its rows record plain-role, the rest bold-name), then- * reference prose, the plain-role transcript and a section quoting `quotes` short bold-name turns under a new title.- */- const mixedFormats = async (brain: AppendBrain, slug: string, quotes: number) => {+/** Which grammar a run reads: the whole page (F3), no_messages, two recorded formats (G1), p7 and pages with no format (R3). */+export function defineConversationFactsGrammarCases(opts: { getBrain: () => AppendBrain }): void {+ test('F3: the grammar is the whole page\'s, not its head\'s; the detection read is counted once, and a run on a pinned grammar reads none', async () => {+ const brain = opts.getBrain();+ const slug = `notes/preamble-${randomUUID().slice(0, 8)}`;await caps(brain.engine, 'off');- const old = Array.from({ length: 100 }, (_, i) => `**${i % 2 ? 'Bob Example' : 'Alice Example'}:** old turn ${i} ${'detail '.repeat(1600)}`).join('\n');- await brain.seed(slug, chatPage('Old transcript', old));+ const preamble = Array.from({ length: 4000 }, (_, i) => (i % 4 === 3 ? 'User: a line of the preamble' : `Notes line ${i} about the roadmap review.`)).join('\n');+ await brain.seed(slug, chatPage('Preamble', `${preamble}\n\n${chatDays(4200, 100, 35)}`));+ const page = (await brain.engine.getPage(slug, { sourceId: 'default' }))!;+ const truth = (await brain.body(slug)).truth;+ expect(parser.parseConversation(truth.slice(0, 64 * 1024), { page }).matched_pattern_id).toBe('plain-role-no-time');+ expect(parser.parseConversation(truth, { page }).matched_pattern_id).toBe('bold-paren-time-12h');+ const expected = splitIntoSegments(parser.parseConversation(truth, { page }).messages, { pageTitle: 'Preamble' }).map(seg => renderSegmentForExtraction('Preamble', seg));+ const detected = conversationDetectionWork.bytes;+ const { calls } = await extract(brain.engine, slug, { segmentLimit: 5 });+ const read = conversationDetectionWork.bytes - detected;+ const rest = await extract(brain.engine, slug);+ const all = [...calls, ...rest.calls];+ expect({ read, again: conversationDetectionWork.bytes - detected - read, same: [...all].sort().join('\n') === [...expected].sort().join('\n') })+ .toEqual({ read: Buffer.byteLength(truth), again: 0, same: true });+ }, 600_000);++ test('a page that reads as a transcript yet parses no message changes nothing and leaves a no_messages receipt doctor lists', async () => {+ const brain = opts.getBrain();+ const slug = `notes/parser-fault-${randomUUID().slice(0, 8)}`;+ await caps(brain.engine, 'off');+ await brain.seed(slug, chatPage('Parser fault', chatDays(4300, 100, 36)));await extract(brain.engine, slug);- const current = Array.from({ length: 200 }, (_, i) => `${i % 2 ? 'Assistant' : 'User'}: current turn ${i} ${'present '.repeat(700)}`).join('\n');- await brain.seed(slug, chatPage('Current transcript', current));- await extract(brain.engine, slug, { segmentLimit: 1 });- expect(await recordedGrammars(brain, slug)).toEqual(['bold-name-no-time', 'plain-role-no-time']);- const quoted = Array.from({ length: quotes }, (_, i) => `**${i % 2 ? 'Bob Example' : 'Alice Example'}:** quoted historical turn ${i}.`).join('\n');- const prose = Array.from({ length: 12_000 }, (_, i) => `Reference paragraph ${i} explains the migration.`).join('\n');- await brain.seed(slug, chatPage('Combined transcript archive', `${prose}\n${current}\n## Quoted historical transcript\n${quoted}`));- expect(await undetected(brain, slug)).toBeNull();- return { prose, current, quoted };- };- const recordedGrammars = async (brain: AppendBrain, slug: string) =>- [...new Set((await derivations(brain.engine, slug)).rows.map(row => (row.output as { pattern?: string | null }).pattern ?? null))].sort();- /** The plain-role turns the run's windows carry. */- const turnsIn = (calls: string[]) => new Set(calls.flatMap(text => [...text.matchAll(/current turn (\d+) /g)].map(m => m[1]))).size;+ const before = (await factsOf(brain.engine, slug)).map(f => f.id);+ await brain.seed(slug, chatPage('Parser fault', Array.from({ length: 8000 }, (_, i) => `Paragraph ${i} of the notes: the roadmap review moved to next quarter and the budget stays flat.`).join('\n\n')));+ // A detector fault: it reports a transcript format the page's text does not hold.+ const spy = spyOn(parser, 'createPatternDetector').mockImplementation(() => ({ push() {}, finish: () => 'bold-paren-time-12h' }));+ try {+ const { calls, result } = await extract(brain.engine, slug);+ expect({ calls: calls.length, failed: result.pages_failed, nonExtractable: result.pages_marked_non_extractable, cleaned: result.orphan_facts_cleaned,+ facts: (await factsOf(brain.engine, slug)).map(f => f.id) }).toEqual({ calls: 0, failed: 1, nonExtractable: 0, cleaned: 0, facts: before });+ } finally {+ spy.mockRestore();+ }+ const check = (await extractionInputTruncatedEntry.run({ engine: brain.engine } as unknown as DoctorContext) as Check[]).find(c => c.name === 'extraction_input_truncated')!;+ const groups = (check.details as { groups: Array<{ pipeline: string; kind: string; samples: string[]; remedy: string | null }> }).groups;+ const group = groups.find(g => g.pipeline === 'conversation_facts' && g.kind === 'no_messages');+ expect({ listed: group?.samples.includes(`default:${slug}`), fault: group?.remedy?.includes('parser fault') }).toEqual({ listed: true, fault: true });+ }, 600_000);test('G1 (round-8 P1, P2): with two recorded formats and none detected, a current transcript beside 2, 250 or 600 quoted turns of the old format is held: no call, every fact and row kept, --force too, never a failed page, and doctor lists it with each format\'s count instead of a spend cap', async () => {const brain = opts.getBrain();@@ -373,6 +417,47 @@ export function defineConversationFactsInvariantCases(opts: { getBrain: () => Ap.toEqual({ runs: [run, run, run], listed: { 'plain-role-no-time': 100, 'bold-name-no-time': 100 } });}, 600_000);+ test('R3 (cases C, C2): a page turned to pure prose whose facts have no recorded grammar (rows without one, or no rows at all) is non-extractable and its facts are collected, --force too', async () => {+ const brain = opts.getBrain();+ const out: Record<string, unknown> = {};+ for (const shape of ['rows without a grammar', 'no rows'] as const) {+ const slug = `notes/no-grammar-${randomUUID().slice(0, 8)}`;+ await caps(brain.engine, 'off');+ await brain.seed(slug, chatPage('Was a chat', chatDays(4700, 100, 39)));+ await extract(brain.engine, slug);+ const { pageId } = await derivations(brain.engine, slug);+ if (shape === 'no rows') await brain.engine.executeRaw("DELETE FROM page_segment_derivations WHERE page_id = $1 AND pipeline = 'conversation_facts'", [pageId]);+ else await brain.engine.executeRaw("UPDATE page_segment_derivations SET output = output - 'pattern' WHERE page_id = $1 AND pipeline = 'conversation_facts'", [pageId]);+ const before = (await factsOf(brain.engine, slug)).length;+ await brain.seed(slug, chatPage('Was a chat', references(9000)));+ expect(await undetected(brain, slug)).toBeNull();+ out[shape] = { before: before > 100, runs: await lostGrammarRuns(brain, slug) };+ }+ const collected = { calls: 0, failed: 0, held: 0, nonExtractable: 1, facts: 0, windows: 0, mismatches: 0 };+ const settled = { ...collected, nonExtractable: 0 };+ expect(out).toEqual({ 'rows without a grammar': { before: true, runs: [collected, settled, collected] }, 'no rows': { before: true, runs: [collected, settled, collected] } });+ }, 600_000);++ test('R3 (legacy): facts the inline extractor left on a small transcript are collected once the page is segmented prose, --force too', async () => {+ const brain = opts.getBrain();+ const slug = `notes/former-conversation-${randomUUID().slice(0, 8)}`;+ await caps(brain.engine, 'off');+ await brain.seed(slug, chatPage('Former conversation', 'user: The fixture door code was 8844.\nassistant: Noted the fixture door code.\n'));+ await extract(brain.engine, slug);+ expect((await factsOf(brain.engine, slug)).length).toBe(1);+ await brain.seed(slug, chatPage('Former conversation', 'Ordinary reference prose with no speaker labels or message lines.\n'.repeat(18_000)));+ expect((await brain.body(slug)).storage).toBe('segmented');+ const runs = [];+ for (const force of [false, true]) {+ const { result } = await extract(brain.engine, slug, { force });+ runs.push({ failed: result.pages_failed, nonExtractable: result.pages_marked_non_extractable, facts: (await factsOf(brain.engine, slug)).length });+ }+ expect(runs).toEqual([{ failed: 0, nonExtractable: 1, facts: 0 }, { failed: 0, nonExtractable: 1, facts: 0 }]);+ }, 600_000);+}++/** The operator's --grammar on a held page: --dry-run, the run, and the one-page rule. */+export function defineConversationFactsGrammarFlagCases(opts: { getBrain: () => AppendBrain }): void {test('--grammar on a held page: --dry-run previews what a run under the format extracts and removes and changes nothing; the run does exactly that, later plain runs follow the choice until the page changes, and none settles a page as no transcript', async () => {const brain = opts.getBrain();const slug = `notes/operator-format-${randomUUID().slice(0, 8)}`;@@ -463,7 +548,10 @@ export function defineConversationFactsInvariantCases(opts: { getBrain: () => Apsingle: { error: null, preview: true },});}, 600_000);+}+/** How long an operator's format choice lasts: one page version, and a detected format after it streams from the head. */+export function defineConversationFactsGrammarChoiceCases(opts: { getBrain: () => AppendBrain }): void {test('a choice holds only for the page version it was made for: after an append the chosen rows do not pin their format, so a page still undetected is held with every fact kept', async () => {const brain = opts.getBrain();const slug = `notes/choice-version-${randomUUID().slice(0, 8)}`;@@ -517,79 +605,4 @@ export function defineConversationFactsInvariantCases(opts: { getBrain: () => Apmismatches: await claimMismatches(brain.engine, slug) }).toEqual({ failed: 0, held: 0, facts: fresh.length, same: true, stale: 0, forcedCalls: 0, forcedSame: true, grammars: ['plain-role-no-time'], chosenRows: 0, mismatches: [] });}, 600_000);-- test('R3 (cases C, C2): a page turned to pure prose whose facts have no recorded grammar (rows without one, or no rows at all) is non-extractable and its facts are collected, --force too', async () => {- const brain = opts.getBrain();- const out: Record<string, unknown> = {};- for (const shape of ['rows without a grammar', 'no rows'] as const) {- const slug = `notes/no-grammar-${randomUUID().slice(0, 8)}`;- await caps(brain.engine, 'off');- await brain.seed(slug, chatPage('Was a chat', chatDays(4700, 100, 39)));- await extract(brain.engine, slug);- const { pageId } = await derivations(brain.engine, slug);- if (shape === 'no rows') await brain.engine.executeRaw("DELETE FROM page_segment_derivations WHERE page_id = $1 AND pipeline = 'conversation_facts'", [pageId]);- else await brain.engine.executeRaw("UPDATE page_segment_derivations SET output = output - 'pattern' WHERE page_id = $1 AND pipeline = 'conversation_facts'", [pageId]);- const before = (await factsOf(brain.engine, slug)).length;- await brain.seed(slug, chatPage('Was a chat', references(9000)));- expect(await undetected(brain, slug)).toBeNull();- out[shape] = { before: before > 100, runs: await lostGrammarRuns(brain, slug) };- }- const collected = { calls: 0, failed: 0, held: 0, nonExtractable: 1, facts: 0, windows: 0, mismatches: 0 };- const settled = { ...collected, nonExtractable: 0 };- expect(out).toEqual({ 'rows without a grammar': { before: true, runs: [collected, settled, collected] }, 'no rows': { before: true, runs: [collected, settled, collected] } });- }, 600_000);-- test('R3 (legacy): facts the inline extractor left on a small transcript are collected once the page is segmented prose, --force too', async () => {- const brain = opts.getBrain();- const slug = `notes/former-conversation-${randomUUID().slice(0, 8)}`;- await caps(brain.engine, 'off');- await brain.seed(slug, chatPage('Former conversation', 'user: The fixture door code was 8844.\nassistant: Noted the fixture door code.\n'));- await extract(brain.engine, slug);- expect((await factsOf(brain.engine, slug)).length).toBe(1);- await brain.seed(slug, chatPage('Former conversation', 'Ordinary reference prose with no speaker labels or message lines.\n'.repeat(18_000)));- expect((await brain.body(slug)).storage).toBe('segmented');- const runs = [];- for (const force of [false, true]) {- const { result } = await extract(brain.engine, slug, { force });- runs.push({ failed: result.pages_failed, nonExtractable: result.pages_marked_non_extractable, facts: (await factsOf(brain.engine, slug)).length });- }- expect(runs).toEqual([{ failed: 0, nonExtractable: 1, facts: 0 }, { failed: 0, nonExtractable: 1, facts: 0 }]);- }, 600_000);-- test('N2: an append_page that commits right after the old version check (before the publication locks the page) leaves the run unsettled with its facts kept; the next run settles it', async () => {- const brain = opts.getBrain();- const slug = `notes/concurrent-append-${randomUUID().slice(0, 8)}`;- await caps(brain.engine, 'off');- await brain.seed(slug, chatPage('Concurrent append', chatDays(4400, 100, 37)));- await extract(brain.engine, slug);- // Two new days: one or two new windows, fewer than a checkpoint, so the only publication after them is the final one.- expect(await brain.call('append_page', { slug, text: chatDays(4500, 2, 37), request_id: randomUUID() }, { remote: true })).toMatchObject({ isError: false });- const before = (await factsOf(brain.engine, slug)).map(f => f.id);- let armed = false;- let injected = 0;- const transaction = brain.engine.transaction;- // The outermost transaction the publication opens (a transaction engine inherits the spy; its nested calls are skipped).- const spy = spyOn(brain.engine, 'transaction').mockImplementation((async function (this: BrainEngine, ...args: Parameters<BrainEngine['transaction']>) {- if (armed && this === brain.engine && (new Error().stack ?? '').includes('maintenanceTransaction')) {- armed = false;- injected++;- expect(await brain.call('append_page', { slug, text: chatDays(4502, 1, 37), request_id: randomUUID() }, { remote: true })).toMatchObject({ isError: false });- }- return transaction.apply(this, args);- }) as typeof brain.engine.transaction);- let run: Awaited<ReturnType<typeof extract>>;- try {- run = await extract(brain.engine, slug, { failOn: () => { armed = true; return false; } });- } finally {- spy.mockRestore();- }- const kept = await factsOf(brain.engine, slug);- expect({ injected, calls: run.calls.length > 0, failed: run.result.pages_failed, processed: run.result.pages_processed, cleaned: run.result.orphan_facts_cleaned,- lost: before.filter(id => !kept.some(f => f.id === id)).length, reason: run.result.failed_pages[0]?.error ?? null })- .toEqual({ injected: 1, calls: true, failed: 1, processed: 0, cleaned: 0, lost: 0, reason: 'the page changed during extraction; left unfinished for replay' });- const next = await extract(brain.engine, slug);- const rows = await derivations(brain.engine, slug);- expect({ calls: next.calls.length > 0, processed: next.result.pages_processed, mismatches: await claimMismatches(brain.engine, slug), states: [...new Set(rows.states)],- facts: (await factsOf(brain.engine, slug)).length }).toEqual({ calls: true, processed: 1, mismatches: [], states: ['done'], facts: rows.keys.length });- }, 600_000);}diff --git a/test/helpers/conversation-facts-property-cases.ts b/test/helpers/conversation-facts-property-cases.tsindex 11288863b7..1b279d0609 100644--- a/test/helpers/conversation-facts-property-cases.ts+++ b/test/helpers/conversation-facts-property-cases.ts@@ -1,8 +1,9 @@/*** Seeded property test of the conversation facts deletion invariant on a segmented page (wave-b spec 8.2; PR 4 lane 4b- * round 5), shared by the PGLite arm (test/large-pages/conversation-facts-property.test.ts) and the Postgres arm- * (test/e2e/conversation-facts-property-postgres.test.ts). A fake extractor yields one to three facts per window,- * determined by the window's text; no model is called.+ * round 5), shared by the PGLite arms (test/large-pages/conversation-facts-property-seeds-<first>-<last>.test.ts) and+ * the Postgres arms (test/e2e/conversation-facts-property-seeds-<first>-<last>-postgres.test.ts): one file per range of+ * PROPERTY_PARTITIONS on each engine, each with its own brains, so every file fits the e2e per-file budget. A fake+ * extractor yields one to three facts per window, determined by the window's text; no model is called.** Each of PROPERTY_SEEDS seeds runs PROPERTY_STEPS steps, each an optional change (an append on the last day or a new* day through the remote append_page, a mid-page edit, insert, delete or oversized turn, a title of another length, a@@ -22,7 +23,7 @@* a page some built-in format still parses a message in must be held: no call, no fact lost.* Each step records which paths it exercised (a moved window, a window-specific failure, a window marked failed, a* settled collection, a --since run, a cap refusal, a lost grammar on a page holding facts, a held page keeping quoted- * lines, a held page recording two grammars); across the seeds every path must fire at least its floor. Each seed+ * lines, a held page recording two grammars); across each range's seeds every path must fire at least its floor. Each seed* also dooms the windows whose text hash starts with one chosen digit for a span of steps, so windows reach the failure* limit and block collection until the final --force run.* At the end a healthy unconstrained --force run leaves the same windows and facts as one extraction of the same page on@@ -164,17 +165,28 @@ function heldOracle(checked: { problems: string[]; after: Fact[]; fired: Set<Pro}}/**- * Steps, across every seed, that must exercise each path: the round-5 floors (about half of 193, 165, 46, 133, 28, 21),- * half of the 24 steps that lose the grammar on a page holding facts, and half of the 18 held runs on a page keeping- * quoted lines and of the 24 on a page recording two grammars (the 30 seeds now exercise 206, 153, 47, 153, 27, 23, 24,- * 18, 24).+ * The seed ranges, one per arm file, together exactly 1..PROPERTY_SEEDS, and the steps each range's seeds must exercise+ * per path: half, rounded up, of the steps they exercise (the same on both engines; the 30 seeds exercise 206, 153, 47,+ * 153, 27, 23, 24, 18, 24). A range whose seeds never reach a path has floor 0 for it.*/-export const PROPERTY_PATH_FLOORS: Record<PropertyPath, number> = { moved: 96, failed_window: 82, marked_failed: 23, collected: 66, since: 14, cap: 10, grammar_lost: 12, held_quoted: 9, held_two_grammars: 12 };+export const PROPERTY_PARTITIONS: ReadonlyArray<{ first: number; last: number; floors: Record<PropertyPath, number> }> = [+ { first: 1, last: 3, floors: { moved: 12, failed_window: 9, marked_failed: 5, collected: 8, since: 0, cap: 1, grammar_lost: 2, held_quoted: 1, held_two_grammars: 3 } },+ { first: 4, last: 6, floors: { moved: 11, failed_window: 6, marked_failed: 3, collected: 8, since: 3, cap: 2, grammar_lost: 1, held_quoted: 1, held_two_grammars: 1 } },+ { first: 7, last: 9, floors: { moved: 11, failed_window: 7, marked_failed: 3, collected: 10, since: 1, cap: 1, grammar_lost: 3, held_quoted: 2, held_two_grammars: 0 } },+ { first: 10, last: 12, floors: { moved: 9, failed_window: 10, marked_failed: 4, collected: 6, since: 1, cap: 1, grammar_lost: 1, held_quoted: 1, held_two_grammars: 2 } },+ { first: 13, last: 15, floors: { moved: 10, failed_window: 8, marked_failed: 0, collected: 8, since: 2, cap: 1, grammar_lost: 2, held_quoted: 2, held_two_grammars: 2 } },+ { first: 16, last: 18, floors: { moved: 12, failed_window: 7, marked_failed: 3, collected: 9, since: 1, cap: 1, grammar_lost: 2, held_quoted: 2, held_two_grammars: 1 } },+ { first: 19, last: 21, floors: { moved: 11, failed_window: 9, marked_failed: 1, collected: 7, since: 1, cap: 2, grammar_lost: 0, held_quoted: 0, held_two_grammars: 2 } },+ { first: 22, last: 24, floors: { moved: 9, failed_window: 8, marked_failed: 2, collected: 8, since: 2, cap: 2, grammar_lost: 0, held_quoted: 0, held_two_grammars: 1 } },+ { first: 25, last: 27, floors: { moved: 10, failed_window: 6, marked_failed: 3, collected: 9, since: 2, cap: 1, grammar_lost: 2, held_quoted: 2, held_two_grammars: 1 } },+ { first: 28, last: 30, floors: { moved: 11, failed_window: 8, marked_failed: 2, collected: 6, since: 2, cap: 2, grammar_lost: 1, held_quoted: 0, held_two_grammars: 1 } },+];-export function defineConversationFactsPropertyCases(opts: { getBrain: () => AppendBrain; getFresh: () => AppendBrain }): void {+export function defineConversationFactsPropertyCases(opts: { getBrain: () => AppendBrain; getFresh: () => AppendBrain; first: number }): void {+ const { first, last, floors } = PROPERTY_PARTITIONS.find(range => range.first === opts.first)!;const firedSteps: Record<PropertyPath, number> = { moved: 0, failed_window: 0, marked_failed: 0, collected: 0, since: 0, cap: 0, grammar_lost: 0, held_quoted: 0, held_two_grammars: 0 };let seedsRun = 0;- for (let seed = 1; seed <= PROPERTY_SEEDS; seed++) {+ for (let seed = first; seed <= last; seed++) {test(`seed ${seed}: ${PROPERTY_STEPS} seeded changes and constrained runs keep the deletion invariant, and the page converges to a fresh extraction`, async () => {const brain = opts.getBrain();const engine = brain.engine;@@ -351,9 +363,11 @@ export function defineConversationFactsPropertyCases(opts: { getBrain: () => App}, 900_000);}- test(`every path fires at least its floor across the ${PROPERTY_SEEDS} seeds`, () => {- process.stderr.write(`[property] steps per path across ${seedsRun} seeds: ${JSON.stringify(firedSteps)}\n`);- expect({ seedsRun, short: Object.entries(PROPERTY_PATH_FLOORS).filter(([path, floor]) => firedSteps[path as PropertyPath] < floor).map(([path]) => path) })- .toEqual({ seedsRun: PROPERTY_SEEDS, short: [] });+ test(`every path fires at least its floor across seeds ${first} to ${last}`, () => {+ process.stderr.write(`[property] steps per path across ${seedsRun} seeds (${first} to ${last}): ${JSON.stringify(firedSteps)}\n`);+ const tiled = PROPERTY_PARTITIONS.flatMap(range => Array.from({ length: range.last - range.first + 1 }, (_, i) => range.first + i));+ expect({ seedsRun, short: Object.entries(floors).filter(([path, floor]) => firedSteps[path as PropertyPath] < floor).map(([path]) => path),+ tiled: tiled.join() === Array.from({ length: PROPERTY_SEEDS }, (_, i) => i + 1).join() })+ .toEqual({ seedsRun: last - first + 1, short: [], tiled: true });});}diff --git a/test/helpers/conversation-facts-recovery-cases.ts b/test/helpers/conversation-facts-recovery-cases.tsindex ddbc9988a7..9fad161cc1 100644--- a/test/helpers/conversation-facts-recovery-cases.ts+++ b/test/helpers/conversation-facts-recovery-cases.ts@@ -1,7 +1,7 @@/*** Conversation facts on a segmented page when things go wrong (wave-b spec 8.2, 8.3; PR 4 lane 4b round 3), shared by- * the PGLite arm (test/large-pages/conversation-facts-incremental.test.ts) and the Postgres arm- * (test/e2e/conversation-facts-incremental-postgres.test.ts). Fake extractors only; appends go through the remote+ * the PGLite arms (test/large-pages/conversation-facts-incremental-{recovery,page-change}.test.ts) and the Postgres arms+ * (test/e2e/conversation-facts-incremental-{recovery,page-change}-postgres.test.ts). Fake extractors only; appends go through the remote* append_page operation (remote=true).** 1. Protects: a partial run on a transcript without per-message times (every message at the page date) clears only@@ -59,6 +59,7 @@ const terminalStamps = async (engine: BrainEngine, slug: string) => {[slug, TERMINAL_AUDIT_SOURCE, outcomeSession(TERMINAL_AUDIT_SOURCE, slug, regularPageVersionToken(page!))]))[0]!.n);};+/** Partial runs, failed checkpoint writes and failing windows: what a run keeps when a window or the provider fails. */export function defineConversationFactsRecoveryCases(opts: { getBrain: () => AppendBrain }): void {test('a partial run on a transcript without message times deletes nothing: the window it extracted is added beside the old facts', async () => {const brain = opts.getBrain();@@ -179,6 +180,63 @@ export function defineConversationFactsRecoveryCases(opts: { getBrain: () => Appexpect({ calls: forced.calls, receipts: (await derivations(brain.engine, slug)).receipts.filter(Boolean) }).toEqual({ calls: [stuck!], receipts: [] });}, 600_000);+ test('provider-wide failures (an auth error, a 503) never count against a window: it is never marked failed and extracts once the provider recovers', async () => {+ const brain = opts.getBrain();+ await caps(brain.engine, 'off');+ await brain.engine.setConfig('facts.extraction_model', PAID_MODEL);+ try {+ for (const [label, failure] of [['auth', () => Object.assign(new Error('invalid x-api-key'), { status: 401 })], ['503', () => Object.assign(new Error('upstream unavailable'), { status: 503 })]] as const) {+ const slug = `notes/provider-down-${label}-${randomUUID().slice(0, 8)}`;+ await brain.seed(slug, chatPage('Provider down', chatDays(3600, 100, 25)));+ let attempts = 0;+ __setChatTransportForTests(async () => { attempts++; throw failure(); });+ const runs: Array<{ attempts: number; failed: number }> = [];+ for (let run = 0; run < WINDOW_FAILURE_LIMIT + 2; run++) {+ attempts = 0;+ const result = await extractProductionRun(brain.engine, slug);+ runs.push({ attempts, failed: result.pages_failed });+ }+ const receipts = (await derivations(brain.engine, slug)).receipts.filter(Boolean).map(r => (r as { kind: string }).kind);+ __setChatTransportForTests(paidTransport);+ const recovered = await extractProductionRun(brain.engine, slug);+ const rows = await derivations(brain.engine, slug);+ expect({ label, runs, receipts, recovered: recovered.pages_failed, states: [...new Set(rows.states)], failedWindows: rows.receipts.filter(r => (r as { kind?: string } | null)?.kind === 'failed_windows').length }).toEqual({+ label, runs: Array.from({ length: WINDOW_FAILURE_LIMIT + 2 }, () => ({ attempts: 1, failed: 1 })), receipts: ['unread_windows'], recovered: 0, states: ['done'], failedWindows: 0 });+ }+ } finally {+ __setChatTransportForTests(null);+ await brain.engine.setConfig('facts.extraction_model', '');+ }+ }, 600_000);++ test('a window marked failed blocks collection across two context changes: every earlier fact stands until a --force run extracts it', async () => {+ const brain = opts.getBrain();+ const slug = `notes/failed-keeps-${randomUUID().slice(0, 8)}`;+ await caps(brain.engine, 'off');+ await brain.seed(slug, chatPage('Keeps T1', chatDays(3700, 100, 26)));+ await extract(brain.engine, slug);+ const before = await factsOf(brain.engine, slug);+ const survivors = (facts: Awaited<ReturnType<typeof factsOf>>) => before.filter(f => facts.some(s => s.id === f.id)).length;+ const stuck: string[] = [];+ for (const title of ['Keeps T2', 'Keeps, a third and longer title']) {+ await brain.seed(slug, chatPage(title, (await brain.body(slug)).truth));+ let first = null as string | null;+ const failOn = (text: string) => { first ??= text; return text === first; };+ for (let run = 1; run <= WINDOW_FAILURE_LIMIT; run++) await extract(brain.engine, slug, { failOn });+ stuck.push(first!);+ const facts = await factsOf(brain.engine, slug);+ expect({ title, survivors: survivors(facts), stamped: await terminalStamps(brain.engine, slug) }).toEqual({ title, survivors: before.length, stamped: 1 });+ }+ const forced = await extract(brain.engine, slug, { force: true });+ const after = await factsOf(brain.engine, slug);+ const rows = await derivations(brain.engine, slug);+ expect({ calls: forced.calls, facts: after.length, survivors: survivors(after), anchored: after.every(f => rows.keys.includes(f.key)) })+ .toEqual({ calls: [stuck[1]!], facts: rows.keys.length, survivors: 0, anchored: true });+ }, 600_000);+}++/** A page that changes shape: oversized turns under a new title, another chat format, prose, and a private transcript. */+export function defineConversationFactsPageChangeCases(opts: { getBrain: () => AppendBrain }): void {test('a one-window run on a page of oversized turns after a title of another length deletes nothing (piece numbers move with the title)', async () => {const brain = opts.getBrain();const slug = `notes/oversized-turns-${randomUUID().slice(0, 8)}`;@@ -240,60 +298,6 @@ export function defineConversationFactsRecoveryCases(opts: { getBrain: () => Appexpect(groups.some(g => g.kind === 'no_messages' && g.samples.includes(`default:${slug}`))).toBe(false);}, 600_000);- test('provider-wide failures (an auth error, a 503) never count against a window: it is never marked failed and extracts once the provider recovers', async () => {- const brain = opts.getBrain();- await caps(brain.engine, 'off');- await brain.engine.setConfig('facts.extraction_model', PAID_MODEL);- try {- for (const [label, failure] of [['auth', () => Object.assign(new Error('invalid x-api-key'), { status: 401 })], ['503', () => Object.assign(new Error('upstream unavailable'), { status: 503 })]] as const) {- const slug = `notes/provider-down-${label}-${randomUUID().slice(0, 8)}`;- await brain.seed(slug, chatPage('Provider down', chatDays(3600, 100, 25)));- let attempts = 0;- __setChatTransportForTests(async () => { attempts++; throw failure(); });- const runs: Array<{ attempts: number; failed: number }> = [];- for (let run = 0; run < WINDOW_FAILURE_LIMIT + 2; run++) {- attempts = 0;- const result = await extractProductionRun(brain.engine, slug);- runs.push({ attempts, failed: result.pages_failed });- }- const receipts = (await derivations(brain.engine, slug)).receipts.filter(Boolean).map(r => (r as { kind: string }).kind);- __setChatTransportForTests(paidTransport);- const recovered = await extractProductionRun(brain.engine, slug);- const rows = await derivations(brain.engine, slug);- expect({ label, runs, receipts, recovered: recovered.pages_failed, states: [...new Set(rows.states)], failedWindows: rows.receipts.filter(r => (r as { kind?: string } | null)?.kind === 'failed_windows').length }).toEqual({- label, runs: Array.from({ length: WINDOW_FAILURE_LIMIT + 2 }, () => ({ attempts: 1, failed: 1 })), receipts: ['unread_windows'], recovered: 0, states: ['done'], failedWindows: 0 });- }- } finally {- __setChatTransportForTests(null);- await brain.engine.setConfig('facts.extraction_model', '');- }- }, 600_000);-- test('a window marked failed blocks collection across two context changes: every earlier fact stands until a --force run extracts it', async () => {- const brain = opts.getBrain();- const slug = `notes/failed-keeps-${randomUUID().slice(0, 8)}`;- await caps(brain.engine, 'off');- await brain.seed(slug, chatPage('Keeps T1', chatDays(3700, 100, 26)));- await extract(brain.engine, slug);- const before = await factsOf(brain.engine, slug);- const survivors = (facts: Awaited<ReturnType<typeof factsOf>>) => before.filter(f => facts.some(s => s.id === f.id)).length;- const stuck: string[] = [];- for (const title of ['Keeps T2', 'Keeps, a third and longer title']) {- await brain.seed(slug, chatPage(title, (await brain.body(slug)).truth));- let first = null as string | null;- const failOn = (text: string) => { first ??= text; return text === first; };- for (let run = 1; run <= WINDOW_FAILURE_LIMIT; run++) await extract(brain.engine, slug, { failOn });- stuck.push(first!);- const facts = await factsOf(brain.engine, slug);- expect({ title, survivors: survivors(facts), stamped: await terminalStamps(brain.engine, slug) }).toEqual({ title, survivors: before.length, stamped: 1 });- }- const forced = await extract(brain.engine, slug, { force: true });- const after = await factsOf(brain.engine, slug);- const rows = await derivations(brain.engine, slug);- expect({ calls: forced.calls, facts: after.length, survivors: survivors(after), anchored: after.every(f => rows.keys.includes(f.key)) })- .toEqual({ calls: [stuck[1]!], facts: rows.keys.length, survivors: 0, anchored: true });- }, 600_000);-test('facts from a private segmented transcript stay private on a world-default brain, on the import run and on the incremental run after an append', async () => {const brain = opts.getBrain();const slug = `notes/private-chat-${randomUUID().slice(0, 8)}`;diff --git a/test/helpers/derivation-spend-cases.ts b/test/helpers/derivation-spend-cases.tsindex e9a4570c3c..f51f62765f 100644--- a/test/helpers/derivation-spend-cases.ts+++ b/test/helpers/derivation-spend-cases.ts@@ -1,7 +1,7 @@/*** Paid derivations on a segmented page under their spend caps (wave-b spec 8.2, 8.3; PR 4 lane 4b round 2), shared by- * the PGLite arm (test/large-pages/conversation-facts-incremental.test.ts) and the Postgres arm- * (test/e2e/conversation-facts-incremental-postgres.test.ts). Fake extractors and fake chat transports only.+ * the PGLite arm (test/large-pages/conversation-facts-incremental-core.test.ts) and the Postgres arm+ * (test/e2e/conversation-facts-incremental-core-postgres.test.ts). Fake extractors and fake chat transports only.** 1. Protects: a window that throws after the provider answered is booked and the windows finished before it keep their* facts and rows; an abort partway through a page keeps the finished windows; a facts call reserves every attemptdiff --git a/test/helpers/derivation-unpriced-cases.ts b/test/helpers/derivation-unpriced-cases.tsindex 4ffac05607..9421ad4863 100644--- a/test/helpers/derivation-unpriced-cases.ts+++ b/test/helpers/derivation-unpriced-cases.ts@@ -1,7 +1,7 @@/*** Paid page derivations under a model with no price (PR 4 lane 4b round 5, item 10), shared by the PGLite arm- * (test/large-pages/conversation-facts-incremental.test.ts) and the Postgres arm- * (test/e2e/conversation-facts-incremental-postgres.test.ts). No default changes and no price is invented: an unpriced+ * (test/large-pages/conversation-facts-incremental-core.test.ts) and the Postgres arm+ * (test/e2e/conversation-facts-incremental-core-postgres.test.ts). No default changes and no price is invented: an unpriced* model reserves its ceiling estimate, so the per-page cap stops it after about one window. Fake extractors only.** 1. Protects: when the facts, conversation facts, atoms or synopsis step stops (or books its reservation) because thediff --git a/test/large-pages/conversation-facts-incremental.test.ts b/test/large-pages/conversation-facts-incremental-core.test.tssimilarity index 54%rename from test/large-pages/conversation-facts-incremental.test.tsrename to test/large-pages/conversation-facts-incremental-core.test.tsindex 871113a543..0a591dd5ee 100644--- a/test/large-pages/conversation-facts-incremental.test.ts+++ b/test/large-pages/conversation-facts-incremental-core.test.ts@@ -1,27 +1,26 @@/**- * Incremental conversation facts on a segmented page, PGLite arm (wave-b spec 8.2, PR 4 lane 4b). Cases:- * test/helpers/conversation-facts-incremental-cases.ts. Postgres arm: test/e2e/conversation-facts-incremental-postgres.test.ts.+ * Incremental conversation facts on a segmented page, PGLite arm: append, retirement, cap, spend and unpriced-model+ * cases (wave-b spec 8.2, PR 4 lane 4b). Cases: test/helpers/conversation-facts-incremental-cases.ts,+ * test/helpers/derivation-spend-cases.ts, test/helpers/derivation-unpriced-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-incremental-core-postgres.test.ts. One of eight files per engine, split by topic so each+ * fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.*/import { afterAll, beforeAll, describe } from 'bun:test';import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsIncrementalCases, defineSegmentReceiptDoctorCases, defineSegmentedAtomsCases, defineSegmentedBackstopCases } from '../helpers/conversation-facts-incremental-cases.ts';import { defineDerivationSpendCases } from '../helpers/derivation-spend-cases.ts';-import { defineConversationFactsRecoveryCases } from '../helpers/conversation-facts-recovery-cases.ts';-import { defineConversationFactsInvariantCases } from '../helpers/conversation-facts-invariant-cases.ts';import { defineDerivationUnpricedCases } from '../helpers/derivation-unpriced-cases.ts';-import { defineConversationFactsIncrementalCases, defineSegmentedAtomsCases, defineSegmentedBackstopCases, defineSegmentReceiptDoctorCases } from '../helpers/conversation-facts-incremental-cases.ts';let brain: AppendBrain;beforeAll(async () => { brain = await openAppendBrain('pglite'); }, 120_000);afterAll(async () => { await brain.close(); }, 120_000);-describe('conversation facts incremental [pglite]', () => {+describe('conversation facts incremental, core [pglite]', () => {defineConversationFactsIncrementalCases({ getBrain: () => brain });defineSegmentedBackstopCases({ getBrain: () => brain });defineSegmentedAtomsCases({ getBrain: () => brain });defineSegmentReceiptDoctorCases({ getBrain: () => brain });defineDerivationSpendCases({ getBrain: () => brain });- defineConversationFactsRecoveryCases({ getBrain: () => brain });- defineConversationFactsInvariantCases({ getBrain: () => brain });defineDerivationUnpricedCases({ getBrain: () => brain });});diff --git a/test/large-pages/conversation-facts-incremental-deletion.test.ts b/test/large-pages/conversation-facts-incremental-deletion.test.tsnew file mode 100644index 0000000000..f87ee2f935--- /dev/null+++ b/test/large-pages/conversation-facts-incremental-deletion.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, PGLite arm: the deletion invariant (F1, F2, F6, F9, N2) (wave-b+ * spec 8.2, PR 4 lane 4b). Cases: test/helpers/conversation-facts-invariant-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-incremental-deletion-postgres.test.ts. One of eight files per engine, split by topic so+ * each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsDeletionCases } from '../helpers/conversation-facts-invariant-cases.ts';++let brain: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); }, 120_000);++describe('conversation facts incremental, deletion [pglite]', () => {+ defineConversationFactsDeletionCases({ getBrain: () => brain });+});diff --git a/test/large-pages/conversation-facts-incremental-grammar-choice.test.ts b/test/large-pages/conversation-facts-incremental-grammar-choice.test.tsnew file mode 100644index 0000000000..2bdd4227b7--- /dev/null+++ b/test/large-pages/conversation-facts-incremental-grammar-choice.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, PGLite arm: how long a --grammar choice lasts (wave-b spec 8.2,+ * PR 4 lane 4b). Cases: test/helpers/conversation-facts-invariant-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-incremental-grammar-choice-postgres.test.ts. One of eight files per engine, split by+ * topic so each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsGrammarChoiceCases } from '../helpers/conversation-facts-invariant-cases.ts';++let brain: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); }, 120_000);++describe('conversation facts incremental, grammar-choice [pglite]', () => {+ defineConversationFactsGrammarChoiceCases({ getBrain: () => brain });+});diff --git a/test/large-pages/conversation-facts-incremental-grammar-flag.test.ts b/test/large-pages/conversation-facts-incremental-grammar-flag.test.tsnew file mode 100644index 0000000000..f0d5b1abb6--- /dev/null+++ b/test/large-pages/conversation-facts-incremental-grammar-flag.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, PGLite arm: the operator's --grammar (wave-b spec 8.2, PR 4 lane+ * 4b). Cases: test/helpers/conversation-facts-invariant-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-incremental-grammar-flag-postgres.test.ts. One of eight files per engine, split by topic+ * so each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsGrammarFlagCases } from '../helpers/conversation-facts-invariant-cases.ts';++let brain: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); }, 120_000);++describe('conversation facts incremental, grammar-flag [pglite]', () => {+ defineConversationFactsGrammarFlagCases({ getBrain: () => brain });+});diff --git a/test/large-pages/conversation-facts-incremental-grammar.test.ts b/test/large-pages/conversation-facts-incremental-grammar.test.tsnew file mode 100644index 0000000000..6b35599f95--- /dev/null+++ b/test/large-pages/conversation-facts-incremental-grammar.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, PGLite arm: which grammar a run reads (F3, G1, p7, R3) (wave-b+ * spec 8.2, PR 4 lane 4b). Cases: test/helpers/conversation-facts-invariant-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-incremental-grammar-postgres.test.ts. One of eight files per engine, split by topic so+ * each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsGrammarCases } from '../helpers/conversation-facts-invariant-cases.ts';++let brain: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); }, 120_000);++describe('conversation facts incremental, grammar [pglite]', () => {+ defineConversationFactsGrammarCases({ getBrain: () => brain });+});diff --git a/test/large-pages/conversation-facts-incremental-held.test.ts b/test/large-pages/conversation-facts-incremental-held.test.tsnew file mode 100644index 0000000000..6482c491d8--- /dev/null+++ b/test/large-pages/conversation-facts-incremental-held.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, PGLite arm: held transcripts (N1, R4) (wave-b spec 8.2, PR 4 lane+ * 4b). Cases: test/helpers/conversation-facts-invariant-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-incremental-held-postgres.test.ts. One of eight files per engine, split by topic so each+ * fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsHeldCases } from '../helpers/conversation-facts-invariant-cases.ts';++let brain: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); }, 120_000);++describe('conversation facts incremental, held [pglite]', () => {+ defineConversationFactsHeldCases({ getBrain: () => brain });+});diff --git a/test/large-pages/conversation-facts-incremental-page-change.test.ts b/test/large-pages/conversation-facts-incremental-page-change.test.tsnew file mode 100644index 0000000000..4236f35bfb--- /dev/null+++ b/test/large-pages/conversation-facts-incremental-page-change.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, PGLite arm: pages that change shape (wave-b spec 8.2, PR 4 lane+ * 4b). Cases: test/helpers/conversation-facts-recovery-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-incremental-page-change-postgres.test.ts. One of eight files per engine, split by topic+ * so each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPageChangeCases } from '../helpers/conversation-facts-recovery-cases.ts';++let brain: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); }, 120_000);++describe('conversation facts incremental, page-change [pglite]', () => {+ defineConversationFactsPageChangeCases({ getBrain: () => brain });+});diff --git a/test/large-pages/conversation-facts-incremental-recovery.test.ts b/test/large-pages/conversation-facts-incremental-recovery.test.tsnew file mode 100644index 0000000000..fd5bca4cad--- /dev/null+++ b/test/large-pages/conversation-facts-incremental-recovery.test.ts@@ -0,0 +1,18 @@+/**+ * Incremental conversation facts on a segmented page, PGLite arm: partial runs, failed checkpoint writes and failing+ * windows (wave-b spec 8.2, PR 4 lane 4b). Cases: test/helpers/conversation-facts-recovery-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-incremental-recovery-postgres.test.ts. One of eight files per engine, split by topic so+ * each fits the e2e per-file budget (scripts/run-e2e.sh); each opens its own brain.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsRecoveryCases } from '../helpers/conversation-facts-recovery-cases.ts';++let brain: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); }, 120_000);++describe('conversation facts incremental, recovery [pglite]', () => {+ defineConversationFactsRecoveryCases({ getBrain: () => brain });+});diff --git a/test/large-pages/conversation-facts-property.test.ts b/test/large-pages/conversation-facts-property-seeds-01-03.test.tssimilarity index 65%rename from test/large-pages/conversation-facts-property.test.tsrename to test/large-pages/conversation-facts-property-seeds-01-03.test.tsindex ecdb755baa..038917712f 100644--- a/test/large-pages/conversation-facts-property.test.ts+++ b/test/large-pages/conversation-facts-property-seeds-01-03.test.ts@@ -1,6 +1,7 @@/**- * Seeded property test of the conversation facts deletion invariant, PGLite arm (PR 4 lane 4b round 5). Cases:- * test/helpers/conversation-facts-property-cases.ts. Postgres arm: test/e2e/conversation-facts-property-postgres.test.ts.+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 1 to 3 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-01-03-postgres.test.ts.*/import { afterAll, beforeAll, describe } from 'bun:test';import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';@@ -12,6 +13,6 @@ let fresh: AppendBrain;beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);-describe('conversation facts deletion invariant [pglite]', () => {- defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh });+describe('conversation facts deletion invariant, seeds 1 to 3 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 1 });});diff --git a/test/large-pages/conversation-facts-property-seeds-04-06.test.ts b/test/large-pages/conversation-facts-property-seeds-04-06.test.tsnew file mode 100644index 0000000000..18e94fe7df--- /dev/null+++ b/test/large-pages/conversation-facts-property-seeds-04-06.test.ts@@ -0,0 +1,18 @@+/**+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 4 to 6 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-04-06-postgres.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';++let brain: AppendBrain;+let fresh: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);++describe('conversation facts deletion invariant, seeds 4 to 6 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 4 });+});diff --git a/test/large-pages/conversation-facts-property-seeds-07-09.test.ts b/test/large-pages/conversation-facts-property-seeds-07-09.test.tsnew file mode 100644index 0000000000..e7e4231109--- /dev/null+++ b/test/large-pages/conversation-facts-property-seeds-07-09.test.ts@@ -0,0 +1,18 @@+/**+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 7 to 9 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-07-09-postgres.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';++let brain: AppendBrain;+let fresh: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);++describe('conversation facts deletion invariant, seeds 7 to 9 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 7 });+});diff --git a/test/large-pages/conversation-facts-property-seeds-10-12.test.ts b/test/large-pages/conversation-facts-property-seeds-10-12.test.tsnew file mode 100644index 0000000000..d1f1bca226--- /dev/null+++ b/test/large-pages/conversation-facts-property-seeds-10-12.test.ts@@ -0,0 +1,18 @@+/**+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 10 to 12 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-10-12-postgres.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';++let brain: AppendBrain;+let fresh: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);++describe('conversation facts deletion invariant, seeds 10 to 12 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 10 });+});diff --git a/test/large-pages/conversation-facts-property-seeds-13-15.test.ts b/test/large-pages/conversation-facts-property-seeds-13-15.test.tsnew file mode 100644index 0000000000..d734ab4358--- /dev/null+++ b/test/large-pages/conversation-facts-property-seeds-13-15.test.ts@@ -0,0 +1,18 @@+/**+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 13 to 15 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-13-15-postgres.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';++let brain: AppendBrain;+let fresh: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);++describe('conversation facts deletion invariant, seeds 13 to 15 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 13 });+});diff --git a/test/large-pages/conversation-facts-property-seeds-16-18.test.ts b/test/large-pages/conversation-facts-property-seeds-16-18.test.tsnew file mode 100644index 0000000000..f6cee88ba7--- /dev/null+++ b/test/large-pages/conversation-facts-property-seeds-16-18.test.ts@@ -0,0 +1,18 @@+/**+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 16 to 18 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-16-18-postgres.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';++let brain: AppendBrain;+let fresh: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);++describe('conversation facts deletion invariant, seeds 16 to 18 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 16 });+});diff --git a/test/large-pages/conversation-facts-property-seeds-19-21.test.ts b/test/large-pages/conversation-facts-property-seeds-19-21.test.tsnew file mode 100644index 0000000000..f9788a5d1f--- /dev/null+++ b/test/large-pages/conversation-facts-property-seeds-19-21.test.ts@@ -0,0 +1,18 @@+/**+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 19 to 21 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-19-21-postgres.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';++let brain: AppendBrain;+let fresh: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);++describe('conversation facts deletion invariant, seeds 19 to 21 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 19 });+});diff --git a/test/large-pages/conversation-facts-property-seeds-22-24.test.ts b/test/large-pages/conversation-facts-property-seeds-22-24.test.tsnew file mode 100644index 0000000000..4807963331--- /dev/null+++ b/test/large-pages/conversation-facts-property-seeds-22-24.test.ts@@ -0,0 +1,18 @@+/**+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 22 to 24 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-22-24-postgres.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';++let brain: AppendBrain;+let fresh: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);++describe('conversation facts deletion invariant, seeds 22 to 24 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 22 });+});diff --git a/test/large-pages/conversation-facts-property-seeds-25-27.test.ts b/test/large-pages/conversation-facts-property-seeds-25-27.test.tsnew file mode 100644index 0000000000..92a88bf16e--- /dev/null+++ b/test/large-pages/conversation-facts-property-seeds-25-27.test.ts@@ -0,0 +1,18 @@+/**+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 25 to 27 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-25-27-postgres.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';++let brain: AppendBrain;+let fresh: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);++describe('conversation facts deletion invariant, seeds 25 to 27 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 25 });+});diff --git a/test/large-pages/conversation-facts-property-seeds-28-30.test.ts b/test/large-pages/conversation-facts-property-seeds-28-30.test.tsnew file mode 100644index 0000000000..a226797b3e--- /dev/null+++ b/test/large-pages/conversation-facts-property-seeds-28-30.test.ts@@ -0,0 +1,18 @@+/**+ * Seeded property test of the conversation facts deletion invariant, PGLite arm, seeds 28 to 30 (PR 4 lane 4b round 5).+ * Cases and seed ranges: test/helpers/conversation-facts-property-cases.ts. Postgres arm:+ * test/e2e/conversation-facts-property-seeds-28-30-postgres.test.ts.+ */+import { afterAll, beforeAll, describe } from 'bun:test';+import { openAppendBrain, type AppendBrain } from '../helpers/append-brain.ts';+import { defineConversationFactsPropertyCases } from '../helpers/conversation-facts-property-cases.ts';++let brain: AppendBrain;+let fresh: AppendBrain;++beforeAll(async () => { brain = await openAppendBrain('pglite'); fresh = await openAppendBrain('pglite'); }, 120_000);+afterAll(async () => { await brain.close(); await fresh.close(); }, 120_000);++describe('conversation facts deletion invariant, seeds 28 to 30 [pglite]', () => {+ defineConversationFactsPropertyCases({ getBrain: () => brain, getFresh: () => fresh, first: 28 });+});diff --git a/test/large-pages/segmented-conversation-facts.test.ts b/test/large-pages/segmented-conversation-facts.test.tsindex fb2d9bfe04..3002311f11 100644--- a/test/large-pages/segmented-conversation-facts.test.ts+++ b/test/large-pages/segmented-conversation-facts.test.ts@@ -3,7 +3,7 @@* segmented page through ranged reads. PR 4 lane 4b (spec 8.2) replaced the* page's single parser input with per-occurrence windows* (core/facts/conversation-incremental.ts; its append, retirement and spend- * cases live in conversation-facts-incremental.test.ts).+ * cases live in conversation-facts-incremental-*.test.ts).** 1. Protects:* - a segmented conversation within the window cap gives the parser the