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

Versions 2 to 318

Compare

+67 −0 in 1 place
new file, 67 lines
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+});
MCP
compare on this site's /mcp
CLI
abso diff 2 318 server/test/push-snapshot.test.ts --json
JSON
/christopher/abso-core/compare/2..318?file=server%2Ftest%2Fpush-snapshot.test.ts&format=json