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 295 to 318

Compare

+209 −4 in 7 places
new file, 60 lines
1+// abso ci for a project whose CI is its pipeline file (abso 719): test-byoc on 2026-10-16 had no abso.json, and abso ci
2+// said "nothing to run" while its abso.yml's run 8 was going. The stored run is the project's CI there.
3+
4+import assert from "node:assert/strict";
5+import { test } from "node:test";
6+import { builtInHasNothing, runLine, storedRuns } from "../src/ci.ts";
7+
8+const base = { latest: null, checked: null, running: null, red: null, behind: null } as const;
9+const nothing = {
10+ version: 6,
11+ from: 6,
12+ reason: "nothing to run: no abso.json, and package.json has no test, typecheck or vite",
13+ at: "2026-10-16T16:47:00.000Z",
14+};
16+test("the stored runs are read strictly, newest first as the server lists them", () => {
17+ const runs = storedRuns({
18+ blocked: null,
19+ runs: [
20+ { id: 8, version: 6, state: "running", file: "abso.yml", started: 1 },
21+ { id: "7", version: 6, state: "failed", file: "abso.yml" },
22+ { id: 6, version: 5, state: "failed", file: "abso.yml" },
23+ ],
24+ });
25+ assert.deepEqual(
26+ runs.map((r) => r.id),
27+ [8, 6],
28+ );
29+ assert.deepEqual(storedRuns(null), []);
30+ assert.deepEqual(storedRuns({ runs: "no" }), []);
31+});
33+test("a run in a line names its file, its state and where its jobs are", () => {
34+ assert.equal(
35+ runLine({ id: 8, version: 6, state: "running", file: "abso.yml" }),
36+ "Pipeline run 8 (abso.yml) is running on version 6. abso pipeline runs 8 shows its jobs.",
37+ );
38+ assert.equal(
39+ runLine({ id: 7, version: 6, state: "failed", file: "abso.yml" }),
40+ "Pipeline run 7 (abso.yml) failed on version 6. abso pipeline runs 7 shows its jobs.",
41+ );
42+ assert.equal(
43+ runLine({ id: 2, version: 1, state: "planned", file: "abso.yml" }),
44+ "Pipeline run 2 (abso.yml) was planned, not run, on version 1. abso pipeline runs 2 shows its jobs.",
45+ );
46+});
48+test("only the built-in check's own nothing to run is set aside, never a red or another skip", () => {
49+ assert.equal(builtInHasNothing({ ...base, skipped: nothing }), true);
50+ assert.equal(builtInHasNothing({ ...base, skipped: { ...nothing, reason: "CI is off" } }), false);
51+ assert.equal(builtInHasNothing({ ...base }), false);
52+ assert.equal(
53+ builtInHasNothing({
54+ ...base,
55+ red: { version: 6, agent: null, message: null, lastGood: null },
56+ skipped: nothing,
57+ }),
58+ false,
59+ );
60+});
Lines 4–15 at 318 (were 4–14 at 295)
44
55import assert from "node:assert/strict";
66import { spawnSync } from "node:child_process";
7−import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
88import { tmpdir } from "node:os";
99import { join } from "node:path";
1010import { after, before, describe, it } from "node:test";
1111import { fileURLToPath } from "node:url";
12+import { closeLocalStores, LOCAL_BASE, localFetch } from "../src/local-store.ts";
1213import { main } from "../src/main.ts";
1314import { stateDir } from "../src/state-dir.ts";
1415
Lines 42–53 at 318 (were 41–47 at 295)
4142}
4243const text = (dir: string, rel: string) => readFileSync(join(dir, rel), "utf8");
4344
44−describe("a local project, with the network off", () => {
45+/** A copy of the client without the open server beside it (a platform that pins only client/) has no local projects to test. */
46+const noServer = existsSync(fileURLToPath(new URL("../../server/src/router.ts", import.meta.url)))
47+ ? false
48+ : "no server/src beside this client, so no local projects";
50+describe("a local project, with the network off", { skip: noServer }, () => {
4551 let alice: string;
4652 let bob: string;
4753 before(() => {
Lines 133–162 at 318 (were 127–135 at 295)
127133 const issue = await run(alice, "issue", "1");
128134 assert.match(issue.out, /In progress|bob/);
129135 });
137+ it("two calls at once on one project are both answered, one after the other", async () => {
138+ // As abso ci and waiting --mine make them, with Promise.all.
139+ const local = localFetch(store);
140+ const answers = await Promise.all([local(`${LOCAL_BASE}/p/demo/queue`), local(`${LOCAL_BASE}/p/demo/queue`)]);
141+ closeLocalStores();
142+ for (const a of answers) assert.equal(a.status, 200, await a.text());
143+ });
145+ it("a project's name can't start with a dot, so its folder stays inside the store", async () => {
146+ const dir = temp("dots");
147+ writeFileSync(join(dir, "a.txt"), "x\n");
148+ for (const name of ["..", ".hidden"]) {
149+ const r = await run(dir, "init", "--local", "--project", name, "--agent", "a");
150+ assert.equal(r.exit, 1, r.out + r.err);
151+ // The name rule says why, before any call is made (a ".." would collapse the call's path).
152+ assert.match(r.err, /project names are letters, digits, dot, dash and underscore/);
153+ }
154+ assert.ok(!existsSync(join(store, "..", "project.sqlite")));
155+ assert.deepEqual(readdirSync(dir), ["a.txt"], "init left nothing behind");
156+ });
130157});
131158
132−describe("where a local project's store is", () => {
159+describe("where a local project's store is", { skip: noServer }, () => {
133160 it("--store inside the folder is kept in its settings and left out of its files", async () => {
134161 store = temp("unused");
135162 const dir = temp("venv");
Lines 191–197 at 318 (were 164–170 at 295)
164191 });
165192});
166193
167−describe("local commands as their own processes", () => {
194+describe("local commands as their own processes", { skip: noServer }, () => {
168195 // The way people and agents run them: client/abso.ts, a process per command, Node's compile cache as it is.
169196 const entry = fileURLToPath(new URL("../abso.ts", import.meta.url));
170197 const cli = (cwd: string, processStore: string, ...argv: string[]) =>
Lines 155–172 at 318 (were 155–160 at 295)
155155 await follow(old.deps);
156156 assert.deepEqual(old.lines, ["fe told you: hello"]);
157157
158+ // On that server a read can find other news waiting: the frame's own item still shows (Code Review, 291).
159+ const mixed = world([{ frames: ["fe told you: hello"], close: { code: 1006 } }]);
160+ mixed.deps.take = async () => ["cloud: an older item"];
161+ await follow(mixed.deps);
162+ assert.deepEqual(mixed.lines, ["cloud: an older item", "fe told you: hello"]);
164+ // A catch-up frame names the first few waiting items and how many more: the read shows them all, the frame adds nothing.
165+ const catchUp = world([{ frames: ["fe told you: hello\ncloud: ship it?\nand 1 more"], close: { code: 1006 } }]);
166+ catchUp.deps.take = async () => ["fe told you: hello", "cloud: ship it?", "desk: a third"];
167+ await follow(catchUp.deps);
168+ assert.deepEqual(catchUp.lines, ["fe told you: hello", "cloud: ship it?", "desk: a third"]);
158170 // A read that fails shows the frames and says why.
159171 const down = world([{ frames: ["fe told you: hello"], close: { code: 1006 } }]);
160172 down.deps.take = async () => {
new file, 106 lines
1+// abso login --web: a staging website session handed to a browser as a one-use link, with no secret printed.
2+
3+import assert from "node:assert/strict";
4+import { mkdtempSync, writeFileSync } from "node:fs";
5+import { tmpdir } from "node:os";
6+import { join } from "node:path";
7+import { test } from "node:test";
8+import { handoffText, patFromFile, siteFor, webHandoff, webLogin } from "../src/web-session.ts";
9+
10+const SITE = "https://abso-website-staging.chrisazy.workers.dev";
11+const STAGING = "https://abso-staging.chrisazy.workers.dev";
12+const BOX = `abso_bx_${"C".repeat(43)}`;
13+const PAT = `abso_pat_${"A".repeat(40)}`;
14+const NOW = Date.UTC(2026, 9, 16, 9, 0, 0);
16+test("the credential goes only to the staging website beside the folder's staging server (Security condition 6)", () => {
17+ assert.equal(siteFor(STAGING, undefined, "box"), SITE);
18+ assert.equal(siteFor("https://avcs-staging.chrisazy.workers.dev/", undefined, "pat"), SITE);
19+ // A server that isn't staging is refused, prod included, whatever is asked.
20+ assert.throws(
21+ () => siteFor("https://api.abso.dev", undefined, "box"),
22+ /for staging.*never sign in to the website on prod/,
23+ );
24+ assert.throws(() => siteFor("https://api.abso.dev", "http://localhost:8871", "pat"), /for staging/);
25+ // A box's sign-in takes no --site, not even the staging website's own address.
26+ assert.throws(() => siteFor(STAGING, SITE, "box"), /isn't taken with a box's sign-in/);
27+ assert.throws(() => siteFor(STAGING, "http://localhost:8871", "box"), /isn't taken with a box's sign-in/);
28+ // A PAT may name this machine over http, and nothing else.
29+ assert.equal(siteFor(STAGING, "http://localhost:8871/x", "pat"), "http://localhost:8871");
30+ assert.equal(siteFor(STAGING, "http://127.0.0.1:8871", "pat"), "http://127.0.0.1:8871");
31+ for (const elsewhere of ["https://anywhere.example", SITE, "https://localhost:8871", "not a url"])
32+ assert.throws(() => siteFor(STAGING, elsewhere, "pat"), /names this machine only/, elsewhere);
33+});
35+test("a refused handoff reads no credential and sends no request", async () => {
36+ const sent: string[] = [];
37+ const fetcher = (async (url: string) => (sent.push(url), Response.json({}))) as unknown as typeof fetch;
38+ let read = 0;
39+ const credential = () => (read++, BOX);
40+ for (const asked of [
41+ { server: "https://api.abso.dev", site: undefined, kind: "box" as const },
42+ { server: STAGING, site: "https://anywhere.example", kind: "box" as const },
43+ { server: STAGING, site: SITE, kind: "box" as const },
44+ { server: "https://api.abso.dev", site: "http://localhost:8871", kind: "pat" as const },
45+ { server: STAGING, site: "https://anywhere.example", kind: "pat" as const },
46+ ])
47+ await assert.rejects(webLogin({ ...asked, credential, fetcher }), /Nothing was sent/, JSON.stringify(asked));
48+ assert.deepEqual(sent, []);
49+ assert.equal(read, 0);
50+ // Allowed, it goes to the staging website only.
51+ await webLogin({ server: STAGING, site: undefined, kind: "pat", credential: () => PAT, fetcher }).catch(() => {});
52+ assert.deepEqual(sent, [`${SITE}/login/handoff`]);
53+});
55+test("the credential goes in Authorization only, and the answer is the one link and who it signs in as", async () => {
56+ const seen: { url: string; authorization: string | null; body: unknown }[] = [];
57+ const fetcher = (async (url: string, init: RequestInit) => {
58+ seen.push({ url, authorization: new Headers(init.headers).get("authorization"), body: init.body ?? null });
59+ return Response.json({
60+ url: `${SITE}/login/handoff#${"t".repeat(50)}`,
61+ expiresAt: new Date(NOW + 60_000).toISOString(),
62+ account: "acct_person1",
63+ name: "christopher",
64+ sessionEnds: "2026-10-16T21:00:00.000Z",
65+ });
66+ }) as typeof fetch;
67+ const h = await webHandoff(SITE, BOX, fetcher);
68+ assert.deepEqual(seen, [{ url: `${SITE}/login/handoff`, authorization: `Bearer ${BOX}`, body: null }]);
69+ const text = handoffText(h, SITE, true, NOW);
70+ assert.match(text, /within 60 seconds/);
71+ assert.match(text, /as christopher, until 2026-10-16T21:00:00.000Z, and works once/);
72+ assert.match(text, /only to the projects this box was granted, at most as a writer/);
73+ assert.match(handoffText(h, SITE, false, NOW), /It reaches at most as a writer:/);
74+ assert.match(text, /\/login\/handoff#t{50}$/);
75+ assert.doesNotMatch(text + JSON.stringify(h), /abso_bx_/);
76+});
78+test("a refusal says why without the credential; an answer that isn't the site's own link is refused", async () => {
79+ const echo = (async () =>
80+ Response.json({ error: `that key was refused: ${BOX}` }, { status: 401 })) as unknown as typeof fetch;
81+ await assert.rejects(webHandoff(SITE, BOX, echo), (err: Error) => {
82+ assert.match(err.message, /refused: that key was refused: \[the credential\]/);
83+ assert.doesNotMatch(err.message, /abso_bx_/);
84+ return true;
85+ });
86+ const off = (async () => Response.json({ error: "not found" }, { status: 404 })) as unknown as typeof fetch;
87+ await assert.rejects(webHandoff(SITE, BOX, off), /doesn't hand out sign-in links/);
88+ const elsewhere = (async () =>
89+ Response.json({
90+ url: "https://elsewhere.example/login/handoff#x",
91+ expiresAt: new Date(NOW).toISOString(),
92+ account: "acct_x",
93+ })) as unknown as typeof fetch;
94+ await assert.rejects(webHandoff(SITE, BOX, elsewhere), /isn't a sign-in link/);
95+});
97+test("--pat-file reads a PAT from its file, and refuses a file that doesn't hold one", () => {
98+ const dir = mkdtempSync(join(tmpdir(), "abso-web-"));
99+ const good = join(dir, "pat");
100+ writeFileSync(good, `abso_pat_${"A".repeat(40)}\n`);
101+ assert.equal(patFromFile(good), `abso_pat_${"A".repeat(40)}`);
102+ const bad = join(dir, "not");
103+ writeFileSync(bad, "hello");
104+ assert.throws(() => patFromFile(bad), /doesn't hold a PAT/);
105+ assert.throws(() => patFromFile(join(dir, "missing")), /can't read/);
106+});
MCP
compare on this site's /mcp
CLI
abso diff 295 318 client/test --json
JSON
/christopher/abso-core/compare/295..318?file=client%2Ftest&format=json