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

Compare

+47 −13 in 4 places
Lines 1–13 at 318 (were 1–12 at 48)
11// Land a named draft in shared as one unit. Writes go through LandHost; today
22// the host is Project. Ingest and pluck call landDraft, the inner step.
33
4−import { type AtomId, buildAtom, type Graph, type View } from "../../src/engine/index.ts";
4+import { type AtomId, buildAtom, type Graph, type ReadView } from "../../src/engine/index.ts";
5+import { differenceSet, StableOverlaySet, unionOverlay } from "../../src/engine/state-source.ts";
56import type { Pair } from "./collisions.ts";
67import type { DefinitionRule } from "./definition-rule.ts";
78import { ProjectError } from "./project-error.ts";
89import type { AgentState, Collision, Entry, LandAnswer } from "./project-types.ts";
9−import { SHARED, type Space, sharedBaseOf } from "./spaces.ts";
10+import { SHARED, SharedAdditions, type Space, sharedBaseOf } from "./spaces.ts";
1011
1112/** What landing a named draft needs from a project. */
1213export interface LandHost {
Lines 23–36 at 318 (were 22–32 at 48)
2223 shared(): Space;
2324 setOf(space: Space): ReadonlySet<AtomId>;
2425 at(space: Space, version: number): ReadonlySet<AtomId>;
25− view(set: ReadonlySet<AtomId>): View;
26− sharedView(): View;
26+ view(set: ReadonlySet<AtomId>): ReadView;
27+ viewAt(space: Space, version: number, changes?: readonly AtomId[]): ReadView;
28+ sharedView(): ReadView;
2729 pairs(draft: readonly AtomId[], against: ReadonlySet<AtomId>, settled: ReadonlySet<AtomId>): Pair[];
28− describe(pair: Pair, yoursView: View, theirsView: View, spaceName: string): Collision;
30+ describe(pair: Pair, yoursView: ReadView, theirsView: ReadView, spaceName: string): Collision;
2931 definitionRule(): DefinitionRule;
32+ /** The files a space's versions after `from`, up to `to`, changed, when each one's are kept; else undefined. */
33+ changedSince(space: Space, from: number, to: number): ReadonlySet<string> | undefined;
3034 refuse(
3135 agent: AgentState,
3236 space: Space,
Lines 74–118 at 318 (were 70–90 at 48)
7074 space: Space,
7175 changes: AtomId[],
7276 pick: boolean,
73−): { collisions: Collision[]; newer: Set<AtomId>; union: Set<AtomId> } {
77+): { collisions: Collision[]; newer: ReadonlySet<AtomId>; union: ReadonlySet<AtomId> } {
7478 const shared = host.shared();
7579 const base = host.at(shared, sharedBaseOf(space));
76− const own = new Set(changes);
77− const union = new Set([...shared.own, ...changes]);
80+ const own = new StableOverlaySet(changes);
81+ const current = host.at(shared, host.version());
82+ const union = unionOverlay(current, changes);
7883 // The draft's own changes (some already plucked into shared) are never newer work to it.
79− const newer = new Set([...shared.own].filter((id) => !base.has(id) && !own.has(id) && !space.own.has(id)));
84+ const newer = differenceSet(
85+ differenceSet(
86+ shared.membershipVersion
87+ ? new SharedAdditions(shared, sharedBaseOf(space), base, current)
88+ : differenceSet(current, base),
89+ own,
90+ ),
91+ space.own,
92+ );
8093 // A pluck is checked as the draft's base plus only the plucked changes.
81− const draftView = host.view(pick ? new Set([...base, ...changes]) : host.setOf(space));
94+ const draftView = pick
95+ ? host.viewAt(shared, sharedBaseOf(space), changes)
96+ : host.viewAt(space, space.versions.length - 1);
8297 const describeLand = (p: Pair): Collision => host.describe(p, draftView, host.sharedView(), SHARED);
98+ // Where shared changed since the draft's base, from the files each version since kept as it landed (abso 738): working
99+ // it out from the newer atoms placed every line they wrote or deleted, about 30% of a warm draft-state read.
100+ const changed = () => host.changedSince(shared, sharedBaseOf(space), host.version());
83101 const collisions = [
84102 ...host.pairs(changes, newer, union).map(describeLand),
85103 ...host
86104 .definitionRule()
87− .collisions(own, draftView, host.view(base), host.sharedView(), newer, SHARED)
105+ .collisions(
106+ own,
107+ draftView,
108+ host.viewAt(shared, sharedBaseOf(space)),
109+ host.sharedView(),
110+ newer,
111+ SHARED,
112+ undefined,
113+ undefined,
114+ changed,
115+ )
88116 .map((d) => d.collision),
89117 ];
90118 return { collisions, newer, union };
Lines 135–149 at 318 (were 107–115 at 48)
107135 if (changes.length === 0) return { ok: true, version: host.version(), changes: 0 };
108136 const { collisions, newer, union } = landCollisions(host, space, changes, !!pick);
109137 if (collisions.length > 0) return host.refuse(agent, space, "land", time, collisions, entries);
110− const seen = host.pairs(changes, new Set([...shared.own].filter((id) => !newer.has(id))), union);
138+ const seen = host.pairs(changes, differenceSet(host.at(shared, host.version()), newer), union);
111139 const resolves = [...new Set(seen.flatMap((p) => [p.yours, p.theirs]))];
112− const tie = buildAtom(host.view(union), { author: agent.name, message, time, needs: changes, resolves });
140+ const tie = buildAtom(host.viewAt(shared, host.version(), changes), {
141+ author: agent.name,
142+ message,
143+ time,
144+ needs: changes,
145+ resolves,
146+ });
113147 host.requireClosed(tie, union);
114148 const version = host.version() + 1;
115149 // A pluck leaves the draft where it is: the rest of it lands later.
MCP
compare on this site's /mcp
CLI
abso diff 48 318 worker/project/land.ts --json
JSON
/christopher/abso-core/compare/48..318?file=worker%2Fproject%2Fland.ts&format=json