{"version":126,"agent":"codex-capacity-chair","message":"Identify suppressed relocation cycles across persistent reads","time":1791837654331,"timeIso":"2026-10-12T20:40:54.331Z","changes":2,"change":1284,"files":["src/engine/test/moves.test.ts","src/engine/view.ts"],"draft":null,"diff":[{"path":"src/engine/test/moves.test.ts","added":19,"removed":1,"diff":"--- a/src/engine/test/moves.test.ts\n+++ b/src/engine/test/moves.test.ts\n@@ -5,8 +5,10 @@\n \n import assert from \"node:assert/strict\";\n import { describe, it } from \"node:test\";\n-import { type Atom, type AtomId, conflicts } from \"../index.ts\";\n+import { type Atom, type AtomId, conflicts, Graph, View } from \"../index.ts\";\n+import { StableOverlaySet } from \"../state-source.ts\";\n import { lines, Repo, Rng } from \"./helpers.ts\";\n+import { SqlState } from \"./storage-helper.ts\";\n \n const BASE_SEED = Number(process.env.PROP_SEED ?? 20261004);\n const CASES = Number(process.env.PROP_CASES ?? 200);\n@@ -243,6 +245,22 @@\n \t\taccept(repo, mk(\"a0.2\", \"a0.0\"));\n \t\tconst text = repo.text(\"f.txt\");\n \t\tassert.deepEqual(text.split(\"\\n\").filter(Boolean).sort(), [\"m\", \"n\", \"x\", \"y\"]);\n+\t\tclass BoundedReads extends SqlState {\n+\t\t\toverride read(collection: string, key: string): unknown {\n+\t\t\t\tif (this.reads > 10_000) throw new Error(\"relocation cycle did not terminate\");\n+\t\t\t\treturn super.read(collection, key);\n+\t\t\t}\n+\t\t}\n+\t\tconst storage = new BoundedReads();\n+\t\ttry {\n+\t\t\tconst stored = new Graph({ storage });\n+\t\t\tfor (let seq = 0; seq < repo.graph.size; seq++) stored.add(repo.graph.atom(repo.graph.idOfSeq(seq)));\n+\t\t\tconst reopened = new Graph({ storage });\n+\t\t\tassert.equal(new View(reopened, repo.shared).text(\"f.txt\"), text);\n+\t\t\tassert.equal(new View(reopened, new StableOverlaySet(repo.shared)).text(\"f.txt\"), text);\n+\t\t} finally {\n+\t\t\tstorage.db.close();\n+\t\t}\n \t});\n \n \tit(\"rejects a move onto itself or out of range\", () => {"},{"path":"src/engine/view.ts","added":6,"removed":3,"diff":"--- a/src/engine/view.ts\n+++ b/src/engine/view.ts\n@@ -198,11 +198,14 @@\n \t\tif (this.#relocs) return this.#relocs;\n \t\tconst graph = this.graph;\n \t\tconst stronger = (a: RelocationInfo, b: RelocationInfo): boolean => graph.comparePriority(a.atom, b.atom) > 0;\n-\t\tconst ignored = new Set<RelocationInfo>();\n+\t\t// Persistent reads decode new objects. Cycle suppression must identify the\n+\t\t// logical move, not one particular decoded JavaScript object.\n+\t\tconst identity = (r: RelocationInfo): string => JSON.stringify([r.atom, r.k]);\n+\t\tconst ignored = new Set<string>();\n \t\tconst pick = (line: LineId): RelocationInfo | undefined => {\n \t\t\tlet best: RelocationInfo | undefined;\n \t\t\tfor (const r of graph.relocationsOf(line)) {\n-\t\t\t\tif (this.#has(graph.atom(r.atom).seq) && !ignored.has(r) && (!best || stronger(r, best))) best = r;\n+\t\t\t\tif (this.#has(graph.atom(r.atom).seq) && !ignored.has(identity(r)) && (!best || stronger(r, best))) best = r;\n \t\t\t}\n \t\t\treturn best;\n \t\t};\n@@ -239,7 +242,7 @@\n \t\t\t\t\tconst r = relocs.get(l);\n \t\t\t\t\tif (r && (!weakest || stronger(weakest, r))) weakest = r;\n \t\t\t\t}\n-\t\t\t\tignored.add(weakest!);\n+\t\t\t\tignored.add(identity(weakest!));\n \t\t\t\tconst next = pick(weakest!.line);\n \t\t\t\tif (next) relocs.set(weakest!.line, next);\n \t\t\t\telse relocs.delete(weakest!.line);"}],"ci":null}