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 159 --json
JSON
/christopher/abso-core/versions/159?format=json

Settles say what they kept in plain words: a held push's hint says the pull writes a marker block, the change page reads "kept bob's" or "rewrote both sides" rather than "kept rewrote", and a line rewritten longer no longer counts as lost

of shared·speed··Not checked

Version 158 · Files at version 159

5 files, 119 lines added, 4 removed.

--- a/client/src/publish-commands.ts
+++ b/client/src/publish-commands.ts
@@ -476,7 +476,7 @@
476476 ]
477477 : []),
478478 newer.length > 0
479− ? `Run abso pull: each of those files comes back holding both sides' lines, with no markers. Edit it to what it should be${twice.length > 0 ? ", keep one definition of each name defined twice" : ""}, then push again.`
479+ ? `Run abso pull: each of those files comes back holding both sides' lines, in a marker block where you both changed the same lines. Settle each as the pull says${twice.length > 0 ? ", keep one definition of each name defined twice" : ""}, then push again.`
480480 : twice.length > 0
481481 ? "Keep one definition of each name defined twice (delete yours, or theirs), then push again."
482482 : "Run abso pull, then push again.",
--- a/client/src/review.ts
+++ b/client/src/review.ts
@@ -83,6 +83,13 @@
8383 return ` ${c.id} ${c.agent}, ${titleLine(c.title)}${c.open ? " (still going)" : ""}: ${versionsText(c)}${files}${open > 0 ? `; ${plural(open, "open objection")}` : ""}`;
8484}
8585
86+/** What a settle kept, read from outside: whose lines, not "yours" or "theirs". */
87+function keptText(s: ChangeAnswer["settled"][number], settler: string): string {
88+ if (s.kept === "yours") return `kept ${settler}'s`;
89+ if (s.kept === "theirs") return `kept ${s.theirs.agent}'s`;
90+ return s.kept === "both" ? "kept both" : "rewrote both sides";
91+}
8693/** The change page, as text. */
8794export function changePage(c: ChangeAnswer): string[] {
8895 const out = [
@@ -99,7 +106,7 @@
99106 ),
100107 ...(c.settled.length > 0
101108 ? [
102− `Settled: ${c.settled.map((s) => `${s.file} (kept ${s.kept}, against ${s.theirs.agent}'s version ${s.theirs.version})`).join("; ")}.`,
109+ `Settled: ${c.settled.map((s) => `${s.file} (${keptText(s, c.agent)}, against ${s.theirs.agent}'s version ${s.theirs.version})`).join("; ")}.`,
103110 ]
104111 : []),
105112 ...(c.refusals.length > 0
--- /dev/null
+++ b/client/test/held-push.test.ts
@@ -0,0 +1,85 @@
1+// A held push from end to end, as two agents meet it: alice and bob change
2+// the same line, bob's push is held, he pulls, settles and pushes again.
3+// What each step prints has to be true.
4+
5+import assert from "node:assert/strict";
6+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7+import { tmpdir } from "node:os";
8+import { join } from "node:path";
9+import { after, before, describe, it } from "node:test";
10+import { main } from "../src/main.ts";
11+import { type Fake, startFake } from "./fake-server.ts";
13+const TOKEN = "test-token-not-secret";
14+const ENV = { AVCS_TOKEN: TOKEN, AVCS_HOOK_FORCE: "1", AVCS_SERVERS_FILE: "no-servers.json" };
15+const POLICY = "# Store policy\n\nFree shipping on orders over $50.\nReturns accepted within 30 days.\n";
16+const HELD = "Lower free shipping to $35: half of abandoned carts were between $35 and $50";
18+let fake: Fake;
19+const dirs: string[] = [];
20+before(async () => {
21+ fake = await startFake(0, TOKEN);
22+});
23+after(async () => {
24+ await fake.close();
25+ for (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 });
26+});
28+function temp(): string {
29+ const d = mkdtempSync(join(tmpdir(), "abso-held-"));
30+ dirs.push(d);
31+ return d;
32+}
34+async function run(cwd: string, ...argv: string[]): Promise<{ exit: number; out: string }> {
35+ const r = await main(argv, { cwd, env: ENV, write: () => {} });
36+ return { exit: r.exit, out: r.stdout + r.stderr };
37+}
39+let projects = 0;
40+/** alice pushes $75; bob's $35 push is held. Answers both folders and bob's held push. */
41+async function held(): Promise<{ alice: string; bob: string; refused: string }> {
42+ const name = `held${++projects}`;
43+ const alice = temp();
44+ writeFileSync(join(alice, "store-policy.md"), POLICY);
45+ assert.equal(
46+ (await run(alice, "init", "--server", fake.url, "--project", name, "--agent", "alice", "--as-is")).exit,
47+ 0,
48+ );
49+ const bob = temp();
50+ assert.equal((await run(bob, "join", name, "--agent", "bob", "--server", fake.url)).exit, 0);
51+ writeFileSync(join(alice, "store-policy.md"), POLICY.replace("$50", "$75"));
52+ writeFileSync(join(bob, "store-policy.md"), POLICY.replace("$50", "$35"));
53+ const pushed = await run(alice, "push", "-m", "Raise free shipping to $75: shipping costs rose");
54+ assert.equal(pushed.exit, 0, pushed.out);
55+ const refused = await run(bob, "push", "-m", HELD);
56+ assert.equal(refused.exit, 2, refused.out);
57+ return { alice, bob, refused: refused.out };
58+}
60+const policy = (dir: string) => readFileSync(join(dir, "store-policy.md"), "utf8");
62+describe("a held push", () => {
63+ it("says what the pull really writes: a marker block where both changed the same lines", async () => {
64+ const { bob, refused } = await held();
65+ assert.doesNotMatch(refused, /no markers/);
66+ assert.match(refused, /Run abso pull: each of those files comes back holding both sides' lines/);
67+ assert.equal((await run(bob, "pull")).exit, 0);
68+ assert.match(policy(bob), /^<<<<<<< yours \(unpublished\)$/m, "the pull wrote a marker block");
69+ });
71+ it("the change page says what a settle kept in words that read for each choice", async () => {
72+ for (const [how, said] of [
73+ ["yours", "kept bob's"],
74+ ["theirs", "kept alice's"],
75+ ["both", "kept both"],
76+ ] as const) {
77+ const { alice, bob } = await held();
78+ assert.equal((await run(bob, "pull")).exit, 0);
79+ assert.equal((await run(bob, "settle", "store-policy.md", `--${how}`)).exit, 0);
80+ assert.equal((await run(bob, "push", "-m", `Settle: keep ${how}`)).exit, 0);
81+ const review = await run(alice, "review", "bob");
82+ assert.ok(review.out.includes(`Settled: store-policy.md (${said}, against alice's version 1).`), review.out);
83+ }
84+ });
85+});
--- a/worker/project/markers.ts
+++ b/worker/project/markers.ts
@@ -181,7 +181,11 @@
181181 );
182182}
183183
184−/** Whether `b` reads as `a` reworded: at least half their words in common. */
184+/**
185+ * Whether `b` reads as `a` reworded: at least half of `a`'s words are still
186+ * in it. Counted against `a` alone, so a rewording that keeps the line and
187+ * adds to it (a reason, the other side's number) still reads as the line.
188+ */
185189function alike(a: string, b: string): boolean {
186190 if (a === b) return true;
187191 const x = words(a);
@@ -189,7 +193,7 @@
189193 if (x.size === 0 || y.size === 0) return false;
190194 let both = 0;
191195 for (const w of x) if (y.has(w)) both++;
192− return both / (x.size + y.size - both) >= 0.5;
196+ return both / x.size >= 0.5;
193197}
194198
195199/**
--- a/worker/project/test/markers.test.ts
+++ b/worker/project/test/markers.test.ts
@@ -244,6 +244,25 @@
244244 assert.deepEqual(lostLines([" rate. *B5: worth +N coin*"], region), ["- [x] **Gauge shows coin**"]);
245245});
246246
247+test("lostLines: a line rewritten longer, keeping its words and adding a reason, is not a loss", () => {
248+ const region = {
249+ file: "store-policy.md",
250+ yours: ["Free shipping on orders over $35."],
251+ base: ["Free shipping on orders over $50."],
252+ theirs: ["Free shipping on orders over $75."],
253+ agent: "alice",
254+ version: 1,
255+ message: "m",
256+ };
257+ const settled = (line: string) => ["# Store policy", "", line, "Returns accepted within 30 days."];
258+ assert.deepEqual(
259+ lostLines(settled("Free shipping on orders over $50 (alice wants $75, bob wants $35: decided by Friday)."), region),
260+ [],
261+ );
262+ assert.deepEqual(lostLines(settled("Free shipping on orders over $60."), region), []);
263+ assert.deepEqual(lostLines(settled("Shipping is free."), region), ["Free shipping on orders over $35."]);
264+});
247266test("markers.ts: blocks round-trip, settle, and say what was kept", () => {
248267 const who = { agent: "a", version: 3, message: 'Line one\nline two "quoted"' };
249268 const block = markerBlock(["y1", "y2"], ["b"], 2, ["t1"], who);