- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/worker/project/test/project-file.test.ts?version=100&format=json
71 linesengine 97% · pinch 1% · rename 1%Last change rename in version 100, 3 versions changed it
You're reading version 100. The newest is 318, and no version since then changed this file.
1// The project file's new name (224): abso.json is read first, then avcs.json
2// from before the rename. Both are checked the same way, and when shared has
3// both, abso.json counts and status says avcs.json is ignored.
5import assert from "node:assert/strict";
6import { test } from "node:test";
7import { MemoryStore, Project } from "../project.ts";
9const review = (reviewer: string) => `${JSON.stringify({ review: [{ paths: ["src/**"], reviewer }] })}\n`;
11function touchSrc(project: Project, time: number): void {
12 project.sync("builder");
13 const a = project.edit("builder", { file: "src/a.ts", old: `${time - 1}`, new: `${time}` }, time);
14 if (!a.ok) throw new Error("edit out of step");
15 project.publish("builder", `a ${time}`, time + 1);
16}
18test("abso.json alone is the project file: its reviewers are told", () => {
19 const project = new Project(new MemoryStore(), { now: () => 100 });
20 project.init({ "abso.json": review("security"), "src/a.ts": "export const a = 0;\n" }, 0);
21 project.sync("security");
22 touchSrc(project, 1);
23 assert.equal(project.news("security").news.length, 1);
24 assert.equal(project.status().projectFile, undefined, "one file: nothing to say");
25});
27test("avcs.json alone still works", () => {
28 const project = new Project(new MemoryStore(), { now: () => 100 });
29 project.init({ "avcs.json": review("security"), "src/a.ts": "export const a = 0;\n" }, 0);
30 project.sync("security");
31 touchSrc(project, 1);
32 assert.equal(project.news("security").news.length, 1);
33});
35test("with both, abso.json counts and status says avcs.json is ignored", () => {
36 const project = new Project(new MemoryStore(), { now: () => 100 });
37 project.init(
38 { "abso.json": review("security"), "avcs.json": review("writer"), "src/a.ts": "export const a = 0;\n" },
39 0,
40 );
41 for (const a of ["security", "writer"]) project.sync(a);
42 touchSrc(project, 1);
43 assert.equal(project.news("security").news.length, 1);
44 assert.equal(project.news("writer").news.length, 0, "avcs.json is ignored");
45 assert.deepEqual(project.status().projectFile, { used: "abso.json", ignored: "avcs.json" });
46});
48test("a broken abso.json is refused like a broken avcs.json, at push and at init", () => {
49 const project = new Project(new MemoryStore());
50 project.init({ "abso.json": '{"queue": false}\n' }, 0);
51 project.sync("alice");
52 project.record("alice", { "abso.json": '{"queue": "yes"}\n' }, 1);
53 assert.throws(() => project.publish("alice", "queue as text", 2), /abso\.json has "queue" that isn't true or false/);
54 assert.equal(project.files()["abso.json"], '{"queue": false}\n', "shared keeps the good one");
55 // A broken avcs.json is still refused when abso.json is there too: it may be read again once abso.json goes.
56 project.record("alice", { "abso.json": '{"queue": false}\n', "avcs.json": "[1]\n" }, 3);
57 assert.throws(() => project.publish("alice", "old file broken", 4), /avcs\.json must be a JSON object/);
58 assert.throws(
59 () => new Project(new MemoryStore()).init({ "abso.json": "[1]\n" }, 0),
60 /init: abso\.json must be a JSON object/,
61 );
62});
64test(".abso/ stays in the agent's folder, like .avcs/", () => {
65 const project = new Project(new MemoryStore());
66 project.init({ "a.txt": "a\n" }, 0);
67 for (const p of [".abso/config.json", "sub/.ABSO/x", ".avcs/config.json"]) {
68 assert.throws(() => project.record("ann", { [p]: "x\n" }, 1), /is under \.(abso|avcs)\//, p);
69 }
70 assert.equal(project.record("ann", { ".absolutely.txt": "x\n" }, 1) !== undefined, true);
71});