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.

Not checked

Versions 25 to 318

Compare

+72 −0 in 1 place
new file, 72 lines
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import { withDecodedFrames } from "../src/decoded-frames.ts";
4+import { logParts, SqliteLog } from "../src/engine-project.ts";
5+import { SqliteWriterState, writerFrameDigest } from "../src/writer-host.ts";
6+import { memoryStorage } from "./helpers.ts";
7+
8+test("decoded frame pages retain views through consumption and remove scratch on all exits", (t) => {
9+ const storage = memoryStorage();
10+ t.after(() => storage.db.close());
11+ const log = new SqliteLog(storage);
12+ const json = JSON.stringify({ type: "join", agent: "alice", version: 0 });
13+ for (const [part, text] of logParts(json).entries())
14+ storage.sql.exec("INSERT INTO log(seq,part,text) VALUES(?,?,?)", 0, part, text);
15+ SqliteWriterState.initialize(storage);
16+ const before = storage.db.prepare("SELECT * FROM writer_state").all();
17+ const input = { from: 0, to: 1, maxEntries: 1, maxBytes: 1000, digest: "" };
18+ const result = withDecodedFrames(storage, "decoded-page", log, input, (frames) => {
19+ const frame = [...frames][0]!;
20+ assert.ok("entry" in frame);
21+ assert.equal(frame.entry.type, "join");
22+ assert.equal(
23+ storage.db.prepare("SELECT COUNT(*) AS n FROM writer_state WHERE namespace = ?").get("decoded-page")!.n,
24+ 0,
25+ );
26+ return frame.entry.type;
27+ });
28+ assert.equal(result.result, "join");
29+ assert.equal(result.digest, writerFrameDigest("", 0, json));
30+ assert.deepEqual(storage.db.prepare("SELECT * FROM writer_state").all(), before);
31+ assert.throws(
32+ () =>
33+ withDecodedFrames(storage, "decoded-page", log, input, (frames) => {
34+ [...frames];
35+ throw Error("consumer failure");
36+ }),
37+ /consumer failure/,
38+ );
39+ assert.deepEqual(storage.db.prepare("SELECT * FROM writer_state").all(), before);
40+});
42+test("frames above the small bound still use temporary disk storage", (t) => {
43+ const storage = memoryStorage();
44+ t.after(() => storage.db.close());
45+ const log = new SqliteLog(storage);
46+ const agent = "a".repeat(5000);
47+ const json = JSON.stringify({ type: "join", agent, version: 0 });
48+ for (const [part, text] of logParts(json).entries())
49+ storage.sql.exec("INSERT INTO log(seq,part,text) VALUES(?,?,?)", 0, part, text);
50+ const result = withDecodedFrames(
51+ storage,
52+ "large-decoded-page",
53+ log,
54+ { from: 0, to: 1, maxEntries: 1, maxBytes: 10000, digest: "" },
55+ (frames) => {
56+ const frame = [...frames][0]!;
57+ assert.ok("entry" in frame);
58+ assert.ok(
59+ Number(
60+ storage.db.prepare("SELECT COUNT(*) AS n FROM writer_state WHERE namespace = ?").get("large-decoded-page")!.n,
61+ ) > 0,
62+ );
63+ assert.equal((frame.entry as { agent: string }).agent, agent);
64+ return frame.entry.type;
65+ },
66+ );
67+ assert.equal(result.result, "join");
68+ assert.equal(
69+ storage.db.prepare("SELECT COUNT(*) AS n FROM writer_state WHERE namespace = ?").get("large-decoded-page")!.n,
70+ 0,
71+ );
72+});
MCP
compare on this site's /mcp
CLI
abso diff 25 318 server/test/decoded-frames-small.test.ts --json
JSON
/christopher/abso-core/compare/25..318?file=server%2Ftest%2Fdecoded-frames-small.test.ts&format=json