13 files, 153 lines added, 31 removed.
--- a/client/src/api-answers.ts
+++ b/client/src/api-answers.ts
@@ -187,6 +187,8 @@
187187 readonly ci?: CiStatus; 188188 /** The merge queue (#39), while anything waits or it's paused. */ 189189 readonly queue?: QueueState | null; 190+ /** Only when shared has both project files: abso.json counts, avcs.json is ignored. */ 191+ readonly projectFile?: { readonly used: string; readonly ignored: string }; 191193/** `POST /a/:agent/draft` answers like a sync, naming the space the agent is now in. */ 192194export interface SwitchAnswer extends SyncAnswer { --- a/client/src/status-commands.ts
+++ b/client/src/status-commands.ts
@@ -301,6 +301,11 @@
301301 // Is shared green (#39)? Right under the first line, since it decides what to do next. 302302 ...ciText(status.ci, status.version), 303303 ...queueText(status.queue, config.agent), 304+ ...(status.projectFile 306+ `Shared has both ${status.projectFile.used} and ${status.projectFile.ignored}: ${status.projectFile.used} counts and ${status.projectFile.ignored} is ignored. Move anything you need into ${status.projectFile.used} and delete ${status.projectFile.ignored}.`, 305310 ? "Everything in this folder is recorded." 306311 : `Not yet recorded (abso record sends them): ${[...local.keys()].join(", ")}`, --- a/worker/project/check-clash.ts
+++ b/worker/project/check-clash.ts
@@ -3,7 +3,7 @@
44import type { AtomId, View } from "../../src/engine/index.ts"; 55import { ProjectError } from "./project-error.ts"; 6−import { configProblem } from "./project-helpers.ts";
6+import { configProblem, PROJECT_FILES } from "./project-helpers.ts"; 77import type { Space } from "./spaces.ts"; 88import { clashIn } from "./spelling.ts"; @@ -38,10 +38,11 @@
3838 const touched = host.touchedFiles(changes, [view]); 3939 const why = clashIn(view, touched, now); 4040 if (why) throw new ProjectError("conflict", why); 41− // A broken avcs.json would quietly switch off files kept whole, the queue and reviewers (Git Lessons' review, batch 4).
42− if (touched.has("avcs.json") && view.hasFile("avcs.json")) {
43− const bad = configProblem(view.text("avcs.json"));
41+ // A broken project file would quietly switch off files kept whole, the queue and reviewers (Git Lessons' review, batch 4). 42+ for (const name of PROJECT_FILES) { 43+ if (!touched.has(name) || !view.hasFile(name)) continue; 44+ const bad = configProblem(view.text(name)); 45− throw new ProjectError("conflict", `avcs.json ${bad}. Shared keeps the one it has; fix yours and publish again.`);
46+ throw new ProjectError("conflict", `${name} ${bad}. Shared keeps the one it has; fix yours and publish again.`); --- a/worker/project/ingest.ts
+++ b/worker/project/ingest.ts
@@ -3,7 +3,7 @@
33import { type AtomId, canonicalText, type Hunk, type View } from "../../src/engine/index.ts"; 44import { checkPath } from "./path-rules.ts"; 55import { ProjectError } from "./project-error.ts"; 6−import { configProblem } from "./project-helpers.ts";
6+import { configProblem, PROJECT_FILES } from "./project-helpers.ts"; 77import type { AgentState, Entry, IngestAnswer, LandAnswer, Meta, Mode, Modes, PublishAnswer } from "./project-types.ts"; 88import type { Space } from "./spaces.ts"; 99import { clashInPaths } from "./spelling.ts"; @@ -103,9 +103,11 @@
104104 `commit ${c.sha.slice(0, 12)}: ${clash} (#49); rename one with git mv and push again`, 106− const config = typeof c.files["avcs.json"] === "string" ? configProblem(c.files["avcs.json"]) : undefined;
107− if (config)
108− throw new ProjectError("conflict", `commit ${c.sha.slice(0, 12)}: avcs.json ${config}; fix it and push again`);
106+ for (const name of PROJECT_FILES) { 107+ const config = typeof c.files[name] === "string" ? configProblem(c.files[name]) : undefined; 109+ throw new ProjectError("conflict", `commit ${c.sha.slice(0, 12)}: ${name} ${config}; fix it and push again`); 110112 const name = `git-${input.commits[0]!.sha.slice(0, 12)}`; 111113 if (host.agents.has(name) || host.spaces.has(name)) { --- a/worker/project/init.ts
+++ b/worker/project/init.ts
@@ -4,7 +4,7 @@
44import { type AttrSet, buildBase, canonicalText, type View } from "../../src/engine/index.ts"; 55import { checkPath } from "./path-rules.ts"; 66import { ProjectError } from "./project-error.ts"; 7−import { configProblem } from "./project-helpers.ts";
7+import { configProblem, PROJECT_FILES, projectFileOf } from "./project-helpers.ts"; 88import type { Entry, Modes, ProjectOptions } from "./project-types.ts"; 99import { clashInPaths } from "./spelling.ts"; 1010import { checkModes } from "./view-changes.ts"; @@ -35,11 +35,13 @@
3535 if (typeof files !== "object" || files === null) throw new ProjectError("bad-request", "init needs {files}"); 3636 const clash = clashInPaths([...new Set([...Object.keys(files), ...Object.keys(blobs)])].toSorted()); 3737 if (clash) throw new ProjectError("bad-request", `init: ${clash} (#49)`); 38− const config = typeof files["avcs.json"] === "string" ? configProblem(files["avcs.json"]) : undefined;
39− if (config) throw new ProjectError("bad-request", `init: avcs.json ${config}`);
38+ for (const name of PROJECT_FILES) { 39+ const config = typeof files[name] === "string" ? configProblem(files[name]) : undefined; 40+ if (config) throw new ProjectError("bad-request", `init: ${name} ${config}`); 4143 // The project file being created says which paths are whole (#46). 42− const config = typeof files["avcs.json"] === "string" ? files["avcs.json"] : undefined;
44+ const config = projectFileOf(files)?.text; 4345 ({ files, blobs } = host.wholeOut(files, blobs, undefined, config) as { 4446 files: Record<string, string>; 4547 blobs: Record<string, string>; --- a/worker/project/path-rules.ts
+++ b/worker/project/path-rules.ts
@@ -46,15 +46,18 @@
4646function reservedKey(seg: string): string { 4747 return pathKey(seg.replace(/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g, "")); 49−const AVCS_KEY = pathKey(".avcs");
49+/** The client's folder: .abso, and .avcs from before the rename (224). */ 50+const SETTINGS_KEYS = new Set([pathKey(".abso"), pathKey(".avcs")]); 51−/** For writes: the path must be canonical, and not under .avcs/ in any spelling, at any depth. */
52+/** For writes: the path must be canonical, and not under .abso/ or .avcs/ in any spelling, at any depth. */ 5253export function checkPath(path: string): void { 5354 const problem = pathProblem(path); 5455 if (problem) throw new ProjectError("bad-request", `bad file path ${JSON.stringify(path)}: ${problem}`); 5556 // The client's settings stay in the agent's folder and are never published. 56− if (path.split("/").some((seg) => reservedKey(seg) === AVCS_KEY)) {
57− throw new ProjectError("bad-request", `${path} is under .avcs/, which stays in the agent's folder`);
57+ const settings = path.split("/").find((seg) => SETTINGS_KEYS.has(reservedKey(seg))); 58+ if (settings !== undefined) { 59+ const folder = reservedKey(settings) === pathKey(".abso") ? ".abso" : ".avcs"; 60+ throw new ProjectError("bad-request", `${path} is under ${folder}/, which stays in the agent's folder`); --- a/worker/project/project-helpers.ts
+++ b/worker/project/project-helpers.ts
@@ -32,8 +32,30 @@
35+/** The project file's names, the one read first first (224): abso.json, then avcs.json from before the rename. */ 36+export const PROJECT_FILES = ["abso.json", "avcs.json"] as const; 36− * What's wrong with an avcs.json, or undefined (Git Lessons' review, batch 4):
39+ * The project file a set of files holds: abso.json when it has one, else 40+ * avcs.json. `ignored` names avcs.json when both are there, so status can say 43+export function projectFileIn(files: { 44+ hasFile(path: string): boolean; 45+ text(path: string): string; 46+}): { name: (typeof PROJECT_FILES)[number]; text: string; ignored?: "avcs.json" } | undefined { 47+ const [name, other] = PROJECT_FILES.filter((n) => files.hasFile(n)); 48+ if (!name) return undefined; 49+ return { name, text: files.text(name), ...(other ? { ignored: "avcs.json" as const } : {}) }; 52+/** projectFileIn for a plain path -> text record (init, git intake). */ 53+export function projectFileOf(files: Readonly<Record<string, unknown>>): ReturnType<typeof projectFileIn> { 54+ return projectFileIn({ hasFile: (p) => typeof files[p] === "string", text: (p) => files[p] as string }); 58+ * What's wrong with a project file (abso.json or avcs.json), or undefined (Git Lessons' review, batch 4): 3759 * it must be a JSON object, and the keys abso reads must have their types: 3860 * "whole" a list of globs, "queue" true or false, "review" a list of 3961 * {paths, reviewer}, and CI's "setup", "build", "check" and "out" strings. --- a/worker/project/project-status.ts
+++ b/worker/project/project-status.ts
@@ -3,7 +3,7 @@
44import type { AtomId, View } from "../../src/engine/index.ts"; 55import { ProjectError } from "./project-error.ts"; 6−import { countRefusals } from "./project-helpers.ts";
6+import { countRefusals, type projectFileIn } from "./project-helpers.ts"; 77import type { AgentState, AgentStatus, EditsVia, Refusal, Starting, StatusAnswer } from "./project-types.ts"; 88import { last, SHARED, type Space, sharedBaseOf } from "./spaces.ts"; @@ -32,6 +32,8 @@
3232 viewAt(space: Space, version: number): View; 3333 agentView(agent: AgentState): View; 35+ /** Shared's project file (224), or undefined before init or without one. */ 36+ projectFile(): ReturnType<typeof projectFileIn>; @@ -143,5 +145,14 @@
145147 const announcements = [...waiting].map(([text, names]) => ({ text, waiting: names })); 146− return { version: host.version(), agents, drafts, refusals: countRefusals(host.refusals), announcements };
148+ // Both project files in shared (224): say which one counts, never quietly. 149+ const file = host.projectFile(); 151+ version: host.version(), 154+ refusals: countRefusals(host.refusals), 156+ ...(file?.ignored ? { projectFile: { used: "abso.json" as const, ignored: file.ignored } } : {}), --- a/worker/project/project-types.ts
+++ b/worker/project/project-types.ts
@@ -511,6 +511,8 @@
511511 refusals: RefusalCounts; 512512 /** Announcements some agent hasn't received yet, oldest first. */ 513513 announcements: { text: string; waiting: string[] }[]; 514+ /** Only when shared has both abso.json and avcs.json (224): abso.json counts and avcs.json is ignored. */ 515+ projectFile?: { used: "abso.json"; ignored: "avcs.json" }; 516518/** Refused publishes and lands, counted by collision kind (a refusal can have several kinds). */ --- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -118,7 +118,7 @@
118118import { pathKey } from "./pathkey.ts"; 119119import { pluck as hostedPluck, type PluckHost } from "./pluck.ts"; 120120import { ProjectError } from "./project-error.ts"; 121−import { checkDraftName, checkPerson, NAME } from "./project-helpers.ts";
121+import { checkDraftName, checkPerson, NAME, projectFileIn } from "./project-helpers.ts"; 123123 type SnapshotHost, 124124 agentPaths as snapshotAgentPaths, @@ -668,8 +668,7 @@
669669 /** The project's reviewers per area (#44): avcs.json's `"review": [{"paths": [...], "reviewer": "..."}]` in shared. */ 670670 #reviewRules(): ReviewRule[] { 671− const view = this.#sharedView();
672− return reviewRulesIn(view.hasFile("avcs.json") ? view.text("avcs.json") : undefined);
671+ return reviewRulesIn(projectFileIn(this.#sharedView())?.text); 675674 /** Each reviewer whose area these files fall in, the files that do, and whether it has noted change `id`. */ @@ -2151,6 +2150,7 @@
21512150 viewAt: (space, version) => this.#viewAt(space, version), 21522151 agentView: (agent) => this.#agentView(agent), 21532152 version: () => this.version, 2153+ projectFile: () => (this.initialized ? projectFileIn(this.#sharedView()) : undefined), 21552155 return this.#snapshotHost; --- a/worker/project/queue.ts
+++ b/worker/project/queue.ts
@@ -7,6 +7,7 @@
77import { keptOf, lostLines } from "./markers.ts"; 88import { clip } from "./news.ts"; 99import { ProjectError } from "./project-error.ts"; 10+import { projectFileIn } from "./project-helpers.ts"; @@ -62,13 +63,13 @@
6263 flush(entries: Entry[]): void; 65−/** Whether shared's avcs.json turns the merge queue on (`"queue": true`). */
66+/** Whether shared's project file (abso.json, else avcs.json) turns the merge queue on (`"queue": true`). */ 6667export function queueOn(host: QueueHost): boolean { 6768 if (!host.checkerReady()) return false; 68− const view = host.sharedView();
69− if (!view.hasFile("avcs.json")) return false;
69+ const file = projectFileIn(host.sharedView()); 70+ if (!file) return false; 71− return (JSON.parse(view.text("avcs.json")) as { queue?: unknown }).queue === true;
72+ return (JSON.parse(file.text) as { queue?: unknown }).queue === true; --- /dev/null
+++ b/worker/project/test/project-file.test.ts
@@ -0,0 +1,71 @@
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. 5+import assert from "node:assert/strict"; 6+import { test } from "node:test"; 7+import { MemoryStore, Project } from "../project.ts"; 9+const review = (reviewer: string) => JSON.stringify({ review: [{ paths: ["src/**"], reviewer }] }) + "\n"; 11+function 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); 18+test("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"); 27+test("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); 35+test("with both, abso.json counts and status says avcs.json is ignored", () => { 36+ const project = new Project(new MemoryStore(), { now: () => 100 }); 38+ { "abso.json": review("security"), "avcs.json": review("writer"), "src/a.ts": "export const a = 0;\n" }, 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" }); 48+test("a broken abso.json is refused like a broken avcs.json, at publish 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/); 59+ () => new Project(new MemoryStore()).init({ "abso.json": "[1]\n" }, 0), 60+ /init: abso\.json must be a JSON object/, 64+test(".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); 70+ assert.equal(project.record("ann", { ".absolutely.txt": "x\n" }, 1) !== undefined, true); --- a/worker/project/whole-files.ts
+++ b/worker/project/whole-files.ts
@@ -3,6 +3,7 @@
44import { canonicalText, type View } from "../../src/engine/index.ts"; 55import { matchesPattern } from "./globs.ts"; 6+import { projectFileIn } from "./project-helpers.ts"; 67import type { ProjectOptions } from "./project-types.ts"; @@ -18,14 +19,13 @@
1819 whole: ProjectOptions["whole"]; 21−/** avcs.json's `"whole": [globs]`: paths kept whole. From `config` when given (init), else shared's. */
22+/** The project file's `"whole": [globs]`: paths kept whole. From `config` when given (init), else shared's. */ 2223export function wholeRules(host: WholeHost, config?: string): string[] { 2425 if (text === undefined) { 2526 if (!host.initialized()) return []; 26− const view = host.sharedView();
27− if (!view.hasFile("avcs.json")) return [];
28− text = view.text("avcs.json");
27+ text = projectFileIn(host.sharedView())?.text; 28+ if (text === undefined) return []; 3131 const whole = (JSON.parse(text) as { whole?: unknown }).whole;