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/attributes.test.ts --json
JSON
/christopher/abso-core/blame/worker/project/test/attributes.test.ts?format=json
135 linesFirst import 99% · rename 1%Last change rename in version 100,

135 lines from 2 changes in 2 versions.

init0Start the project1// File attributes (#27): empty files, the executable bit and symbolic links
2// live in the graph as claims of their own, so they travel through publish,
3// sync, drafts and plain-git intake, and collide only with the same attribute.
4
5import assert from "node:assert/strict";
6import { test } from "node:test";
7import { MemoryStore, Project } from "../project.ts";
8
9function setup() {
10 const store = new MemoryStore();
11 const project = new Project(store);
12 project.init({ "run.sh": "echo hi\n", "pkg/__init__.py": "", "notes.md": "a\n" }, 0, {
13 "run.sh": { exec: true },
14 latest: { link: "run.sh" },
15 });
16 return { project, store };
19test("init keeps empty files, executable files and links", () => {
20 const { project } = setup();
21 const s = project.sync("ann");
22 assert.deepEqual(s.files, { latest: "", "notes.md": "a\n", "pkg/__init__.py": "", "run.sh": "echo hi\n" });
23 assert.deepEqual(s.modes, { latest: { exec: false, link: "run.sh" }, "run.sh": { exec: true, link: null } });
24 assert.deepEqual(project.modes(), { latest: { link: "run.sh" }, "run.sh": { exec: true } });
25});
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.Compare27test("an empty file can be made, pushed, pulled and removed", () => {
init0Start the project28 const { project } = setup();
29 project.sync("ann");
30 project.sync("bob");
31 project.edit("ann", { file: ".gitkeep", content: "" }, 1);
32 project.record("ann", { "notes.md": "" }, 1); // emptied, not deleted
33 project.publish("ann", "Empty files", 2);
34 assert.deepEqual(project.sync("bob").files, { ".gitkeep": "", "notes.md": "" });
35 project.record("bob", { ".gitkeep": null }, 3);
36 project.publish("bob", "Drop gitkeep", 4);
37 assert.equal(".gitkeep" in project.files(), false);
38 assert.equal(project.files()["notes.md"], "");
39});
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.Compare41test("the executable bit and links change on their own, and show up in pull, show and diff", () => {
init0Start the project42 const { project } = setup();
43 project.sync("ann");
44 project.sync("bob");
45 project.record("ann", {}, 1, { "notes.md": { exec: true }, latest: { link: "notes.md" } });
46 assert.deepEqual(project.diff("ann").files, [
47 {
48 path: "latest",
49 before: "",
50 after: "",
51 mode: { before: { exec: false, link: "run.sh" }, after: { exec: false, link: "notes.md" } },
52 },
53 {
54 path: "notes.md",
55 before: "a\n",
56 after: "a\n",
57 mode: { before: { exec: false, link: null }, after: { exec: true, link: null } },
58 },
59 ]);
60 project.publish("ann", "Modes", 2);
61 const b = project.sync("bob");
62 assert.deepEqual(b.files, {});
63 assert.deepEqual(b.modes, { latest: { exec: false, link: "notes.md" }, "notes.md": { exec: true, link: null } });
64 assert.equal(project.show(1).diff.length, 2);
65 // Recording the same modes again changes nothing.
66 assert.deepEqual(project.record("bob", {}, 3, { "notes.md": { exec: true } }).changed, []);
67});
69test("two drafts collide on the same attribute only", () => {
70 const { project } = setup();
71 project.sync("ann");
72 project.sync("bob");
73 project.record("ann", {}, 1, { "notes.md": { exec: true } });
74 project.edit("bob", { file: "notes.md", old: "a\n", new: "b\n" }, 1); // lines, not the bit: no collision
75 project.record("bob", {}, 1, { "run.sh": { exec: false } });
76 project.publish("ann", "exec notes", 2);
77 assert.equal(project.publish("bob", "lines and run.sh", 3).ok, true);
79 project.sync("ann");
80 project.sync("bob");
81 // Both set run.sh's bit (bob cleared it above), so both write the same attribute.
82 project.record("ann", {}, 4, { "run.sh": { exec: true } });
83 project.record("bob", {}, 4, { "run.sh": { exec: true } });
84 project.record("bob", { "run.sh": "echo bye\n" }, 4);
85 project.publish("ann", "run.sh executable again", 5);
86 const refused = project.publish("bob", "run.sh plain", 6);
87 assert.equal(refused.ok, false);
88 const c = !refused.ok ? refused.collisions.find((x) => x.kind === "attribute") : undefined;
89 assert.deepEqual(c && { kind: c.kind, name: c.name, file: c.file, yours: c.yours.text, theirs: c.theirs.text }, {
90 kind: "attribute",
91 name: "exec",
92 file: "run.sh",
93 yours: "1",
94 theirs: "1",
95 });
96 // After a sync bob has seen ann's; publishing settles it.
97 project.sync("bob");
98 assert.equal(project.publish("bob", "Keep it executable", 8).ok, true);
99 assert.deepEqual(project.modes()["run.sh"], { exec: true });
100});
102test("restore puts the mode back, and plain-git intake reads modes", () => {
103 const { project, store } = setup();
104 project.sync("ann");
105 project.record("ann", {}, 1, { "run.sh": { exec: false } });
106 assert.deepEqual(project.restore("ann", ["run.sh"], 2), {
107 files: { "run.sh": "echo hi\n" },
108 dropped: 1,
109 modes: { "run.sh": { exec: true, link: null } },
110 });
112 const files = { "run.sh": "echo hi\n", "pkg/__init__.py": "", "notes.md": "a\n", latest: "", "tool.sh": "x\n" };
113 const answer = project.ingest(
114 {
115 author: "p",
116 base: 0,
117 commits: [
118 {
119 sha: "abcdef12",
120 message: "tool",
121 files,
122 modes: { "run.sh": { exec: true }, latest: { link: "run.sh" }, "tool.sh": { exec: true } },
123 },
124 ],
125 },
126 3,
127 );
128 assert.equal(answer.landed, true);
129 assert.deepEqual(project.modes(), {
130 latest: { link: "run.sh" },
131 "run.sh": { exec: true },
132 "tool.sh": { exec: true },
133 });
134 assert.deepEqual(Project.load(store.entries, new MemoryStore()).modes(), project.modes());
135});