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
MCP
blame on this site's /mcp
CLI
abso blame worker/project/sync.ts --json
JSON
/christopher/abso-core/blame/worker/project/sync.ts?format=json
97 linesFirst import 81% · codex-capacity-chair 12% · rename 5% · trials 1%Last change codex-capacity-chair in version 163,

97 lines from 5 changes in 5 versions.

codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare1import { View } from "../../src/engine/index.ts";
init0Start the project2// Move the agent's base to its space's newest version. Writes go through
3// SyncHost; today the host is Project.
4
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare5import type { AtomId, Graph, ReadView } from "../../src/engine/index.ts";
init0Start the project6import { ProjectError } from "./project-error.ts";
7import type { AgentState, Entry, MergedLine, SyncAnswer } from "./project-types.ts";
8import { last, SHARED, type Space } from "./spaces.ts";
9
10/** What a sync needs from a project. */
11export interface SyncHost {
12 readonly graph: Graph;
13 readonly labels: ReadonlyMap<string, readonly number[]>;
14 agent(name: string, entries: Entry[]): AgentState;
15 spaceOf(agent: AgentState): Space;
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare16 agentView(agent: AgentState): ReadView;
codex-capacity-chair163Integrate reviewed disk-backed operations, queue and bounded read cachesCompare17 captureAgentView?(agent: AgentState): () => ReadView;
init0Start the project18 at(space: Space, version: number): ReadonlySet<AtomId>;
19 draft(agent: AgentState): AtomId[];
20 strandedFiles(draft: readonly AtomId[], set: ReadonlySet<AtomId>): string[];
21 apply(entry: Entry): void;
22 flush(entries: Entry[]): void;
23 mergeIdentical(
24 agent: AgentState,
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare25 before: ReadView,
init0Start the project26 oldBase: ReadonlySet<AtomId>,
27 oldVersion: number,
28 time: number,
29 entries: Entry[],
30 ): MergedLine[];
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare31 changesSince(agent: AgentState, before: ReadView): SyncAnswer;
init0Start the project32}
34/**
35 * Move the agent's base to its space's newest version. Returns every file
36 * whose text in its view changes (null when it's gone), and the collisions
37 * it now has to settle. A first sync returns every file (that's how a
38 * folder joins).
39 */
40export function sync(host: SyncHost, agentName: string, options: { label?: string; full?: boolean } = {}): SyncAnswer {
41 const entries: Entry[] = [];
42 const agent = host.agent(agentName, entries);
43 const space = host.spaceOf(agent);
44 let target = last(space);
45 if (options.label !== undefined) {
46 // Follow a label (#10): the newest version of shared that carries it.
47 if (space.name !== SHARED)
48 throw new ProjectError("bad-request", "labels mark versions of shared; switch to shared to follow one");
49 const versions = host.labels.get(options.label);
50 if (!versions)
51 throw new ProjectError("bad-request", `no version of shared has the label ${JSON.stringify(options.label)}`);
52 target = versions[versions.length - 1]!;
53 }
codex-capacity-chair163Integrate reviewed disk-backed operations, queue and bounded read cachesCompare54 const reopenBefore = agent.synced ? host.captureAgentView?.(agent) : undefined;
init0Start the project55 const before = agent.synced ? host.agentView(agent) : new View(host.graph, []);
56 const set = host.at(space, target);
57 const stranded = host.strandedFiles(host.draft(agent), set);
58 if (stranded.length > 0) {
59 host.flush(entries);
60 throw new ProjectError(
61 "conflict",
62 target === last(space)
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare63 ? `your unpushed changes to ${stranded.join(", ")} build on lines a drop took out of shared; ` +
64 `restore those files (abso restore ${stranded.join(" ")}) and pull again`
65 : `your unpushed changes to ${stranded.join(", ")} build on lines version ${target} doesn't have yet; ` +
66 `push or restore them before following label ${options.label}`,
init0Start the project67 );
68 }
69 // Moving back to a labeled version: the agent's own newer published work must not build on what that version lacks.
70 const mineAfter = agent.mine.filter((id) => !set.has(id));
71 const lacking = host.strandedFiles(mineAfter, set);
72 if (lacking.length > 0) {
73 host.flush(entries);
74 throw new ProjectError(
75 "conflict",
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare76 `your pushed changes to ${lacking.join(", ")} build on versions after ${target}, so you can't move back to it`,
init0Start the project77 );
78 }
79 const oldBase = host.at(space, agent.base);
80 const oldVersion = agent.base;
81 entries.push({ type: "sync", agent: agent.name, version: target });
82 host.apply(entries[entries.length - 1]!);
83 // News about versions the agent has now synced past is moot: the sync answer lists what's still open (#37).
codex-capacity-chair163Integrate reviewed disk-backed operations, queue and bounded read cachesCompare84 if (agent.news.some((t) => !t.startsWith("Announcement from "))) {
init0Start the project85 const heard: Entry = { type: "heard", agent: agent.name, stale: true };
86 entries.push(heard);
87 host.apply(heard);
88 }
89 const merged = host.mergeIdentical(agent, before, oldBase, oldVersion, Date.now(), entries);
trials51Drop a seat name from notes on who reported things Nine comments and test names named the person who reported a #37 case. The notes keep the case and drop the name. Only comments and test names change.Compare90 // full (#37, a partial join): every file in the view, as for a first sync, whatever the folder had.
codex-capacity-chair163Integrate reviewed disk-backed operations, queue and bounded read cachesCompare91 const answer = host.changesSince(
92 agent,
93 options.full ? new View(host.graph, []) : reopenBefore ? reopenBefore() : before,
94 );
init0Start the project95 host.flush(entries);
96 return merged.length > 0 ? { ...answer, merged } : answer;