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 145 to 146

Compare

+41 −41 in 2 places
Lines 119–128 at 146 (were 119–168 at 145)
119119 return this.storage.transaction(() => {
120120 const state = { ...previous };
121121 const sequence = this.sequence;
122− const insert = (rank: number, text: string, hidden = false): number => {
123− const id = state.sequence.next;
124− state.sequence = sequence.update(state.sequence, { kind: "insert", rank, text });
125− if (hidden) state.sequence = sequence.update(state.sequence, { kind: "visibility", id, delta: 1 });
126− return id;
127− };
128122 this.ensureFile(state, this.path);
129123 for (const run of atom.inserts) this.ensureFile(state, run.file);
130124 let k = 0;
131− for (const run of atom.inserts)
132− for (const text of run.lines) {
133− const line = `${atom.id}.${k++}`,
134− n = this.graph.lineN(line),
135− parent = this.graph.parentCodeOf(n);
136− if (n + 1 >= 0x80000000) throw Error("prototype line identity limit");
137− const existing = this.markers.get(state.locator, n + 1);
138− if (existing) {
139− state.sequence = sequence.update(state.sequence, { kind: "visibility", id: existing.enter, delta: -1 });
140− continue;
141− }
142− const parentMarker = this.markers.get(state.locator, this.parentKey(parent));
143− if (!parentMarker) throw Error("missing parent marker");
144− const parentKey = this.parentKey(parent);
145− const index = this.priorities;
146− const root = this.childRoots.get(state.children, parentKey)?.root ?? null;
147− const seq = this.graph.writerSeqOf(n);
148− const key = orderedChildKey({
149− n,
150− replaces: this.graph.replacesN(n) ? 1 : 0,
151− lamport: this.graph.lamportOfSeq(seq),
152− seq,
153− k: this.graph.kOf(n),
154− });
155− const preceding = index.before(root, key);
156− const anchor =
157− preceding === undefined
158− ? parentMarker.enter
159− : required(this.markers.get(state.locator, preceding + 1)).exit;
160− state.children = this.childRoots.set(state.children, parentKey, { root: index.insert(root, key, n) });
161− const at = sequence.rank(state.sequence, anchor) + 1;
162− const enter = insert(at, line),
163− exit = insert(at + 1, `${line}:end`, true);
164− state.locator = this.markers.set(state.locator, n + 1, { kind: "line", enter, exit, parentKey, key });
165− }
125+ for (const run of atom.inserts) for (const _ of run.lines) this.insertLine(state, `${atom.id}.${k++}`);
166126 for (const line of atom.deletes) {
167127 const marker = this.markers.get(state.locator, this.graph.lineN(line) + 1);
168128 if (!marker) throw Error("missing deleted marker");
Lines 139–184 at 146 (were 179–184 at 145)
179139 return atom.moves?.length ? this.reconcileMoves(state) : state;
180140 });
181141 }
142+ /** One canonical line insertion; used by atomic apply and resumable inactive adoption. */
143+ insertLine(state: MarkerState, line: string): void {
144+ this.assertContext(state);
145+ const sequence = this.sequence;
146+ const insert = (rank: number, text: string, hidden = false): number => {
147+ const id = state.sequence.next;
148+ state.sequence = sequence.update(state.sequence, { kind: "insert", rank, text });
149+ if (hidden) state.sequence = sequence.update(state.sequence, { kind: "visibility", id, delta: 1 });
150+ return id;
151+ };
152+ const n = this.graph.lineN(line),
153+ parent = this.graph.parentCodeOf(n);
154+ if (n + 1 >= 0x80000000) throw Error("prototype line identity limit");
155+ const existing = this.markers.get(state.locator, n + 1);
156+ if (existing) {
157+ state.sequence = sequence.update(state.sequence, { kind: "visibility", id: existing.enter, delta: -1 });
158+ return;
159+ }
160+ const parentMarker = this.markers.get(state.locator, this.parentKey(parent));
161+ if (!parentMarker) throw Error("missing parent marker");
162+ const parentKey = this.parentKey(parent);
163+ const index = this.priorities;
164+ const root = this.childRoots.get(state.children, parentKey)?.root ?? null;
165+ const seq = this.graph.writerSeqOf(n);
166+ const key = orderedChildKey({
167+ n,
168+ replaces: this.graph.replacesN(n) ? 1 : 0,
169+ lamport: this.graph.lamportOfSeq(seq),
170+ seq,
171+ k: this.graph.kOf(n),
172+ });
173+ const preceding = index.before(root, key);
174+ const anchor =
175+ preceding === undefined ? parentMarker.enter : required(this.markers.get(state.locator, preceding + 1)).exit;
176+ state.children = this.childRoots.set(state.children, parentKey, { root: index.insert(root, key, n) });
177+ const at = sequence.rank(state.sequence, anchor) + 1;
178+ const enter = insert(at, line),
179+ exit = insert(at + 1, `${line}:end`, true);
180+ state.locator = this.markers.set(state.locator, n + 1, { kind: "line", enter, exit, parentKey, key });
181+ }
182182 removeDeleter(previous: MarkerState, atom: Atom): MarkerState {
183183 return this.removeAtom(previous, atom);
184184 }
MCP
compare on this site's /mcp
CLI
abso diff 145 146 src/engine/experimental/projection-marker.ts --json
JSON
/christopher/abso-core/compare/145..146?file=src%2Fengine%2Fexperimental%2Fprojection-marker.ts&format=json