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/view-changes.ts --json
JSON
/christopher/abso-core/blame/worker/project/view-changes.ts?format=json
111 linesFirst import 56% · capacity 40% · codex-capacity-chair 5%Last change capacity in version 243,

111 lines from 3 changes in 3 versions.

capacity243compare's summary: each changed file's size and SHA-256 instead of its texts (abso issue 680; disk-first 2; abso Capacity). compare 612 to 1224 on abso answers 13.2 MB: the full before and after text of about 3,000 changed files. Read Speed's shape lets the site ask for a summary and fetch a file's texts when it opens it. - view-changes.ts summariesBetween: the files changesBetween would list, each side as {size, sha256} for text (UTF-8 bytes, SHA-256 of the text), {blob} for a binary file (its hash; the Worker adds its size from the blob store), or null when absent; mode and blob as in the full answer. Each text is read, summed up and let go. - version-log compare takes summary and answers {from, to, summary: true, files}. ProjectHistory.compare and both engine-project.ts implementations take a fifth argument, summary; http.ts passes ?summary=1. The full answer is unchanged. On abso adopted fresh: the summary for 612 to 1224 is 174 KB instead of 13.2 MB, with heap after at 38 MB. The time is the same (about 20 s cold): it still lays the files out to hash them. Stored per-version sizes and hashes would remove that; they're proposed with the author totals table. New test compare-summary: on an in-memory and a writer-backed project, the summary lists the files the full compare does, with sizes and SHA-256s of its texts, blob hashes for a binary file, and no text. Every engine test (292 of 292), every worker/project test (342 of 342); tsc (worker and server) and biome clean.Compare1import { createHash } from "node:crypto";
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare2import type { ReadView } from "../../src/engine/index.ts";
init0Start the project3import { ProjectError } from "./project-error.ts";
4import type { FileChange, Mode, Modes } from "./project-types.ts";
5
6/** The listed files whose text differs between two views, before and after. */
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare7export function changesBetween(before: ReadView, after: ReadView, files: Iterable<string>): FileChange[] {
init0Start the project8 const out: FileChange[] = [];
9 for (const path of [...new Set(files)].toSorted()) {
10 const b = before.hasFile(path) ? before.text(path) : null;
11 const a = after.hasFile(path) ? after.text(path) : null;
12 const mode = modeChange(before, after, path);
13 const bb = before.attrs(path).blob;
14 const ab = after.attrs(path).blob;
15 const blob = bb !== ab ? { before: bb, after: ab } : undefined;
16 if (a !== b || mode || blob)
17 out.push({ path, before: b, after: a, ...(mode ? { mode } : {}), ...(blob ? { blob } : {}) });
capacity243compare's summary: each changed file's size and SHA-256 instead of its texts (abso issue 680; disk-first 2; abso Capacity). compare 612 to 1224 on abso answers 13.2 MB: the full before and after text of about 3,000 changed files. Read Speed's shape lets the site ask for a summary and fetch a file's texts when it opens it. - view-changes.ts summariesBetween: the files changesBetween would list, each side as {size, sha256} for text (UTF-8 bytes, SHA-256 of the text), {blob} for a binary file (its hash; the Worker adds its size from the blob store), or null when absent; mode and blob as in the full answer. Each text is read, summed up and let go. - version-log compare takes summary and answers {from, to, summary: true, files}. ProjectHistory.compare and both engine-project.ts implementations take a fifth argument, summary; http.ts passes ?summary=1. The full answer is unchanged. On abso adopted fresh: the summary for 612 to 1224 is 174 KB instead of 13.2 MB, with heap after at 38 MB. The time is the same (about 20 s cold): it still lays the files out to hash them. Stored per-version sizes and hashes would remove that; they're proposed with the author totals table. New test compare-summary: on an in-memory and a writer-backed project, the summary lists the files the full compare does, with sizes and SHA-256s of its texts, blob hashes for a binary file, and no text. Every engine test (292 of 292), every worker/project test (342 of 342); tsc (worker and server) and biome clean.Compare18 }
19 return out;
22/** A changed file's text or blob, summed up: its size in UTF-8 bytes and its SHA-256, or a blob's hash. */
23export type FileSummary = { size: number; sha256: string } | { blob: string };
25/**
26 * changesBetween without the texts (abso issue 680, compare's summary): each changed file before and after as its size
27 * and SHA-256, or its blob's hash for a binary file. Each text is read, summed up and let go, so a compare of thousands
28 * of files never holds them all.
29 */
30export function summariesBetween(
31 before: ReadView,
32 after: ReadView,
33 files: Iterable<string>,
34): {
35 path: string;
36 before: FileSummary | null;
37 after: FileSummary | null;
38 mode?: { before: Mode; after: Mode };
39 blob?: { before: string | null; after: string | null };
40}[] {
41 const sum = (view: ReadView, path: string): FileSummary | null => {
42 if (!view.hasFile(path)) return null;
43 const blob = view.attrs(path).blob;
44 if (blob !== null) return { blob };
45 const text = view.text(path);
46 return { size: Buffer.byteLength(text, "utf8"), sha256: createHash("sha256").update(text, "utf8").digest("hex") };
47 };
48 const out: ReturnType<typeof summariesBetween> = [];
49 for (const path of [...new Set(files)].toSorted()) {
50 if (!differs(before, after, path)) continue;
51 const mode = modeChange(before, after, path);
52 const bb = before.attrs(path).blob;
53 const ab = after.attrs(path).blob;
54 out.push({
55 path,
56 before: sum(before, path),
57 after: sum(after, path),
58 ...(mode ? { mode } : {}),
59 ...(bb !== ab ? { blob: { before: bb, after: ab } } : {}),
60 });
init0Start the project61 }
62 return out;
65/** Whether a file differs between two views: its text, its mode, or its blob (what changesBetween lists). */
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare66export function differs(before: ReadView, after: ReadView, path: string): boolean {
init0Start the project67 const had = before.hasFile(path);
68 if (had !== after.hasFile(path)) return true;
69 if (had && !before.sameText(path, after)) return true;
70 const b = before.attrs(path);
71 const a = after.attrs(path);
72 return b.exec !== a.exec || b.link !== a.link || b.blob !== a.blob;
75/** A file's executable bit and link target, before and after, when either changed. */
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare76export function modeChange(before: ReadView, after: ReadView, path: string): { before: Mode; after: Mode } | undefined {
init0Start the project77 const b = before.attrs(path);
78 const a = after.attrs(path);
79 if (b.exec === a.exec && b.link === a.link) return undefined;
80 return { before: { exec: b.exec, link: b.link }, after: { exec: a.exec, link: a.link } };
83/** Every executable file and link in a view. */
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare84export function modesOf(view: ReadView): Modes {
init0Start the project85 const out: Modes = {};
86 for (const path of view.paths()) {
87 const a = view.attrs(path);
88 if (a.exec || a.link !== null)
89 out[path] = { ...(a.exec ? { exec: true } : {}), ...(a.link !== null ? { link: a.link } : {}) };
90 }
91 return out;
94export function checkModes(modes: unknown): Modes {
95 if (typeof modes !== "object" || modes === null || Array.isArray(modes))
96 throw new ProjectError("bad-request", "modes must be {path: {exec, link}}");
97 for (const [path, m] of Object.entries(modes as Record<string, unknown>)) {
98 const mode = m as Mode;
99 if (typeof m !== "object" || m === null) throw new ProjectError("bad-request", `${path}: a mode is {exec?, link?}`);
100 if (mode.exec !== undefined && typeof mode.exec !== "boolean")
101 throw new ProjectError("bad-request", `${path}: exec is true or false`);
102 if (
103 mode.link !== undefined &&
104 mode.link !== null &&
105 (typeof mode.link !== "string" || mode.link === "" || /[\n\r]/.test(mode.link))
106 ) {
107 throw new ProjectError("bad-request", `${path}: link is a target path or null`);
108 }
109 }
110 return modes as Modes;