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 108 to 109

Compare

+37 −8 in 7 places
Lines 11–17 at 109 (were 11–16 at 108)
1111
1212import type { Graph, RelocationInfo } from "./graph.ts";
1313import { isStartNode } from "./keys.ts";
14+import { StableSet } from "./state-source.ts";
1415import { joinLines } from "./text.ts";
1516import { type AtomId, type AtomSet, EngineError, type LineId, type NodeId } from "./types.ts";
1617
Lines 91–98 at 109 (were 90–96 at 108)
9091export class View {
9192 readonly graph: Graph;
9293 /** The set, made from #in the first time it's asked for: a view keeps a byte per atom, not a copy of the set (#46). */
93− #set: Set<AtomId> | undefined;
94+ #set: AtomSet | undefined;
95+ readonly #stable: StableSet<AtomId> | undefined;
9496 #files = new Map<string, FileState>();
9597 /** Every file the set wrote in, sorted; worked out the first time it's asked for. */
9698 #knownList: string[] | undefined;
Lines 111–144 at 109 (were 109–122 at 108)
109111 #textCache: { path: string; text: string } | undefined;
110112
111113 constructor(graph: Graph, set: Iterable<AtomId>) {
114+ this.graph = graph;
115+ if (set instanceof StableSet) {
116+ this.#stable = set;
117+ this.#set = set;
118+ this.#in = new Uint8Array(0);
119+ for (const id of set) {
120+ const atom = graph.atom(id);
121+ for (const dependency of atom.deps) {
122+ graph.atom(dependency);
123+ if (!set.has(dependency))
124+ throw new EngineError("not-closed", `set is not closed: ${id} depends on ${dependency}`);
125+ }
126+ }
127+ this.#movers = graph.movers().filter((id) => set.has(id));
128+ this.#relocs = this.#movers.length === 0 ? new Map() : undefined;
129+ this.#relocsN = this.#movers.length === 0 ? new Map() : undefined;
130+ return;
131+ }
112132 const inSet = new Uint8Array(graph.size);
113− const atoms: { readonly id: AtomId; readonly deps: readonly AtomId[] }[] = [];
114133 for (const id of set) {
115134 const atom = graph.atom(id);
116135 inSet[atom.seq] = 1;
117− atoms.push(atom);
118136 }
119− for (const atom of atoms) {
137+ // Validate one atom at a time. Keeping all decoded atoms here defeats
138+ // storage-backed Graph reads even though the view only needs membership.
139+ for (let seq = 0; seq < inSet.length; seq++) {
140+ if (inSet[seq] !== 1) continue;
141+ const atom = graph.atom(graph.idOfSeq(seq));
120142 for (const d of atom.deps) {
121143 if (inSet[graph.atom(d).seq] !== 1)
122144 throw new EngineError("not-closed", `set is not closed: ${atom.id} depends on ${d}`);
Lines 163–169 at 109 (were 141–146 at 108)
141163
142164 /** Whether the atom with this seq is in the set. */
143165 #has(seq: number): boolean {
166+ if (this.#stable) return this.#stable.has(this.graph.idOfSeq(seq));
144167 return seq < this.#in.length && this.#in[seq] === 1;
145168 }
146169
Lines 295–302 at 109 (were 272–278 at 108)
272295 if (relocs) {
273296 for (const r of graph.relocatedToCode(code)) {
274297 const n = graph.lineN(r.line);
275− if (relocs.get(n)?.r !== r) continue;
298+ const selected = relocs.get(n)?.r;
299+ if (!selected || selected.atom !== r.atom || selected.k !== r.k) continue;
276300 const seq = graph.atom(r.atom).seq;
277301 out.push({ n, replaces: 0, lamport: graph.lamportOfSeq(seq), seq, k: r.k });
278302 }
Lines 360–371 at 109 (were 336–343 at 108)
336360 get #known(): string[] {
337361 if (!this.#knownList) {
338362 const known = new Set<string>();
339− for (let seq = 0; seq < this.#in.length; seq++)
340− if (this.#in[seq] === 1) for (const file of this.graph.filesOf(this.graph.idOfSeq(seq))) known.add(file);
363+ if (this.#stable) {
364+ for (const id of this.#stable) for (const file of this.graph.filesOf(id)) known.add(file);
365+ } else {
366+ for (let seq = 0; seq < this.#in.length; seq++)
367+ if (this.#in[seq] === 1) for (const file of this.graph.filesOf(this.graph.idOfSeq(seq))) known.add(file);
368+ }
341369 this.#knownList = [...known].sort();
342370 }
343371 return this.#knownList;
Lines 498–505 at 109 (were 470–476 at 108)
470498 n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#movers.length;
471499 n += MAP_HEADER_BYTES; // #files exists from construction.
472500 n += MAP_HEADER_BYTES; // #fileOf exists from construction.
473− if (this.#set) n += OBJECT_BYTES + SET_ENTRY_BYTES * this.#set.size;
501+ if (this.#stable) n += this.#stable.retainedBytes;
502+ else if (this.#set) n += OBJECT_BYTES + SET_ENTRY_BYTES * this.#set.size;
474503 if (this.#knownList) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#knownList.length;
475504 if (this.#relocs) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * this.#relocs.size;
476505 if (this.#relocsN) n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + OBJECT_BYTES) * this.#relocsN.size;
MCP
compare on this site's /mcp
CLI
abso diff 108 109 src/engine/view.ts --json
JSON
/christopher/abso-core/compare/108..109?file=src%2Fengine%2Fview.ts&format=json