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 73 --json
JSON
/christopher/abso-core/versions/73?format=json

Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.

of shared·engine··Not checked

  • amended; first pushed as: Messages and notes can't hold characters a reader can't see (abso issue 276): publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.

Version 72 · Files at version 73

3 files, 111 lines added, 0 removed.

--- a/worker/project/http.ts
+++ b/worker/project/http.ts
@@ -1,6 +1,8 @@
11// The JSON routes of the contract (docs/v2-slice1.md), as a pure function of
22// the project calls, so they can be tested in Node without a Worker.
3+
34import type { EditBody, ProjectCalls, ProjectHistory } from "./project-api.ts";
5+import { unseenError } from "./unseen.ts";
46
57export interface Answer {
68 status: number;
@@ -429,6 +431,8 @@
429431 case "publish": {
430432 const message = (body as { message?: string })?.message;
431433 if (typeof message !== "string" || !message.trim()) return fail(400, "publish needs {message} saying why");
434+ const unseen = unseenError("the message", message);
435+ if (unseen) return fail(400, unseen);
432436 // asIs (#37): publish even with collided lines untouched since the sync, both sides kept.
433437 return { status: 200, body: project.publish(agent, message, (body as { asIs?: unknown }).asIs === true) };
434438 }
@@ -466,6 +470,8 @@
466470 case "land": {
467471 const message = (body as { message?: string })?.message;
468472 if (typeof message !== "string" || !message.trim()) return fail(400, "land needs {message} saying why");
473+ const unseen = unseenError("the message", message);
474+ if (unseen) return fail(400, unseen);
469475 return { status: 200, body: project.land(agent, message) };
470476 }
471477 case "draft-sync":
@@ -491,6 +497,8 @@
491497 if (!history.amend) return fail(501, "amend needs the engine");
492498 const message = (body as { message?: unknown } | undefined)?.message;
493499 if (typeof message !== "string" || !message.trim()) return fail(400, "amend needs {message}");
500+ const unseen = unseenError("the message", message);
501+ if (unseen) return fail(400, unseen);
494502 return { status: 200, body: history.amend(agent, message) };
495503 }
496504 // Pluck (#27): take some versions of a named draft into shared.
@@ -507,6 +515,8 @@
507515 if (!Array.isArray(b.versions) || b.versions.length === 0 || !b.versions.every((v) => Number.isInteger(v)))
508516 return fail(400, "pluck needs {versions: [number]}");
509517 if (typeof b.message !== "string" || !b.message.trim()) return fail(400, "pluck needs {message} saying why");
518+ const unseen = unseenError("the message", b.message);
519+ if (unseen) return fail(400, unseen);
510520 return {
511521 status: 200,
512522 body: history.pluck(agent, b.draft, b.versions as number[], b.message, b.withDependencies === true),
@@ -520,6 +530,8 @@
520530 if (!Array.isArray(b.versions) || b.versions.length === 0 || !b.versions.every((v) => Number.isInteger(v)))
521531 return fail(400, "drop needs {versions: [number], message}");
522532 if (typeof b.message !== "string" || !b.message.trim()) return fail(400, "drop needs {message} saying why");
533+ const unseen = unseenError("the message", b.message);
534+ if (unseen) return fail(400, unseen);
523535 return { status: 200, body: history.drop(agent, b.versions as number[], b.message, b.withDependents === true) };
524536 }
525537 // Announcements, and news without an edit.
@@ -537,6 +549,8 @@
537549 if (!history.note || !history.closeNote) return fail(501, `${op} needs the engine`);
538550 const b = (body ?? {}) as Record<string, unknown>;
539551 if (op === "note-close") return { status: 200, body: history.closeNote(agent, b.id as number, b.how) };
552+ const unseen = unseenError("the note", b.text);
553+ if (unseen) return fail(400, unseen);
540554 return { status: 200, body: history.note(agent, b) };
541555 }
542556 case "announce":
@@ -546,6 +560,8 @@
546560 if (op === "news") return { status: 200, body: history.news(agent) };
547561 const b = (body ?? {}) as { text?: unknown; to?: unknown };
548562 if (typeof b.text !== "string" || !b.text.trim()) return fail(400, "announce needs {text}");
563+ const unseen = unseenError("the text", b.text);
564+ if (unseen) return fail(400, unseen);
549565 if (b.to !== undefined && (!Array.isArray(b.to) || !b.to.every((a) => typeof a === "string")))
550566 return fail(400, "to must be a list of agent names");
551567 return { status: 200, body: history.announce(agent, b.text, b.to as string[] | undefined, how) };
@@ -557,6 +573,8 @@
557573 const b = (body ?? {}) as { text?: unknown; files?: unknown; issue?: unknown; done?: unknown };
558574 if (b.text !== null && (typeof b.text !== "string" || !b.text.trim()))
559575 return fail(400, "starting needs {text}, or {text: null} to take it back");
576+ const unseen = unseenError("the note", b.text);
577+ if (unseen) return fail(400, unseen);
560578 if (b.files !== undefined && (!Array.isArray(b.files) || !b.files.every((f) => typeof f === "string")))
561579 return fail(400, "files must be a list of paths");
562580 // issue (#54): the issue the note works on; done: a take-back because the work is finished, closing it.
--- /dev/null
+++ b/worker/project/test/unseen.test.ts
@@ -0,0 +1,52 @@
1+// Text the engine keeps and prints can't hold characters a reader can't see
2+// (abso issue 276): a version message with an escape sequence would run in
3+// every terminal that shows `abso log` or news.
4+
5+import assert from "node:assert/strict";
6+import { test } from "node:test";
7+import { answer } from "../http.ts";
8+import type { ProjectCalls } from "../project-api.ts";
9+import { unseenIn } from "../unseen.ts";
11+const ESC = String.fromCharCode(0x1b);
12+const BEL = String.fromCharCode(0x07);
13+const CSI = String.fromCharCode(0x9b);
14+const RLO = String.fromCharCode(0x202e);
15+const CR = String.fromCharCode(0x0d);
17+test("unseenIn: ESC, C1, BEL and bidi overrides are found; newline, tab and CRLF pass", () => {
18+ assert.equal(unseenIn(`Fix the parser\n\nDetails\twith a tab${CR}\nand CRLF.`), null);
19+ assert.equal(unseenIn(`ok ${ESC}]52;c;aGk=${BEL}`), "a control character at character 4");
20+ assert.equal(unseenIn(`${CSI}31m`), "a control character at character 1");
21+ assert.equal(unseenIn(`a${CR}b`), "a control character at character 2");
22+ assert.match(unseenIn(`abc${RLO}def`)!, /bidirectional embedding or override/);
23+ assert.equal(unseenIn(`emoji 🎉 counts as one character ${ESC}`), "a control character at character 33");
24+});
26+test("publish, amend, land, starting notes and announcements refuse unseen characters before the engine sees them", () => {
27+ // A stand-in for the engine: it records each call that gets through.
28+ const calls: string[] = [];
29+ const project = new Proxy({} as ProjectCalls, {
30+ get:
31+ (_, name) =>
32+ (...args: unknown[]) => {
33+ if (name === "exists") return true;
34+ calls.push(`${String(name)} ${JSON.stringify(args[1])}`);
35+ return { ok: true };
36+ },
37+ });
38+ const osc8 = `Fix ${ESC}]8;;https://example.invalid${BEL}here${ESC}]8;;${BEL}`;
39+ const refused = answer(project, "publish", "ann", { message: osc8 });
40+ assert.equal(refused.status, 400);
41+ assert.match(JSON.stringify(refused.body), /the message holds a control character at character 5/);
42+ assert.equal(answer(project, "amend", "ann", { message: `Two ${ESC}[2J` }).status, 400);
43+ assert.equal(answer(project, "land", "ann", { message: `Land ${CSI}1m` }).status, 400);
44+ assert.equal(answer(project, "starting", "ann", { text: `on ${RLO}this` }).status, 400);
45+ assert.equal(answer(project, "announce", "ann", { text: `hi ${BEL}` }).status, 400);
46+ assert.deepEqual(calls, [], "none reached the engine");
48+ const windows = `Two${CR}\n${CR}\nWritten on Windows.`;
49+ assert.equal(answer(project, "publish", "ann", { message: windows }).status, 200);
50+ assert.equal(answer(project, "starting", "ann", { text: "on the parser" }).status, 200);
51+ assert.deepEqual(calls, [`publish ${JSON.stringify(windows)}`, 'starting "on the parser"']);
52+});
--- /dev/null
+++ b/worker/project/unseen.ts
@@ -0,0 +1,41 @@
1+// Characters a reader can't see, refused in text the engine keeps and prints
2+// (abso issue 276): version messages, starting notes, line notes and
3+// announcements. In a terminal, ESC and C1 start escape sequences that can
4+// set the clipboard or draw a fake link, so `abso log` and news must never
5+// carry them. The same list as the website's announcements and Issues.
6+
7+const UNSEEN: [number, number, string][] = [
8+ [0x00, 0x08, "a control character"],
9+ [0x0b, 0x1f, "a control character"],
10+ [0x7f, 0x9f, "a control character"],
11+ [0x180e, 0x180e, "the Mongolian vowel separator (U+180E)"],
12+ [0x200b, 0x200f, "a zero-width or direction mark (U+200B-200F)"],
13+ [0x2028, 0x2029, "a line or paragraph separator (U+2028-2029)"],
14+ [0x202a, 0x202e, "a bidirectional embedding or override (U+202A-202E)"],
15+ [0x2060, 0x2064, "an invisible joiner or operator (U+2060-2064)"],
16+ [0x2066, 0x2069, "a bidirectional isolate (U+2066-2069)"],
17+ [0xfe00, 0xfe0f, "a variation selector (U+FE00-FE0F)"],
18+ [0xfeff, 0xfeff, "a byte order mark (U+FEFF)"],
19+ [0xe0000, 0xe007f, "a tag character (U+E0000-E007F)"],
20+ [0xe0100, 0xe01ef, "a variation selector (U+E0100-E01EF)"],
21+];
23+/**
24+ * The first character in `text` a reader can't see, as "<what> at character N", or null.
25+ * \n and \t pass, and so does \r before \n, since a message file written on Windows ends its lines that way.
26+ */
27+export function unseenIn(text: string): string | null {
28+ for (const [i, ch] of [...text].entries()) {
29+ const c = ch.codePointAt(0)!;
30+ if (c === 0x0d && text[i + 1] === "\n") continue;
31+ const hit = UNSEEN.find(([lo, hi]) => c >= lo && c <= hi);
32+ if (hit) return `${hit[2]} at character ${i + 1}`;
33+ }
34+ return null;
35+}
37+/** Why `text`, named `what` ("the message"), can't be kept, or null. */
38+export function unseenError(what: string, text: unknown): string | null {
39+ const hit = typeof text === "string" ? unseenIn(text) : null;
40+ return hit === null ? null : `${what} holds ${hit}, which a reader can't see; take it out`;
41+}