{"draft":null,"from":108,"to":109,"files":[{"path":"src/engine/test/view.test.ts","added":29,"removed":0,"diff":"--- a/src/engine/test/view.test.ts\n+++ b/src/engine/test/view.test.ts\n@@ -3,9 +3,38 @@\n import assert from \"node:assert/strict\";\n import { describe, it } from \"node:test\";\n import { buildBase, conflicts, Graph, project, View } from \"../index.ts\";\n+import { StableOverlaySet, StableSet } from \"../state-source.ts\";\n+import type { AtomId } from \"../types.ts\";\n import { lines, Repo } from \"./helpers.ts\";\n \n describe(\"View\", () => {\n+\tit(\"immutable indexed membership avoids a history-sized bitmap and remains a snapshot\", () => {\n+\t\tclass RangeMembership extends StableSet<AtomId> {\n+\t\t\treadonly retainedBytes = 64;\n+\t\t\treadonly count: number;\n+\t\t\tconstructor(count: number) {\n+\t\t\t\tsuper();\n+\t\t\t\tthis.count = count;\n+\t\t\t}\n+\t\t\thas(id: AtomId): boolean {\n+\t\t\t\treturn /^a[0-9]+$/.test(id) && Number(id.slice(1)) < this.count;\n+\t\t\t}\n+\t\t\t*values(): SetIterator<AtomId> {\n+\t\t\t\tfor (let i = 0; i < this.count; i++) yield `a${i}`;\n+\t\t\t}\n+\t\t}\n+\t\tconst repo = Repo.init({ \"a.txt\": \"0\\n\" });\n+\t\tfor (let i = 1; i <= 40; i++) repo.edit({ edits: [{ file: \"a.txt\", old: `${i - 1}\\n`, new: `${i}\\n` }] });\n+\t\tconst first = new View(repo.graph, new RangeMembership(repo.graph.size));\n+\t\tconst weight = first.weight();\n+\t\tfor (let i = 41; i <= 80; i++) repo.edit({ edits: [{ file: \"a.txt\", old: `${i - 1}\\n`, new: `${i}\\n` }] });\n+\t\tconst second = new View(repo.graph, new RangeMembership(repo.graph.size));\n+\t\tassert.equal(second.weight(), weight, \"membership resident size does not increase with historical atom count\");\n+\t\tassert.equal(first.text(\"a.txt\"), \"40\\n\");\n+\t\tassert.equal(second.text(\"a.txt\"), \"80\\n\");\n+\t\tassert.equal(first.set.has(\"a80\"), false);\n+\t\tassert.throws(() => new View(repo.graph, new StableOverlaySet<AtomId>([\"a1\"])), /not closed/);\n+\t});\n \tit(\"keeps deleted lines as tombstones in the full sequence\", () => {\n \t\tconst repo = Repo.init({ \"f.txt\": lines(\"one\", \"two\", \"three\") });\n \t\tconst del = repo.edit({ edits: [{ file: \"f.txt\", old: \"two\\n\", new: \"\" }] });"}],"unmatched":[]}