- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/worker/project/test/blobs-stored.test.ts?version=277&format=json
53 linescapacity 100%Last change capacity in version 233, 1 version changed it
You're reading version 277. The newest is 318, and no version since then changed this file.
1// Binary files on a writer-backed project (abso Capacity, View.blobs): the blob list is read from file attributes
2// alone, with no file laid out. It must answer as the in-memory project does: a file binary from the start, one that
3// turns binary and back to text, and one deleted, at every version and in each agent's draft.
5import assert from "node:assert/strict";
6import { test } from "node:test";
7import { storedArray } from "../../../src/engine/state-source.ts";
8import { SqlState } from "../../../src/engine/test/storage-helper.ts";
9import { MemoryStore, Project } from "../project.ts";
10import type { Entry, ProjectStore } from "../project-types.ts";
12const A = "a".repeat(64);
13const B = "b".repeat(64);
14const C = "c".repeat(64);
15const held = (sha: string) => [A, B, C].includes(sha);
17function writer() {
18 const storage = new SqlState();
19 const entries = storedArray<Entry>(storage, "canonical-log");
20 const store: ProjectStore = {
21 append(batch) {
22 for (const entry of batch) entries.push(entry);
23 },
24 };
25 return new Project(store, { writerStorage: storage, hasBlob: held });
26}
28function history(project: Project) {
29 project.init({ "README.md": "hi\n", "notes.txt": "notes\n" }, 0, {}, { "logo.png": A, "old.bin": B });
30 project.sync("ann");
31 project.sync("bob");
32 project.record("ann", { "old.bin": null }, 1, {}, { "logo.png": B, "README.md": C });
33 assert.equal(project.publish("ann", "README turns binary, old.bin goes", 2).ok, true);
34 project.sync("bob");
35 project.record("bob", { "README.md": "text again\n" }, 3);
36 assert.equal(project.publish("bob", "README is text again", 4).ok, true);
37 project.sync("cy");
38 project.record("cy", {}, 5, {}, { "icon.png": C });
39}
41test("a stored writer's blob list matches the in-memory project's at every version and draft", () => {
42 const oracle = new Project(new MemoryStore(), { hasBlob: held });
43 const project = writer();
44 history(oracle);
45 history(project);
46 assert.deepEqual(oracle.blobs(), { "logo.png": B });
47 assert.deepEqual(project.blobs(), oracle.blobs());
48 for (let v = 0; v <= oracle.version; v++)
49 assert.deepEqual(project.viewAt(v).blobs(), oracle.viewAt(v).blobs(), `version ${v}`);
50 for (const agent of ["ann", "bob", "cy"])
51 assert.deepEqual(project.draftOf(agent)?.view.blobs(), oracle.draftOf(agent)?.view.blobs(), agent);
52 assert.deepEqual(oracle.draftOf("cy")?.view.blobs(), { "icon.png": C, "logo.png": B });
53});