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

Compare

+26 −4 in 6 places
Lines 6–12 at 318 (were 6–11 at 248)
66import { claimantsAmong, describeSide, fileOfKey, pairsFrom } from "./collisions.ts";
77import type { DefinitionRule } from "./definition-rule.ts";
88import { type Definition, definedTwice } from "./definitions.ts";
9+import { definitionsBytes, type KeptParts } from "./kept-parts.ts";
910import { pathKey } from "./pathkey.ts";
1011import type { CollisionSide, DraftCollision } from "./project-types.ts";
1112import { last, SHARED, type Space } from "./spaces.ts";
Lines 29–38 at 318 (were 28–33 at 248)
2829 /** Shared now with these agents' drafts on top. */
2930 draftsView(agents: readonly Agent[]): ReadView;
3031 touchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string>;
32+ /** What collisions keep between calls (kept-parts.ts), when the project keeps any. */
33+ keptParts?(): KeptParts | undefined;
34+ /** A key naming everything a draft's part of the answer depends on: shared's version, its base and its atoms. */
35+ draftKey(agent: Agent): string;
3136}
3237
3338/**
Lines 104–119 at 318 (were 99–104 at 248)
99104 // Shared now with each agent's draft on top (project.ts, draftsView): kept between calls while shared and the
100105 // draft stay the same, and laid out as shared is for every file the draft doesn't touch (abso Capacity).
101106 const nowViewOf = (agent: Agent) => host.draftsView([agent]);
107+ // Each draft's uses and changed definitions, and each pair's names defined twice, kept between calls (kept-parts.ts,
108+ // abso Capacity): what this call doesn't use is dropped at its end.
109+ const parts = host.keptParts?.();
110+ const keys = new Map<Agent, string>();
111+ const keyOf = (agent: Agent) => {
112+ let key = keys.get(agent);
113+ if (key === undefined) keys.set(agent, (key = host.draftKey(agent)));
114+ return key;
115+ };
116+ parts?.startRound();
102117 // Each agent's touched files once, not once per pair (abso Capacity).
103118 const touched = new Map<Agent, Set<string>>();
104119 const touchedBy = (agent: Agent) => {
Lines 169–183 at 318 (were 154–163 at 248)
154169 const mineA = new Set(draftA);
155170 const mineB = new Set(draftB);
156171 const filesA = touchedBy(a);
172+ const twiceIn = (file: string): ReadonlyMap<string, Definition[]> => {
173+ const make = () => {
174+ both ??= host.draftsView([a, b]);
175+ return both.hasFile(file) ? definedTwice(both, file) : new Map<string, Definition[]>();
176+ };
177+ return parts ? parts.get(`twice ${keyOf(a)} | ${keyOf(b)} ${file}`, make, definitionsBytes) : make();
178+ };
157179 for (const file of [...touchedBy(b)].filter((f) => filesA.has(f)).toSorted()) {
158− both ??= host.draftsView([a, b]);
159− if (!both.hasFile(file)) continue;
160− for (const [name, defs] of definedTwice(both, file)) {
180+ for (const [name, defs] of twiceIn(file)) {
161181 const by = (mine: Set<AtomId>) => defs.find((d) => d.lines.some((l) => mine.has(host.graph.lineAtom(l)!)));
162182 const dA = by(mineA);
163183 const dB = by(mineB);
Lines 197–204 at 318 (were 177–183 at 248)
177197 }
178198 // Definitions: b's new lines use a name whose definition a's changes change.
179199 const nowView = () => nowViewOf(a);
180− for (const d of host.definitionRule().collisions(draftSet(b), viewB, sharedView, nowView, newer, SHARED)) {
200+ const kept = parts ? { parts, uses: keyOf(b), changed: keyOf(a) } : undefined;
201+ for (const d of host.definitionRule().collisions(draftSet(b), viewB, sharedView, nowView, newer, SHARED, kept)) {
181202 const c = d.collision;
182203 out.push({
183204 kind: "definition",
Lines 210–216 at 318 (were 189–194 at 248)
189210 }
190211 }
191212 }
213+ parts?.endRound();
192214 const fileKey = options.file !== undefined ? pathKey(options.file) : undefined;
193215 const folderParts =
194216 options.folder !== undefined ? options.folder.split("/").filter((s) => s !== "" && s !== ".") : undefined;
MCP
compare on this site's /mcp
CLI
abso diff 248 318 worker/project/draft-collisions.ts --json
JSON
/christopher/abso-core/compare/248..318?file=worker%2Fproject%2Fdraft-collisions.ts&format=json