{"version":289,"agent":"pinch","message":"Local projects run as their own processes again: no compile cache for a local command, and plain words when the server's code can't load\n\nAt 287, every local command run as `node client/abso.ts` could crash with a segmentation fault (exit 139, at random, init and join included). The cause is Node's compile cache, which client/avcs.ts turns on, together with the module hook that gives the open server's code its cloudflare:workers stand-in. avcs.ts now leaves the cache off for a --local command and in a folder whose config names the server \"local\". The hook also stays registered rather than being removed after the import.\n\n- If the server's code can't load (a package missing, say), it's said as \"local projects couldn't load the server's code: ...\" rather than \"Can't reach local ... check your connection\".\n- In a local folder, status says \"It's a local project, in <store>/<project>.\" instead of \"Signed in with none.\", and skips the npm newer-client check, which reaches for the network.\n- worker/project/news.ts is Biome-formatted (only formatting), so the check gets past Biome again.\n- scripts/local-measure.ts times status, log, blame, pull and push as separate processes on a small and a large local history, with peak memory and the store's size. scripts/local-writers.ts pushes from 1, 4 and 16 writers at once to measure the store lock.\n\nTests: client/test/local.test.ts (9, one running init, push, status and log as child processes with the cache as it is); tsc and Biome clean. Three rounds of init, push and status as processes exit 0.","time":1792120394633,"timeIso":"2026-10-16T03:13:14.633Z","changes":9,"change":4550,"files":["client/avcs.ts","client/src/local-store.ts","client/src/status-commands.ts","client/test/local.test.ts","scripts/local-measure.ts","scripts/local-writers.ts","worker/project/news.ts"],"draft":null,"diff":[{"path":"client/avcs.ts","added":21,"removed":3,"diff":"--- a/client/avcs.ts\n+++ b/client/avcs.ts\n@@ -3,15 +3,33 @@\n // `abso help` lists the commands. `abso hook` is the Claude Code hook; it\n // loads only what it needs, since every edit pays for its start-up.\n \n+import { readFileSync } from \"node:fs\";\n import * as nodeModule from \"node:module\";\n+import { dirname, join } from \"node:path\";\n \n+const argv = process.argv.slice(2);\n+\n+/**\n+ * Whether this command opens a local project (abso init --local): --local, or a folder whose config names the server\n+ * \"local\". Those load the open server's code through a module hook, and with the compile cache on Node 24 crashes.\n+ */\n+function opensLocal(): boolean {\n+\tif (argv.includes(\"--local\")) return true;\n+\tfor (let dir = process.cwd(); ; dir = dirname(dir)) {\n+\t\tfor (const state of [\".abso\", \".avcs\"]) {\n+\t\t\ttry {\n+\t\t\t\treturn /\"server\"\\s*:\\s*\"local\"/.test(readFileSync(join(dir, state, \"config.json\"), \"utf8\"));\n+\t\t\t} catch {}\n+\t\t}\n+\t\tif (dirname(dir) === dir) return false;\n+\t}\n+}\n+\n // Node keeps the compiled modules (TypeScript already stripped) in a cache in\n // the temp folder. Loading the hook's modules drops from about 55 ms to 11 ms.\n // Node 20 has no compile cache, and the built client runs there without one.\n-(nodeModule as { enableCompileCache?: () => unknown }).enableCompileCache?.();\n+if (!opensLocal()) (nodeModule as { enableCompileCache?: () => unknown }).enableCompileCache?.();\n \n-const argv = process.argv.slice(2);\n-\n if (argv[0] === \"hook\") {\n \tconst { runHook } = await import(\"./src/hook.ts\");\n \tconst chunks: Buffer[] = [];"},{"path":"client/src/local-store.ts","added":12,"removed":10,"diff":"--- a/client/src/local-store.ts\n+++ b/client/src/local-store.ts\n@@ -221,24 +221,26 @@\n \t\t// copy has it already: the build points the import at the same file (scripts/build-client.mjs).\n \t\tconst standIn = new URL(\"./durable-object-stand-in.ts\", import.meta.url).href;\n \t\tconst mod = (await import(\"node:module\")) as unknown as {\n-\t\t\tregisterHooks?: (hooks: unknown) => { deregister(): void };\n+\t\t\tregisterHooks?: (hooks: unknown) => unknown;\n \t\t};\n-\t\tconst hooks = mod.registerHooks?.({\n+\t\t// The hook stays for the rest of the process: deregistering it crashes Node 24 at exit when the compile cache\n+\t\t// is on (client/avcs.ts turns it on). It answers only cloudflare:workers.\n+\t\tmod.registerHooks?.({\n \t\t\tresolve(specifier: string, context: unknown, next: (s: string, c: unknown) => unknown) {\n \t\t\t\tif (specifier === \"cloudflare:workers\") return { url: standIn, shortCircuit: true };\n \t\t\t\treturn next(specifier, context);\n \t\t\t},\n \t\t});\n+\t\tlet loaded: typeof import(\"./local-server.mjs\");\n \t\ttry {\n-\t\t\tconst { handle, ProjectObject } = await import(\"./local-server.mjs\");\n-\t\t\treturn {\n-\t\t\t\tDatabaseSync: sqlite.DatabaseSync,\n-\t\t\t\thandle,\n-\t\t\t\tProjectObject,\n-\t\t\t};\n-\t\t} finally {\n-\t\t\thooks?.deregister();\n+\t\t\tloaded = await import(\"./local-server.mjs\");\n+\t\t} catch (e) {\n+\t\t\t// Nothing is reached for here: a part of the client is missing (its packages not installed, say).\n+\t\t\tthrow new LocalError(\n+\t\t\t\t`local projects couldn't load the server's code: ${e instanceof Error ? e.message : String(e)}`,\n+\t\t\t);\n \t\t}\n+\t\treturn { DatabaseSync: sqlite.DatabaseSync, handle: loaded.handle, ProjectObject: loaded.ProjectObject };\n \t})();\n \treturn server;\n }"},{"path":"client/src/status-commands.ts","added":5,"removed":2,"diff":"--- a/client/src/status-commands.ts\n+++ b/client/src/status-commands.ts\n@@ -40,6 +40,7 @@\n } from \"./folder.ts\";\n import { fileArg } from \"./history.ts\";\n import { modsBehindText } from \"./install.ts\";\n+import { isLocal } from \"./local-store.ts\";\n import { withFolderLock } from \"./lock.ts\";\n import { readKnownModes, writeKnownModes } from \"./modes.ts\";\n import { queueText } from \"./queue.ts\";\n@@ -325,9 +326,11 @@\n \tconst space = (draft: string | null | undefined): string => (draft ? `draft ${draft}` : \"shared\");\n \tconst parked = (me?.parked ?? []).filter((p) => p.draftChanges > 0);\n \tconst credential = credentialLabel(root, config.server, env.env);\n-\tconst behind = await newerClientNote(config.server);\n+\t// A local project reaches for nothing on the network, npm included.\n+\tconst localProject = isLocal(config.server);\n+\tconst behind = localProject ? undefined : await newerClientNote(config.server);\n \tconst lines = [\n-\t\t`Project ${config.project}: shared is at version ${status.version}. This folder is ${config.agent}${config.reader || me?.reader ? \", a reader (it records and pushes nothing)\" : \"\"}, working in ${space(me?.draft)}.${config.follow ? ` It follows label ${config.follow}: pulls take it to the newest version with that label.` : \"\"} Signed in with ${credential.kind}${credential.id ? ` ${credential.id}` : \"\"}.`,\n+\t\t`Project ${config.project}: shared is at version ${status.version}. This folder is ${config.agent}${config.reader || me?.reader ? \", a reader (it records and pushes nothing)\" : \"\"}, working in ${space(me?.draft)}.${config.follow ? ` It follows label ${config.follow}: pulls take it to the newest version with that label.` : \"\"}${localProject ? ` It's a local project, in ${join(config.localStore ?? \"\", config.project)}.` : ` Signed in with ${credential.kind}${credential.id ? ` ${credential.id}` : \"\"}.`}`,\n \t\t...(behind ? [behind] : []),\n \t\t// Is shared green (#39)? Right under the first line, since it decides what to do next.\n \t\t...ciText(status.ci, status.version),"},{"path":"client/test/local.test.ts","added":32,"removed":0,"diff":"--- a/client/test/local.test.ts\n+++ b/client/test/local.test.ts\n@@ -3,10 +3,12 @@\n // call that would leave the machine fails the test.\n \n import assert from \"node:assert/strict\";\n+import { spawnSync } from \"node:child_process\";\n import { existsSync, mkdirSync, 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 { fileURLToPath } from \"node:url\";\n import { main } from \"../src/main.ts\";\n import { stateDir } from \"../src/state-dir.ts\";\n \n@@ -138,3 +140,33 @@\n \t\tassert.equal(existsSync(join(dir, \".abso\")) || existsSync(join(dir, \".avcs\")), false);\n \t});\n });\n+\n+describe(\"local commands as their own processes\", () => {\n+\t// The way people and agents run them: client/abso.ts, a process per command, Node's compile cache as it is.\n+\tconst entry = fileURLToPath(new URL(\"../abso.ts\", import.meta.url));\n+\tconst cli = (cwd: string, processStore: string, ...argv: string[]) =>\n+\t\tspawnSync(process.execPath, [entry, ...argv], {\n+\t\t\tcwd,\n+\t\t\tenv: { ...process.env, ABSO_STORE: processStore, ABSO_SERVERS_FILE: \"no-servers.json\" },\n+\t\t\tencoding: \"utf8\",\n+\t\t});\n+\n+\tit(\"init, push, status and log each exit cleanly\", () => {\n+\t\tconst processStore = temp(\"process-store\");\n+\t\tconst dir = temp(\"process\");\n+\t\twriteFileSync(join(dir, \"a.txt\"), \"one\\n\");\n+\t\tconst steps: [string, string[]][] = [\n+\t\t\t[\"init\", [\"init\", \"--local\", \"--project\", \"proc\", \"--agent\", \"p\"]],\n+\t\t\t[\"push\", [\"push\", \"-m\", \"Two\"]],\n+\t\t\t[\"status\", [\"status\"]],\n+\t\t\t[\"log\", [\"log\"]],\n+\t\t];\n+\t\tfor (const [name, argv] of steps) {\n+\t\t\tif (name === \"push\") writeFileSync(join(dir, \"a.txt\"), \"one\\ntwo\\n\");\n+\t\t\tconst r = cli(dir, processStore, ...argv);\n+\t\t\tassert.equal(r.status, 0, `${name}: exit ${r.status} ${r.signal ?? \"\"}\\n${r.stdout}${r.stderr}`);\n+\t\t\tif (name === \"status\") assert.match(r.stdout, /It's a local project, in /);\n+\t\t\tif (name === \"log\") assert.match(r.stdout, /Two/);\n+\t\t}\n+\t});\n+});"},{"path":"scripts/local-measure.ts","added":123,"removed":0,"diff":"--- /dev/null\n+++ b/scripts/local-measure.ts\n@@ -0,0 +1,123 @@\n+// Time and memory of a local project's commands (abso init --local) on a small and a large history:\n+//\n+//   node scripts/local-measure.ts [versions ...]        (default: 20 1000)\n+//\n+// Each history is built in this process through the client's main(); then every command is run as its own\n+// `node client/abso.ts` process, the way a person or an agent runs it, five times. It prints the median and slowest\n+// wall time, and the largest peak memory (maxRSS) of those runs, with the store's size on disk.\n+\n+import { spawnSync } from \"node:child_process\";\n+import { mkdtempSync, readdirSync, rmSync, statSync, writeFileSync } from \"node:fs\";\n+import { tmpdir } from \"node:os\";\n+import { join, resolve } from \"node:path\";\n+import { fileURLToPath, pathToFileURL } from \"node:url\";\n+import { main } from \"../client/src/main.ts\";\n+\n+const ROOT = resolve(fileURLToPath(new URL(\"..\", import.meta.url)));\n+const ENTRY = join(ROOT, \"client\", \"abso.ts\");\n+const FILES = 40;\n+const RUNS = 5;\n+\n+const sizes = process.argv.slice(2).map(Number);\n+const histories = sizes.length > 0 ? sizes : [20, 1000];\n+\n+function sizeOf(dir: string): number {\n+\tlet total = 0;\n+\tfor (const name of readdirSync(dir)) {\n+\t\tconst path = join(dir, name);\n+\t\tconst s = statSync(path);\n+\t\ttotal += s.isDirectory() ? sizeOf(path) : s.size;\n+\t}\n+\treturn total;\n+}\n+\n+const lines = (file: number, version: number) =>\n+\tArray.from({ length: 30 }, (_, i) =>\n+\t\ti === version % 30 ? `line ${i} of file ${file}, version ${version}` : `line ${i} of file ${file}`,\n+\t)\n+\t\t.join(\"\\n\")\n+\t\t.concat(\"\\n\");\n+\n+async function build(versions: number): Promise<{ store: string; alice: string; bob: string }> {\n+\tconst store = mkdtempSync(join(tmpdir(), \"abso-measure-store-\"));\n+\tconst alice = mkdtempSync(join(tmpdir(), \"abso-measure-alice-\"));\n+\tconst bob = mkdtempSync(join(tmpdir(), \"abso-measure-bob-\"));\n+\tconst env = { ABSO_STORE: store, ABSO_SERVERS_FILE: \"no-servers.json\" };\n+\tconst run = async (cwd: string, ...argv: string[]) => {\n+\t\tconst r = await main(argv, { cwd, env, write: () => {} });\n+\t\tif (r.exit !== 0) throw new Error(`${argv.join(\" \")}: ${r.stdout}${r.stderr}`);\n+\t};\n+\tfor (let f = 0; f < FILES; f++) writeFileSync(join(alice, `f${f}.txt`), lines(f, 0));\n+\tawait run(alice, \"init\", \"--local\", \"--project\", \"measure\", \"--agent\", \"alice\", \"--as-is\");\n+\tfor (let v = 1; v < versions; v++) {\n+\t\t// Each version changes three files, as a small piece of work does.\n+\t\tfor (const f of [v % FILES, (v * 7) % FILES, (v * 13) % FILES])\n+\t\t\twriteFileSync(join(alice, `f${f}.txt`), lines(f, v));\n+\t\tawait run(alice, \"push\", \"-m\", `Version ${v}`);\n+\t}\n+\tawait run(bob, \"join\", \"measure\", \"--local\", \"--agent\", \"bob\", \"--dir\", bob);\n+\treturn { store, alice, bob };\n+}\n+\n+function measure(cwd: string, store: string, argv: string[]): { median: number; slowest: number; rss: number } {\n+\tconst times: number[] = [];\n+\tlet rss = 0;\n+\tconst preload = join(tmpdir(), `abso-measure-rss-${process.pid}.mjs`);\n+\tconst out = join(tmpdir(), `abso-measure-rss-${process.pid}.json`);\n+\twriteFileSync(\n+\t\tpreload,\n+\t\t`import { writeFileSync } from \"node:fs\";\\nprocess.on(\"exit\", () => writeFileSync(${JSON.stringify(out)}, String(process.resourceUsage().maxRSS)));\\n`,\n+\t);\n+\tfor (let i = 0; i < RUNS; i++) {\n+\t\tconst started = performance.now();\n+\t\tconst r = spawnSync(process.execPath, [\"--import\", pathToFileURL(preload).href, ENTRY, ...argv], {\n+\t\t\tcwd,\n+\t\t\tenv: { ...process.env, ABSO_STORE: store, ABSO_SERVERS_FILE: \"no-servers.json\" },\n+\t\t\tencoding: \"utf8\",\n+\t\t});\n+\t\ttimes.push(performance.now() - started);\n+\t\tif (r.status !== 0 && argv[0] !== \"push\") throw new Error(`${argv.join(\" \")}: ${r.stdout}${r.stderr}`);\n+\t\trss = Math.max(\n+\t\t\trss,\n+\t\t\tNumber(\n+\t\t\t\tspawnSync(\n+\t\t\t\t\tprocess.execPath,\n+\t\t\t\t\t[\"-e\", `process.stdout.write(require(\"fs\").readFileSync(${JSON.stringify(out)}, \"utf8\"))`],\n+\t\t\t\t\t{ encoding: \"utf8\" },\n+\t\t\t\t).stdout,\n+\t\t\t),\n+\t\t);\n+\t}\n+\ttimes.sort((a, b) => a - b);\n+\treturn { median: times[Math.floor(RUNS / 2)]!, slowest: times[RUNS - 1]!, rss };\n+}\n+\n+const kb = (n: number) => `${(n / 1024).toFixed(0)} MB`;\n+const ms = (n: number) => `${n.toFixed(0)} ms`;\n+console.log(\n+\t`Node ${process.versions.node}, ${FILES} files of 30 lines, three files changed per version, ${RUNS} runs each.`,\n+);\n+console.log(\"history   | command              | median   | slowest  | peak memory\");\n+for (const versions of histories) {\n+\tconst started = performance.now();\n+\tconst { store, alice, bob } = await build(versions);\n+\tconst built = performance.now() - started;\n+\tconst steps: [string, string, string[]][] = [\n+\t\t[\"status\", alice, [\"status\"]],\n+\t\t[\"log\", alice, [\"log\"]],\n+\t\t[\"blame\", alice, [\"blame\", \"f0.txt\"]],\n+\t\t[\"pull (no change)\", bob, [\"pull\"]],\n+\t\t[\"record + push\", alice, [\"push\", \"-m\", \"One more\"]],\n+\t];\n+\tfor (const [name, cwd, argv] of steps) {\n+\t\tif (argv[0] === \"push\") writeFileSync(join(cwd, \"f1.txt\"), lines(1, versions + Math.random()));\n+\t\tconst m = measure(cwd, store, argv);\n+\t\tconsole.log(\n+\t\t\t`${String(versions).padStart(5)} v   | ${name.padEnd(20)} | ${ms(m.median).padStart(8)} | ${ms(m.slowest).padStart(8)} | ${kb(m.rss)}`,\n+\t\t);\n+\t}\n+\tconsole.log(\n+\t\t`${String(versions).padStart(5)} v   | store on disk ${(sizeOf(store) / 1048576).toFixed(1)} MB, built in-process in ${(built / 1000).toFixed(1)} s`,\n+\t);\n+\tfor (const d of [store, alice, bob]) rmSync(d, { recursive: true, force: true, maxRetries: 5 });\n+}"},{"path":"scripts/local-writers.ts","added":87,"removed":0,"diff":"--- /dev/null\n+++ b/scripts/local-writers.ts\n@@ -0,0 +1,87 @@\n+// A local project's store lock under load: 1, 4 and 16 writers pushing to one local project at once.\n+//\n+//   node scripts/local-writers.ts [writers ...]        (default: 1 4 16; PUSHES=10 pushes per writer)\n+//\n+// Each writer is its own agent, in its own folder, changing its own file, so nothing collides: what's measured is the\n+// store's lock (one SQLite write transaction per call). Every push is its own `node client/abso.ts push` process, as\n+// an agent runs it. It prints each push's wall time (median, 95th percentile, slowest), the pushes per second across\n+// all writers, and any push that failed.\n+\n+import { spawn } from \"node:child_process\";\n+import { mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\n+import { tmpdir } from \"node:os\";\n+import { join, resolve } from \"node:path\";\n+import { fileURLToPath } from \"node:url\";\n+import { main } from \"../client/src/main.ts\";\n+\n+const ROOT = resolve(fileURLToPath(new URL(\"..\", import.meta.url)));\n+const ENTRY = join(ROOT, \"client\", \"abso.ts\");\n+const PUSHES = Number(process.env.PUSHES ?? 10);\n+const counts = process.argv.slice(2).map(Number);\n+\n+function push(cwd: string, store: string, message: string): Promise<{ ms: number; ok: boolean; out: string }> {\n+\tconst started = performance.now();\n+\treturn new Promise((done) => {\n+\t\tconst child = spawn(process.execPath, [ENTRY, \"push\", \"-m\", message], {\n+\t\t\tcwd,\n+\t\t\tenv: { ...process.env, ABSO_STORE: store, ABSO_SERVERS_FILE: \"no-servers.json\" },\n+\t\t});\n+\t\tlet out = \"\";\n+\t\tchild.stdout.on(\"data\", (d) => {\n+\t\t\tout += d;\n+\t\t});\n+\t\tchild.stderr.on(\"data\", (d) => {\n+\t\t\tout += d;\n+\t\t});\n+\t\tchild.on(\"close\", (code) => done({ ms: performance.now() - started, ok: code === 0, out }));\n+\t});\n+}\n+\n+const pct = (sorted: number[], p: number) => sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * p))]!;\n+console.log(`Node ${process.versions.node}, ${PUSHES} pushes per writer, each writer its own agent and file.`);\n+console.log(\"writers | pushes | median   | p95      | slowest  | pushes/s | failed\");\n+for (const writers of counts.length > 0 ? counts : [1, 4, 16]) {\n+\tconst store = mkdtempSync(join(tmpdir(), \"abso-writers-store-\"));\n+\tconst folders: string[] = [];\n+\tconst env = { ABSO_STORE: store, ABSO_SERVERS_FILE: \"no-servers.json\" };\n+\tconst first = mkdtempSync(join(tmpdir(), \"abso-writers-w0-\"));\n+\twriteFileSync(join(first, \"readme.txt\"), \"writers\\n\");\n+\tconst init = await main([\"init\", \"--local\", \"--project\", \"writers\", \"--agent\", \"w0\", \"--as-is\"], {\n+\t\tcwd: first,\n+\t\tenv,\n+\t\twrite: () => {},\n+\t});\n+\tif (init.exit !== 0) throw new Error(init.stdout + init.stderr);\n+\tfolders.push(first);\n+\tfor (let w = 1; w < writers; w++) {\n+\t\tconst dir = mkdtempSync(join(tmpdir(), `abso-writers-w${w}-`));\n+\t\tconst joined = await main([\"join\", \"writers\", \"--local\", \"--agent\", `w${w}`, \"--dir\", dir], {\n+\t\t\tcwd: dir,\n+\t\t\tenv,\n+\t\t\twrite: () => {},\n+\t\t});\n+\t\tif (joined.exit !== 0) throw new Error(joined.stdout + joined.stderr);\n+\t\tfolders.push(dir);\n+\t}\n+\tconst times: number[] = [];\n+\tconst failures: string[] = [];\n+\tconst started = performance.now();\n+\tawait Promise.all(\n+\t\tfolders.map(async (dir, w) => {\n+\t\t\tfor (let i = 0; i < PUSHES; i++) {\n+\t\t\t\twriteFileSync(join(dir, `w${w}.txt`), `writer ${w}, push ${i}\\n`);\n+\t\t\t\tconst r = await push(dir, store, `w${w} push ${i}`);\n+\t\t\t\ttimes.push(r.ms);\n+\t\t\t\tif (!r.ok) failures.push(`w${w} push ${i}: ${r.out.trim().split(\"\\n\").slice(-2).join(\" / \")}`);\n+\t\t\t}\n+\t\t}),\n+\t);\n+\tconst total = (performance.now() - started) / 1000;\n+\ttimes.sort((a, b) => a - b);\n+\tconst ms = (n: number) => `${n.toFixed(0)} ms`.padStart(8);\n+\tconsole.log(\n+\t\t`${String(writers).padStart(7)} | ${String(times.length).padStart(6)} | ${ms(pct(times, 0.5))} | ${ms(pct(times, 0.95))} | ${ms(times.at(-1)!)} | ${(times.length / total).toFixed(1).padStart(8)} | ${failures.length}`,\n+\t);\n+\tfor (const f of failures.slice(0, 5)) console.log(`        ${f}`);\n+\tfor (const d of [store, ...folders]) rmSync(d, { recursive: true, force: true, maxRetries: 5 });\n+}"},{"path":"worker/project/news.ts","added":5,"removed":1,"diff":"--- a/worker/project/news.ts\n+++ b/worker/project/news.ts\n@@ -361,7 +361,11 @@\n \t\t\tchangedNames.size > 0\n \t\t\t\t? host.definitionCollisions(agent, host.newerFor(agent), changedNames).filter((d) => just.has(d.by))\n \t\t\t\t: [];\n-\t\tconst items = [...lineNews(host, agent, lines), ...definitionNews(defs), ...moveNews(host, draft, just, space, version)];\n+\t\tconst items = [\n+\t\t\t...lineNews(host, agent, lines),\n+\t\t\t...definitionNews(defs),\n+\t\t\t...moveNews(host, draft, just, space, version),\n+\t\t];\n \t\tnews += items.length;\n \t\thost.queueNews(agent, items, entries);\n \t}"}],"ci":null}