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 142 to 143

Compare

+37 −18 in 17 places
Lines 12–18 at 143 (were 12–18 at 142)
1212// agents publish into under the same rules, and that lands in shared as one
1313// unit. Every agent works in one space at a time.
1414
15−import { type Atom, type AtomId, EngineError, Graph, type LineId, type View } from "../../src/engine/index.ts";
15+import { type Atom, type AtomId, EngineError, Graph, type LineId, type ReadView } from "../../src/engine/index.ts";
1616import {
1717 CachedStateStorage,
1818 differenceSet,
Lines 406–412 at 143 (were 406–412 at 142)
406406 : entryAt
407407 ? new Graph({ texts: (seq) => stored(seq).inserts.map((r) => r.lines), lists: (seq) => stored(seq) })
408408 : new Graph();
409− this.#views = new ViewCache(this.#graph);
409+ this.#views = new ViewCache(this.#graph, options.readViewProvider);
410410 this.#paths = new PathIndex({
411411 graph: this.#graph,
412412 at: (space, version) => this.#at(space, version),
Lines 606–613 at 143 (were 606–613 at 142)
606606 return modesOf(this.#sharedView());
607607 }
608608
609− /** Shared as a View, for reading lines (blame, why). Don't hold on to it across calls. */
610− sharedView(): View {
609+ /** Shared as a ReadView, for reading lines (blame, why). Don't hold on to it across calls. */
610+ sharedView(): ReadView {
611611 return this.#sharedView();
612612 }
613613
Lines 621–627 at 143 (were 621–627 at 142)
621621 * The view is laid out on first use: where asks every agent, most have no changes, and a big project has more
622622 * agents than the view cache holds, so building every view cost each call about 0.7 s.
623623 */
624− draftOf(agentName: string): { atoms: AtomId[]; readonly view: View } | undefined {
624+ draftOf(agentName: string): { atoms: AtomId[]; readonly view: ReadView } | undefined {
625625 const agent = this.#agents.get(agentName);
626626 if (!agent) return undefined;
627627 const view = () => this.#agentView(agent);
Lines 757–763 at 143 (were 757–763 at 142)
757757 * last makes it one-way: a file kept whole stays whole while it exists,
758758 * even if it shrinks or the rule changes, so it never flips back and forth.
759759 */
760− #isWhole(path: string, length: number, view: View | undefined, rules: readonly string[]): boolean {
760+ #isWhole(path: string, length: number, view: ReadView | undefined, rules: readonly string[]): boolean {
761761 return hostedIsWhole(this.#wholeHost, path, length, view, rules);
762762 }
763763
Lines 765–771 at 143 (were 765–771 at 142)
765765 #wholeOut(
766766 files: Readonly<Record<string, string | null>>,
767767 blobs: Readonly<Record<string, string>>,
768− view: View | undefined,
768+ view: ReadView | undefined,
769769 config?: string,
770770 ): { files: Record<string, string | null>; blobs: Record<string, string> } {
771771 return hostedWholeOut(this.#wholeHost, files, blobs, view, config);
Lines 1085–1091 at 143 (were 1085–1091 at 142)
10851085 */
10861086 #mergeIdentical(
10871087 agent: AgentState,
1088− before: View,
1088+ before: ReadView,
10891089 oldBase: ReadonlySet<AtomId>,
10901090 oldVersion: number,
10911091 time: number,
Lines 1172–1178 at 143 (were 1172–1178 at 142)
11721172 }
11731173
11741174 /** The collided changes behind each block whose marker lines `atom` deletes (#11). */
1175− #markersSettled(agent: AgentState, view: View, atom: Atom): AtomId[] {
1175+ #markersSettled(agent: AgentState, view: ReadView, atom: Atom): AtomId[] {
11761176 return hostedMarkersSettled(this.#markerHost, agent, view, atom);
11771177 }
11781178
Lines 1418–1424 at 143 (were 1418–1424 at 142)
14181418 * the one file ever in the view it matches, for a file since taken out.
14191419 * A path that matches two files is answered exactly.
14201420 */
1421− spellingIn(view: View, path: string): string {
1421+ spellingIn(view: ReadView, path: string): string {
14221422 if (view.hasFile(path)) return path;
14231423 const key = pathKey(path);
14241424 const live = view.knownPaths().filter((p) => pathKey(p) === key && view.hasFile(p));
Lines 1660–1666 at 143 (were 1660–1666 at 142)
16601660 return versionCompare(this.#logHost, ...args);
16611661 }
16621662
1663− /** A version of shared (or of a named draft) as a View (version-log.ts). */
1663+ /** A version of shared (or of a named draft) as a ReadView (version-log.ts). */
16641664 viewAt(...args: Tail<Parameters<typeof versionViewAt>>): ReturnType<typeof versionViewAt> {
16651665 return versionViewAt(this.#logHost, ...args);
16661666 }
Lines 1725–1740 at 143 (were 1725–1730 at 142)
17251725 this.#movesHost ??= {
17261726 graph: this.#graph,
17271727 draft: (agent) => this.#unqueuedDraft(agent),
1728+ beforeDraft: (agent, draft) => {
1729+ const base = this.#at(this.#spaceOf(agent), agent.base);
1730+ if (draft.some((id) => base.has(id)))
1731+ return this.#view(differenceSet(this.#agentView(agent).set, new StableOverlaySet(draft)));
1732+ const removed = new Set(draft),
1733+ kept = agent.mine.filter((id) => !removed.has(id));
1734+ return kept.length === 0
1735+ ? this.#viewAt(this.#spaceOf(agent), agent.base)
1736+ : this.#viewKeyed(`a ${agent.space}@${agent.base}+${kept.join(",")}`, () => unionOverlay(base, kept));
1737+ },
17281738 agentView: (agent) => this.#agentView(agent),
17291739 view: (set) => this.#view(set),
17301740 apply: (entry) => this.#apply(entry),
Lines 1933–1942 at 143 (were 1923–1928 at 142)
19231933 this.#enqueue(agent, message, time, draft, resolves, entries),
19241934 view: (set) => this.#view(set),
19251935 requireClosed: (tie, union) => this.#requireClosed(tie, union),
1936+ spaceOverlay: (space, atoms) =>
1937+ this.#viewKeyed(`a ${space.name}@${last(space)}+${atoms.join(",")}`, () =>
1938+ unionOverlay(this.#setOf(space), atoms),
1939+ ),
19261940 newerFor: (agent) => this.#newerFor(agent),
19271941 currentChange: (agent, time) => this.#currentChange(agent, time),
19281942 apply: (entry) => this.#apply(entry),
Lines 2203–2212 at 143 (were 2189–2194 at 142)
21892203 setOf: (space) => this.#setOf(space),
21902204 view: (set) => this.#view(set),
21912205 sharedView: () => this.#sharedView(),
2206+ sharedOverlay: (atoms) =>
2207+ this.#viewKeyed(`a @${last(this.#shared)}+${atoms.join(",")}`, () =>
2208+ unionOverlay(this.#setOf(this.#shared), atoms),
2209+ ),
21922210 touchedFiles: (ids, views) => this.#touchedFiles(ids, views),
21932211 };
21942212 return this.#checkClashes;
Lines 2493–2499 at 143 (were 2475–2481 at 142)
24752493 return new Set([...this.#at(this.#spaceOf(agent), agent.base), ...agent.mine]);
24762494 }
24772495
2478− #agentView(agent: AgentState): View {
2496+ #agentView(agent: AgentState): ReadView {
24792497 return this.#viewKeyed(this.#agentViewKey(agent), () => {
24802498 const base = this.#at(this.#spaceOf(agent), agent.base);
24812499 return base instanceof StableSet
Lines 2511–2532 at 143 (were 2493–2513 at 142)
24932511 }
24942512
24952513 /** A space at a version: published versions never change, so the key is just their names (#46). */
2496− #viewAt(space: Space, version: number): View {
2514+ #viewAt(space: Space, version: number): ReadView {
24972515 return this.#viewKeyed(`v ${space.name}@${version}`, () => this.#at(space, version));
24982516 }
24992517
2500− #sharedView(): View {
2518+ #sharedView(): ReadView {
25012519 return this.#viewAt(this.#shared, last(this.#shared));
25022520 }
25032521
25042522 /** A view of a set, cached by the set's exact contents (views.ts). */
2505− #view(set: ReadonlySet<AtomId>): View {
2523+ #view(set: ReadonlySet<AtomId>): ReadView {
2524+ this.#views.assertUnkeyedAllowed();
25062525 return this.#views.view(this.#closed(set));
25072526 }
25082527
25092528 /** A view cached under `key` (views.ts). */
2510− #viewKeyed(key: string, set: () => ReadonlySet<AtomId>): View {
2529+ #viewKeyed(key: string, set: () => ReadonlySet<AtomId>): ReadView {
25112530 return this.#views.keyed(key, () => this.#closed(set()));
25122531 }
25132532
Lines 2691–2697 at 143 (were 2672–2678 at 142)
26722691 );
26732692 }
26742693
2675− #describe(pair: Pair, yoursView: View, theirsView: View, spaceName: string): Collision {
2694+ #describe(pair: Pair, yoursView: ReadView, theirsView: ReadView, spaceName: string): Collision {
26762695 return describePair(
26772696 this.#graph,
26782697 (atom, space) => this.#origin(atom, space),
Lines 2702–2708 at 143 (were 2683–2689 at 142)
26832702 );
26842703 }
26852704
2686− #touchedFiles(ids: Iterable<AtomId>, views: readonly View[]): Set<string> {
2705+ #touchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string> {
26872706 return touchedFiles(this.#graph, ids, views);
26882707 }
26892708
MCP
compare on this site's /mcp
CLI
abso diff 142 143 worker/project/project.ts --json
JSON
/christopher/abso-core/compare/142..143?file=worker%2Fproject%2Fproject.ts&format=json