{"draft":null,"from":130,"to":131,"files":[{"path":"src/engine/test/state-source.test.ts","added":70,"removed":0,"diff":"--- a/src/engine/test/state-source.test.ts\n+++ b/src/engine/test/state-source.test.ts\n@@ -419,3 +419,73 @@\n \t\tstorage.db.close();\n \t}\n });\n+\n+test(\"persistent layout uses ordered successors without retaining deep or wide history frontiers\", () => {\n+\tfor (const shape of [\"deep\", \"wide\"] as const) {\n+\t\tconst storage = new SqlState();\n+\t\ttry {\n+\t\t\tconst oracle = Repo.init({\n+\t\t\t\t\"a.txt\": shape === \"deep\" ? Array.from({ length: 1024 }, (_, n) => `line ${n}\\n`).join(\"\") : \"base\\n\",\n+\t\t\t});\n+\t\t\tif (shape === \"wide\") {\n+\t\t\t\tconst draft = oracle.draft({ edits: [{ file: \"a.txt\", old: \"base\", new: \"branch\" }] });\n+\t\t\t\tfor (let seq = 1; seq <= 256; seq++) {\n+\t\t\t\t\tconst atom = { ...draft, id: `a${seq}`, seq };\n+\t\t\t\t\toracle.graph.add(atom);\n+\t\t\t\t\toracle.shared.add(atom.id);\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tconst before = oracle.view().text(\"a.txt\");\n+\t\t\toracle.edit({ edits: [{ file: \"a.txt\", old: before, new: \"live\\n\" }] });\n+\t\t\tconst graph = new Graph({ storage });\n+\t\t\tfor (const id of oracle.shared) graph.add(oracle.graph.atom(id));\n+\t\t\tconst reopened = new Graph({ storage });\n+\t\t\treopened.eachChildN = () => {\n+\t\t\t\tthrow Error(\"unordered child collection forbidden\");\n+\t\t\t};\n+\t\t\treopened.childrenN = () => {\n+\t\t\t\tthrow Error(\"materialized child collection forbidden\");\n+\t\t\t};\n+\t\t\tconst original = reopened.orderedChildrenN.bind(reopened);\n+\t\t\tlet active = 0,\n+\t\t\t\tmaximum = 0;\n+\t\t\treopened.orderedChildrenN = function* (parent: number, after?: number) {\n+\t\t\t\tactive++;\n+\t\t\t\tmaximum = Math.max(maximum, active);\n+\t\t\t\ttry {\n+\t\t\t\t\tyield* original(parent, after);\n+\t\t\t\t} finally {\n+\t\t\t\t\tactive--;\n+\t\t\t\t}\n+\t\t\t};\n+\t\t\tconst view = new View(reopened, new StableOverlaySet(oracle.shared));\n+\t\t\tassert.equal(view.text(\"a.txt\"), \"live\\n\");\n+\t\t\tassert.equal(active, 0);\n+\t\t\tassert.equal(maximum, 1, \"no ordered iterator retained per historical ancestor\");\n+\t\t\tassert.deepEqual(view.sequence(\"a.txt\"), oracle.view().sequence(\"a.txt\"));\n+\t\t} finally {\n+\t\t\tstorage.db.close();\n+\t\t}\n+\t}\n+});\n+\n+test(\"ordered layout refuses missing format or child metadata instead of dropping history\", () => {\n+\tconst storage = new SqlState();\n+\ttry {\n+\t\tconst oracle = Repo.init({ \"a.txt\": \"one\\n\" });\n+\t\tconst graph = new Graph({ storage });\n+\t\tgraph.add(oracle.graph.atom(\"a0\"));\n+\t\tstorage.remove(\"ordered-children\", \"format\");\n+\t\tassert.throws(() => new View(new Graph({ storage }), new StableOverlaySet([\"a0\"])).text(\"a.txt\"), /fresh adoption/);\n+\t\tassert.throws(\n+\t\t\t() => new Graph({ storage }).add(oracle.draft({ edits: [{ file: \"a.txt\", old: \"one\", new: \"two\" }] })),\n+\t\t\t/fresh adoption/,\n+\t\t);\n+\t\tstorage.write(\"ordered-children\", \"format\", 1);\n+\t\tconst parent = graph.startCodeOf(\"a.txt\")!;\n+\t\tstorage.remove(\"ordered-children\", JSON.stringify([String(parent), \"meta\"]));\n+\t\tassert.throws(() => [...graph.orderedChildrenN(parent)], /missing ordered index metadata/);\n+\t} finally {\n+\t\tstorage.db.close();\n+\t}\n+});"}],"unmatched":[]}