Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 0 to 318

Compare

+8 −7 in 4 places
Lines 8–25 at 318 (were 8–24 at 0)
88//
99// The lock is never there without its contents: they're written to a file of
1010// the taker's own and linked into place, which fails if a lock exists
11−// (AVCS - Git Lessons). Its holder renews it every RENEW_MS, so a lock not
11+// already. Its holder renews it every RENEW_MS, so a lock not
1212// renewed for LOCK_STALE_MS was left behind, whatever process now has its
1313// id; a long record or sync is never taken over while it writes. Taking one
1414// over goes through a rename aside, which only one process can win.
1515
1616import { closeSync, linkSync, openSync, readFileSync, renameSync, rmSync, statSync, writeSync } from "node:fs";
17−import { join } from "node:path";
17+import { basename, join } from "node:path";
1818import { UsageError } from "./args.ts";
19−import { AVCS_DIR } from "./config.ts";
2019import { LOCK_FILE, LOCK_STALE_MS, type LockInfo } from "./core.ts";
20+import { fromEnv } from "./env-names.ts";
2121import { writeFileAtomic } from "./folder.ts";
22+import { stateDir } from "./state-dir.ts";
2223
2324/** How long a command waits for the lock before it says who holds it. */
2425const WAIT_MS = 3000;
Lines 29–35 at 318 (were 28–34 at 0)
2829/** Locks this process holds, by folder, and how deep: a locked call inside another one doesn't wait for itself. */
2930const held = new Map<string, { depth: number; renew: ReturnType<typeof setInterval> }>();
3031
31−const lockPath = (root: string): string => join(root, AVCS_DIR, LOCK_FILE);
32+const lockPath = (root: string): string => join(stateDir(root), LOCK_FILE);
3233
3334function readInfo(path: string): LockInfo | undefined {
3435 try {
Lines 143–150 at 318 (were 142–149 at 0)
142143 const mine = held.get(root);
143144 if (mine) mine.depth++;
144145 else {
145− // AVCS_LOCK_WAIT_MS shortens the wait in tests.
146− const until = Date.now() + (Number(process.env.AVCS_LOCK_WAIT_MS) || WAIT_MS);
146+ // ABSO_LOCK_WAIT_MS shortens the wait in tests.
147+ const until = Date.now() + (Number(fromEnv(process.env, "LOCK_WAIT_MS")) || WAIT_MS);
147148 for (;;) {
148149 const got = take(root, what);
149150 if (got === "no folder") return fn(); // no .avcs/ yet (init): nothing to protect
Lines 153–159 at 318 (were 152–158 at 0)
152153 const info = readInfo(lockPath(root));
153154 const since = info ? new Date(info.time).toISOString().slice(11, 19) : "?";
154155 throw new UsageError(
155− `another abso command (${info?.what ?? "one"}, process ${info?.pid ?? "?"}, since ${since} UTC) is changing this folder's records; run this again when it has finished. If none is running, delete .avcs/lock.`,
156+ `another abso command (${info?.what ?? "one"}, process ${info?.pid ?? "?"}, since ${since} UTC) is changing this folder's records; run this again when it has finished. If none is running, delete ${basename(stateDir(root))}/lock.`,
156157 );
157158 }
158159 await new Promise((ok) => setTimeout(ok, 50));
MCP
compare on this site's /mcp
CLI
abso diff 0 318 client/src/lock.ts --json
JSON
/christopher/abso-core/compare/0..318?file=client%2Fsrc%2Flock.ts&format=json