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 client/test/lost-pull.test.ts --json
JSON
/christopher/abso-core/blame/client/test/lost-pull.test.ts?format=json
88 linespinch 100%Last change pinch in version 280,

88 lines from 1 change in 1 version.

pinch280A pull whose answer never arrives no longer leaves the folder behind The server moves the agent's base when it answers a pull, and later pulls send only what changed since that base. When the answer was lost (a timeout on a slow server), the files it carried were never written, and every later pull, status, restore and export agreed the folder was current. Now the client notes a pull in .abso/pulling.json before asking, and takes the note away once the answer is written. While the note is there, abso status says a pull didn't finish, and the next pull asks for every file in the view (as pull --full does) and writes the ones that differ, keeping work done in the folder meanwhile, as every pull does. follow, draft switching and draft-pull pull the same way. A server without full pulls gets a plain pull. Tests: client/test/lost-pull.test.ts (a fake server that carries out a pull and drops its answer), plus held-push, join-signed-out and record-batches: 19 pass. tsc and Biome clean.Compare1// A pull whose answer never arrives (abso-core 26): the server has moved the agent's base, so later pulls
2// send only what changed since then. The folder notes the pull it started and, until one is written, the
3// next pull asks for every file and writes the ones that differ. Status says so in the meantime.
4
5import assert from "node:assert/strict";
6import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7import { tmpdir } from "node:os";
8import { join } from "node:path";
9import { after, before, describe, it } from "node:test";
10import { main } from "../src/main.ts";
11import { type Fake, startFake } from "./fake-server.ts";
13const TOKEN = "test-token-not-secret";
14const ENV = { AVCS_TOKEN: TOKEN, AVCS_HOOK_FORCE: "1", AVCS_SERVERS_FILE: "no-servers.json" };
16let fake: Fake;
17const dirs: string[] = [];
18before(async () => {
19 fake = await startFake(0, TOKEN);
20});
21after(async () => {
22 await fake.close();
23 for (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 });
24});
26function temp(): string {
27 const d = mkdtempSync(join(tmpdir(), "abso-lost-pull-"));
28 dirs.push(d);
29 return d;
32async function run(cwd: string, ...argv: string[]): Promise<{ exit: number; out: string }> {
33 const r = await main(argv, { cwd, env: ENV, write: () => {} });
34 return { exit: r.exit, out: r.stdout + r.stderr };
37let projects = 0;
38/** alice and bob on one project; alice pushes a change and a new file, and bob's pull of them is lost. */
39async function lost(): Promise<{ alice: string; bob: string }> {
40 const name = `lost${++projects}`;
41 const alice = temp();
42 writeFileSync(join(alice, "a.txt"), "one\n");
43 assert.equal(
44 (await run(alice, "init", "--server", fake.url, "--project", name, "--agent", "alice", "--as-is")).exit,
45 0,
46 );
47 const bob = temp();
48 assert.equal((await run(bob, "join", name, "--agent", "bob", "--server", fake.url)).exit, 0);
49 writeFileSync(join(alice, "a.txt"), "two\n");
50 writeFileSync(join(alice, "b.txt"), "new\n");
51 const pushed = await run(alice, "push", "-m", "Change a.txt and add b.txt");
52 assert.equal(pushed.exit, 0, pushed.out);
53 fake.loseSyncAnswers = 1;
54 assert.notEqual((await run(bob, "pull")).exit, 0, "the pull whose answer was lost fails");
55 return { alice, bob };
58const text = (dir: string, rel: string) => readFileSync(join(dir, rel), "utf8");
60describe("a pull whose answer never arrives", () => {
61 it("leaves the folder as it was, and status says a pull didn't finish", async () => {
62 const { bob } = await lost();
63 assert.equal(text(bob, "a.txt"), "one\n");
64 assert.equal(existsSync(join(bob, "b.txt")), false);
65 const status = await run(bob, "status");
66 assert.match(status.out, /A pull here didn't finish/);
67 });
69 it("the next pull asks for every file and writes what the lost one would have", async () => {
70 const { bob } = await lost();
71 const pulled = await run(bob, "pull");
72 assert.equal(pulled.exit, 0, pulled.out);
73 assert.match(pulled.out, /The last pull here didn't finish, so this one asked for every file/);
74 assert.equal(text(bob, "a.txt"), "two\n");
75 assert.equal(text(bob, "b.txt"), "new\n");
76 assert.doesNotMatch((await run(bob, "status")).out, /A pull here didn't finish/);
77 const again = await run(bob, "pull");
78 assert.doesNotMatch(again.out, /didn't finish/, "once caught up, pulls are plain again");
79 });
81 it("keeps work done in the folder meanwhile", async () => {
82 const { bob } = await lost();
83 writeFileSync(join(bob, "a.txt"), "bob's own\n");
84 const pulled = await run(bob, "pull");
85 assert.equal(text(bob, "a.txt"), "bob's own\n", pulled.out);
86 assert.equal(text(bob, "b.txt"), "new\n");
87 });
88});