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 158 to 159

Compare

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