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/starting.test.ts --json
JSON
/christopher/abso-core/blame/worker/project/test/starting.test.ts?format=json
221 linesFirst import 96% · rename 3% · infra-split 1%Last change rename in version 100,

221 lines from 3 changes in 3 versions.

infra-split37Comments and test names give each reason in plain words, without naming who raised it Notes like "(#37, Builder 5)" or "(AVCS - Security)" become "(#37)" or go, and a private commit hash after a name goes with it. Issue numbers and references such as git's CVE-2019-1353 stay. Only comments and test names change; no behavior changes.Compare1// Seeing overlap before it happens (#37; #13): a
init0Start the project2// starting note says what an agent is taking on before any edit lands, and
3// the first edit to a file someone else is working on brings one line of
4// news. Neither ever stops an edit or a publish.
5
6import assert from "node:assert/strict";
7import { test } from "node:test";
8import { matchesPattern, pathsInText, patternsMeet } from "../globs.ts";
9import { type EditBody, MemoryStore, Project } from "../project.ts";
11/** An edit that must go through: its news. */
12function edit(project: Project, agent: string, body: EditBody, time: number): { news: string[] } {
13 const a = project.edit(agent, body, time);
14 if (!a.ok) throw new Error(`edit by ${agent} was out of step`);
15 return a;
18function setup() {
19 const store = new MemoryStore();
20 const project = new Project(store);
21 project.init(
22 {
23 "src/storm/storm.ts": "export const storm = 1;\n",
24 "src/storm/system.ts": "export const system = 1;\n",
25 "notes/todo.md": "# todo\n",
26 },
27 0,
28 );
29 for (const a of ["builder3", "builder6", "writer1"]) project.sync(a);
30 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.Compare33test("the first edit to a file in someone else's unpushed draft brings one line of news, once", () => {
init0Start the project34 const { project } = setup();
35 edit(project, "builder3", { file: "src/storm/storm.ts", old: "1", new: "2" }, 1);
36 edit(project, "builder3", { file: "src/storm/system.ts", old: "1", new: "2" }, 2);
37 const first = edit(project, "builder6", { file: "src/storm/storm.ts", old: "storm = 1", new: "storm = 3" }, 3);
38 assert.equal(first.news.length, 1);
39 assert.match(
40 first.news[0]!,
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.Compare41 /^builder3 has unpushed changes in src\/storm\/storm\.ts, which you just started changing/,
init0Start the project42 );
43 // Its second edit to the same file says nothing more; a new file does.
44 assert.deepEqual(
45 edit(project, "builder6", { file: "src/storm/storm.ts", old: "storm = 3", new: "storm = 4" }, 4).news,
46 [],
47 );
48 const second = project.record("builder6", { "src/storm/system.ts": "export const system = 5;\n" }, 5);
49 assert.equal(second.news.length, 1);
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.Compare50 assert.match(second.news[0]!, /^builder3 has unpushed changes in src\/storm\/system\.ts/);
init0Start the project51 // A file nobody else is in: no news.
52 assert.deepEqual(
53 edit(project, "builder6", { file: "notes/todo.md", old: "# todo", new: "# todo\n- storm" }, 6).news,
54 [],
55 );
56});
58test("a starting note shows in where-style notes and status before any edit, and the answer names who is already there", () => {
59 const { project } = setup();
60 edit(project, "builder3", { file: "src/storm/storm.ts", old: "1", new: "2" }, 1);
61 const a = project.starting(
62 "builder6",
63 "Storm cloud art (playtest-2 item 4)",
64 ["src/storm/storm.ts", "src/storm/art.ts"],
65 2,
66 );
67 assert.deepEqual(a.starting, {
68 text: "Storm cloud art (playtest-2 item 4)",
69 files: ["src/storm/art.ts", "src/storm/storm.ts"],
70 time: 2,
71 });
72 assert.deepEqual(a.overlaps, [{ agent: "builder3", file: "src/storm/storm.ts", changes: 1 }]);
73 assert.deepEqual(project.startingNotes(), [
74 {
75 agent: "builder6",
76 draft: null,
77 text: "Storm cloud art (playtest-2 item 4)",
78 files: ["src/storm/art.ts", "src/storm/storm.ts"],
79 time: 2,
80 },
81 ]);
82 assert.equal(
83 project.status().agents.find((s) => s.agent === "builder6")!.starting!.text,
84 "Storm cloud art (playtest-2 item 4)",
85 );
86 // builder3 hears of it with its next edit.
87 const heard = edit(project, "builder3", { file: "src/storm/storm.ts", old: "2", new: "7" }, 3);
88 assert.equal(heard.news.length, 1);
89 assert.match(
90 heard.news[0]!,
91 /^builder6 says it is starting on "Storm cloud art \(playtest-2 item 4\)", naming src\/storm\/storm\.ts/,
92 );
93});
95test("a first edit to a file named in someone's starting note brings news, before that agent has edited anything", () => {
96 const { project } = setup();
97 project.starting("writer1", "Smoke Harbour goal card", ["notes/todo.md"], 1);
98 const n = edit(project, "builder6", { file: "notes/todo.md", old: "# todo", new: "# todo\n- goal card" }, 2);
99 assert.equal(n.news.length, 1);
100 assert.match(
101 n.news[0]!,
102 /^writer1 says it is starting on notes\/todo\.md \("Smoke Harbour goal card"\), which you just started changing/,
103 );
104});
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.Compare106test("a starting note lasts through pushes until taken back, the next start, or 2 hours idle (#44); nothing is locked or refused", () => {
init0Start the project107 const { project, store } = setup();
108 project.starting("builder3", "Storm", ["src/storm/storm.ts"], 1);
109 // Someone else can still edit and publish the file.
110 edit(project, "builder6", { file: "src/storm/storm.ts", old: "1", new: "2" }, 2);
111 assert.equal(project.publish("builder6", "Mine", 3).ok, true);
112 project.sync("builder3");
113 edit(project, "builder3", { file: "src/storm/storm.ts", old: "2", new: "3" }, 4);
114 assert.equal(project.startingNotes().length, 1);
115 assert.equal(project.publish("builder3", "Storm", 5).ok, true);
116 assert.deepEqual(
117 project.startingNotes().map((n) => n.text),
118 ["Storm"],
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.Compare119 "a push no longer ends it",
init0Start the project120 );
121 // Two hours and a bit with nothing from builder3: it has ended.
122 assert.equal(
123 Project.load(store.entries, new MemoryStore(), { now: () => 5 + 2 * 60 * 60 * 1000 + 1 }).startingNotes().length,
124 0,
125 );
126 // The next start replaces it.
127 project.starting("builder3", "Storm, part two", undefined, 6);
128 assert.deepEqual(
129 project.startingNotes().map((n) => n.text),
130 ["Storm, part two"],
131 );
132 project.starting("builder3", null, undefined, 6);
133 project.starting("writer1", "Docs", undefined, 6);
134 assert.equal(project.startingNotes().length, 1);
135 assert.deepEqual(project.starting("writer1", null, undefined, 7), { starting: null, overlaps: [] });
136 assert.deepEqual(project.startingNotes(), []);
137 // The log loads back the same.
138 project.starting("writer1", "Docs again", ["notes/todo.md"], 8);
139 assert.deepEqual(
140 Project.load(store.entries, new MemoryStore(), { now: () => 8 }).startingNotes(),
141 project.startingNotes(),
142 );
143});
infra-split37Comments and test names give each reason in plain words, without naming who raised it Notes like "(#37, Builder 5)" or "(AVCS - Security)" become "(#37)" or go, and a private commit hash after a name goes with it. Issue numbers and references such as git's CVE-2019-1353 stay. Only comments and test names change; no behavior changes.Compare145test("a note that names files by glob, or only in its text, brings news on a first edit (#37)", () => {
init0Start the project146 const project = new Project(new MemoryStore());
147 project.init(
148 {
149 "tools/play.mjs": "launch();\n",
150 "tools/shot.mjs": "launch();\n",
151 "tools/lib/args.mjs": "x;\n",
152 "src/audio/audio.ts": "a;\n",
153 "src/main.ts": "m;\n",
154 },
155 0,
156 );
157 for (const a of ["builder4", "builder6", "builder5"]) project.sync(a);
158 // builder6's real note: the glob is only in the text.
159 project.starting("builder6", "Add --mute-audio to every Chromium launch in tools/*.mjs", undefined, 1);
160 const first = edit(
161 project,
162 "builder4",
163 { file: "tools/play.mjs", old: "launch();", new: "launch({ mute: true });" },
164 2,
165 );
166 assert.deepEqual(first.news, [
167 'builder6 says it is starting on tools/play.mjs ("Add --mute-audio to every Chromium launch in tools/*.mjs"), which you just started changing. If it\'s the same work, talk to builder6 before going further; abso where shows the lines.',
168 ]);
169 // `*` stays in its folder.
170 assert.deepEqual(edit(project, "builder4", { file: "tools/lib/args.mjs", old: "x;", new: "y;" }, 3).news, []);
171 // Globs in files, and a bare file name in the text, count too.
172 project.starting("builder5", "Mute flag: one line in main.ts", ["src/audio/**"], 4);
173 const n = project.record("builder4", { "src/audio/audio.ts": "b;\n", "src/main.ts": "n;\n" }, 5).news;
174 assert.equal(n.length, 1);
175 assert.match(
176 n[0]!,
177 /^builder5 says it is starting on src\/audio\/audio\.ts, src\/main\.ts \("Mute flag: one line in main\.ts"\)/,
178 );
179});
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.Compare181test("starting on a glob names the unpushed changes it covers, and their author hears of it", () => {
init0Start the project182 const project = new Project(new MemoryStore());
183 project.init({ "tools/play.mjs": "launch();\n", "tools/shot.mjs": "launch();\n", "src/x.ts": "x;\n" }, 0);
184 for (const a of ["builder4", "builder6"]) project.sync(a);
185 edit(project, "builder4", { file: "tools/play.mjs", old: "launch();", new: "launch(1);" }, 1);
186 edit(project, "builder4", { file: "src/x.ts", old: "x;", new: "y;" }, 2);
187 const a = project.starting("builder6", "Mute every launch", ["tools/*.mjs"], 3);
188 assert.deepEqual(a.overlaps, [{ agent: "builder4", file: "tools/play.mjs", changes: 1 }]);
189 assert.match(
190 project.news("builder4").news[0]!,
191 /^builder6 says it is starting on "Mute every launch", naming tools\/play\.mjs/,
192 );
193});
195test("globs.ts: patterns, meeting patterns, and paths in a note's text", () => {
196 assert.equal(matchesPattern("tools/*.mjs", "tools/play.mjs"), true);
197 assert.equal(matchesPattern("tools/*.mjs", "tools/lib/a.mjs"), false);
198 assert.equal(matchesPattern("tools/**/*.mjs", "tools/lib/a.mjs"), true);
199 assert.equal(matchesPattern("tools/**/*.mjs", "tools/a.mjs"), true);
200 assert.equal(matchesPattern("main.ts", "src/main.ts"), true);
201 assert.equal(matchesPattern("main.ts", "src/domain.ts"), false);
202 assert.equal(matchesPattern("src/main.ts", "main.ts"), false);
203 assert.equal(patternsMeet("tools/*.mjs", "tools/play.mjs"), true);
204 assert.equal(patternsMeet("tools/*.mjs", "tools/*.mjs"), true);
205 assert.equal(patternsMeet("tools/*.mjs", "src/*.ts"), false);
206 assert.deepEqual(pathsInText("Add --mute-audio to every Chromium launch in tools/*.mjs"), ["tools/*.mjs"]);
207 assert.deepEqual(
208 pathsInText(
209 "Key rebinding: src/render/keys.ts (remap + Keys panel), one line each in main.ts keydown/keyup, audio.ts KeyM",
210 ),
211 ["audio.ts", "keydown/keyup", "main.ts", "src/render/keys.ts"],
212 );
213 assert.deepEqual(pathsInText("ice saws x1.3, sells 0.05 iron/s at 120; see https://example.com/a.ts."), ["iron/s"]);
214});
216test("starting checks its input", () => {
217 const { project } = setup();
218 assert.throws(() => project.starting("writer1", " ", undefined, 1), /starting needs \{text\}/);
219 assert.throws(() => project.starting("writer1", "x", ["../etc"], 1));
220 assert.throws(() => project.starting("writer1", "x".repeat(1001), undefined, 1), /at most 1000/);
221});