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

Compare

+41 −22 in 13 places
Lines 1–12 at 318 (were 1–10 at 33)
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";
1012import { projectFileIn } from "./project-helpers.ts";
Lines 29–37 at 318 (were 27–33 at 33)
2729export interface QueueHost {
2830 readonly graph: Graph;
2931 checkerReady(): boolean;
30− sharedView(): View;
32+ sharedView(): ReadView;
33+ sharedOverlay?(atoms: readonly AtomId[]): ReadView;
34+ sharedAgentOverlay?(agent: AgentState, atoms: readonly AtomId[]): ReadView;
3135 queued(): readonly QueuedPublish[];
3236 queuedId(): number;
3337 checkingHas(id: number): boolean;
Lines 40–51 at 318 (were 36–47 at 33)
3640 needInit(): void;
3741 shared(): Space;
3842 setOf(space: Space): ReadonlySet<AtomId>;
39− view(set: ReadonlySet<AtomId>): View;
43+ view(set: ReadonlySet<AtomId>): ReadView;
4044 agentSet(agent: AgentState): Set<AtomId>;
41− agentView(agent: AgentState): View;
45+ agentView(agent: AgentState): ReadView;
4246 pairs(draft: readonly AtomId[], against: ReadonlySet<AtomId>, settled: ReadonlySet<AtomId>): Pair[];
43− describe(pair: Pair, yoursView: View, theirsView: View, spaceName: string): Collision;
44− 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>;
4549 refuse(
4650 agent: AgentState,
4751 space: Space,
Lines 53–59 at 318 (were 49–54 at 33)
4953 time: number,
5054 collisions: Collision[],
5155 entries: Entry[],
56+ message?: string,
5257 ): { ok: false; collisions: Collision[] };
5358 currentChange(agent: AgentState, time: number): number | undefined;
5459 nextAt(): number;
Lines 85–91 at 318 (were 80–86 at 33)
8085 if (queueOn(host))
8186 throw new ProjectError(
8287 "conflict",
83− `${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`,
8489 );
8590}
8691
Lines 121–133 at 318 (were 116–126 at 33)
116121 const ahead = queuedAtoms(host, agent.name);
117122 const now = host.setOf(space);
118123 if (ahead.size > 0) {
119− const landed = new Set([...now, ...ahead]);
120− const theirsView = host.view(landed);
121− 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)));
122129 const queuedBy = (id: AtomId) => host.queued().find((q) => q.changes.includes(id));
123− 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) => {
124131 const c = host.describe(p, host.agentView(agent), theirsView, agent.space);
125132 const q = queuedBy(p.theirs);
126133 return q ? { ...c, theirs: { ...c.theirs, agent: q.agent, message: q.message, queued: q.id } } : c;
Lines 144–153 at 318 (were 137–146 at 33)
137144 kind: "duplicate",
138145 name,
139146 file,
140− yours: { lines: [yours.start + 1, yours.end], text: yours.text + "\n" },
147+ yours: { lines: [yours.start + 1, yours.end], text: `${yours.text}\n` },
141148 theirs: {
142149 lines: [theirs.start + 1, theirs.end],
143− text: theirs.text + "\n",
150+ text: `${theirs.text}\n`,
144151 agent: q.agent,
145152 message: q.message,
146153 version: last(space),
Lines 156–179 at 318 (were 149–167 at 33)
149156 });
150157 }
151158 }
152− 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);
153160 }
154161 const view = host.agentView(agent);
162+ const auto = autoSettledOf(message);
155163 const settled: Settled[] = agent.marked
156164 .filter((r) => r.space === SHARED)
157165 .map((r) => {
158166 const lines = view.hasFile(r.file) ? view.lines(r.file).map((l) => l.text) : [];
159167 const lost = lostLines(lines, r);
168+ const held = heldMessage(agent, r.file);
169+ const by = auto.get(r.file);
160170 return {
161171 file: r.file,
162172 kept: keptOf(lines, r),
163173 theirs: { agent: r.agent, version: r.version },
164174 ...(lost.length > 0 ? { lost } : {}),
175+ ...(held ? { held } : {}),
176+ ...(by ? { auto: by } : {}),
165177 };
166178 });
167179 const id = host.queuedId() + 1;
Lines 240–252 at 318 (were 228–234 at 33)
228240} {
229241 host.needInit();
230242 const items = host.queued().slice(0, Math.max(0, n));
231− 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));
232250 const files = view.files();
233251 const modes = modesOf(view);
234252 const blobs = view.blobs();
Lines 265–273 at 318 (were 247–254 at 33)
247265 for (const q of host.queued().slice(0, Math.max(0, n))) {
248266 const agent = host.agentOf(q.agent);
249267 const space = host.shared();
250− const union = new Set([...host.setOf(space), ...q.changes]);
251− 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, {
252271 author: q.agent,
253272 message: q.message,
254273 time,
Lines 299–305 at 318 (were 280–286 at 33)
280299 host.reviewNews(agent, version, entries);
281300 host.queueNews(
282301 agent,
283− [{ 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}.` }],
284303 entries,
285304 );
286305 out.push({ id: q.id, version });
Lines 343–355 at 318 (were 324–336 at 33)
324343 ? `the project's check failed on it on top of version ${last(host.shared())}${tail ? `:\n${tail}` : ""}`
325344 : why === "withdrawn"
326345 ? "you withdrew it"
327− : `it builds on queued publish ${id}, which was pulled`;
346+ : `it builds on queued push ${id}, which was turned back`;
328347 host.queueNews(
329348 host.agentOf(q.agent),
330349 [
331350 {
332351 key: `pulled ${q.id}`,
333− 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.`,
334353 },
335354 ],
336355 entries,
Lines 369–375 at 318 (were 350–356 at 33)
350369 if (busy)
351370 throw new ProjectError(
352371 "conflict",
353− `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)`,
354373 );
355374 const pulled: number[] = [];
356375 for (const q of mine)
MCP
compare on this site's /mcp
CLI
abso diff 33 318 worker/project/queue.ts --json
JSON
/christopher/abso-core/compare/33..318?file=worker%2Fproject%2Fqueue.ts&format=json