{"draft":null,"from":126,"to":127,"files":[{"path":"src/engine/test/state-source.test.ts","added":43,"removed":0,"diff":"--- a/src/engine/test/state-source.test.ts\n+++ b/src/engine/test/state-source.test.ts\n@@ -5,6 +5,49 @@\n import { lines, Repo } from \"./helpers.ts\";\n import { SqlState } from \"./storage-helper.ts\";\n \n+test(\"relocation indexes stream one fixed page before yielding and preserve order\", () => {\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.startsWith(\"relocat\") && collection.endsWith(\":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.startsWith(\"relocat\") && collection.endsWith(\":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\\n\", \"b.txt\": \"\" });\n+\t\tconst move = oracle.draft({ move: { file: \"a.txt\", start: 0, end: 1, to: \"b.txt\", at: 0 } });\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 = { ...move, 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\tstorage.pageReads = 0;\n+\t\tconst iterator = reopened.eachRelocationOf(\"a0.0\");\n+\t\tassert.deepEqual(iterator.next().value, oracle.graph.relocationsOf(\"a0.0\")[0]);\n+\t\tassert.equal(storage.pageReads, 1, \"first result must decode only one page\");\n+\t\tassert.deepEqual(reopened.relocationsOf(\"a0.0\"), oracle.graph.relocationsOf(\"a0.0\"));\n+\t\tconst parent = move.moves![0]!.parent;\n+\t\tconst code = reopened.codeOf(parent)!;\n+\t\tassert.deepEqual(reopened.relocatedTo(parent), oracle.graph.relocatedTo(parent));\n+\t\tassert.deepEqual([...reopened.eachRelocatedToCode(code)], oracle.graph.relocatedToCode(code));\n+\t\tassert.equal(storage.largestPage, 256);\n+\t} finally {\n+\t\tstorage.db.close();\n+\t}\n+});\n+\n test(\"hot claim indexes stream bounded pages after reopening\", (t) => {\n \tconst oracle = Repo.init({ \"a.txt\": lines(\"one\", \"two\") });\n \tconst draft = oracle.draft({ edits: [{ file: \"a.txt\", old: \"one\", new: \"ONE\" }] });"}],"unmatched":[]}