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

Compare

+46 −26 in 14 places
Lines 1–15 at 318 (were 1–12 at 8)
11// The merge queue: publishes to shared waiting for their batch's check.
22// Writes go through QueueHost; today the host is Project.
33
4−import { type AtomId, buildAtom, type Graph, type View } from "../../src/engine/index.ts";
4+import { type AtomId, buildAtom, type Graph, type ReadView } from "../../src/engine/index.ts";
5+import { unionOverlay } from "../../src/engine/state-source.ts";
6+import { autoSettledOf } from "./autosettle.ts";
57import type { Pair } from "./collisions.ts";
68import { definedTwice } from "./definitions.ts";
7−import { keptOf, lostLines } from "./markers.ts";
9+import { heldMessage, keptOf, lostLines } from "./markers.ts";
810import { clip } from "./news.ts";
911import { ProjectError } from "./project-error.ts";
12+import { projectFileIn } from "./project-helpers.ts";
1013import type {
1114 AgentState,
1215 Blobs,
Lines 29–37 at 318 (were 26–32 at 8)
2629export interface QueueHost {
2730 readonly graph: Graph;
2831 checkerReady(): boolean;
29− sharedView(): View;
32+ sharedView(): ReadView;
33+ sharedOverlay?(atoms: readonly AtomId[]): ReadView;
34+ sharedAgentOverlay?(agent: AgentState, atoms: readonly AtomId[]): ReadView;
3035 queued(): readonly QueuedPublish[];
3136 queuedId(): number;
3237 checkingHas(id: number): boolean;
Lines 40–51 at 318 (were 35–46 at 8)
3540 needInit(): void;
3641 shared(): Space;
3742 setOf(space: Space): ReadonlySet<AtomId>;
38− view(set: ReadonlySet<AtomId>): View;
43+ view(set: ReadonlySet<AtomId>): ReadView;
3944 agentSet(agent: AgentState): Set<AtomId>;
40− agentView(agent: AgentState): View;
45+ agentView(agent: AgentState): ReadView;
4146 pairs(draft: readonly AtomId[], against: ReadonlySet<AtomId>, settled: ReadonlySet<AtomId>): Pair[];
42− describe(pair: Pair, yoursView: View, theirsView: View, spaceName: string): Collision;
43− touchedFiles(ids: Iterable<AtomId>, views: readonly View[]): Set<string>;
47+ describe(pair: Pair, yoursView: ReadView, theirsView: ReadView, spaceName: string): Collision;
48+ touchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string>;
4449 refuse(
4550 agent: AgentState,
4651 space: Space,
Lines 53–59 at 318 (were 48–53 at 8)
4853 time: number,
4954 collisions: Collision[],
5055 entries: Entry[],
56+ message?: string,
5157 ): { ok: false; collisions: Collision[] };
5258 currentChange(agent: AgentState, time: number): number | undefined;
5359 nextAt(): number;
Lines 68–80 at 318 (were 62–74 at 8)
6268 flush(entries: Entry[]): void;
6369}
6470
65−/** Whether shared's avcs.json turns the merge queue on (`"queue": true`). */
71+/** Whether shared's project file (abso.json, else avcs.json) turns the merge queue on (`"queue": true`). */
6672export function queueOn(host: QueueHost): boolean {
6773 if (!host.checkerReady()) return false;
68− const view = host.sharedView();
69− if (!view.hasFile("avcs.json")) return false;
74+ const file = projectFileIn(host.sharedView());
75+ if (!file) return false;
7076 try {
71− return (JSON.parse(view.text("avcs.json")) as { queue?: unknown }).queue === true;
77+ return (JSON.parse(file.text) as { queue?: unknown }).queue === true;
7278 } catch {
7379 return false;
7480 }
Lines 85–91 at 318 (were 79–85 at 8)
7985 if (queueOn(host))
8086 throw new ProjectError(
8187 "conflict",
82− `${what} doesn't go through the merge queue yet; switch to shared, take the changes into your draft, and publish`,
88+ `${what} doesn't go through the merge queue yet; switch to shared, take the changes into your draft, and push`,
8389 );
8490}
8591
Lines 121–133 at 318 (were 115–125 at 8)
115121 const ahead = queuedAtoms(host, agent.name);
116122 const now = host.setOf(space);
117123 if (ahead.size > 0) {
118− const landed = new Set([...now, ...ahead]);
119− const theirsView = host.view(landed);
120− const yoursView = host.view(new Set([...landed, ...host.agentSet(agent)]));
124+ const landed = unionOverlay(now, ahead);
125+ const theirsView = host.sharedOverlay ? host.sharedOverlay([...ahead]) : host.view(landed);
126+ const yoursView = host.sharedAgentOverlay
127+ ? host.sharedAgentOverlay(agent, [...ahead])
128+ : host.view(unionOverlay(landed, host.agentSet(agent)));
121129 const queuedBy = (id: AtomId) => host.queued().find((q) => q.changes.includes(id));
122− const collisions: Collision[] = host.pairs(changes, ahead, new Set([...landed, ...changes])).map((p) => {
130+ const collisions: Collision[] = host.pairs(changes, ahead, unionOverlay(landed, changes)).map((p) => {
123131 const c = host.describe(p, host.agentView(agent), theirsView, agent.space);
124132 const q = queuedBy(p.theirs);
125133 return q ? { ...c, theirs: { ...c.theirs, agent: q.agent, message: q.message, queued: q.id } } : c;
Lines 144–153 at 318 (were 136–145 at 8)
136144 kind: "duplicate",
137145 name,
138146 file,
139− yours: { lines: [yours.start + 1, yours.end], text: yours.text + "\n" },
147+ yours: { lines: [yours.start + 1, yours.end], text: `${yours.text}\n` },
140148 theirs: {
141149 lines: [theirs.start + 1, theirs.end],
142− text: theirs.text + "\n",
150+ text: `${theirs.text}\n`,
143151 agent: q.agent,
144152 message: q.message,
145153 version: last(space),
Lines 156–179 at 318 (were 148–166 at 8)
148156 });
149157 }
150158 }
151− if (collisions.length > 0) return host.refuse(agent, space, "publish", time, collisions, entries);
159+ if (collisions.length > 0) return host.refuse(agent, space, "publish", time, collisions, entries, message);
152160 }
153161 const view = host.agentView(agent);
162+ const auto = autoSettledOf(message);
154163 const settled: Settled[] = agent.marked
155164 .filter((r) => r.space === SHARED)
156165 .map((r) => {
157166 const lines = view.hasFile(r.file) ? view.lines(r.file).map((l) => l.text) : [];
158167 const lost = lostLines(lines, r);
168+ const held = heldMessage(agent, r.file);
169+ const by = auto.get(r.file);
159170 return {
160171 file: r.file,
161172 kept: keptOf(lines, r),
162173 theirs: { agent: r.agent, version: r.version },
163174 ...(lost.length > 0 ? { lost } : {}),
175+ ...(held ? { held } : {}),
176+ ...(by ? { auto: by } : {}),
164177 };
165178 });
166179 const id = host.queuedId() + 1;
Lines 240–252 at 318 (were 227–233 at 8)
227240} {
228241 host.needInit();
229242 const items = host.queued().slice(0, Math.max(0, n));
230− const view = host.view(new Set([...host.setOf(host.shared()), ...items.flatMap((q) => q.changes)]));
243+ const changes = items.flatMap((q) => q.changes);
244+ const view =
245+ changes.length === 0
246+ ? host.sharedView()
247+ : host.sharedOverlay
248+ ? host.sharedOverlay(changes)
249+ : host.view(unionOverlay(host.setOf(host.shared()), changes));
231250 const files = view.files();
232251 const modes = modesOf(view);
233252 const blobs = view.blobs();
Lines 265–273 at 318 (were 246–253 at 8)
246265 for (const q of host.queued().slice(0, Math.max(0, n))) {
247266 const agent = host.agentOf(q.agent);
248267 const space = host.shared();
249− const union = new Set([...host.setOf(space), ...q.changes]);
250− const tie = buildAtom(host.view(union), {
268+ const union = unionOverlay(host.setOf(space), q.changes);
269+ const view = host.sharedOverlay ? host.sharedOverlay(q.changes) : host.view(union);
270+ const tie = buildAtom(view, {
251271 author: q.agent,
252272 message: q.message,
253273 time,
Lines 299–305 at 318 (were 279–285 at 8)
279299 host.reviewNews(agent, version, entries);
280300 host.queueNews(
281301 agent,
282− [{ key: `landed ${q.id}`, text: `Your queued publish "${clip(q.message)}" landed as version ${version}.` }],
302+ [{ key: `landed ${q.id}`, text: `Your queued push "${clip(q.message)}" landed as version ${version}.` }],
283303 entries,
284304 );
285305 out.push({ id: q.id, version });
Lines 343–355 at 318 (were 323–335 at 8)
323343 ? `the project's check failed on it on top of version ${last(host.shared())}${tail ? `:\n${tail}` : ""}`
324344 : why === "withdrawn"
325345 ? "you withdrew it"
326− : `it builds on queued publish ${id}, which was pulled`;
346+ : `it builds on queued push ${id}, which was turned back`;
327347 host.queueNews(
328348 host.agentOf(q.agent),
329349 [
330350 {
331351 key: `pulled ${q.id}`,
332− text: `Your queued publish "${clip(q.message)}" was pulled: ${said}. Its changes are still in your draft.`,
352+ text: `Your queued push "${clip(q.message)}" was turned back: ${said}. Its changes are still in your draft.`,
333353 },
334354 ],
335355 entries,
Lines 369–375 at 318 (were 349–355 at 8)
349369 if (busy)
350370 throw new ProjectError(
351371 "conflict",
352− `queued publish ${busy.id} is being checked; it lands or is pulled in about a minute (abso drop takes it back after it lands)`,
372+ `queued push ${busy.id} is being checked; it lands or is turned back in about a minute (abso drop takes it back after it lands)`,
353373 );
354374 const pulled: number[] = [];
355375 for (const q of mine)
MCP
compare on this site's /mcp
CLI
abso diff 8 318 worker/project/queue.ts --json
JSON
/christopher/abso-core/compare/8..318?file=worker%2Fproject%2Fqueue.ts&format=json