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 148 to 149

Compare

+76 −35 in 9 places
Lines 1–6 at 149 (were 1–5 at 148)
11import { createHash } from "node:crypto";
22import type { Atom } from "../types.ts";
3+import { ProjectionAtomDescriptor } from "./projection-atom-index.ts";
34import type { ExperimentalMarkerProjection, MarkerState } from "./projection-marker.ts";
45import { adoptMovesStep } from "./projection-move-adoption.ts";
56
Lines 82–88 at 149 (were 81–87 at 148)
8182 }
8283 page(input: {
8384 previous: MarkerState;
84− atom: Atom;
85+ atom: Atom | ProjectionAtomDescriptor;
8586 remove: boolean;
8687 source: string;
8788 maxSteps: number;
Lines 102–137 at 149 (were 101–108 at 148)
101102 )
102103 throw Error("invalid atom adoption page bounds");
103104 const atom = input.atom;
104− const identity = digest([input.source, input.previous, atom, input.remove]);
105− if (digest(p.graph.atom(atom.id)) !== digest(atom)) throw Error("canonical adoption atom mismatch");
105+ const indexed = atom instanceof ProjectionAtomDescriptor ? atom : undefined;
106+ const full = indexed ? undefined : (atom as Atom);
107+ const identity = digest([
108+ input.source,
109+ input.previous,
110+ indexed ? [indexed.id, indexed.seq, indexed.digest] : atom,
111+ input.remove,
112+ ]);
113+ if (indexed) {
114+ if (p.graph.idOfSeq(indexed.seq) !== indexed.id) throw Error("canonical adoption atom mismatch");
115+ } else if (digest(p.graph.atom(atom.id)) !== digest(full)) throw Error("canonical adoption atom mismatch");
116+ const inserts = indexed?.count("inserts") ?? full!.inserts.length;
117+ const run = (i: number) =>
118+ indexed
119+ ? indexed.item("inserts", i)
120+ : { file: full!.inserts[i]!.file, parent: full!.inserts[i]!.parent, lines: full!.inserts[i]!.lines.length };
121+ const deps = indexed?.count("deps") ?? full!.deps.length;
122+ const dependency = (i: number) => (indexed ? indexed.item("deps", i) : full!.deps[i]!);
123+ const deletes = indexed?.count("deletes") ?? full!.deletes.length;
124+ const deletion = (i: number) => (indexed ? indexed.item("deletes", i) : full!.deletes[i]!);
125+ const attrs = indexed?.count("attrs") ?? full!.attrs?.length ?? 0;
126+ const attribute = (i: number) => (indexed ? indexed.item("attrs", i) : full!.attrs![i]!);
127+ const moves = indexed?.count("moves") ?? full!.moves?.length ?? 0;
128+ const fullFiles = indexed ? undefined : p.graph.filesOf(atom.id);
129+ const files = indexed?.count("files") ?? fullFiles!.length;
130+ const file = (i: number) => (indexed ? indexed.item("files", i) : fullFiles![i]!);
131+ const seqOf = (id: string) => {
132+ if (!p.graph.has(id)) throw Error("missing dependency");
133+ return Number(id.slice(1));
134+ };
106135 const collection = `atom-adoption:${this.task}`;
107136 const validate = () => {
108137 const result: unknown = input.validateSource();
Lines 150–168 at 149 (were 121–139 at 148)
121150 )
122151 throw Error("invalid or changed atom adoption cursor");
123152 p.assertContext(cursor.state);
124− if (cursor.run > atom.inserts.length || cursor.line > (atom.inserts[cursor.run]?.lines.length ?? 0))
153+ if (cursor.run > inserts || cursor.line > (cursor.run < inserts ? run(cursor.run).lines : 0))
125154 throw Error("invalid atom adoption line position");
126155 const limits: Record<Phase, number> = {
127− dependencies: atom.deps.length,
128− files: atom.inserts.length + 1,
156+ dependencies: deps,
157+ files: inserts + 1,
129158 lines: 0,
130− deletes: atom.deletes.length,
131− counts: atom.deps.length,
132− attributes: atom.attrs?.length ?? 0,
133− contributions: p.graph.filesOf(atom.id).length,
159+ deletes: deletes,
160+ counts: deps,
161+ attributes: attrs,
162+ contributions: files,
134163 membership: 0,
135164 moves: 0,
136− cleanup: atom.attrs?.length ?? 0,
165+ cleanup: attrs,
137166 done: 0,
138167 };
139168 if (cursor.index > limits[cursor.phase]) throw Error("invalid atom adoption phase position");
Lines 187–221 at 149 (were 158–192 at 148)
158187 cursor!.index = 0;
159188 };
160189 const state = cursor.state;
161− const contributionFiles = p.graph.filesOf(atom.id);
162191 while (cursor.phase !== "done" && steps < input.maxSteps) {
163192 steps++;
164193 switch (cursor.phase) {
165194 case "dependencies": {
166− if (input.remove || cursor.index === atom.deps.length) {
195+ if (input.remove || cursor.index === deps) {
167196 next();
168197 break;
169198 }
170− const id = atom.deps[cursor.index++]!;
171− if (!p.members.get(state.membership, p.graph.atom(id).seq)?.present) throw Error("missing dependency");
199+ const id = dependency(cursor.index++);
200+ if (!p.members.get(state.membership, seqOf(id))?.present) throw Error("missing dependency");
172201 break;
173202 }
174203 case "files": {
175− if (input.remove || cursor.index > atom.inserts.length) {
204+ if (input.remove || cursor.index > inserts) {
176205 next();
177206 break;
178207 }
179− p.ensureFile(state, cursor.index === 0 ? p.path : atom.inserts[cursor.index - 1]!.file);
208+ p.ensureFile(state, cursor.index === 0 ? p.path : run(cursor.index - 1).file);
180209 cursor.index++;
181210 break;
182211 }
183212 case "lines": {
184− if (cursor.run === atom.inserts.length) {
213+ if (cursor.run === inserts) {
185214 next();
186215 break;
187216 }
188− const run = atom.inserts[cursor.run]!;
189− if (cursor.line === run.lines.length) {
217+ const currentRun = run(cursor.run);
218+ if (cursor.line === currentRun.lines) {
190219 cursor.run++;
191220 cursor.line = 0;
192221 break;
Lines 231–241 at 149 (were 202–212 at 148)
202231 break;
203232 }
204233 case "deletes": {
205− if (cursor.index === atom.deletes.length) {
234+ if (cursor.index === deletes) {
206235 next();
207236 break;
208237 }
209− const marker = p.markers.get(state.locator, p.graph.lineN(atom.deletes[cursor.index++]!) + 1);
238+ const marker = p.markers.get(state.locator, p.graph.lineN(deletion(cursor.index++)) + 1);
210239 if (!marker) throw Error("missing deleted marker");
211240 state.sequence = p.sequence.update(state.sequence, {
212241 kind: "visibility",
Lines 245–255 at 149 (were 216–226 at 148)
216245 break;
217246 }
218247 case "counts": {
219− if (cursor.index === atom.deps.length) {
248+ if (cursor.index === deps) {
220249 next();
221250 break;
222251 }
223− const seq = p.graph.atom(atom.deps[cursor.index++]!).seq;
252+ const seq = seqOf(dependency(cursor.index++));
224253 const member = p.members.get(state.membership, seq);
225254 if (!member?.present || (input.remove && member.dependents < 1)) throw Error("invalid dependency count");
226255 state.membership = p.members.set(state.membership, seq, {
Lines 259–282 at 149 (were 230–254 at 148)
230259 break;
231260 }
232261 case "attributes": {
233− const attrs = atom.attrs ?? [];
234− if (cursor.index === attrs.length) {
262+ if (cursor.index === attrs) {
235263 next();
236264 break;
237265 }
238− const attr = attrs[cursor.index++]!;
266+ const attr = attribute(cursor.index++);
239267 const key = JSON.stringify([attr.file, attr.name]);
240268 if (!p.storage.read(`${collection}:attributes`, key)) {
241− p.updateAttributes(state, { ...atom, attrs: [attr] }, !input.remove);
269+ p.updateAttributes(state, { seq: atom.seq, attrs: [attr] }, !input.remove);
242270 p.storage.write(`${collection}:attributes`, key, true);
243271 }
244272 break;
245273 }
246274 case "contributions": {
247− if (cursor.index === contributionFiles.length) {
275+ if (cursor.index === files) {
248276 next();
249277 break;
250278 }
251− const path = contributionFiles[cursor.index++]!;
279+ const path = file(cursor.index++);
252280 p.ensureFile(state, path);
253281 const key = p.fileKey(path)!;
254282 const marker = p.markers.get(state.locator, key);
Lines 294–326 at 149 (were 266–285 at 148)
266294 next();
267295 break;
268296 case "moves":
269− if (atom.moves?.length) {
270− const result = adoptMovesStep(p, state, this.task, identity);
297+ if (moves) {
298+ const result = adoptMovesStep(
299+ p,
300+ state,
301+ this.task,
302+ identity,
303+ indexed
304+ ? {
305+ count: (id) => indexed.related(id).count("moves"),
306+ at: (id, k) => {
307+ const atom = indexed.related(id);
308+ return k < atom.count("moves") ? atom.item("moves", k) : undefined;
309+ },
310+ }
311+ : undefined,
312+ );
271313 Object.assign(state, result.state);
272314 if (!result.done) break;
273315 }
274316 next();
275317 break;
276318 case "cleanup": {
277− const attrs = atom.attrs ?? [];
278− if (cursor.index === attrs.length) {
319+ if (cursor.index === attrs) {
279320 next();
280321 break;
281322 }
282− const attr = attrs[cursor.index++]!;
323+ const attr = attribute(cursor.index++);
283324 p.storage.remove(`${collection}:attributes`, JSON.stringify([attr.file, attr.name]));
284325 break;
285326 }
MCP
compare on this site's /mcp
CLI
abso diff 148 149 src/engine/experimental/projection-atom-adoption.ts --json
JSON
/christopher/abso-core/compare/148..149?file=src%2Fengine%2Fexperimental%2Fprojection-atom-adoption.ts&format=json