Versions 68 to 318
new file, 474 lines
4+import { indexAcceptedProjectionAtom } from "../../src/engine/experimental/projection-atom-index.ts";
17+
30+ "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))",
36+ "SELECT value FROM writer_state WHERE namespace = ? AND collection = ? AND key = ? AND part = -1",
43+ const meta = JSON.parse(header[0]!.value) as { parts: number; characters: number; bytes: number };
58+ "SELECT part, value FROM writer_state WHERE namespace = ? AND collection = ? AND key = ? AND part >= 0 ORDER BY part LIMIT ?",
65+ if (rows.length !== meta.parts || rows.some((row, index) => row.part !== index || row.value.length > PART))
68+ if (json.length !== meta.characters || new TextEncoder().encode(json).byteLength !== meta.bytes)
74+ if (json.length > SqliteWriterState.maxValueBytes) throw new Error("writer-state value exceeds byte bound");
76+ if (bytes > SqliteWriterState.maxValueBytes) throw new Error("writer-state value exceeds byte bound");
122+ "SELECT key FROM writer_state WHERE namespace = ? AND collection = ? AND part = -1 ORDER BY key LIMIT 1",
127+ "SELECT key FROM writer_state WHERE namespace = ? AND collection = ? AND part = -1 AND key > ? ORDER BY key LIMIT 1",
142+
147+
152+
154+export function writerFrameChunksDigest(previous: string, seq: number, chunks: Iterable<string>): string {
170+
171+export function advanceWriterRoot(log: SqliteLog, previous: WriterRoot, source: WriterSource): WriterRoot {
173+ if (source.logLength < previous.logLength) throw new Error("writer root cannot move backwards");
178+
182+ historicalReadViewProvider?(state: GraphStateStorage): NonNullable<ProjectOptions["readViewProvider"]>;
187+
190+ open(input: { state: SqliteWriterState; log: SqliteLog; root: WriterRoot }): WriterProjectionSession;
192+
218+ if (mode !== undefined && mode !== expected) throw Error("writer atom indexing mode mismatch");
219+ if (mode === undefined && this.#indexProjectionAtoms && (!adopting || this.#state.read("atoms:meta", "length")))
221+ if (mode === undefined && adopting) this.#state.write("host", "projection-atom-index-mode", expected);
222+ return { indexAcceptedAtom: this.#indexProjectionAtoms ? indexAcceptedProjectionAtom : undefined };
224+
227+ const shared = this.#storage.sql.exec("SELECT value FROM counts WHERE name = 'shared'").toArray() as {
232+ return { generation: this.#log.generation(), logLength: this.#log.seq(), sharedVersion: shared[0]!.value };
235+ return a?.generation === b.generation && a.logLength === b.logLength && a.sharedVersion === b.sharedVersion;
239+ if (root?.format !== 1 || !/^[a-f0-9]{64}$/.test(root.digest) || !SqliteWriterHost.#same(root, this.source()))
260+ if (!SqliteWriterHost.#same(input.expected, this.source())) throw new Error("adoption source changed");
285+ const cursor = this.#state.read("host", "adoption-root") as { next: number; digest: string } | undefined;
295+ adoptPage(from: number, limits: { maxEntries: number; maxBytes: number }, validateAuthority: () => void) {
306+ (from > 0 && (!previous || previous.next !== from || !SqliteWriterHost.#same(previous.source, source)))
337+ this.#state.write("host", "canonical-root", { format: 1, ...source, digest } satisfies WriterRoot);
353+ if (!SqliteWriterHost.#same(input.expected, source)) throw new Error("reader source is stale");
364+ const projection = this.#projection?.open({ state: this.#state, log: this.#log, root: this.root() });
368+ ...(input.services?.whole ? { whole: { read: input.services.whole.read, keep: refuse } } : {}),
400+
419+ ? (at, operation) => this.#history!.read(root, () => this.root(), input.validateAuthority, at, operation)
460+ this.#history?.advance(this.#log, root, committedRoot, () => this.root(), input.validateAuthority);
- MCP
- compare on this site's /mcp
- CLI
- abso diff 68 318 server/src/writer-host.ts --json
- JSON
- /christopher/abso-core/compare/68..318?file=server%2Fsrc%2Fwriter-host.ts&format=json