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

Compare

+91 −7 in 8 places
Lines 12–21 at 318 (were 12–17 at 166)
1212import { DiskFirstRuntime } from "./disk-first-runtime.ts";
1313import { EngineProject, SqliteLog } from "./engine-project.ts";
1414import { artifactsOf, type Env } from "./env.ts";
15+import { GitDiskIntake } from "./git-disk-intake.ts";
16+import { GitFileContents } from "./git-file-contents.ts";
17+import { GitIntakeLimitError } from "./git-intake-limit.ts";
18+import { GitIntakeTrees } from "./git-intake-trees.ts";
1519import { pushedSince, remoteHead } from "./ingest.ts";
1620import {
1721 checkKey,
Lines 30–36 at 318 (were 26–31 at 166)
2630 revokeKey,
2731} from "./keys.ts";
2832import { type PushResult, pushShared, repoName } from "./push.ts";
33+import { pushSnapshot } from "./push-snapshot.ts";
2934import { SqliteWriterState } from "./writer-host.ts";
3035
3136const READ_OPS = new Set([
Lines 49–55 at 318 (were 44–49 at 166)
4449 "file",
4550 "files",
4651 "compare",
52+ "without",
4753 "where",
4854 "feed",
4955 "drafts",
Lines 64–74 at 318 (were 58–63 at 166)
5864export const PUSH_EVERY_MS = 60_000;
5965/** While agents are working, how often a call looks for plain-git pushes to the repo. */
6066const GIT_CHECK_MS = 15_000;
67+// Disk scratch admission limits, independent of the Worker's resident memory.
68+const GIT_PACK_MAX_BYTES = 128 * 1024 * 1024;
69+const GIT_OBJECT_MAX_BYTES = 64 * 1024 * 1024;
70+const GIT_DECODED_MAX_BYTES = 256 * 1024 * 1024;
71+const GIT_LIMIT_POLICY = `expanded-v2:${GIT_PACK_MAX_BYTES}:${GIT_OBJECT_MAX_BYTES}:${GIT_DECODED_MAX_BYTES}`;
6172
6273/**
6374 * The load guard (platform issue 46): an estimate of a loaded project's memory from its log entries, lines and claim
Lines 129–139 at 318 (were 118–123 at 166)
118129 constructor(ctx: DurableObjectState, env: Env) {
119130 super(ctx, env);
120131 this.blobs = new BlobStore(ctx.storage);
132+ if (env.ABSO_DISK_FIRST === "on") {
133+ GitDiskIntake.recover(ctx.storage);
134+ GitFileContents.recover(ctx.storage);
135+ GitIntakeTrees.recover(ctx.storage);
136+ }
121137 }
122138
123139 /** Where files kept whole go: the project's blob store. */
Lines 546–600 at 318 (were 530–544 at 166)
530546 const seen = await this.ctx.storage.get<string>("git:head");
531547 const pushed = await this.ctx.storage.get<PushResult>("pushed");
532548 const head = await remoteHead(artifacts, name);
549+ const refusal = this.diskRuntime()
550+ ? await this.ctx.storage.get<{ head: string; policy: string; kind: GitIntakeLimitError["kind"]; error: string }>(
551+ "git:size-refusal",
552+ )
553+ : undefined;
554+ if (refusal) {
555+ if (
556+ head &&
557+ head !== seen &&
558+ head !== pushed?.commit &&
559+ refusal.head === head &&
560+ refusal.policy === GIT_LIMIT_POLICY
561+ )
562+ throw new GitIntakeLimitError(refusal.kind, refusal.error);
563+ await this.ctx.storage.delete("git:size-refusal");
564+ }
533565 if (!head || head === seen || head === pushed?.commit) return null;
534566 const sharedBlobs = this.useProject((p) => p.shared().blobs ?? {});
567+ using trees = this.diskRuntime() ? new GitIntakeTrees(this.ctx.storage) : undefined;
535568 const found = await pushedSince(
536569 artifacts,
537570 name,
538571 seen,
539572 async (bytes) => (bytes.byteLength > BLOB_MAX ? null : this.blobs.putBytes(bytes)),
540573 (path) => sharedBlobs[path],
541− );
574+ trees ? (files, path, body, oid) => trees.retainFile(files, path, body, oid) : undefined,
575+ trees
576+ ? {
577+ storage: this.ctx.storage,
578+ maxPackBytes: GIT_PACK_MAX_BYTES,
579+ maxObjectBytes: GIT_OBJECT_MAX_BYTES,
580+ maxDecodedBytes: GIT_DECODED_MAX_BYTES,
581+ maxBinaryBytes: BLOB_MAX,
582+ retainFileChunks: (files, path, chunks, oid) => trees.retainChunks(files, path, chunks, oid),
583+ }
584+ : undefined,
585+ ).catch(async (error: unknown) => {
586+ if (trees && error instanceof GitIntakeLimitError) {
587+ const refusal = {
588+ head,
589+ policy: GIT_LIMIT_POLICY,
590+ kind: error.kind,
591+ error: error.message,
592+ at: new Date().toISOString(),
593+ };
594+ await this.ctx.storage.put({ "git:size-refusal": refusal, "git:error": refusal });
595+ }
596+ throw error;
597+ });
542598 if (!found || found.commits.length === 0) {
543599 if (found) await this.ctx.storage.put("git:head", found.head);
544600 return null;
Lines 653–682 at 318 (were 597–611 at 166)
597653 if (!artifacts) return;
598654 const name = await this.ctx.storage.get<string>("name");
599655 if (!name || !this.useProject((p) => p.exists())) return;
656+ let intakeFailed = false;
600657 await this.gitSync().then(
601− () => this.ctx.storage.delete("git:error"),
602− (e) =>
603− this.ctx.storage.put("git:error", {
658+ async () => {
659+ await this.ctx.storage.delete("git:error");
660+ await this.ctx.storage.delete("git:retry-attempts");
661+ },
662+ async (e) => {
663+ intakeFailed = true;
664+ const attempts = ((await this.ctx.storage.get<number>("git:retry-attempts")) ?? 0) + 1;
665+ await this.ctx.storage.put("git:retry-attempts", attempts);
666+ await this.ctx.storage.put("git:error", {
604667 at: new Date().toISOString(),
605668 error: e instanceof Error ? e.message : String(e),
606− }),
669+ });
670+ await this.soon(Date.now() + (attempts === 1 ? 1 : attempts === 2 ? 5 : 15) * 60_000);
671+ },
607672 );
608− const shared = this.useProject((p) => p.shared());
673+ // Never export over a remote head whose changes could not be taken in.
674+ if (intakeFailed) return;
675+ const shared = pushSnapshot(
676+ this.useProject((p) => p.sharedPushMetadata()),
677+ (version, path) => this.useProject((current) => current.fileTextAt(version, path)),
678+ (version, paths) => this.useProject((current) => current.fileTextsAt(version, paths)),
679+ );
609680 const done = await this.ctx.storage.get<PushResult>("pushed");
610681 if (done && done.version >= shared.version) return;
611682 const pushedAt = (await this.ctx.storage.get<number>("pushedAt")) ?? 0;
Lines 686–705 at 318 (were 615–621 at 166)
615686 }
616687 let result: PushResult;
617688 try {
618− result = await pushShared(artifacts, name, shared, (sha) => this.blobs.read(sha));
689+ result = await pushShared(
690+ artifacts,
691+ name,
692+ shared,
693+ (sha) => this.blobs.read(sha),
694+ this.env.ABSO_DISK_FIRST === "on"
695+ ? {
696+ storage: this.ctx.storage,
697+ maxPackBytes: GIT_PACK_MAX_BYTES,
698+ maxObjectBytes: GIT_OBJECT_MAX_BYTES,
699+ maxDecodedBytes: GIT_DECODED_MAX_BYTES,
700+ }
701+ : undefined,
702+ );
619703 } catch (e) {
620704 // Kept for /out, and tried again with a backoff of our own (a thrown alarm is retried only six times).
621705 const was = await this.ctx.storage.get<{ attempts?: number }>("pushError");
MCP
compare on this site's /mcp
CLI
abso diff 166 318 server/src/project-object.ts --json
JSON
/christopher/abso-core/compare/166..318?file=server%2Fsrc%2Fproject-object.ts&format=json