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 156 to 157

Compare

+38 −3 in 2 places
Lines 17–30 at 157 (were 17–30 at 156)
1717
1818// Characters per row. SQLite's 2 MB cap is in bytes, and a character is at
1919// most 3 bytes of UTF-8 (an emoji is 2 characters and 4 bytes), so 600,000 stays under it.
20−const PART = 600_000;
20+export const LOG_PART_CHARACTERS = 600_000;
2121
22−/** An entry's JSON in rows of at most PART characters, never cutting an emoji's two halves apart. */
22+/** An entry's JSON in rows of at most LOG_PART_CHARACTERS characters, never cutting an emoji's two halves apart. */
2323export function logParts(text: string): string[] {
2424 const parts: string[] = [];
2525 let at = 0;
2626 do {
27− let end = Math.min(at + PART, text.length);
27+ let end = Math.min(at + LOG_PART_CHARACTERS, text.length);
2828 const c = text.charCodeAt(end - 1);
2929 if (end < text.length && c >= 0xd800 && c <= 0xdbff) end--;
3030 parts.push(text.slice(at, end));
Lines 95–135 at 157 (were 95–100 at 156)
9595 return this.next;
9696 }
9797
98+ /** Reject an oversized canonical frame before loading its text into JavaScript. */
99+ boundedFrame(seq: number, maxBytes: number): string {
100+ if (
101+ !Number.isSafeInteger(seq) ||
102+ seq < 0 ||
103+ !Number.isSafeInteger(maxBytes) ||
104+ maxBytes < 1 ||
105+ maxBytes > 8_000_000
106+ )
107+ throw new Error("invalid canonical frame bound");
108+ const size = this.storage.sql
109+ .exec(
110+ "SELECT COUNT(*) AS parts, COALESCE(SUM(LENGTH(CAST(text AS BLOB))), 0) AS bytes FROM log WHERE seq = ?",
111+ seq,
112+ )
113+ .toArray()[0] as { parts: number; bytes: number };
114+ if (!size || size.parts < 1 || size.parts > 256 || size.bytes > maxBytes)
115+ throw new Error("canonical frame exceeds adoption bound or is missing");
116+ const rows = this.storage.sql.exec("SELECT part, text FROM log WHERE seq = ? ORDER BY part", seq).toArray() as {
117+ part: number;
118+ text: string;
119+ }[];
120+ if (rows.length !== size.parts || rows.some((row, part) => row.part !== part))
121+ throw new Error("canonical frame parts are incomplete");
122+ return rows.map((row) => row.text).join("");
123+ }
125+ /** Refreshes the in-memory cursor after an enclosing transaction rolls back. */
126+ refreshSequence(): void {
127+ const rows = this.storage.sql.exec("SELECT COALESCE(MAX(seq), -1) AS last FROM log").toArray() as {
128+ last: number;
129+ }[];
130+ this.next = (rows[0]?.last ?? -1) + 1;
131+ }
98133 /** Monotonic cache invalidation epoch for every canonical log mutation. */
99134 generation(): number {
100135 const rows = this.storage.sql.exec("SELECT value FROM marks WHERE name = ?", "generation").toArray() as {
MCP
compare on this site's /mcp
CLI
abso diff 156 157 server/src/engine-project.ts --json
JSON
/christopher/abso-core/compare/156..157?file=server%2Fsrc%2Fengine-project.ts&format=json