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

Compare

+31 −15 in 6 places
Lines 2–12 at 318 (were 2–11 at 232)
22// is the project in memory.
33
44import { type AtomId, type Graph, parseKey, type ReadView } from "../../src/engine/index.ts";
5−import { StableSet, unionOverlay } from "../../src/engine/state-source.ts";
5+import { StableSet } from "../../src/engine/state-source.ts";
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 26–38 at 318 (were 25–32 at 232)
2526 definitionRule(): DefinitionRule;
2627 draft(agent: Agent): AtomId[];
2728 agentView(agent: Agent): ReadView;
28− view(set: ReadonlySet<AtomId>): ReadView;
29+ /** Shared now with these agents' drafts on top. */
30+ draftsView(agents: readonly Agent[]): ReadView;
2931 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;
3036}
3137
3238/**
Lines 101–119 at 318 (were 95–110 at 232)
95101 if (!set) draftSets.set(agent, (set = new Set(host.draft(agent))));
96102 return set;
97103 };
98− // Shared now with each agent's draft on top, once per agent. Over shared's view's own set (abso Capacity): a view's set
99− // is closed under dependencies anyway, so shared's closed set and the drafts lay out what shared's atoms and the drafts
100− // do, and only the drafts' atoms are walked to close it.
101− const withDraftsView = (...drafts: readonly AtomId[][]) => host.view(unionOverlay(sharedView.set, drafts.flat()));
102− const nowViews = new Map<Agent, ReadView>();
103− const nowViewOf = (agent: Agent) => {
104− let view = nowViews.get(agent);
105− if (!view) nowViews.set(agent, (view = withDraftsView(host.draft(agent))));
106− return view;
104+ // Shared now with each agent's draft on top (project.ts, draftsView): kept between calls while shared and the
105+ // draft stay the same, and laid out as shared is for every file the draft doesn't touch (abso Capacity).
106+ 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;
107115 };
116+ parts?.startRound();
108117 // Each agent's touched files once, not once per pair (abso Capacity).
109118 const touched = new Map<Agent, Set<string>>();
110119 const touchedBy = (agent: Agent) => {
Lines 169–183 at 318 (were 160–169 at 232)
160169 const mineA = new Set(draftA);
161170 const mineB = new Set(draftB);
162171 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+ };
163179 for (const file of [...touchedBy(b)].filter((f) => filesA.has(f)).toSorted()) {
164− both ??= withDraftsView(draftA, draftB);
165− if (!both.hasFile(file)) continue;
166− for (const [name, defs] of definedTwice(both, file)) {
180+ for (const [name, defs] of twiceIn(file)) {
167181 const by = (mine: Set<AtomId>) => defs.find((d) => d.lines.some((l) => mine.has(host.graph.lineAtom(l)!)));
168182 const dA = by(mineA);
169183 const dB = by(mineB);
Lines 197–204 at 318 (were 183–189 at 232)
183197 }
184198 // Definitions: b's new lines use a name whose definition a's changes change.
185199 const nowView = () => nowViewOf(a);
186− 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)) {
187202 const c = d.collision;
188203 out.push({
189204 kind: "definition",
Lines 210–216 at 318 (were 195–200 at 232)
195210 }
196211 }
197212 }
213+ parts?.endRound();
198214 const fileKey = options.file !== undefined ? pathKey(options.file) : undefined;
199215 const folderParts =
200216 options.folder !== undefined ? options.folder.split("/").filter((s) => s !== "" && s !== ".") : undefined;
MCP
compare on this site's /mcp
CLI
abso diff 232 318 worker/project/draft-collisions.ts --json
JSON
/christopher/abso-core/compare/232..318?file=worker%2Fproject%2Fdraft-collisions.ts&format=json