A pull whose answer never arrives no longer leaves the folder behind Version 280 of shared· pinch· Oct 16 (2026-10-16 01:21 UTC) · Not checked
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.
Version 279 · Files at version 280
7 files, 171 lines added, 5 removed.
--- a/client/src/commands.ts
+++ b/client/src/commands.ts
@@ -7,6 +7,7 @@
7 7 // The engine's own key, so both sides match spellings the same way (#49). Not in core.ts: the edit mod installs core.ts alone. @@ -431,9 +432,54 @@
433 434 export async function syncFolder(root: string, api: Api, full = false): Promise<Applied> { 434 − return applyAnswer(root, api, await api.sync({ full }));
435 + const applied = await applyAnswer(root, api, await pullAnswer(root, api, full)); 440 + const PULLING_FILE = "pulling.json"; 443 + * Whether a pull here asked the server and never wrote its answer (abso-core 26): it timed out, or stopped 444 + * partway. The server moved the agent's base when it answered, and later pulls send only what changed since 445 + * that base, so the files it would have written stay behind until a pull asks for every file. 447 + export function pullUnfinished(root: string): boolean { 448 + return existsSync(join(stateDir(root), PULLING_FILE)); 452 + * Ask the server for a pull, noting first that one is under way, so a pull whose answer never gets written 453 + * leaves the note behind. With that note, or `full`, it asks for every file in the agent's view, which the 454 + * folder's own checks then write only where the folder differs. pullWritten takes the note away. 456 + export async function pullAnswer(root: string, api: Api, full = false): Promise<SyncAnswer> { 457 + const unfinished = pullUnfinished(root); 458 + writeFileAtomic(join(stateDir(root), PULLING_FILE), `${JSON.stringify({ at: new Date().toISOString() })}\n`); 459 + if (!full && !unfinished) return api.sync(); 461 + return await api.sync({ full: true }); 463 + // A server from before full pulls (501): the plain pull is still better than none. 464 + if (unfinished && !full && err instanceof ApiError && err.status === 501) return api.sync(); 469 + /** The pull's answer is written into the folder: take away pullAnswer's note. */ 470 + export function pullWritten(root: string): void { 471 + rmSync(join(stateDir(root), PULLING_FILE), { force: true }); 474 + /** Status's line, and pull's when it caught up. */ 475 + export function pullUnfinishedText(root: string): string[] { 476 + return pullUnfinished(root) 478 + "A pull here didn't finish (its answer never arrived or wasn't written), so files may be behind this folder's base. abso pull fetches every file and writes the ones that differ.", 437 483 /** What writing a sync or switch answer into the folder did. */ 438 484 export interface Applied { 439 485 readonly version: number; --- a/client/src/drafts.ts
+++ b/client/src/drafts.ts
@@ -19,6 +19,8 @@
24 26 } from "./commands.ts"; @@ -57,9 +59,10 @@
58 60 const switched = await applyAnswer(root, api, answer); 59 61 // The switch brings back the space as it was when parked; sync straight away so the folder shows it as it is now (#22). 60 − const syncAnswer = await api.sync();
62 + const syncAnswer = await pullAnswer(root, api); 61 63 note(syncAnswer.files); 62 64 const synced = await applyAnswer(root, api, syncAnswer); 63 66 const touched = new Set([...switched.written, ...switched.deleted, ...synced.written, ...synced.deleted]); 64 67 const written: string[] = []; 65 68 const deleted: string[] = []; @@ -148,7 +151,8 @@
148 151 const moved = await api.draftSync(); 149 152 // Bring the moved draft's new view into this folder straight away. 150 153 const recorded = await recordFolder(root, api); 151 − const applied = await applyAnswer(root, api, await api.sync());
154 + const applied = await applyAnswer(root, api, await pullAnswer(root, api)); 153 157 `Moved draft ${moved.draft} onto shared version ${moved.sharedBase} (the draft is at version ${moved.version}).`, 154 158 ...recordedFirst(recorded), --- a/client/src/publish-commands.ts
+++ b/client/src/publish-commands.ts
@@ -13,6 +13,7 @@
@@ -621,6 +622,8 @@
621 622 const { root, api } = open(env); 622 623 const recorded = await recordFolder(root, api); 623 624 const ignoredDropped = await dropIgnoredFromDraft(root, api); 625 + // A pull here that never wrote its answer (abso-core 26): this one asks for every file to catch up. 626 + const catchingUp = pullUnfinished(root) && !bool(args, "full"); 624 627 const s = await syncFolder(root, api, bool(args, "full")); 625 628 const changes = s.written.length + s.deleted.length; 626 629 // A renamed file is one line, not an update and a delete. @@ -632,6 +635,9 @@
632 635 ...droppedIgnoredText(ignoredDropped), 633 636 `Pulled to version ${s.version}: ${changes === 0 ? "no files changed" : `${plural(updated.length, "file")} updated, ${removed.length} deleted${s.renamed.length > 0 ? `, ${s.renamed.length} renamed` : ""}`}.`, 634 637 ...changedFilesText("pull", updated, removed, s.renamed, bool(args, "verbose")), 639 + ? ["The last pull here didn't finish, so this one asked for every file and wrote the ones that differed."] 635 641 ...refusedText(s.refused), 636 642 // Ones an earlier sync couldn't write; this sync's are named just above. 637 643 ...unwrittenText(s.unwritten, new Set(s.refused.map((r) => r.path))), --- a/client/src/status-commands.ts
+++ b/client/src/status-commands.ts
@@ -14,6 +14,7 @@
@@ -349,6 +350,7 @@
349 350 ...modsBehindText(env.env), 350 351 ...missingText(missing), 351 352 ...unwrittenText(unwritten), 353 + ...pullUnfinishedText(root), 352 354 ...(crlf.length > 0 354 356 `${plural(crlf.length, "file")} differ${crlf.length === 1 ? "s" : ""} from what abso recorded only in line endings (CRLF here; abso records and abso run sends LF). Harmless; abso fix-eol rewrites ${crlf.length === 1 ? "it" : "them"} with LF.`, --- a/client/src/versions.ts
+++ b/client/src/versions.ts
@@ -3,7 +3,18 @@
4 4 import type { VersionRef } from "./api.ts"; 5 5 import { bool, type Parsed, str, UsageError } from "./args.ts"; 6 − import { applyAnswer, collisionText, type Env, EXIT, type Output, open, plural, recordFolder } from "./commands.ts";
17 + } from "./commands.ts"; 7 18 import { writeConfig } from "./config.ts"; 8 19 import { refusedText } from "./safety.ts"; @@ -144,7 +155,8 @@
144 155 // Sync now (recording first, as sync does), so the folder is where it now says it is. 145 156 const { api } = open(env); 146 157 await recordFolder(root, api); 147 − const s = await applyAnswer(root, api, await api.sync());
158 + const s = await applyAnswer(root, api, await pullAnswer(root, api)); 148 160 const changes = s.written.length + s.deleted.length; 149 161 const head = follow 150 162 ? `This folder now follows label ${follow}: every pull takes it to the newest version with that label. It is on version ${s.version}.` --- a/client/test/fake-server.ts
+++ b/client/test/fake-server.ts
@@ -89,6 +89,8 @@
90 90 /** The next publish: commit it and answer 500 ('after'), or answer 500 without it ('before'), as a storage reset does. */ 91 91 failPublish: "after" | "before" | undefined; 92 + /** How many of the next pulls to carry out and then cut before answering, as an answer that never arrives (abso-core 26). */ 93 + loseSyncAnswers: number; 92 94 /** Run the merge queue's rounds now (after queueHold is let go). */ 93 95 kickQueue(name: string): Promise<void>; 94 96 /** Each run POST's X-Abso-Run-Key, and whether a run started for it. */ @@ -155,6 +157,7 @@
155 157 boxExtra: undefined, 157 159 failPublish: undefined, 158 161 kickQueue: async () => {}, 159 162 close: async () => {}, @@ -632,6 +635,11 @@
632 635 ...(typeof body.label === "string" ? { label: body.label } : {}), 633 636 ...(body.full === true ? { full: true } : {}), 638 + if (fake.loseSyncAnswers > 0) { 639 + fake.loseSyncAnswers--; 635 643 const extra = fake.injectSync; 636 644 fake.injectSync = undefined; 637 645 if (extra === undefined) return send(res, 200, synced); --- /dev/null
+++ b/client/test/lost-pull.test.ts
@@ -0,0 +1,88 @@
1 + // 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. 5 + import assert from "node:assert/strict"; 6 + import { existsSync, 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" }; 17 + const dirs: string[] = []; 19 + fake = await startFake(0, TOKEN); 23 + for (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 }); 26 + function temp(): string { 27 + const d = mkdtempSync(join(tmpdir(), "abso-lost-pull-")); 32 + async 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 }; 38 + /** alice and bob on one project; alice pushes a change and a new file, and bob's pull of them is lost. */ 39 + async function lost(): Promise<{ alice: string; bob: string }> { 40 + const name = `lost${++projects}`; 41 + const alice = temp(); 42 + writeFileSync(join(alice, "a.txt"), "one\n"); 44 + (await run(alice, "init", "--server", fake.url, "--project", name, "--agent", "alice", "--as-is")).exit, 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 }; 58 + const text = (dir: string, rel: string) => readFileSync(join(dir, rel), "utf8"); 60 + describe("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/); 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"); 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");