- MCP
- show on this site's /mcp
- CLI
- abso show 165 --json
- JSON
- /christopher/abso-core/versions/165?format=json
Stream projection atom hashing and comparison and reduce locator writes
of shared·codex-capacity-chair··Not checked
Version 164 · Files at version 165
8 files, 216 lines added, 38 removed.
--- a/src/engine/experimental/projection-atom-index.ts
+++ b/src/engine/experimental/projection-atom-index.ts
@@ -1,4 +1,5 @@
45
@@ -173,6 +174,8 @@
173174
175176export function indexAcceptedProjectionAtom(atom: Atom, files: readonly string[], storage: GraphStateStorage): void {
176− const digest = createHash("sha256").update(JSON.stringify(atom)).digest("hex");
--- a/src/engine/experimental/projection-locator.ts
+++ b/src/engine/experimental/projection-locator.ts
@@ -55,14 +55,6 @@
5555 if (!/^[0-9a-f]$/.test(digit) || !safe(child) || child === id) throw Error("invalid locator child");
58− #write(node: Node): number {
59− const next = this.#storage.read(this.#collection, "next") ?? 0;
60− if (!safe(next) || !Number.isSafeInteger(next + 1)) throw Error("invalid locator allocation");
61− if (this.#storage.read(this.#collection, String(next)) !== undefined) throw Error("locator allocation collision");
62− this.#storage.write(this.#collection, String(next), node);
63− this.#storage.write(this.#collection, "next", next + 1);
64− return next;
65− }
@@ -149,31 +141,8 @@
150142
152− page(root);
153− const key = keyOf(id),
154− checked = structuredClone(this.#decode(structuredClone(value)));
155− return this.#storage.transaction(() => {
156− const visit = (current: Page, parent?: string, digit?: string, depth = 0): number => {
157− if (depth > 8) throw Error("invalid locator depth");
158− if (current === null) return this.#write({ format: 1, kind: "leaf", prefix: key, value: checked });
159− const node = this.#read(current, parent, digit);
160− let common = 0;
161− while (common < node.prefix.length && node.prefix[common] === key[common]) common++;
162− if (common < node.prefix.length) {
163− const leaf = this.#write({ format: 1, kind: "leaf", prefix: key, value: checked });
164− return this.#write({
165− format: 1,
166− kind: "branch",
167− prefix: key.slice(0, common),
168− children: { [node.prefix[common]!]: current, [key[common]!]: leaf },
169− });
170− }
171− if (node.kind === "leaf") return this.#write({ format: 1, kind: "leaf", prefix: key, value: checked });
172− const nextDigit = key[common]!;
173− const child = visit(node.children[nextDigit] ?? null, node.prefix, nextDigit, depth + 1);
174− return this.#write({ ...node, children: { ...node.children, [nextDigit]: child } });
175− };
176− return visit(root);
177− });
--- a/src/engine/experimental/projection-marker.ts
+++ b/src/engine/experimental/projection-marker.ts
@@ -1,4 +1,5 @@
@@ -112,7 +113,7 @@
115− if (JSON.stringify(this.graph.atom(atom.id)) !== JSON.stringify(atom)) throw Error("canonical atom mismatch");
118119 if (!this.members.get(previous.membership, this.graph.atom(id).seq)?.present) throw Error("missing dependency");
@@ -187,7 +188,7 @@
190− if (JSON.stringify(this.graph.atom(atom.id)) !== JSON.stringify(atom)) throw Error("canonical atom mismatch");
--- /dev/null
+++ b/src/engine/json-value-chunks.ts
@@ -0,0 +1,94 @@
25+ const omitted = (value: unknown) => value === undefined || typeof value === "function" || typeof value === "symbol";
28+ else if (value === null || typeof value === "boolean" || typeof value === "number") yield JSON.stringify(value);
29+ else if (typeof value !== "object" || value === null) throw Error("unsupported canonical JSON value");
65+
--- /dev/null
+++ b/src/engine/test/json-value-chunks.test.ts
@@ -0,0 +1,66 @@
5+
28+ for (const value of values) assert.equal([...jsonValueChunks(value)].join(""), JSON.stringify(value));
33+
34+test("canonical JSON string chunks preserve every surrogate split and bound escaped output", () => {
42+ assert.equal(hash.digest("hex"), createHash("sha256").update(JSON.stringify(value)).digest("hex"));
45+
--- a/src/engine/test/projection-atom-index.test.ts
+++ b/src/engine/test/projection-atom-index.test.ts
@@ -11,6 +11,21 @@
1313
14+test("accepted atom indexing preserves the original digest without serializing the whole atom", (t) => {
17+ const repo = Repo.init({ "a.txt": `${"x".repeat(16383)}\ud83d\ude80\n${"\u0000".repeat(20000)}\n` });
28+
--- a/src/engine/test/projection-locator.test.ts
+++ b/src/engine/test/projection-locator.test.ts
@@ -114,6 +114,7 @@
@@ -122,8 +123,15 @@
125− for (const [key, value] of edits) right = sequential.set(right, key, value);