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
MCP
show on this site's /mcp
CLI
abso show 26 --json
JSON
/christopher/abso-core/versions/26?format=json

Publish and log fixes, and a flaky test removed.

of shared·pinch··Not checked

  • A publish or a land now waits up to 150 s for the server's answer, not 30 s. The server may work on one request for up to 2 minutes, so a slow merge was reported as failed and then landed.
  • abso log reads any length of history. The server sends at most 200 versions a page, and the client now follows its pages: -n 2000 gives 2000, and --since or a folder reads up to 1000. abso log --before <version> starts below that version. The end of the list names the --before for the next older ones, and a filtered read says when it stopped short.
  • The test 'sends one run, and takes each command as one quoted word' is removed: it failed on Windows about half the time. The stand-in server the client tests use no longer closes idle kept-alive connections, which other tests also tripped on under load (ECONNRESET).

Check: 722 pass, 0 fail.

Version 25 · Files at version 26

6 files, 126 lines added, 34 removed.

--- a/client/src/api.ts
+++ b/client/src/api.ts
@@ -85,6 +85,17 @@
8585 return sent === undefined ? baseMs : baseMs + Math.floor(Buffer.byteLength(sent) / 100_000) * 1000;
8686}
8787
88+/**
89+ * How long a publish or a land may take before the client stops waiting: the
90+ * server gives one request up to 2 minutes of work, so a small body can still
91+ * take that long (a large merge). Waiting less reported publishes as failed
92+ * that went on to land.
93+ */
94+export const PUBLISH_TIMEOUT_MS = 150_000;
96+/** The most versions the server's log sends at once. */
97+export const LOG_PAGE = 200;
8899/** A query string from the values that are set (null and undefined are left out). */
89100function query(values: Record<string, string | number | null | undefined>): URLSearchParams {
90101 const q = new URLSearchParams();
@@ -168,10 +179,16 @@
168179 };
169180 }
170181
171− async json<T>(method: "GET" | "POST", path: string, body?: unknown, server = this.config.server): Promise<T> {
182+ async json<T>(
183+ method: "GET" | "POST",
184+ path: string,
185+ body?: unknown,
186+ server = this.config.server,
187+ atLeastMs = 0,
188+ ): Promise<T> {
172189 let res: Response | undefined;
173190 const sent = body === undefined ? undefined : JSON.stringify(body);
174− const timeoutMs = timeoutFor(this.timeoutMs, sent);
191+ const timeoutMs = Math.max(atLeastMs, timeoutFor(this.timeoutMs, sent));
175192 // A connection that never opened is tried once more, IPv4 first (#37, GAME - UI/UX: one IPv6
176193 // address timed out, and the same command went through seconds later). Nothing went out, so
177194 // a POST is as safe to send again as a GET.
@@ -375,7 +392,13 @@
375392 }
376393
377394 publish(message: string, asIs = false): Promise<PublishAnswer> {
378− return this.json("POST", this.agentPath("publish"), { message, ...(asIs ? { asIs: true } : {}) });
395+ return this.json(
396+ "POST",
397+ this.agentPath("publish"),
398+ { message, ...(asIs ? { asIs: true } : {}) },
399+ undefined,
400+ PUBLISH_TIMEOUT_MS,
401+ );
379402 }
380403
381404 /** One change (#44). */
@@ -709,7 +732,7 @@
709732
710733 /** Land never queues: with the merge queue on, the server refuses it (#39). */
711734 land(message: string): Promise<Exclude<PublishAnswer, { queued: number }>> {
712− return this.json("POST", this.agentPath("land"), { message });
735+ return this.json("POST", this.agentPath("land"), { message }, undefined, PUBLISH_TIMEOUT_MS);
713736 }
714737
715738 draftSync(): Promise<DraftSyncAnswer> {
@@ -731,10 +754,31 @@
731754 }
732755
733756 /** The versions of a space, newest first; with `path`, only those that changed it. */
734− log(where: Where, limit?: number, path?: string): Promise<LogAnswer> {
735− return this.json("GET", `/log?${query({ ...where, limit, path })}`);
757+ /**
758+ * The versions newest first, below `before` when it's given. The server
759+ * sends at most LOG_PAGE at a time, so a longer log is read page by page,
760+ * following each page's next. `next` on the answer says older ones are left.
761+ */
762+ async log(where: Where, limit?: number, path?: string, before?: number): Promise<LogAnswer> {
763+ let page = await this.#logPage(where, limit === undefined ? undefined : Math.min(limit, LOG_PAGE), path, before);
764+ const versions = [...page.versions];
765+ while (limit !== undefined && versions.length < limit && page.next !== undefined) {
766+ page = await this.#logPage(where, Math.min(limit - versions.length, LOG_PAGE), path, page.next);
767+ versions.push(...page.versions);
768+ }
769+ const { next, ...rest } = page;
770+ return { ...rest, versions, ...(next !== undefined ? { next } : {}) };
736771 }
737772
773+ #logPage(
774+ where: Where,
775+ limit: number | undefined,
776+ path: string | undefined,
777+ before: number | undefined,
778+ ): Promise<LogAnswer> {
779+ return this.json("GET", `/log?${query({ ...where, limit, path, before })}`);
780+ }
738782 show(version: number, where: Where): Promise<ShowAnswer> {
739783 return this.json("GET", `/show?${query({ version, ...where })}`);
740784 }
--- a/client/src/changes.ts
+++ b/client/src/changes.ts
@@ -311,6 +311,8 @@
311311 const rawLimit = str(args, "limit");
312312 const limit = rawLimit === undefined ? undefined : version(rawLimit, "-n");
313313 if (limit === 0) throw new UsageError("-n is how many versions to show; give 1 or more");
314+ const rawBefore = str(args, "before");
315+ const before = rawBefore === undefined ? undefined : version(rawBefore, "--before");
314316 // The server filters by one file; a folder (or the whole folder) is filtered here, from a longer log.
315317 const folder = path !== undefined && (path === "" || /[/]$/.test(typed!) || isFolder(root, path));
316318 // --since, --by and --count (#37, Reporter's progress reports) filter here, from a longer log.
@@ -332,6 +334,7 @@
332334 space(args, config.agent),
333335 folder || filtering ? FOLDER_LOG : limit,
334336 folder ? undefined : path,
337+ before,
335338 );
336339 const found = folder
337340 ? {
@@ -392,9 +395,14 @@
392395 ]),
393396 ];
394397 const oldest = answer.versions[answer.versions.length - 1];
395− if (path === undefined && !filtering && oldest !== undefined && oldest.version > 0)
396− lines.push(`Older versions: abso log -n ${answer.versions.length + 50}`);
398+ if (!filtering && !folder && raw.next !== undefined && oldest !== undefined)
399+ lines.push(`Older versions: abso log${typed === undefined ? "" : ` ${typed}`} --before ${oldest.version}`);
397400 if (filtering && answer.versions.length === 0) lines.push("No version matches.");
401+ // A filter or a folder reads the newest FOLDER_LOG versions; say so when older ones were left unread.
402+ if ((filtering || folder) && raw.next !== undefined)
403+ lines.push(
404+ `Only the newest ${FOLDER_LOG} versions${before === undefined ? "" : ` below ${before}`} were read; --before ${raw.next} reads older ones.`,
405+ );
398406 return { text: lines.join("\n"), json: { ...answer } };
399407}
400408
--- a/client/src/history-answers.ts
+++ b/client/src/history-answers.ts
@@ -82,6 +82,8 @@
8282 readonly draft: string | null;
8383 readonly version: number;
8484 readonly versions: readonly LogEntry[];
85+ /** When older versions are left: the version to read below (log --before) for the next ones. */
86+ readonly next?: number;
8587}
8688export interface ShowAnswer extends LogEntry {
8789 readonly draft: string | null;
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -573,11 +573,11 @@
573573 run: runFiles,
574574 },
575575 log: {
576− flags: { limit: "string", draft: "string", since: "string", by: "string", count: "boolean" },
576+ flags: { limit: "string", before: "string", draft: "string", since: "string", by: "string", count: "boolean" },
577577 usage:
578− "abso log [file] [-n <count>] [--draft <name>] [--since <version|30m|2h|1d|date>] [--by <agent,...>] [--count]",
578+ "abso log [file] [-n <count>] [--before <version>] [--draft <name>] [--since <version|30m|2h|1d|date>] [--by <agent,...>] [--count]",
579579 about:
580− "The published versions of this folder's space (shared or a named draft), newest first: who, when, why and which files, and for shared, whether the version passed CI's check (abso ci). With a file: only the versions that changed it. --since takes a version (the versions after it), a span back from now (30m, 2h, 1d), a clock time today (20:00) or a date and time; --by keeps one agent's versions (or several, comma-separated); --count prints versions and files per agent instead of the list.",
580+ "The published versions of this folder's space (shared or a named draft), newest first: who, when, why and which files, and for shared, whether the version passed CI's check (abso ci). With a file: only the versions that changed it. --before <version> starts below that version, so any stretch of history can be listed; the end of the list names the --before for the next older ones. --since takes a version (the versions after it), a span back from now (30m, 2h, 1d), a clock time today (20:00) or a date and time; --by keeps one agent's versions (or several, comma-separated); --count prints versions and files per agent instead of the list.",
581581 run: runLog,
582582 },
583583 show: {
--- a/client/test/client.test.ts
+++ b/client/test/client.test.ts
@@ -20,12 +20,13 @@
2020 utimesSync,
2121 writeFileSync,
2222} from "node:fs";
23+import { createServer as createHttpServer } from "node:http";
2324import { type AddressInfo, createServer as createTcpServer } from "node:net";
2425import { tmpdir } from "node:os";
2526import { dirname, join, relative, sep } from "node:path";
2627import { after, before, describe, it } from "node:test";
2728import { fileURLToPath } from "node:url";
28−import { timeoutFor } from "../src/api.ts";
29+import { Api, LOG_PAGE, PUBLISH_TIMEOUT_MS, timeoutFor } from "../src/api.ts";
2930import { parseArgs } from "../src/args.ts";
3031import { globTest } from "../src/at.ts";
3132import { forgetBox, readBox, writeBox } from "../src/box.ts";
@@ -1299,27 +1300,6 @@
12991300 );
13001301 assert.equal(sh.status, 137);
13011302 });
1302−
1303− it("sends one run, and takes each command as one quoted word", async () => {
1304− const { folders } = await project({ "a.txt": "a\n" }, "alice");
1305− const before = fake.runStarts.length;
1306− await main(["run", "--parallel", "npm test", "node bench.js"], {
1307− cwd: folders.alice!,
1308− env: ENV,
1309− write: () => {},
1310− writeErr: () => {},
1311− });
1312− const sent = fake.runStarts.slice(before);
1313− assert.equal(sent.length, 1);
1314− assert.ok(sent[0]!.cmd.endsWith(parallelScript(["npm test", "node bench.js"])), sent[0]!.cmd);
1315− const bad = await main(["run", "--parallel", "--", "npm", "test"], {
1316− cwd: folders.alice!,
1317− env: ENV,
1318− write: () => {},
1319− });
1320− assert.equal(bad.exit, 1);
1321− assert.match(bad.stderr, /--parallel takes each command as one quoted word/);
1322− });
13231303});
13241304
13251305describe("paths from the server never leave the folder (Security)", () => {
@@ -2490,6 +2470,61 @@
24902470 assert.equal(timeoutFor(30_000, "x".repeat(3_000_000)), 60_000);
24912471 });
24922472
2473+ it("reads a log longer than the server's page by following next, and starts below --before", async () => {
2474+ // A stand-in for the server's log: versions 0-449, newest first, at most LOG_PAGE a page, as version-log.ts pages.
2475+ const asked: string[] = [];
2476+ const paged = createHttpServer((req, res) => {
2477+ const q = new URL(req.url ?? "", "http://x").searchParams;
2478+ asked.push(`${q.get("limit")} ${q.get("before") ?? "-"}`);
2479+ const limit = Math.min(Number(q.get("limit") ?? 50), LOG_PAGE);
2480+ let v = Math.min(449, Number(q.get("before") ?? 450) - 1);
2481+ const versions = [];
2482+ for (; v >= 0 && versions.length < limit; v--)
2483+ versions.push({ version: v, agent: "a", message: `v${v}`, time: 0, files: [] });
2484+ const next = v >= 0 && versions.length > 0 ? versions[versions.length - 1]!.version : undefined;
2485+ res.writeHead(200, { "content-type": "application/json" });
2486+ res.end(JSON.stringify({ draft: null, version: 449, versions, ...(next !== undefined ? { next } : {}) }));
2487+ });
2488+ await new Promise<void>((ok) => paged.listen(0, "127.0.0.1", ok));
2489+ try {
2490+ const server = `http://127.0.0.1:${(paged.address() as AddressInfo).port}`;
2491+ const api = new Api({ server, project: "p", agent: "a", token: "t" } as ConstructorParameters<typeof Api>[0]);
2492+ const all = await api.log({ draft: null }, 2000);
2493+ assert.equal(all.versions.length, 450);
2494+ assert.deepEqual([all.versions[0]!.version, all.versions[449]!.version], [449, 0]);
2495+ assert.equal(all.next, undefined, "nothing older is left");
2496+ assert.deepEqual(asked, ["200 -", "200 250", "200 50"]);
2497+ const some = await api.log({ draft: null }, 250, undefined, 300);
2498+ assert.deepEqual([some.versions[0]!.version, some.versions.at(-1)!.version, some.next], [299, 50, 50]);
2499+ assert.equal((await api.log({ draft: null })).versions.length, 50, "no -n: the server's own default, one page");
2500+ } finally {
2501+ paged.closeAllConnections();
2502+ await new Promise((ok) => paged.close(ok));
2503+ }
2504+ });
2506+ it("waits for a publish and a land as long as the server may work on them, past the base timeout", async () => {
2507+ assert.ok(PUBLISH_TIMEOUT_MS > 120_000, "longer than the server's 2 minutes for one request");
2508+ // Every answer comes after 300 ms; the client's base timeout here is 100 ms.
2509+ const slow = createHttpServer((_req, res) => {
2510+ setTimeout(() => res.writeHead(200, { "content-type": "application/json" }).end('{"version": 7}'), 300);
2511+ });
2512+ await new Promise<void>((ok) => slow.listen(0, "127.0.0.1", ok));
2513+ try {
2514+ const server = `http://127.0.0.1:${(slow.address() as AddressInfo).port}`;
2515+ const api = new Api(
2516+ { server, project: "p", agent: "a", token: "t" } as ConstructorParameters<typeof Api>[0],
2517+ 100,
2518+ );
2519+ assert.deepEqual(await api.publish("slow"), { version: 7 });
2520+ assert.deepEqual(await api.land("slow"), { version: 7 });
2521+ await assert.rejects(api.json("GET", "/status"), /no answer within 100 ms/);
2522+ } finally {
2523+ slow.closeAllConnections();
2524+ await new Promise((ok) => slow.close(ok));
2525+ }
2526+ });
24932528 it("lists a change by its message's first line, and an import's commit as a short hash (#43, Git Lessons)", () => {
24942529 const imported =
24952530 "Issues' own Worker: the skeleton\n\nA long body\nover lines.\n\ngit ad107af03b56, Alex Rivera, 2026-10-07T14:00:00-05:00";
@@ -4086,7 +4121,7 @@
40864121 const logText = await main(["log", "-n", "1"], { cwd: alice, env: ENV, write: () => {} });
40874122 assert.match(
40884123 logText.stdout,
4089− /^shared is at version 2\.\nversion 2 by bob, .* UTC: bob: change b\n {2}1 file: b\.txt\nOlder versions: abso log -n 51\n$/,
4124+ /^shared is at version 2\.\nversion 2 by bob, .* UTC: bob: change b\n {2}1 file: b\.txt\nOlder versions: abso log --before 2\n$/,
40904125 );
40914126
40924127 const show = await avcs(alice, "show", "1");
--- a/client/test/fake-server.ts
+++ b/client/test/fake-server.ts
@@ -726,6 +726,9 @@
726726 else res.end();
727727 });
728728 });
729+ // Never close an idle kept-alive connection: on Windows, under load, the client could reuse one in the moment
730+ // the server closed it, and the next call failed with ECONNRESET. close() below drops every connection.
731+ server.keepAliveTimeout = 0;
729732 await new Promise<void>((ok) => server.listen(port, "127.0.0.1", ok));
730733 const address = server.address() as AddressInfo;
731734 return Object.assign(fake, {