{"file":"client/test/lost-pull.test.ts","version":318,"total":88,"from":1,"to":88,"lines":[{"n":1,"text":"// A pull whose answer never arrives (abso-core 26): the server has moved the agent's base, so later pulls","atom":"a2756","author":"pinch","version":280},{"n":2,"text":"// send only what changed since then. The folder notes the pull it started and, until one is written, the","atom":"a2756","author":"pinch","version":280},{"n":3,"text":"// next pull asks for every file and writes the ones that differ. Status says so in the meantime.","atom":"a2756","author":"pinch","version":280},{"n":4,"text":"","atom":"a2756","author":"pinch","version":280},{"n":5,"text":"import assert from \"node:assert/strict\";","atom":"a2756","author":"pinch","version":280},{"n":6,"text":"import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";","atom":"a2756","author":"pinch","version":280},{"n":7,"text":"import { tmpdir } from \"node:os\";","atom":"a2756","author":"pinch","version":280},{"n":8,"text":"import { join } from \"node:path\";","atom":"a2756","author":"pinch","version":280},{"n":9,"text":"import { after, before, describe, it } from \"node:test\";","atom":"a2756","author":"pinch","version":280},{"n":10,"text":"import { main } from \"../src/main.ts\";","atom":"a2756","author":"pinch","version":280},{"n":11,"text":"import { type Fake, startFake } from \"./fake-server.ts\";","atom":"a2756","author":"pinch","version":280},{"n":12,"text":"","atom":"a2756","author":"pinch","version":280},{"n":13,"text":"const TOKEN = \"test-token-not-secret\";","atom":"a2756","author":"pinch","version":280},{"n":14,"text":"const ENV = { AVCS_TOKEN: TOKEN, AVCS_HOOK_FORCE: \"1\", AVCS_SERVERS_FILE: \"no-servers.json\" };","atom":"a2756","author":"pinch","version":280},{"n":15,"text":"","atom":"a2756","author":"pinch","version":280},{"n":16,"text":"let fake: Fake;","atom":"a2756","author":"pinch","version":280},{"n":17,"text":"const dirs: string[] = [];","atom":"a2756","author":"pinch","version":280},{"n":18,"text":"before(async () => {","atom":"a2756","author":"pinch","version":280},{"n":19,"text":"\tfake = await startFake(0, TOKEN);","atom":"a2756","author":"pinch","version":280},{"n":20,"text":"});","atom":"a2756","author":"pinch","version":280},{"n":21,"text":"after(async () => {","atom":"a2756","author":"pinch","version":280},{"n":22,"text":"\tawait fake.close();","atom":"a2756","author":"pinch","version":280},{"n":23,"text":"\tfor (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 });","atom":"a2756","author":"pinch","version":280},{"n":24,"text":"});","atom":"a2756","author":"pinch","version":280},{"n":25,"text":"","atom":"a2756","author":"pinch","version":280},{"n":26,"text":"function temp(): string {","atom":"a2756","author":"pinch","version":280},{"n":27,"text":"\tconst d = mkdtempSync(join(tmpdir(), \"abso-lost-pull-\"));","atom":"a2756","author":"pinch","version":280},{"n":28,"text":"\tdirs.push(d);","atom":"a2756","author":"pinch","version":280},{"n":29,"text":"\treturn d;","atom":"a2756","author":"pinch","version":280},{"n":30,"text":"}","atom":"a2756","author":"pinch","version":280},{"n":31,"text":"","atom":"a2756","author":"pinch","version":280},{"n":32,"text":"async function run(cwd: string, ...argv: string[]): Promise<{ exit: number; out: string }> {","atom":"a2756","author":"pinch","version":280},{"n":33,"text":"\tconst r = await main(argv, { cwd, env: ENV, write: () => {} });","atom":"a2756","author":"pinch","version":280},{"n":34,"text":"\treturn { exit: r.exit, out: r.stdout + r.stderr };","atom":"a2756","author":"pinch","version":280},{"n":35,"text":"}","atom":"a2756","author":"pinch","version":280},{"n":36,"text":"","atom":"a2756","author":"pinch","version":280},{"n":37,"text":"let projects = 0;","atom":"a2756","author":"pinch","version":280},{"n":38,"text":"/** alice and bob on one project; alice pushes a change and a new file, and bob's pull of them is lost. */","atom":"a2756","author":"pinch","version":280},{"n":39,"text":"async function lost(): Promise<{ alice: string; bob: string }> {","atom":"a2756","author":"pinch","version":280},{"n":40,"text":"\tconst name = `lost${++projects}`;","atom":"a2756","author":"pinch","version":280},{"n":41,"text":"\tconst alice = temp();","atom":"a2756","author":"pinch","version":280},{"n":42,"text":"\twriteFileSync(join(alice, \"a.txt\"), \"one\\n\");","atom":"a2756","author":"pinch","version":280},{"n":43,"text":"\tassert.equal(","atom":"a2756","author":"pinch","version":280},{"n":44,"text":"\t\t(await run(alice, \"init\", \"--server\", fake.url, \"--project\", name, \"--agent\", \"alice\", \"--as-is\")).exit,","atom":"a2756","author":"pinch","version":280},{"n":45,"text":"\t\t0,","atom":"a2756","author":"pinch","version":280},{"n":46,"text":"\t);","atom":"a2756","author":"pinch","version":280},{"n":47,"text":"\tconst bob = temp();","atom":"a2756","author":"pinch","version":280},{"n":48,"text":"\tassert.equal((await run(bob, \"join\", name, \"--agent\", \"bob\", \"--server\", fake.url)).exit, 0);","atom":"a2756","author":"pinch","version":280},{"n":49,"text":"\twriteFileSync(join(alice, \"a.txt\"), \"two\\n\");","atom":"a2756","author":"pinch","version":280},{"n":50,"text":"\twriteFileSync(join(alice, \"b.txt\"), \"new\\n\");","atom":"a2756","author":"pinch","version":280},{"n":51,"text":"\tconst pushed = await run(alice, \"push\", \"-m\", \"Change a.txt and add b.txt\");","atom":"a2756","author":"pinch","version":280},{"n":52,"text":"\tassert.equal(pushed.exit, 0, pushed.out);","atom":"a2756","author":"pinch","version":280},{"n":53,"text":"\tfake.loseSyncAnswers = 1;","atom":"a2756","author":"pinch","version":280},{"n":54,"text":"\tassert.notEqual((await run(bob, \"pull\")).exit, 0, \"the pull whose answer was lost fails\");","atom":"a2756","author":"pinch","version":280},{"n":55,"text":"\treturn { alice, bob };","atom":"a2756","author":"pinch","version":280},{"n":56,"text":"}","atom":"a2756","author":"pinch","version":280},{"n":57,"text":"","atom":"a2756","author":"pinch","version":280},{"n":58,"text":"const text = (dir: string, rel: string) => readFileSync(join(dir, rel), \"utf8\");","atom":"a2756","author":"pinch","version":280},{"n":59,"text":"","atom":"a2756","author":"pinch","version":280},{"n":60,"text":"describe(\"a pull whose answer never arrives\", () => {","atom":"a2756","author":"pinch","version":280},{"n":61,"text":"\tit(\"leaves the folder as it was, and status says a pull didn't finish\", async () => {","atom":"a2756","author":"pinch","version":280},{"n":62,"text":"\t\tconst { bob } = await lost();","atom":"a2756","author":"pinch","version":280},{"n":63,"text":"\t\tassert.equal(text(bob, \"a.txt\"), \"one\\n\");","atom":"a2756","author":"pinch","version":280},{"n":64,"text":"\t\tassert.equal(existsSync(join(bob, \"b.txt\")), false);","atom":"a2756","author":"pinch","version":280},{"n":65,"text":"\t\tconst status = await run(bob, \"status\");","atom":"a2756","author":"pinch","version":280},{"n":66,"text":"\t\tassert.match(status.out, /A pull here didn't finish/);","atom":"a2756","author":"pinch","version":280},{"n":67,"text":"\t});","atom":"a2756","author":"pinch","version":280},{"n":68,"text":"","atom":"a2756","author":"pinch","version":280},{"n":69,"text":"\tit(\"the next pull asks for every file and writes what the lost one would have\", async () => {","atom":"a2756","author":"pinch","version":280},{"n":70,"text":"\t\tconst { bob } = await lost();","atom":"a2756","author":"pinch","version":280},{"n":71,"text":"\t\tconst pulled = await run(bob, \"pull\");","atom":"a2756","author":"pinch","version":280},{"n":72,"text":"\t\tassert.equal(pulled.exit, 0, pulled.out);","atom":"a2756","author":"pinch","version":280},{"n":73,"text":"\t\tassert.match(pulled.out, /The last pull here didn't finish, so this one asked for every file/);","atom":"a2756","author":"pinch","version":280},{"n":74,"text":"\t\tassert.equal(text(bob, \"a.txt\"), \"two\\n\");","atom":"a2756","author":"pinch","version":280},{"n":75,"text":"\t\tassert.equal(text(bob, \"b.txt\"), \"new\\n\");","atom":"a2756","author":"pinch","version":280},{"n":76,"text":"\t\tassert.doesNotMatch((await run(bob, \"status\")).out, /A pull here didn't finish/);","atom":"a2756","author":"pinch","version":280},{"n":77,"text":"\t\tconst again = await run(bob, \"pull\");","atom":"a2756","author":"pinch","version":280},{"n":78,"text":"\t\tassert.doesNotMatch(again.out, /didn't finish/, \"once caught up, pulls are plain again\");","atom":"a2756","author":"pinch","version":280},{"n":79,"text":"\t});","atom":"a2756","author":"pinch","version":280},{"n":80,"text":"","atom":"a2756","author":"pinch","version":280},{"n":81,"text":"\tit(\"keeps work done in the folder meanwhile\", async () => {","atom":"a2756","author":"pinch","version":280},{"n":82,"text":"\t\tconst { bob } = await lost();","atom":"a2756","author":"pinch","version":280},{"n":83,"text":"\t\twriteFileSync(join(bob, \"a.txt\"), \"bob's own\\n\");","atom":"a2756","author":"pinch","version":280},{"n":84,"text":"\t\tconst pulled = await run(bob, \"pull\");","atom":"a2756","author":"pinch","version":280},{"n":85,"text":"\t\tassert.equal(text(bob, \"a.txt\"), \"bob's own\\n\", pulled.out);","atom":"a2756","author":"pinch","version":280},{"n":86,"text":"\t\tassert.equal(text(bob, \"b.txt\"), \"new\\n\");","atom":"a2756","author":"pinch","version":280},{"n":87,"text":"\t});","atom":"a2756","author":"pinch","version":280},{"n":88,"text":"});","atom":"a2756","author":"pinch","version":280}],"atoms":[{"atom":"a2756","author":"pinch","message":"","time":1792113647992,"timeIso":"2026-10-16T01:20:47.992Z","publish":{"draft":null,"version":280,"agent":"pinch","message":"A pull whose answer never arrives no longer leaves the folder behind\n\nThe 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.\n\nNow 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.\n\nTests: 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.","time":1792113718029,"timeIso":"2026-10-16T01:21:58.029Z"}}]}