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

Compare

+23 −13 in 10 places
Lines 1–12 at 318 (were 1–10 at 91)
11// Add the agent's draft to its space. Writes go through PublishHost; today
22// the host is Project. Ingest calls publishDraft, the inner step.
33
4−import { type AtomId, buildAtom, type Hunk, joinLines, type View } from "../../src/engine/index.ts";
4+import { type AtomId, buildAtom, type Hunk, joinLines, type ReadView } from "../../src/engine/index.ts";
5+import { differenceSet, unionOverlay } from "../../src/engine/state-source.ts";
6+import { autoSettledOf } from "./autosettle.ts";
57import type { Pair } from "./collisions.ts";
68import type { DefinitionCollision } from "./definition-rule.ts";
7−import { keptOf, lostLines, settleLines } from "./markers.ts";
9+import { heldMessage, keptOf, lostLines, settleLines } from "./markers.ts";
810import { ProjectError } from "./project-error.ts";
911import type { AgentState, Collision, Entry, Meta, Mode, PublishAnswer, Settled } from "./project-types.ts";
1012import { last, SHARED, type Space } from "./spaces.ts";
Lines 24–33 at 318 (were 22–31 at 91)
2224 strandedFiles(draft: readonly AtomId[], set: ReadonlySet<AtomId>): string[];
2325 setOf(space: Space): ReadonlySet<AtomId>;
2426 markedFiles(agent: AgentState): string[];
25− agentView(agent: AgentState): View;
27+ agentView(agent: AgentState): ReadView;
2628 recordFile(
2729 agent: AgentState,
28− view: View,
30+ view: ReadView,
2931 path: string,
3032 text: string | null | undefined,
3133 time: number,
Lines 49–55 at 318 (were 47–52 at 91)
4749 time: number,
4850 collisions: Collision[],
4951 entries: Entry[],
52+ message?: string,
5053 ): { ok: false; collisions: Collision[] };
5154 markerCollisions(agent: AgentState): Collision[];
5255 enqueue(
Lines 60–69 at 318 (were 57–65 at 91)
5760 resolves: readonly AtomId[],
5861 entries: Entry[],
5962 ): PublishAnswer;
60− view(set: ReadonlySet<AtomId>): View;
63+ view(set: ReadonlySet<AtomId>): ReadView;
64+ spaceOverlay?(space: Space, atoms: readonly AtomId[]): ReadView;
6165 requireClosed(tie: { deps: readonly AtomId[] }, union: ReadonlySet<AtomId>): void;
62− newerFor(agent: AgentState): Set<AtomId>;
66+ newerFor(agent: AgentState): ReadonlySet<AtomId>;
6367 currentChange(agent: AgentState, time: number): number | undefined;
6468 apply(entry: Entry): void;
6569 newsForOthers(publisher: AgentState, space: Space, version: number, entries: Entry[]): void;
Lines 85–91 at 318 (were 81–87 at 91)
8185 time: number,
8286 options: { asIs?: boolean } = {},
8387): PublishAnswer {
84− if (typeof message !== "string") throw new ProjectError("bad-request", "publish needs a message");
88+ if (typeof message !== "string") throw new ProjectError("bad-request", "push needs a message");
8589 const known = host.agents.get(agentName);
8690 if (known && known.space === SHARED)
8791 host.checkClash(host.draft(known), host.queueOn() ? host.queuedAtoms(known.name) : undefined);
Lines 110–117 at 318 (were 106–113 at 91)
106110 if (stranded.length > 0) {
107111 throw new ProjectError(
108112 "conflict",
109− `your unpublished changes to ${stranded.join(", ")} build on lines a drop took out of shared; ` +
110− `restore those files (abso restore ${stranded.join(" ")}), sync, and make the change again`,
113+ `your unpushed changes to ${stranded.join(", ")} build on lines a drop took out of shared; ` +
114+ `restore those files (abso restore ${stranded.join(" ")}), pull, and make the change again`,
111115 );
112116 }
113117 // asIs (#11): every block of markers keeps both sides, and the publish says which files it settled that way.
Lines 130–143 at 318 (were 126–139 at 91)
126130 const draft = host.draft(agent);
127131 if (draft.length === 0) return { ok: true, version: last(space), changes: 0 };
128132 const now = host.setOf(space);
129− const union = new Set([...now, ...draft]);
133+ const union = unionOverlay(now, draft);
130134 const newer = host.newerFor(agent);
131135 const collisions = [
132136 ...host.pairs(draft, newer, union).map((p) => host.collision(agent, p)),
133137 ...host.definitionCollisions(agent, newer).map((d) => d.collision),
134138 ...host.duplicates(agent),
135139 ];
136− if (collisions.length > 0) return host.refuse(agent, space, "publish", time, collisions, entries);
140+ if (collisions.length > 0) return host.refuse(agent, space, "publish", time, collisions, entries, message);
137141 // Settled means the markers are gone (#11): refused while the draft adds any.
138142 const marked = host.markerCollisions(agent);
139143 if (marked.length > 0) return host.refuse(agent, space, "publish", time, marked, entries);
Lines 147–153 at 318 (were 143–149 at 91)
143147 // (#37: twenty goals twice, shared red for three versions). So
144148 // that is refused unless the agent says to publish as it is (asIs); then,
145149 // like any other seen collision, publishing settles it.
146− const seen = host.pairs(draft, new Set([...now].filter((id) => !newer.has(id))), union);
150+ const seen = host.pairs(draft, differenceSet(now, newer), union);
147151 if (!asIs) {
148152 const untouched = seen
149153 .map((p) => host.collision(agent, p))
Lines 158–165 at 318 (were 154–160 at 91)
154158 const resolves = [...new Set(seen.flatMap((p) => [p.yours, p.theirs]))];
155159 if (space.name === SHARED && !direct && host.queueOn())
156160 return host.enqueue(agent, message, time, draft, resolves, entries);
157− const tie = buildAtom(host.view(union), { author: agent.name, message, time, needs: draft, resolves });
161+ const candidate = host.spaceOverlay ? host.spaceOverlay(space, draft) : host.view(union);
162+ const tie = buildAtom(candidate, { author: agent.name, message, time, needs: draft, resolves });
158163 host.requireClosed(tie, union);
159164 const version = last(space) + 1;
160165 const othersPublished = space.versions.slice(agent.base + 1).some((p) => p.agent !== agent.name);
Lines 170–190 at 318 (were 165–180 at 91)
165170 .map((p) => ({ version: p.version, agent: p.agent, message: p.message }));
166171 // What each marked collision kept, judged from the file as published (#11).
167172 const view = host.agentView(agent);
173+ const auto = autoSettledOf(message);
168174 const settled: Settled[] = agent.marked
169175 .filter((r) => r.space === space.name)
170176 .map((r) => {
171177 const lines = view.hasFile(r.file) ? view.lines(r.file).map((l) => l.text) : [];
172178 const lost = lostLines(lines, r);
179+ const held = heldMessage(agent, r.file);
180+ const by = auto.get(r.file);
173181 return {
174182 file: r.file,
175183 kept: keptOf(lines, r),
176184 theirs: { agent: r.agent, version: r.version },
177185 ...(lost.length > 0 ? { lost } : {}),
186+ ...(held ? { held } : {}),
187+ ...(by ? { auto: by } : {}),
178188 };
179189 });
180190 entries.push({
MCP
compare on this site's /mcp
CLI
abso diff 91 318 worker/project/publish.ts --json
JSON
/christopher/abso-core/compare/91..318?file=worker%2Fproject%2Fpublish.ts&format=json