status: skip reading files found unchanged before. A record in the folder's state dir (clean.json) keeps, per file, the size, time and inode of the file and its known copy, taken before reading; only status's unrecorded and line-ending checks use it, record always reads every file. Files changed too recently to trust are read; an unknown format or client version reads everything. The state dir is found once per walk. The mod-commit test no longer depends on how long it takes. Version 44 of shared· speed· Oct 9 (2026-10-09 15:00 UTC) · Not checked
status: skip reading files found unchanged before. A record in the folder's state dir (clean.json) keeps, per file, the size, time and inode of the file and its known copy, taken before reading; only status's unrecorded and line-ending checks use it, record always reads every file.
Files changed too recently to trust are read; an unknown format or client version reads everything. The state dir is found once per walk. The mod-commit test no longer depends on how long it takes.
Version 43 · Files at version 44
5 files, 251 lines added, 11 removed.
--- /dev/null
+++ b/client/src/clean-files.ts
@@ -0,0 +1,134 @@
1 + // Which files `abso status` found the same as their known copy last time, so the 2 + // next status reads only the files that may have changed, as git's index does. 4 + // An entry is kept per file: the size, modified time and inode of the file on 5 + // disk and of its known copy, each taken before either was read, and whether 6 + // the file held a CR. It's trusted only while both still match, and only when 7 + // both were changed clearly before the entry was made: a file changed in the 8 + // same moment can't be told apart from one changed just after, so it's read. 9 + // Anything abso writes into the folder or the known copy changes one side's 10 + // size, time or inode, so no writer has to remember to drop entries. 12 + // Only status and the checks it prints use this. record reads every file: a 13 + // line status misses is a nuisance, a change record misses is lost work. 15 + import { lstatSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs"; 16 + import { join } from "node:path"; 17 + import { clientVersion } from "./client-version.ts"; 18 + import { stateDir } from "./state-dir.ts"; 20 + const FILE = "clean.json"; 22 + /** How much older than an entry a file's time must be to trust it. */ 23 + const RACY_MS = 2_000; 25 + /** A file's place in the record now, taken before it is read. */ 26 + export interface CleanKey { 28 + /** The newer of the two modified times. */ 29 + readonly newest: number; 30 + /** The file on disk's mode bits. */ 31 + readonly mode: number; 37 + readonly cr: boolean; 40 + export class CleanFiles { 41 + readonly #root: string; 42 + readonly #entries: Map<string, Entry>; 43 + /** When this run started looking; entries made in it carry this time. */ 44 + readonly #at = Date.now(); 45 + readonly #keys = new Map<string, CleanKey | undefined>(); 48 + private constructor(root: string, entries: Map<string, Entry>) { 50 + this.#entries = entries; 53 + /** The folder's record, or an empty one when it's missing, unreadable, or from another format or client. */ 54 + static load(root: string): CleanFiles { 55 + const entries = new Map<string, Entry>(); 57 + const file = JSON.parse(readFileSync(join(stateDir(root), FILE), "utf8")) as { 60 + files?: Record<string, [string, number, boolean]>; 62 + if (file.format === FORMAT && file.client === clientVersion() && typeof file.files === "object" && file.files) 63 + for (const [rel, [id, at, cr]] of Object.entries(file.files)) 64 + if (typeof id === "string" && typeof at === "number" && typeof cr === "boolean") 65 + entries.set(rel, { id, at, cr }); 67 + return new CleanFiles(root, entries); 71 + * The key of a plain file on disk and its known copy; undefined for a link, or when either is missing. 72 + * Taken once per run: a key taken before a later read is still safe to mark with, since any change 73 + * after it was taken makes the next run's key differ. 75 + key(diskPath: string, knownPath: string): CleanKey | undefined { 76 + if (this.#keys.has(diskPath)) return this.#keys.get(diskPath); 77 + let key: CleanKey | undefined; 79 + const disk = lstatSync(diskPath); 81 + const known = statSync(knownPath); 83 + id: `${disk.size}:${disk.mtimeMs}:${disk.ino}|${known.size}:${known.mtimeMs}:${known.ino}`, 84 + newest: Math.max(disk.mtimeMs, known.mtimeMs), 89 + this.#keys.set(diskPath, key); 93 + /** Whether the file was the same as its known copy at this key, and if so whether it held a CR; undefined: read it. */ 94 + check(rel: string, key: CleanKey): { cr: boolean } | undefined { 95 + const entry = this.#entries.get(rel); 96 + if (entry === undefined || entry.id !== key.id || key.newest >= entry.at - RACY_MS) return undefined; 97 + return { cr: entry.cr }; 100 + /** The file, read after `key` was taken, is the same as its known copy. */ 101 + mark(rel: string, key: CleanKey, cr: boolean): void { 102 + const entry = this.#entries.get(rel); 103 + if (key.newest >= this.#at - RACY_MS) { 104 + // Too new to trust next time either; an old entry for it is no use now. 105 + if (entry !== undefined) { 106 + this.#entries.delete(rel); 107 + this.#changed = true; 111 + if (entry?.id === key.id && entry.cr === cr) return; 112 + this.#entries.set(rel, { id: key.id, at: this.#at, cr }); 113 + this.#changed = true; 116 + /** The file differs from its known copy, or is gone. */ 117 + drop(rel: string): void { 118 + if (this.#entries.delete(rel)) this.#changed = true; 121 + /** Write the record, if anything changed. Best effort: a run that can't write it just reads more next time. */ 123 + if (!this.#changed) return; 125 + const dir = stateDir(this.#root); 126 + mkdirSync(dir, { recursive: true }); 127 + const files = Object.fromEntries([...this.#entries].map(([rel, e]) => [rel, [e.id, e.at, e.cr]])); 128 + const next = join(dir, `${FILE}.${process.pid}.tmp`); 129 + writeFileSync(next, JSON.stringify({ format: FORMAT, client: clientVersion(), files })); 130 + renameSync(next, join(dir, FILE)); 131 + this.#changed = false; --- a/client/src/folder.ts
+++ b/client/src/folder.ts
@@ -26,8 +26,9 @@
26 26 import { homedir } from "node:os"; 27 27 import { dirname, join, relative, sep } from "node:path"; 28 28 import { blobOf, keptWholeAs, readKnownBlobs } from "./blobs.ts"; 29 + import type { CleanFiles } from "./clean-files.ts"; 29 30 import { type GitHome, gitIgnoreSetup, type Ignore, isLocalOnly, makeIgnore, normalize, readAllSync } from "./core.ts"; 30 − import { type Mode, modeChange, onDisk, PLAIN, readKnownModes } from "./modes.ts";
31 + import { FILE_MODE, type Mode, modeChange, onDisk, PLAIN, readKnownModes } from "./modes.ts"; 31 32 import { stateDir } from "./state-dir.ts"; 33 34 export { type Ignore, isLocalOnly, normalize, withEndingsOf } from "./core.ts"; @@ -279,12 +280,13 @@
280 281 // --- the known copy --- 282 − function knownPath(root: string, rel: string): string {
283 − return join(stateDir(root), KNOWN, ...insideParts(rel));
283 + /** `state` is the folder's stateDir, for a caller that looks up many files: finding it checks the disk each time. */ 284 + export function knownPath(root: string, rel: string, state: string = stateDir(root)): string { 285 + return join(state, KNOWN, ...insideParts(rel)); 286 − export function readKnown(root: string, rel: string): string | undefined {
287 − return readText(knownPath(root, rel));
288 + export function readKnown(root: string, rel: string, state?: string): string | undefined { 289 + return readText(knownPath(root, rel, state)); 290 292 export function writeKnown(root: string, rel: string, text: string): void { @@ -321,11 +323,15 @@
321 323 * server's form), known files that are gone (null), and the modes that differ 322 324 * from the known modes. An empty file is a file like any other (""); a link's 327 + * `clean` lets status skip reading the files it found unchanged last time 328 + * (clean-files.ts). record never passes it, so it always reads every file. 325 330 export function unrecorded( 328 333 meantBinary: ReadonlySet<string> = new Set(), 330 336 files: Map<string, string | null>; 331 337 blobs: Map<string, BlobToSend>; @@ -342,10 +348,23 @@
342 348 const turnedBinary: TurnedBinary[] = []; 343 349 // Exact names: on a case-insensitive disk, known/a.ts would also answer for A.ts, hiding a rename that changes only case. 344 350 const knownPaths = new Set(listKnown(root)); 351 + const state = stateDir(root); 345 352 const knownBlobs = readKnownBlobs(root); 346 353 const knownModes = readKnownModes(root); 354 + const trusted = all ? undefined : clean; 347 355 for (const rel of walk(root, ignore)) { 348 356 const was = knownModes.get(rel) ?? PLAIN; 357 + // Taken before the file is read, so an edit during the read changes the key. 359 + trusted && knownPaths.has(rel) && was.link === null 360 + ? trusted.key(absolute(root, rel), knownPath(root, rel, state)) 362 + if (key && trusted!.check(rel, key)) { 364 + const change = modeChange(was, { exec: FILE_MODE ? (key.mode & 0o111) !== 0 : was.exec, link: null }); 365 + if (change) modes[rel] = change; 349 368 const d = onDisk(absolute(root, rel), was); 350 369 if (d === undefined) continue; 351 370 if (d.text === undefined) { @@ -367,11 +386,13 @@
367 386 if (all || knownBlobs.get(rel) !== b.sha) blobs.set(rel, { sha: b.sha, bytes: b.bytes }); 369 388 const text = normalize(d.text); 370 − const known = knownPaths.has(rel) ? readKnown(root, rel) : undefined;
389 + const known = knownPaths.has(rel) ? readKnown(root, rel, state) : undefined; 372 391 // A file the server keeps whole has no known copy, only its hash (#46). 373 392 if (all || (known !== text && !(known === undefined && keptWholeAs(text, knownBlobs.get(rel))))) 374 393 out.set(rel, text); 394 + if (key && d.link === null && known === text) trusted!.mark(rel, key, d.text.includes("\r")); 395 + else trusted?.drop(rel); 376 397 // --all sends every file's whole mode, as it sends every file's text. 377 398 const change = all ? { exec: d.exec, link: d.link } : modeChange(was, d); --- a/client/src/status-commands.ts
+++ b/client/src/status-commands.ts
@@ -8,6 +8,7 @@
8 8 import { bool, type Parsed, UsageError } from "./args.ts"; 9 9 import { readKnownBlobs, writeKnownBlobs } from "./blobs.ts"; 10 10 import { ciText } from "./ci.ts"; 11 + import { CleanFiles } from "./clean-files.ts"; 11 12 import { newerCommitNote } from "./client-version.ts"; 12 13 import { type Env, heard, type Output, open, plural } from "./command-env.ts"; @@ -26,6 +27,7 @@
@@ -68,13 +70,24 @@
68 70 * line endings (#37: Python's text mode on Windows writes CRLF). 69 71 * abso records them, and abso run sends them, with LF; a tool run here sees 70 72 * CRLF. Files git would check out with CRLF are left out of the list. 73 + * With `clean` (status), a file found unchanged before is answered without reading it. 72 − export function crlfOnly(root: string): string[] {
75 + export function crlfOnly(root: string, clean?: CleanFiles): string[] { 73 76 const out: string[] = []; 77 + const state = stateDir(root); 74 78 for (const rel of listKnown(root)) { 79 + const key = clean?.key(absolute(root, rel), knownPath(root, rel, state)); 80 + const was = key && clean!.check(rel, key); 82 + if (was.cr) out.push(rel); 75 85 const disk = readText(absolute(root, rel)); 76 86 if (disk === undefined || !disk.includes("\r")) continue; 77 − if (normalize(disk) === readKnown(root, rel)) out.push(rel);
87 + if (normalize(disk) === readKnown(root, rel, state)) { 89 + if (key) clean!.mark(rel, key, true); 79 92 const git = newFileEndings(root, out); 80 93 return out.filter((rel) => git.get(rel) !== "crlf").sort(); @@ -269,9 +282,11 @@
269 282 const { root, config, api } = open(env); 270 283 const short = bool(args, "short"); 271 284 const { files: view, ...status } = short ? { ...(await api.status()), files: undefined } : await api.statusAndFiles(); 272 − const pending = unrecorded(root);
285 + const clean = CleanFiles.load(root); 286 + const pending = unrecorded(root, false, new Set(), clean); 273 287 const local = new Set([...pending.files.keys(), ...pending.blobs.keys(), ...Object.keys(pending.modes)]); 275 290 // One word to stamp a build with (#37): 214, coast@3, 214+unpublished. 276 291 const me = status.agents.find((a) => a.agent === config.agent); 277 292 const unpublished = local.size > 0 || (me?.draftChanges ?? 0) > 0; @@ -281,7 +296,8 @@
282 297 const missing = view === undefined ? [] : missingHere(root, view.files, local); 283 298 const unwritten = readUnwritten(root); 284 − const crlf = crlfOnly(root);
299 + const crlf = crlfOnly(root, clean); 285 301 // Files an earlier record added to the draft and that are gone again (#37: scratch files a run 286 302 // recorded, deleted after): nothing reached shared, and the next record takes them out of the draft. 287 303 const deleted = [...pending.files].filter(([, text]) => text === null).map(([rel]) => rel); --- a/client/test/client.test.ts
+++ b/client/test/client.test.ts
@@ -46,7 +46,7 @@
47 47 } from "../src/core.ts"; 48 48 import { unifiedDiff } from "../src/diff.ts"; 49 − import { absolute, writeFileAtomic } from "../src/folder.ts";
49 + import { absolute, knownPath, unrecorded, writeFileAtomic } from "../src/folder.ts"; 50 50 import { runHook } from "../src/hook.ts"; 51 51 import { tryFolderLock } from "../src/lock.ts"; 52 52 import { boxServer, commandTable, main } from "../src/main.ts"; @@ -3495,6 +3495,72 @@
3495 3495 assert.deepEqual(after.json.unrecorded, []); 3498 + it("status skips reading files it found unchanged before, never trusts one changed too recently, and record still reads every file", async () => { 3499 + const { folders } = await project({ "a.txt": "a\n", "b.txt": "b\n", "c.txt": "c\r\n" }, "alice", "bob"); 3500 + const root = folders.alice!; 3501 + const record = join(stateDir(root), "clean.json"); 3502 + const old = new Date(Date.now() - 60_000); 3503 + // The file and its known copy a minute old, as after a quiet spell. 3504 + const age = (...rels: string[]) => { 3505 + for (const rel of rels) { 3506 + utimesSync(join(root, rel), old, old); 3507 + utimesSync(knownPath(root, rel), old, old); 3510 + // Changes a file without changing its size or time: only reading it can tell. 3511 + const swap = (rel: string, text: string) => { 3512 + const was = statSync(join(root, rel)); 3513 + writeFileSync(join(root, rel), text); 3514 + utimesSync(join(root, rel), was.atime, was.mtime); 3516 + writeFileSync(join(root, "c.txt"), "c\r\n"); 3518 + // Files too new to trust are read, and not kept: a swap is still caught. A time a minute ahead stays 3519 + // too new however long the run takes. 3520 + const soon = new Date(Date.now() + 60_000); 3521 + for (const rel of ["a.txt", "b.txt", "c.txt"]) utimesSync(join(root, rel), soon, soon); 3522 + assert.deepEqual((await avcs(root, "status")).json.unrecorded, []); 3523 + swap("a.txt", "A\n"); 3524 + assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["a.txt"]); 3525 + swap("a.txt", "a\n"); 3527 + // Old files are kept after one status, and the next answers from the record without reading them. 3528 + age("a.txt", "b.txt", "c.txt"); 3529 + const first = await avcs(root, "status"); 3530 + assert.deepEqual(first.json.unrecorded, []); 3531 + assert.deepEqual(first.json.crlf, ["c.txt"]); 3532 + assert.deepEqual(Object.keys(JSON.parse(readFileSync(record, "utf8")).files).sort(), ["a.txt", "b.txt", "c.txt"]); 3533 + swap("b.txt", "B\n"); 3534 + const second = await avcs(root, "status"); 3535 + assert.deepEqual(second.json.unrecorded, [], "b.txt was answered from the record"); 3536 + assert.deepEqual(second.json.crlf, ["c.txt"]); 3537 + // What record sends is read from every file, whatever the record says. 3538 + assert.deepEqual([...unrecorded(root).files.keys()], ["b.txt"]); 3540 + // A record of an unknown format, or one that doesn't parse, is not used. 3541 + const kept = JSON.parse(readFileSync(record, "utf8")); 3542 + writeFileSync(record, JSON.stringify({ ...kept, format: 2 })); 3543 + assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["b.txt"]); 3544 + writeFileSync(record, "not json"); 3545 + assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["b.txt"]); 3547 + // An edit that changes the size or time is read at once. 3548 + swap("b.txt", "b\n"); 3550 + assert.deepEqual((await avcs(root, "status")).json.unrecorded, []); 3551 + writeFileSync(join(root, "b.txt"), "bb\n"); 3552 + assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["b.txt"]); 3554 + // A sync writes the file and its known copy, so what was kept for them no longer holds. 3555 + writeFileSync(join(root, "b.txt"), "b\n"); 3556 + write(folders.bob!, { "a.txt": "a2\n" }); 3557 + assert.equal((await avcs(folders.bob!, "publish", "-m", "a2")).exit, 0); 3558 + assert.equal((await avcs(root, "sync")).exit, 0); 3559 + assert.equal(readFileSync(join(root, "a.txt"), "utf8"), "a2\n"); 3560 + swap("a.txt", "a3\n"); 3561 + assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["a.txt"]); 3498 3564 it("several files marked against one version get one settle --theirs hint", () => { 3499 3565 const c = (file: string, version: number) => ({ 3500 3566 kind: "lines" as const, --- a/client/test/install.test.ts
+++ b/client/test/install.test.ts
@@ -337,7 +337,10 @@
337 337 assert.equal(keptModCommit(spec, home), "fffffff", "a kept answer is used while nothing moved"); 339 339 // A file changed in the same moment the answer was kept is never trusted, even when its size and time match. 340 + // A time a minute ahead stays too new however long the run takes. 340 341 write(spec.from, "src/core.ts", "export const core = 2\n"); 342 + const soon = new Date(Date.now() + 60_000); 343 + utimesSync(at(spec.from, "src/core.ts"), soon, soon); 341 344 assert.equal(keptModCommit(spec, home), `${mod}.dirty`); 343 346 assert.equal(keptModCommit(spec, home), `${mod}.dirty`, "too new to trust: git runs again");