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

Compare

+43 −7 in 6 places
Lines 3–13 at 318 (were 3–11 at 178)
33import { test } from "node:test";
44import git, { type HttpClient } from "isomorphic-git";
55import { GitDiskIntake } from "../src/git-disk-intake.ts";
6+import { GitFileContents } from "../src/git-file-contents.ts";
67import { GitIntakeTrees } from "../src/git-intake-trees.ts";
78import { pushedSince } from "../src/ingest.ts";
89import { MemoryFS } from "../src/memory-fs.ts";
10+import { commitShared } from "../src/push.ts";
911import { memoryStorage } from "./helpers.ts";
1012
1113const packet = (text: string | Uint8Array) => {
Lines 15–28 at 318 (were 13–25 at 178)
1315 return Buffer.concat([Buffer.from((body.length + 4).toString(16).padStart(4, "0")), body]);
1416};
1517
16−for (const mode of ["success", "limit", "fatal", "server-intake", "text-intake"])
18+for (const mode of ["success", "limit", "fatal", "server-intake", "text-intake", "binary-limit"])
1719 test(`actual disk clone handles ${mode}`, async (t) => {
1820 const rejectPack = mode === "limit";
1921 const source = new MemoryFS(),
2022 dir = "/repo";
2123 await git.init({ fs: source, dir, defaultBranch: "main" });
2224 const blob = mode === "text-intake" ? Buffer.from("x".repeat(16383) + "🚀é中".repeat(20000)) : randomBytes(400000);
25+ if (mode === "binary-limit") blob[0] = 255;
2326 const blobOid = await git.writeBlob({ fs: source, dir, blob });
2427 const tree = await git.writeTree({
2528 fs: source,
Lines 120–139 at 318 (were 117–135 at 178)
117120 };
118121 const cache = {};
119122 intake.attach(cache);
120− const fs = new MemoryFS();
123+ const contents = new GitFileContents(storage, 1000000, 2000000);
124+ const fs = new MemoryFS(contents);
121125 const write = fs.promises.writeFile;
122126 fs.promises.writeFile = async (path, ...args) => {
123127 assert.ok(!/\.(pack|idx)$/.test(path), "clone must not persist a collected pack or index");
124128 return write(path, ...args);
125129 };
126130 try {
127− if (mode === "server-intake" || mode === "text-intake") {
131+ if (mode === "server-intake" || mode === "text-intake" || mode === "binary-limit") {
128132 const trees = new GitIntakeTrees(storage);
129− if (mode === "text-intake") {
133+ if (mode === "text-intake" || mode === "binary-limit") {
130134 const original = GitDiskIntake.prototype.read;
131135 t.mock.method(GitDiskIntake.prototype, "read", function (this: GitDiskIntake, oid: string) {
132− if (oid === blobOid) throw Error("whole text blob read forbidden");
136+ if (oid === blobOid) throw Error("whole blob read forbidden");
133137 return original.call(this, oid);
134138 });
135139 }
Lines 149–165 at 318 (were 145–159 at 178)
145149 "fixture",
146150 undefined,
147151 async (bytes) => {
152+ assert.notEqual(mode, "binary-limit", "oversized binary must not reach the store");
148153 assert.deepEqual(Buffer.from(bytes), blob);
149154 return "fixture-blob";
150155 },
156+ mode === "binary-limit" ? () => "previous-blob" : undefined,
151157 undefined,
152− undefined,
153158 {
154159 storage,
155160 maxPackBytes: 2000000,
156161 maxObjectBytes: 1000000,
162+ maxBinaryBytes: mode === "binary-limit" ? 100000 : undefined,
157163 http,
158164 retainFileChunks: (files, path, chunks, oid) => trees.retainChunks(files, path, chunks, oid),
159165 },
Lines 167–176 at 318 (were 161–167 at 178)
161167 assert.equal(found!.base, 0);
162168 assert.equal(found!.commits.length, 1);
163169 if (mode === "text-intake") assert.equal(found!.commits[0]!.files["large.bin"], blob.toString("utf8"));
164− else assert.equal(found!.commits[0]!.blobs["large.bin"], "fixture-blob");
170+ else if (mode === "binary-limit") {
171+ assert.equal(found!.commits[0]!.blobs["large.bin"], "previous-blob");
172+ assert.deepEqual(found!.tooBig, ["large.bin"]);
173+ } else assert.equal(found!.commits[0]!.blobs["large.bin"], "fixture-blob");
165174 trees.dispose();
166175 for (const table of ["git_pack_spool", "git_pack_resolve", "git_object_meta", "git_object_bytes"])
167176 assert.equal(storage.db.prepare(`SELECT COUNT(*) AS n FROM ${table}`).get()!.n, 0);
Lines 215–248 at 318 (were 206–212 at 178)
206215 assert.equal(await git.resolveRef({ fs, dir, ref: "main" }), head);
207216 assert.equal((await git.readCommit({ fs, dir, cache, oid: head })).commit.tree, tree);
208217 assert.deepEqual(Buffer.from((await git.readBlob({ fs, dir, cache, oid: blobOid })).blob), blob);
218+ const exported = await commitShared(
219+ fs,
220+ dir,
221+ head,
222+ {
223+ version: 1,
224+ files: { "new.txt": "Disk export fixture" },
225+ blobs: { "large.bin": "fixture-blob" },
226+ },
227+ () => blob,
228+ undefined,
229+ cache,
230+ );
231+ const next = await git.readCommit({ fs, dir, cache, oid: exported.commit });
232+ assert.deepEqual(next.commit.parent, [head]);
233+ assert.deepEqual(
234+ Buffer.from((await git.readBlob({ fs, dir, cache, oid: exported.commit, filepath: "large.bin" })).blob),
235+ blob,
236+ );
237+ assert.equal(
238+ Buffer.from(
239+ (await git.readBlob({ fs, dir, cache, oid: exported.commit, filepath: "new.txt" })).blob,
240+ ).toString(),
241+ "Disk export fixture",
242+ );
243+ for (const entry of fs.entries.values()) if (entry.kind === "file") assert.equal(entry.data.byteLength, 0);
209244 } finally {
245+ contents.dispose();
210246 intake.dispose();
211247 storage.db.close();
212248 }
MCP
compare on this site's /mcp
CLI
abso diff 178 318 server/test/git-disk-clone.test.ts --json
JSON
/christopher/abso-core/compare/178..318?file=server%2Ftest%2Fgit-disk-clone.test.ts&format=json