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 25 to 26

Compare

+58 −23 in 4 places
Lines 20–32 at 26 (were 20–31 at 25)
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";
Lines 1300–1305 at 26 (were 1299–1325 at 25)
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)", () => {
Lines 2470–2530 at 26 (were 2490–2495 at 25)
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";
Lines 4121–4127 at 26 (were 4086–4092 at 25)
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");
MCP
compare on this site's /mcp
CLI
abso diff 25 26 client/test/client.test.ts --json
JSON
/christopher/abso-core/compare/25..26?file=client%2Ftest%2Fclient.test.ts&format=json