Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 177 --json
JSON
/christopher/abso-core/versions/177?format=json

Read Artifacts snapshots in version-pinned batches; cleared in review ask 45

of shared·codex-capacity-chair··Not checked

Version 176 · Files at version 177

5 files, 175 lines added, 1 removed.

--- a/server/src/engine-project.ts
+++ b/server/src/engine-project.ts
@@ -9,6 +9,7 @@
99import { type Entry, type ProjectStore as LogStore, MemoryStore, Project } from "../../worker/project/project.ts";
1010import type { EditBody, ProjectCalls, ProjectHistory } from "../../worker/project/project-api.ts";
1111import { where } from "../../worker/project/where.ts";
12+import type { PushSnapshotMetadata } from "./push-snapshot.ts";
1213
1314/** The parts of a Durable Object's storage the log and blob store use, declared structurally so tests can stand in. */
1415export interface SqliteStorage {
@@ -807,6 +808,38 @@
807808 filesAt(version: number) {
808809 return this.project.viewAt(version).files();
809810 }
811+ fileTextAt(version: number, path: string): string {
812+ return this.project.viewAt(version).text(path);
813+ }
814+ /** One scoped batch: at most 64 files and 64 Ki characters plus one whole file. */
815+ fileTextsAt(version: number, paths: readonly string[]): Record<string, string> {
816+ const view = this.project.viewAt(version);
817+ const files: Record<string, string> = Object.create(null);
818+ let characters = 0;
819+ for (const path of paths.slice(0, 64)) {
820+ const text = view.attrs(path).link !== null ? "" : view.text(path);
821+ files[path] = text;
822+ characters += text.length;
823+ if (characters >= 65536) break;
824+ }
825+ return files;
826+ }
827+ /** Capture metadata now; each text read reopens the captured version in a fresh host scope. */
828+ sharedPushMetadata(): PushSnapshotMetadata {
829+ const version = this.project.version;
830+ const view = this.project.viewAt(version);
831+ const paths: string[] = [];
832+ const modes: PushSnapshotMetadata["modes"] = Object.create(null);
833+ const blobs: Record<string, string> = Object.create(null);
834+ for (const path of view.paths()) {
835+ const attrs = view.attrs(path);
836+ modes[path] = { exec: attrs.exec, link: attrs.link };
837+ if (attrs.blob !== null) blobs[path] = attrs.blob;
838+ else paths.push(path);
839+ }
840+ const by = version > 0 ? this.project.published(version) : undefined;
841+ return { version, paths, modes, blobs, ...(by ? { last: { agent: by.agent, message: by.message } } : {}) };
842+ }
810843 blobsAt(version: number) {
811844 return this.project.viewAt(version).blobs();
812845 }
--- a/server/src/project-object.ts
+++ b/server/src/project-object.ts
@@ -26,6 +26,7 @@
2626 revokeKey,
2727} from "./keys.ts";
2828import { type PushResult, pushShared, repoName } from "./push.ts";
29+import { pushSnapshot } from "./push-snapshot.ts";
2930import { SqliteWriterState } from "./writer-host.ts";
3031
3132const READ_OPS = new Set([
@@ -605,7 +606,11 @@
605606 error: e instanceof Error ? e.message : String(e),
606607 }),
607608 );
608− const shared = this.useProject((p) => p.shared());
609+ const shared = pushSnapshot(
610+ this.useProject((p) => p.sharedPushMetadata()),
611+ (version, path) => this.useProject((current) => current.fileTextAt(version, path)),
612+ (version, paths) => this.useProject((current) => current.fileTextsAt(version, paths)),
613+ );
609614 const done = await this.ctx.storage.get<PushResult>("pushed");
610615 if (done && done.version >= shared.version) return;
611616 const pushedAt = (await this.ctx.storage.get<number>("pushedAt")) ?? 0;
--- /dev/null
+++ b/server/src/push-snapshot.ts
@@ -0,0 +1,35 @@
1+import type { FileModes } from "../../worker/project/project-api.ts";
2+
3+export interface PushSnapshotMetadata {
4+ version: number;
5+ paths: string[];
6+ modes: FileModes;
7+ blobs: Record<string, string>;
8+ last?: { agent: string; message: string };
9+}
11+/** Construct outside the read scope so detaching metadata never evaluates file text. */
12+export function pushSnapshot(
13+ metadata: PushSnapshotMetadata,
14+ readText: (version: number, path: string) => string,
15+ readBatch?: (version: number, paths: readonly string[]) => Record<string, string>,
16+) {
17+ const { paths, ...shared } = metadata;
18+ const files: Record<string, string> = Object.create(null);
19+ let cache: Record<string, string> = Object.create(null);
20+ for (let index = 0; index < paths.length; index++) {
21+ const path = paths[index]!;
22+ Object.defineProperty(files, path, {
23+ enumerable: true,
24+ get: () => {
25+ if (!readBatch) return readText(shared.version, path);
26+ if (!Object.hasOwn(cache, path)) cache = readBatch(shared.version, paths.slice(index, index + 64));
27+ if (!Object.hasOwn(cache, path)) throw Error("push batch omitted requested file");
28+ const text = cache[path]!;
29+ delete cache[path];
30+ return text;
31+ },
32+ });
33+ }
34+ return { ...shared, files };
35+}
--- /dev/null
+++ b/server/test/push-snapshot-batch.test.ts
@@ -0,0 +1,34 @@
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import { answer } from "../../worker/project/http.ts";
4+import { EngineProject } from "../src/engine-project.ts";
5+import { pushSnapshot } from "../src/push-snapshot.ts";
6+import { memoryStorage } from "./helpers.ts";
7+
8+test("push batches cap file count and text while preserving exact lazy contents", (t) => {
9+ const storage = memoryStorage();
10+ t.after(() => storage.db.close());
11+ const project = EngineProject.open(storage);
12+ const files = Object.fromEntries(Array.from({ length: 130 }, (_, i) => [`f${i}`, `${i}\n`]));
13+ assert.equal(answer(project, "init", undefined, { files }).status, 200);
14+ let batches = 0;
15+ const snapshot = pushSnapshot(
16+ project.sharedPushMetadata(),
17+ () => {
18+ throw Error("single read forbidden");
19+ },
20+ (version, paths) => {
21+ batches++;
22+ return project.fileTextsAt(version, paths);
23+ },
24+ );
25+ assert.equal(batches, 0);
26+ assert.deepEqual({ ...snapshot.files }, files);
27+ assert.equal(batches, 3);
28+ const large = "x".repeat(70000) + "\n";
29+ assert.equal(answer(project, "record", "writer", { files: { large } }).status, 200);
30+ assert.equal(answer(project, "publish", "writer", { message: "Large file" }).status, 200);
31+ const batch = project.fileTextsAt(1, ["large", "f0"]);
32+ assert.deepEqual(Object.keys(batch), ["large"]);
33+ assert.equal(batch.large, large);
34+});
--- /dev/null
+++ b/server/test/push-snapshot.test.ts
@@ -0,0 +1,67 @@
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import { answer } from "../../worker/project/http.ts";
4+import { MemoryStore, Project } from "../../worker/project/project.ts";
5+import { DiskFirstRuntime } from "../src/disk-first-runtime.ts";
6+import { SqliteLog } from "../src/engine-project.ts";
7+import { pushSnapshot } from "../src/push-snapshot.ts";
8+import { memoryStorage } from "./helpers.ts";
9+
10+test("push snapshot reads a pinned version through fresh disk scopes after another publish", (t) => {
11+ const storage = memoryStorage();
12+ t.after(() => storage.db.close());
13+ const seed = new MemoryStore();
14+ new Project(seed).init({ "a.txt": "old\n", "b.txt": "stable\n" }, 0);
15+ new SqliteLog(storage).append(seed.entries);
16+ t.mock.method(Project, "load", () => {
17+ throw Error("full-history replay forbidden");
18+ });
19+ const runtime = () => new DiskFirstRuntime(storage, "push-snapshot", "push-snapshot");
20+ while (!runtime().preparePage(() => {}).ready) {}
21+ let reads = 0;
22+ const snapshot = pushSnapshot(
23+ runtime().read(
24+ (calls) => calls.sharedPushMetadata(),
25+ () => {},
26+ ),
27+ (version, path) => {
28+ reads++;
29+ return runtime().read(
30+ (current) => current.fileTextAt(version, path),
31+ () => {},
32+ );
33+ },
34+ (version, paths) => {
35+ reads++;
36+ return runtime().read(
37+ (current) => current.fileTextsAt(version, paths),
38+ () => {},
39+ );
40+ },
41+ );
42+ assert.equal(reads, 0);
43+ assert.equal(snapshot.files["a.txt"], "old\n");
44+ for (const [op, body] of [
45+ ["sync", {}],
46+ ["record", { files: { "a.txt": "new", "b.txt": "changed" } }],
47+ ["publish", { message: "Changed during push" }],
48+ ] as const)
49+ assert.equal(
50+ runtime().write(
51+ (calls) => answer(calls, op, "alice", body),
52+ () => {},
53+ ).status,
54+ 200,
55+ );
56+ assert.equal(snapshot.files["b.txt"], "stable\n");
57+ assert.equal(snapshot.files["a.txt"], "old\n");
58+ assert.equal(snapshot.version, 0);
59+ assert.equal(reads, 2);
60+ assert.equal(
61+ runtime().read(
62+ (calls) => calls.shared().version,
63+ () => {},
64+ ),
65+ 1,
66+ );
67+});