{"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","changes":10,"change":4412,"files":["client/src/commands.ts","client/src/drafts.ts","client/src/publish-commands.ts","client/src/status-commands.ts","client/src/versions.ts","client/test/fake-server.ts","client/test/lost-pull.test.ts"],"draft":null,"diff":[{"path":"client/src/commands.ts","added":47,"removed":1,"diff":"--- a/client/src/commands.ts\n+++ b/client/src/commands.ts\n@@ -7,6 +7,7 @@\n // 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.\n import {\n \ttype Api,\n+\tApiError,\n \ttype Collision,\n \ttype FileChange,\n \ttype MergedLine,\n@@ -431,9 +432,54 @@\n  * overwritten.\n  */\n export async function syncFolder(root: string, api: Api, full = false): Promise<Applied> {\n-\treturn applyAnswer(root, api, await api.sync({ full }));\n+\tconst applied = await applyAnswer(root, api, await pullAnswer(root, api, full));\n+\tpullWritten(root);\n+\treturn applied;\n }\n \n+const PULLING_FILE = \"pulling.json\";\n+\n+/**\n+ * Whether a pull here asked the server and never wrote its answer (abso-core 26): it timed out, or stopped\n+ * partway. The server moved the agent's base when it answered, and later pulls send only what changed since\n+ * that base, so the files it would have written stay behind until a pull asks for every file.\n+ */\n+export function pullUnfinished(root: string): boolean {\n+\treturn existsSync(join(stateDir(root), PULLING_FILE));\n+}\n+\n+/**\n+ * Ask the server for a pull, noting first that one is under way, so a pull whose answer never gets written\n+ * leaves the note behind. With that note, or `full`, it asks for every file in the agent's view, which the\n+ * folder's own checks then write only where the folder differs. pullWritten takes the note away.\n+ */\n+export async function pullAnswer(root: string, api: Api, full = false): Promise<SyncAnswer> {\n+\tconst unfinished = pullUnfinished(root);\n+\twriteFileAtomic(join(stateDir(root), PULLING_FILE), `${JSON.stringify({ at: new Date().toISOString() })}\\n`);\n+\tif (!full && !unfinished) return api.sync();\n+\ttry {\n+\t\treturn await api.sync({ full: true });\n+\t} catch (err) {\n+\t\t// A server from before full pulls (501): the plain pull is still better than none.\n+\t\tif (unfinished && !full && err instanceof ApiError && err.status === 501) return api.sync();\n+\t\tthrow err;\n+\t}\n+}\n+\n+/** The pull's answer is written into the folder: take away pullAnswer's note. */\n+export function pullWritten(root: string): void {\n+\trmSync(join(stateDir(root), PULLING_FILE), { force: true });\n+}\n+\n+/** Status's line, and pull's when it caught up. */\n+export function pullUnfinishedText(root: string): string[] {\n+\treturn pullUnfinished(root)\n+\t\t? [\n+\t\t\t\t\"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.\",\n+\t\t\t]\n+\t\t: [];\n+}\n+\n /** What writing a sync or switch answer into the folder did. */\n export interface Applied {\n \treadonly version: number;"},{"path":"client/src/drafts.ts","added":6,"removed":2,"diff":"--- a/client/src/drafts.ts\n+++ b/client/src/drafts.ts\n@@ -19,6 +19,8 @@\n \ttype Output,\n \topen,\n \tplural,\n+\tpullAnswer,\n+\tpullWritten,\n \trecordedFirst,\n \trecordFolder,\n } from \"./commands.ts\";\n@@ -57,9 +59,10 @@\n \tnote(answer.files);\n \tconst switched = await applyAnswer(root, api, answer);\n \t// The switch brings back the space as it was when parked; sync straight away so the folder shows it as it is now (#22).\n-\tconst syncAnswer = await api.sync();\n+\tconst syncAnswer = await pullAnswer(root, api);\n \tnote(syncAnswer.files);\n \tconst synced = await applyAnswer(root, api, syncAnswer);\n+\tpullWritten(root);\n \tconst touched = new Set([...switched.written, ...switched.deleted, ...synced.written, ...synced.deleted]);\n \tconst written: string[] = [];\n \tconst deleted: string[] = [];\n@@ -148,7 +151,8 @@\n \tconst moved = await api.draftSync();\n \t// Bring the moved draft's new view into this folder straight away.\n \tconst recorded = await recordFolder(root, api);\n-\tconst applied = await applyAnswer(root, api, await api.sync());\n+\tconst applied = await applyAnswer(root, api, await pullAnswer(root, api));\n+\tpullWritten(root);\n \tconst lines = [\n \t\t`Moved draft ${moved.draft} onto shared version ${moved.sharedBase} (the draft is at version ${moved.version}).`,\n \t\t...recordedFirst(recorded),"},{"path":"client/src/publish-commands.ts","added":6,"removed":0,"diff":"--- a/client/src/publish-commands.ts\n+++ b/client/src/publish-commands.ts\n@@ -13,6 +13,7 @@\n \tFOLDER_LOG_LIMIT,\n \tLISTED,\n \tmeantBinary,\n+\tpullUnfinished,\n \tREADER_REFUSES,\n \trecordedFirst,\n \trecordFolder,\n@@ -621,6 +622,8 @@\n \tconst { root, api } = open(env);\n \tconst recorded = await recordFolder(root, api);\n \tconst ignoredDropped = await dropIgnoredFromDraft(root, api);\n+\t// A pull here that never wrote its answer (abso-core 26): this one asks for every file to catch up.\n+\tconst catchingUp = pullUnfinished(root) && !bool(args, \"full\");\n \tconst s = await syncFolder(root, api, bool(args, \"full\"));\n \tconst changes = s.written.length + s.deleted.length;\n \t// A renamed file is one line, not an update and a delete.\n@@ -632,6 +635,9 @@\n \t\t...droppedIgnoredText(ignoredDropped),\n \t\t`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` : \"\"}`}.`,\n \t\t...changedFilesText(\"pull\", updated, removed, s.renamed, bool(args, \"verbose\")),\n+\t\t...(catchingUp\n+\t\t\t? [\"The last pull here didn't finish, so this one asked for every file and wrote the ones that differed.\"]\n+\t\t\t: []),\n \t\t...refusedText(s.refused),\n \t\t// Ones an earlier sync couldn't write; this sync's are named just above.\n \t\t...unwrittenText(s.unwritten, new Set(s.refused.map((r) => r.path))),"},{"path":"client/src/status-commands.ts","added":2,"removed":0,"diff":"--- a/client/src/status-commands.ts\n+++ b/client/src/status-commands.ts\n@@ -14,6 +14,7 @@\n import {\n \tLISTED,\n \tleftOutText,\n+\tpullUnfinishedText,\n \tREADER_REFUSES,\n \treadUnwritten,\n \trecordedFirst,\n@@ -349,6 +350,7 @@\n \t\t...modsBehindText(env.env),\n \t\t...missingText(missing),\n \t\t...unwrittenText(unwritten),\n+\t\t...pullUnfinishedText(root),\n \t\t...(crlf.length > 0\n \t\t\t? [\n \t\t\t\t\t`${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.`,"},{"path":"client/src/versions.ts","added":14,"removed":2,"diff":"--- a/client/src/versions.ts\n+++ b/client/src/versions.ts\n@@ -3,7 +3,18 @@\n \n import type { VersionRef } from \"./api.ts\";\n import { bool, type Parsed, str, UsageError } from \"./args.ts\";\n-import { applyAnswer, collisionText, type Env, EXIT, type Output, open, plural, recordFolder } from \"./commands.ts\";\n+import {\n+\tapplyAnswer,\n+\tcollisionText,\n+\ttype Env,\n+\tEXIT,\n+\ttype Output,\n+\topen,\n+\tplural,\n+\tpullAnswer,\n+\tpullWritten,\n+\trecordFolder,\n+} from \"./commands.ts\";\n import { writeConfig } from \"./config.ts\";\n import { refusedText } from \"./safety.ts\";\n \n@@ -144,7 +155,8 @@\n \t// Sync now (recording first, as sync does), so the folder is where it now says it is.\n \tconst { api } = open(env);\n \tawait recordFolder(root, api);\n-\tconst s = await applyAnswer(root, api, await api.sync());\n+\tconst s = await applyAnswer(root, api, await pullAnswer(root, api));\n+\tpullWritten(root);\n \tconst changes = s.written.length + s.deleted.length;\n \tconst head = follow\n \t\t? `This folder now follows label ${follow}: every pull takes it to the newest version with that label. It is on version ${s.version}.`"},{"path":"client/test/fake-server.ts","added":8,"removed":0,"diff":"--- a/client/test/fake-server.ts\n+++ b/client/test/fake-server.ts\n@@ -89,6 +89,8 @@\n \tqueueHold: boolean;\n \t/** The next publish: commit it and answer 500 ('after'), or answer 500 without it ('before'), as a storage reset does. */\n \tfailPublish: \"after\" | \"before\" | undefined;\n+\t/** How many of the next pulls to carry out and then cut before answering, as an answer that never arrives (abso-core 26). */\n+\tloseSyncAnswers: number;\n \t/** Run the merge queue's rounds now (after queueHold is let go). */\n \tkickQueue(name: string): Promise<void>;\n \t/** Each run POST's X-Abso-Run-Key, and whether a run started for it. */\n@@ -155,6 +157,7 @@\n \t\tboxExtra: undefined,\n \t\tqueueHold: false,\n \t\tfailPublish: undefined,\n+\t\tloseSyncAnswers: 0,\n \t\tkickQueue: async () => {},\n \t\tclose: async () => {},\n \t};\n@@ -632,6 +635,11 @@\n \t\t\t\t...(typeof body.label === \"string\" ? { label: body.label } : {}),\n \t\t\t\t...(body.full === true ? { full: true } : {}),\n \t\t\t});\n+\t\t\tif (fake.loseSyncAnswers > 0) {\n+\t\t\t\tfake.loseSyncAnswers--;\n+\t\t\t\tres.destroy();\n+\t\t\t\treturn;\n+\t\t\t}\n \t\t\tconst extra = fake.injectSync;\n \t\t\tfake.injectSync = undefined;\n \t\t\tif (extra === undefined) return send(res, 200, synced);"},{"path":"client/test/lost-pull.test.ts","added":88,"removed":0,"diff":"--- /dev/null\n+++ b/client/test/lost-pull.test.ts\n@@ -0,0 +1,88 @@\n+// A pull whose answer never arrives (abso-core 26): the server has moved the agent's base, so later pulls\n+// send only what changed since then. The folder notes the pull it started and, until one is written, the\n+// next pull asks for every file and writes the ones that differ. Status says so in the meantime.\n+\n+import assert from \"node:assert/strict\";\n+import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n+import { tmpdir } from \"node:os\";\n+import { join } from \"node:path\";\n+import { after, before, describe, it } from \"node:test\";\n+import { main } from \"../src/main.ts\";\n+import { type Fake, startFake } from \"./fake-server.ts\";\n+\n+const TOKEN = \"test-token-not-secret\";\n+const ENV = { AVCS_TOKEN: TOKEN, AVCS_HOOK_FORCE: \"1\", AVCS_SERVERS_FILE: \"no-servers.json\" };\n+\n+let fake: Fake;\n+const dirs: string[] = [];\n+before(async () => {\n+\tfake = await startFake(0, TOKEN);\n+});\n+after(async () => {\n+\tawait fake.close();\n+\tfor (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 });\n+});\n+\n+function temp(): string {\n+\tconst d = mkdtempSync(join(tmpdir(), \"abso-lost-pull-\"));\n+\tdirs.push(d);\n+\treturn d;\n+}\n+\n+async function run(cwd: string, ...argv: string[]): Promise<{ exit: number; out: string }> {\n+\tconst r = await main(argv, { cwd, env: ENV, write: () => {} });\n+\treturn { exit: r.exit, out: r.stdout + r.stderr };\n+}\n+\n+let projects = 0;\n+/** alice and bob on one project; alice pushes a change and a new file, and bob's pull of them is lost. */\n+async function lost(): Promise<{ alice: string; bob: string }> {\n+\tconst name = `lost${++projects}`;\n+\tconst alice = temp();\n+\twriteFileSync(join(alice, \"a.txt\"), \"one\\n\");\n+\tassert.equal(\n+\t\t(await run(alice, \"init\", \"--server\", fake.url, \"--project\", name, \"--agent\", \"alice\", \"--as-is\")).exit,\n+\t\t0,\n+\t);\n+\tconst bob = temp();\n+\tassert.equal((await run(bob, \"join\", name, \"--agent\", \"bob\", \"--server\", fake.url)).exit, 0);\n+\twriteFileSync(join(alice, \"a.txt\"), \"two\\n\");\n+\twriteFileSync(join(alice, \"b.txt\"), \"new\\n\");\n+\tconst pushed = await run(alice, \"push\", \"-m\", \"Change a.txt and add b.txt\");\n+\tassert.equal(pushed.exit, 0, pushed.out);\n+\tfake.loseSyncAnswers = 1;\n+\tassert.notEqual((await run(bob, \"pull\")).exit, 0, \"the pull whose answer was lost fails\");\n+\treturn { alice, bob };\n+}\n+\n+const text = (dir: string, rel: string) => readFileSync(join(dir, rel), \"utf8\");\n+\n+describe(\"a pull whose answer never arrives\", () => {\n+\tit(\"leaves the folder as it was, and status says a pull didn't finish\", async () => {\n+\t\tconst { bob } = await lost();\n+\t\tassert.equal(text(bob, \"a.txt\"), \"one\\n\");\n+\t\tassert.equal(existsSync(join(bob, \"b.txt\")), false);\n+\t\tconst status = await run(bob, \"status\");\n+\t\tassert.match(status.out, /A pull here didn't finish/);\n+\t});\n+\n+\tit(\"the next pull asks for every file and writes what the lost one would have\", async () => {\n+\t\tconst { bob } = await lost();\n+\t\tconst pulled = await run(bob, \"pull\");\n+\t\tassert.equal(pulled.exit, 0, pulled.out);\n+\t\tassert.match(pulled.out, /The last pull here didn't finish, so this one asked for every file/);\n+\t\tassert.equal(text(bob, \"a.txt\"), \"two\\n\");\n+\t\tassert.equal(text(bob, \"b.txt\"), \"new\\n\");\n+\t\tassert.doesNotMatch((await run(bob, \"status\")).out, /A pull here didn't finish/);\n+\t\tconst again = await run(bob, \"pull\");\n+\t\tassert.doesNotMatch(again.out, /didn't finish/, \"once caught up, pulls are plain again\");\n+\t});\n+\n+\tit(\"keeps work done in the folder meanwhile\", async () => {\n+\t\tconst { bob } = await lost();\n+\t\twriteFileSync(join(bob, \"a.txt\"), \"bob's own\\n\");\n+\t\tconst pulled = await run(bob, \"pull\");\n+\t\tassert.equal(text(bob, \"a.txt\"), \"bob's own\\n\", pulled.out);\n+\t\tassert.equal(text(bob, \"b.txt\"), \"new\\n\");\n+\t});\n+});"}],"ci":null}