{"version":135,"agent":"codex-capacity-chair","message":"Skip priority decoding for implicit-only child traversal","time":1791843539159,"timeIso":"2026-10-12T22:18:59.159Z","changes":2,"change":1284,"files":["src/engine/graph.ts","src/engine/test/state-source.test.ts"],"draft":null,"diff":[{"path":"src/engine/graph.ts","added":10,"removed":2,"diff":"--- a/src/engine/graph.ts\n+++ b/src/engine/graph.ts\n@@ -665,8 +665,8 @@\n \t\tconst index = new OrderedIndex(this.#storage, \"ordered-children\", String(code));\n \t\tif (this.#storage.read(\"ordered-children\", \"format\") !== 1)\n \t\t\tthrow new Error(\"ordered children require fresh adoption\");\n-\t\tif (index.size !== this.#runStartPages!.length(String(code))) throw new Error(\"ordered child index count mismatch\");\n-\t\tconst cursor = after === undefined ? undefined : this.#childPriority(after);\n+\t\tconst count = index.size;\n+\t\tif (count !== this.#runStartPages!.length(String(code))) throw new Error(\"ordered child index count mismatch\");\n \t\tlet implicit: number | undefined;\n \t\tif (\n \t\t\tcode >= 0 &&\n@@ -675,6 +675,14 @@\n \t\t\tthis.#lineParent.at(code + 1) === code\n \t\t)\n \t\t\timplicit = code + 1;\n+\t\t// Most historical run lines have no explicit child. With zero or one\n+\t\t// child, traversal needs no priority decoding or radix lookup. Keep the\n+\t\t// format/count checks above even on this path.\n+\t\tif (count === 0 && (after === undefined || after === implicit)) {\n+\t\t\tif (implicit !== undefined && after !== implicit) yield implicit;\n+\t\t\treturn;\n+\t\t}\n+\t\tconst cursor = after === undefined ? undefined : this.#childPriority(after);\n \t\tif (implicit !== undefined && cursor !== undefined && this.#childPriority(implicit) <= cursor) implicit = undefined;\n \t\tfor (const n of index.values(cursor)) {\n \t\t\tif (implicit !== undefined && this.#childPriority(implicit) < this.#childPriority(n)) {"},{"path":"src/engine/test/state-source.test.ts","added":25,"removed":0,"diff":"--- a/src/engine/test/state-source.test.ts\n+++ b/src/engine/test/state-source.test.ts\n@@ -469,6 +469,31 @@\n \t}\n });\n \n+test(\"implicit ordered successors avoid priority reads but retain index validation\", () => {\n+\tclass ObservedStorage extends SqlState {\n+\t\tpriorityReads = 0;\n+\t\toverride read(collection: string, key: string): unknown {\n+\t\t\tif (collection === \"lamport\" || collection.startsWith(\"replacing:\")) this.priorityReads++;\n+\t\t\treturn super.read(collection, key);\n+\t\t}\n+\t}\n+\tconst storage = new ObservedStorage();\n+\ttry {\n+\t\tconst oracle = Repo.init({ \"a.txt\": \"one\\ntwo\\nthree\\n\" });\n+\t\tconst graph = new Graph({ storage });\n+\t\tgraph.add(oracle.graph.atom(\"a0\"));\n+\t\tstorage.priorityReads = 0;\n+\t\tassert.deepEqual([...graph.orderedChildrenN(0)], [1]);\n+\t\tassert.deepEqual([...graph.orderedChildrenN(0, 1)], []);\n+\t\tassert.deepEqual([...graph.orderedChildrenN(2)], []);\n+\t\tassert.equal(storage.priorityReads, 0, \"single-child traversal does not decode sort priority\");\n+\t\tstorage.remove(\"ordered-children\", \"format\");\n+\t\tassert.throws(() => [...graph.orderedChildrenN(0)], /fresh adoption/);\n+\t} finally {\n+\t\tstorage.db.close();\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 {"}],"ci":null}