Versions 156 to 157
new file, 429 lines
4+import { indexAcceptedProjectionAtom } from "../../src/engine/experimental/projection-atom-index.ts";
15+
28+ "CREATE TABLE IF NOT EXISTS writer_state (namespace TEXT NOT NULL, collection TEXT NOT NULL, key TEXT NOT NULL, part INTEGER NOT NULL, value TEXT NOT NULL, PRIMARY KEY(namespace, collection, key, part))",
34+ "SELECT value FROM writer_state WHERE namespace = ? AND collection = ? AND key = ? AND part = -1",
41+ const meta = JSON.parse(header[0]!.value) as { parts: number; characters: number; bytes: number };
56+ "SELECT part, value FROM writer_state WHERE namespace = ? AND collection = ? AND key = ? AND part >= 0 ORDER BY part LIMIT ?",
63+ if (rows.length !== meta.parts || rows.some((row, index) => row.part !== index || row.value.length > PART))
66+ if (json.length !== meta.characters || new TextEncoder().encode(json).byteLength !== meta.bytes)
72+ if (json.length > SqliteWriterState.maxValueBytes) throw new Error("writer-state value exceeds byte bound");
74+ if (bytes > SqliteWriterState.maxValueBytes) throw new Error("writer-state value exceeds byte bound");
120+ "SELECT key FROM writer_state WHERE namespace = ? AND collection = ? AND part = -1 ORDER BY key LIMIT 1",
125+ "SELECT key FROM writer_state WHERE namespace = ? AND collection = ? AND part = -1 AND key > ? ORDER BY key LIMIT 1",
140+
145+
155+
156+export function advanceWriterRoot(log: SqliteLog, previous: WriterRoot, source: WriterSource): WriterRoot {
158+ if (source.logLength < previous.logLength) throw new Error("writer root cannot move backwards");
163+
171+
174+ open(input: { state: SqliteWriterState; log: SqliteLog; root: WriterRoot }): WriterProjectionSession;
176+
198+ if (mode !== undefined && mode !== expected) throw Error("writer atom indexing mode mismatch");
199+ if (mode === undefined && this.#indexProjectionAtoms && (!adopting || this.#state.read("atoms:meta", "length")))
201+ if (mode === undefined && adopting) this.#state.write("host", "projection-atom-index-mode", expected);
202+ return { indexAcceptedAtom: this.#indexProjectionAtoms ? indexAcceptedProjectionAtom : undefined };
204+
207+ const shared = this.#storage.sql.exec("SELECT value FROM counts WHERE name = 'shared'").toArray() as {
212+ return { generation: this.#log.generation(), logLength: this.#log.seq(), sharedVersion: shared[0]!.value };
215+ return a?.generation === b.generation && a.logLength === b.logLength && a.sharedVersion === b.sharedVersion;
219+ if (root?.format !== 1 || !/^[a-f0-9]{64}$/.test(root.digest) || !SqliteWriterHost.#same(root, this.source()))
240+ if (!SqliteWriterHost.#same(input.expected, this.source())) throw new Error("adoption source changed");
266+ const cursor = this.#state.read("host", "adoption-root") as { next: number; digest: string } | undefined;
276+ adoptPage(from: number, limits: { maxEntries: number; maxBytes: number }, validateAuthority: () => void) {
287+ (from > 0 && (!previous || previous.next !== from || !SqliteWriterHost.#same(previous.source, source)))
319+ this.#state.write("host", "canonical-root", { format: 1, ...source, digest } satisfies WriterRoot);
335+ if (!SqliteWriterHost.#same(input.expected, source)) throw new Error("reader source is stale");
346+ const projection = this.#projection?.open({ state: this.#state, log: this.#log, root: this.root() });
350+ ...(input.services?.whole ? { whole: { read: input.services.whole.read, keep: refuse } } : {}),
364+
377+ const calls = new EngineProject(project, (from, limit) => this.#log.since(from, limit), this.#log);
- MCP
- compare on this site's /mcp
- CLI
- abso diff 156 157 server/src/writer-host.ts --json
- JSON
- /christopher/abso-core/compare/156..157?file=server%2Fsrc%2Fwriter-host.ts&format=json