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
blame on this site's /mcp
CLI
abso blame worker/project/test/blobs.test.ts --json
JSON
/christopher/abso-core/blame/worker/project/test/blobs.test.ts?format=json
110 linesFirst import 98% · rename 2%Last change rename in version 100,

110 lines from 2 changes in 2 versions.

init0Start the project1// Binary files (#27): a file with no lines and a `blob` attribute, the
2// SHA-256 of its bytes, which live outside the graph (R2). They travel
3// through record, publish, sync, restore and plain-git intake, and collide
4// only when two drafts set the same file's blob.
5
6import assert from "node:assert/strict";
7import { test } from "node:test";
8import { MemoryStore, Project, ProjectError } from "../project.ts";
9
10const A = "a".repeat(64);
11const B = "b".repeat(64);
12const C = "c".repeat(64);
14function setup(held: Set<string> = new Set([A, B, C])) {
15 const store = new MemoryStore();
16 const project = new Project(store, { hasBlob: (sha) => held.has(sha) });
17 project.init({ "README.md": "hi\n" }, 0, {}, { "logo.png": A });
18 project.sync("ann");
19 project.sync("bob");
20 return { project, store };
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare23test("init and a first pull carry binary files as blobs, not text", () => {
init0Start the project24 const store = new MemoryStore();
25 const project = new Project(store, { hasBlob: () => true });
26 project.init({ "README.md": "hi\n" }, 0, {}, { "logo.png": A });
27 const s = project.sync("cat");
28 assert.deepEqual(s.files, { "README.md": "hi\n" });
29 assert.deepEqual((s as { blobs?: unknown }).blobs, { "logo.png": A });
30 assert.deepEqual(project.files(), { "README.md": "hi\n" });
31 assert.deepEqual(project.blobs(), { "logo.png": A });
32});
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare34test("a blob changed, pushed and pulled; a file turning binary and back", () => {
init0Start the project35 const { project } = setup();
36 project.record("ann", {}, 1, {}, { "logo.png": B, "README.md": C });
37 assert.equal(project.publish("ann", "New logo; readme is binary now", 2).ok, true);
38 const b = project.sync("bob") as { files: unknown; blobs?: unknown };
39 assert.deepEqual(b.files, {});
40 assert.deepEqual(b.blobs, { "README.md": C, "logo.png": B });
41 project.record("bob", { "README.md": "text again\n" }, 3);
42 assert.equal(project.publish("bob", "Readme is text", 4).ok, true);
43 const a = project.sync("ann") as { files: unknown; blobs?: unknown };
44 assert.deepEqual(a.files, { "README.md": "text again\n" });
45 assert.deepEqual(a.blobs, { "README.md": null });
46 assert.deepEqual(project.blobs(), { "logo.png": B });
47 assert.equal(project.show(1).diff.find((f) => f.path === "logo.png")?.blob?.after, B);
48});
50test("two drafts changing the same binary file collide; different files do not", () => {
51 const { project } = setup();
52 project.record("ann", {}, 1, {}, { "logo.png": B });
53 project.record("bob", {}, 1, {}, { "logo.png": C });
54 project.publish("ann", "Blue logo", 2);
55 const refused = project.publish("bob", "Red logo", 3);
56 assert.equal(refused.ok, false);
57 const c = !refused.ok ? refused.collisions[0]! : undefined;
58 assert.deepEqual(c && [c.kind, c.name, c.file, c.yours.text, c.theirs.text], ["attribute", "blob", "logo.png", C, B]);
59 project.sync("bob");
60 project.record("bob", {}, 4, {}, { "icon.png": C });
61 assert.equal(project.publish("bob", "Red logo after all", 5).ok, true);
62});
64test("a blob must be uploaded first, be a SHA-256, and not also be text", () => {
65 const { project } = setup(new Set([A]));
66 const code = (f: () => unknown) => {
67 try {
68 f();
69 } catch (e) {
70 return e instanceof ProjectError ? e.message : String(e);
71 }
72 return "no error";
73 };
74 assert.match(
75 code(() => project.record("ann", {}, 1, {}, { "x.png": B })),
76 /upload blob b{64} first/,
77 );
78 assert.match(
79 code(() => project.record("ann", {}, 1, {}, { "x.png": "nope" })),
80 /SHA-256/,
81 );
82 assert.match(
83 code(() => project.record("ann", { "x.png": "x" }, 1, {}, { "x.png": A })),
84 /both text and a blob/,
85 );
86});
88test("restore puts the blob back; plain-git intake takes blobs; a log with blobs loads", () => {
89 const { project, store } = setup();
90 project.record("ann", {}, 1, {}, { "logo.png": B });
91 const r = project.restore("ann", ["logo.png"], 2) as { files: unknown; blobs?: unknown };
92 assert.deepEqual(r.files, {});
93 assert.deepEqual(r.blobs, { "logo.png": A });
95 const answer = project.ingest(
96 {
97 author: "pat",
98 base: 0,
99 commits: [
100 { sha: "abcdef12", message: "pics", files: { "README.md": "hi\n" }, blobs: { "logo.png": A, "pic.jpg": C } },
101 ],
102 },
103 3,
104 );
105 assert.equal(answer.landed, true);
106 assert.deepEqual(project.blobs(), { "logo.png": A, "pic.jpg": C });
107 assert.deepEqual(Project.load(store.entries, new MemoryStore()).blobs(), project.blobs());
108 // Without a blob store, binary files are refused.
109 assert.throws(() => new Project(new MemoryStore()).init({}, 0, {}, { "logo.png": A }), /upload blob/);
110});