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

Compare

+85 −0 in 1 place
new file, 85 lines
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import {
4+ canonicalJson,
5+ chunkEntries,
6+ digestOperation,
7+ type OperationChunk,
8+ type ProjectOperation,
9+ utf8JsonFrames,
10+} from "../operation-protocol.ts";
11+import type { Entry } from "../project-types.ts";
13+const operation: ProjectOperation = {
14+ id: "op-1",
15+ tenant: "tenant-1",
16+ project: "project-1",
17+ incarnation: "incarnation-1",
18+ actor: "builder",
19+ build: "build-1",
20+ executorIdentity: "trusted-local-executor",
21+ rootDigest: "root-0",
22+ authorizationRevision: "auth-1",
23+ policyRevision: "policy-1",
24+ operationTime: 20,
25+ queuePolicy: { policyRevision: "policy-1", checkerReady: false },
26+ generation: 0,
27+ heads: { log: 0, shared: 0, actorMine: 0, actorBase: 0, queueRevision: 0 },
28+ message: "record and publish",
29+ files: { "readme.txt": "updated\n" },
30+};
32+test("canonical request binding ignores object property order and binds every request field", async () => {
33+ const reordered = {
34+ ...operation,
35+ files: { "readme.txt": "updated\n" },
36+ heads: { actorBase: 0, actorMine: 0, shared: 0, log: 0, queueRevision: 0 },
37+ };
38+ assert.equal(await digestOperation(operation), await digestOperation(reordered));
39+ assert.notEqual(
40+ await digestOperation(operation),
41+ await digestOperation({ ...operation, authorizationRevision: "revoked" }),
42+ );
43+ assert.notEqual(
44+ await digestOperation(operation),
45+ await digestOperation({ ...operation, files: { "readme.txt": "other\n" } }),
46+ );
47+ assert.notEqual(await digestOperation(operation), await digestOperation({ ...operation, operationTime: 21 }));
48+ assert.notEqual(
49+ await digestOperation(operation),
50+ await digestOperation({ ...operation, queuePolicy: { ...operation.queuePolicy, checkerReady: true } }),
51+ );
52+ assert.equal(canonicalJson({ z: 1, a: 2 }), '{"a":2,"z":1}');
53+});
55+test("chunk generator preserves exact order with bounded entries and UTF-8 byte accounting", async () => {
56+ const entries: Entry[] = Array.from({ length: 70 }, (_, index) => ({
57+ type: "join",
58+ agent: `agent-${index}`,
59+ version: index,
60+ time: index,
61+ }));
62+ const chunks: OperationChunk[] = [];
63+ for await (const chunk of chunkEntries(entries)) chunks.push(chunk);
64+ assert.deepEqual(
65+ chunks.flatMap((chunk) => chunk.entries),
66+ entries,
67+ );
68+ assert.ok(chunks.every((chunk, index) => chunk.index === index && chunk.count <= 32 && chunk.bytes <= 64 * 1024));
69+ assert.deepEqual(
70+ chunks.map((chunk) => chunk.firstEntry),
71+ [0, 32, 64],
72+ );
73+ assert.ok(chunks.every((chunk, index) => index === 0 || chunk.chain !== chunks[index - 1]!.chain));
75+ const large: Entry = { type: "join", agent: "🙂".repeat(8_000), version: 0, time: 1 };
76+ const utf8: OperationChunk[] = [];
77+ for await (const chunk of chunkEntries([large])) utf8.push(chunk);
78+ assert.ok(utf8[0]!.bytes > JSON.stringify(large).length);
79+ assert.ok(utf8[0]!.bytes <= 64 * 1024);
80+ const largeEntry: Entry = { type: "join", agent: `🙂\n"`.repeat(20_000), version: 0, time: 1 };
81+ const frames = [...utf8JsonFrames(largeEntry)];
82+ assert.ok(frames.length > 1);
83+ assert.ok(frames.every((frame) => frame.bytes <= 64 * 1024));
84+ assert.deepEqual(JSON.parse(frames.map((frame) => frame.text).join("")), largeEntry);
85+});
MCP
compare on this site's /mcp
CLI
abso diff 2 318 worker/project/test/operation-protocol.test.ts --json
JSON
/christopher/abso-core/compare/2..318?file=worker%2Fproject%2Ftest%2Foperation-protocol.test.ts&format=json