{"draft":null,"from":129,"to":130,"files":[{"path":"src/engine/test/state-source.test.ts","added":57,"removed":0,"diff":"--- a/src/engine/test/state-source.test.ts\n+++ b/src/engine/test/state-source.test.ts\n@@ -362,3 +362,60 @@\n \t\tstorage.db.close();\n \t}\n });\n+\n+test(\"child indexes stream bounded pages before filtering historical siblings\", () => {\n+\tclass ObservedStorage extends SqlState {\n+\t\tpageReads = 0;\n+\t\tlargestPage = 0;\n+\t\toverride read(collection: string, key: string): unknown {\n+\t\t\tif (collection === \"run-starts:pages\") this.pageReads++;\n+\t\t\treturn super.read(collection, key);\n+\t\t}\n+\t\toverride write(collection: string, key: string, value: unknown): void {\n+\t\t\tif (collection === \"run-starts:pages\") {\n+\t\t\t\tassert.ok(Array.isArray(value));\n+\t\t\t\tthis.largestPage = Math.max(this.largestPage, value.length);\n+\t\t\t}\n+\t\t\tsuper.write(collection, key, value);\n+\t\t}\n+\t}\n+\tconst storage = new ObservedStorage();\n+\ttry {\n+\t\tconst oracle = Repo.init({ \"a.txt\": \"one\\ntwo\\n\" });\n+\t\tconst draft = oracle.draft({ edits: [{ file: \"a.txt\", old: \"one\", new: \"ONE\" }] });\n+\t\tconst graph = new Graph({ storage });\n+\t\tgraph.add(oracle.graph.atom(\"a0\"));\n+\t\tfor (let seq = 1; seq <= 513; seq++) {\n+\t\t\tconst atom = { ...draft, id: `a${seq}`, seq };\n+\t\t\tgraph.add(atom);\n+\t\t\toracle.graph.add(atom);\n+\t\t}\n+\t\tconst reopened = new Graph({ storage });\n+\t\tconst parent = draft.inserts[0]!.parent;\n+\t\tconst code = reopened.codeOf(parent)!;\n+\t\tstorage.pageReads = 0;\n+\t\tconst iterator = reopened.eachChildN(code);\n+\t\tconst first = iterator.next().value!;\n+\t\tassert.equal(first, reopened.lineN(oracle.graph.childrenOf(parent)[0]!));\n+\t\tassert.ok(storage.pageReads <= 1);\n+\t\tif (storage.pageReads === 0) {\n+\t\t\titerator.next();\n+\t\t\tassert.equal(storage.pageReads, 1, \"the implicit child needs no page; the next sibling needs one\");\n+\t\t}\n+\t\tassert.deepEqual(reopened.childrenOf(parent), oracle.graph.childrenOf(parent));\n+\t\tassert.deepEqual(\n+\t\t\treopened.childrenOf(\"a0.0\"),\n+\t\t\toracle.graph.childrenOf(\"a0.0\"),\n+\t\t\t\"implicit same-run child order is retained\",\n+\t\t);\n+\t\tassert.equal(storage.largestPage, 256);\n+\t\tconst membership = new StableOverlaySet([\"a0\"]);\n+\t\tassert.equal(new View(reopened, membership).text(\"a.txt\"), \"one\\ntwo\\n\");\n+\t\tassert.deepEqual(\n+\t\t\tnew View(reopened, membership).sequence(\"a.txt\"),\n+\t\t\tnew View(oracle.graph, membership).sequence(\"a.txt\"),\n+\t\t);\n+\t} finally {\n+\t\tstorage.db.close();\n+\t}\n+});"}],"unmatched":[]}