{"draft":null,"from":175,"to":318,"files":[{"path":"server/src/project-object.ts","added":91,"removed":7,"diff":"--- a/server/src/project-object.ts\n+++ b/server/src/project-object.ts\n@@ -12,6 +12,10 @@\n import { DiskFirstRuntime } from \"./disk-first-runtime.ts\";\n import { EngineProject, SqliteLog } from \"./engine-project.ts\";\n import { artifactsOf, type Env } from \"./env.ts\";\n+import { GitDiskIntake } from \"./git-disk-intake.ts\";\n+import { GitFileContents } from \"./git-file-contents.ts\";\n+import { GitIntakeLimitError } from \"./git-intake-limit.ts\";\n+import { GitIntakeTrees } from \"./git-intake-trees.ts\";\n import { pushedSince, remoteHead } from \"./ingest.ts\";\n import {\n \tcheckKey,\n@@ -26,6 +30,7 @@\n \trevokeKey,\n } from \"./keys.ts\";\n import { type PushResult, pushShared, repoName } from \"./push.ts\";\n+import { pushSnapshot } from \"./push-snapshot.ts\";\n import { SqliteWriterState } from \"./writer-host.ts\";\n \n const READ_OPS = new Set([\n@@ -44,6 +49,7 @@\n \t\"file\",\n \t\"files\",\n \t\"compare\",\n+\t\"without\",\n \t\"where\",\n \t\"feed\",\n \t\"drafts\",\n@@ -58,6 +64,11 @@\n export const PUSH_EVERY_MS = 60_000;\n /** While agents are working, how often a call looks for plain-git pushes to the repo. */\n const GIT_CHECK_MS = 15_000;\n+// Disk scratch admission limits, independent of the Worker's resident memory.\n+const GIT_PACK_MAX_BYTES = 128 * 1024 * 1024;\n+const GIT_OBJECT_MAX_BYTES = 64 * 1024 * 1024;\n+const GIT_DECODED_MAX_BYTES = 256 * 1024 * 1024;\n+const GIT_LIMIT_POLICY = `expanded-v2:${GIT_PACK_MAX_BYTES}:${GIT_OBJECT_MAX_BYTES}:${GIT_DECODED_MAX_BYTES}`;\n \n /**\n  * The load guard (platform issue 46): an estimate of a loaded project's memory from its log entries, lines and claim\n@@ -118,6 +129,11 @@\n \tconstructor(ctx: DurableObjectState, env: Env) {\n \t\tsuper(ctx, env);\n \t\tthis.blobs = new BlobStore(ctx.storage);\n+\t\tif (env.ABSO_DISK_FIRST === \"on\") {\n+\t\t\tGitDiskIntake.recover(ctx.storage);\n+\t\t\tGitFileContents.recover(ctx.storage);\n+\t\t\tGitIntakeTrees.recover(ctx.storage);\n+\t\t}\n \t}\n \n \t/** Where files kept whole go: the project's blob store. */\n@@ -530,15 +546,55 @@\n \t\tconst seen = await this.ctx.storage.get<string>(\"git:head\");\n \t\tconst pushed = await this.ctx.storage.get<PushResult>(\"pushed\");\n \t\tconst head = await remoteHead(artifacts, name);\n+\t\tconst refusal = this.diskRuntime()\n+\t\t\t? await this.ctx.storage.get<{ head: string; policy: string; kind: GitIntakeLimitError[\"kind\"]; error: string }>(\n+\t\t\t\t\t\"git:size-refusal\",\n+\t\t\t\t)\n+\t\t\t: undefined;\n+\t\tif (refusal) {\n+\t\t\tif (\n+\t\t\t\thead &&\n+\t\t\t\thead !== seen &&\n+\t\t\t\thead !== pushed?.commit &&\n+\t\t\t\trefusal.head === head &&\n+\t\t\t\trefusal.policy === GIT_LIMIT_POLICY\n+\t\t\t)\n+\t\t\t\tthrow new GitIntakeLimitError(refusal.kind, refusal.error);\n+\t\t\tawait this.ctx.storage.delete(\"git:size-refusal\");\n+\t\t}\n \t\tif (!head || head === seen || head === pushed?.commit) return null;\n \t\tconst sharedBlobs = this.useProject((p) => p.shared().blobs ?? {});\n+\t\tusing trees = this.diskRuntime() ? new GitIntakeTrees(this.ctx.storage) : undefined;\n \t\tconst found = await pushedSince(\n \t\t\tartifacts,\n \t\t\tname,\n \t\t\tseen,\n \t\t\tasync (bytes) => (bytes.byteLength > BLOB_MAX ? null : this.blobs.putBytes(bytes)),\n \t\t\t(path) => sharedBlobs[path],\n-\t\t);\n+\t\t\ttrees ? (files, path, body, oid) => trees.retainFile(files, path, body, oid) : undefined,\n+\t\t\ttrees\n+\t\t\t\t? {\n+\t\t\t\t\t\tstorage: this.ctx.storage,\n+\t\t\t\t\t\tmaxPackBytes: GIT_PACK_MAX_BYTES,\n+\t\t\t\t\t\tmaxObjectBytes: GIT_OBJECT_MAX_BYTES,\n+\t\t\t\t\t\tmaxDecodedBytes: GIT_DECODED_MAX_BYTES,\n+\t\t\t\t\t\tmaxBinaryBytes: BLOB_MAX,\n+\t\t\t\t\t\tretainFileChunks: (files, path, chunks, oid) => trees.retainChunks(files, path, chunks, oid),\n+\t\t\t\t\t}\n+\t\t\t\t: undefined,\n+\t\t).catch(async (error: unknown) => {\n+\t\t\tif (trees && error instanceof GitIntakeLimitError) {\n+\t\t\t\tconst refusal = {\n+\t\t\t\t\thead,\n+\t\t\t\t\tpolicy: GIT_LIMIT_POLICY,\n+\t\t\t\t\tkind: error.kind,\n+\t\t\t\t\terror: error.message,\n+\t\t\t\t\tat: new Date().toISOString(),\n+\t\t\t\t};\n+\t\t\t\tawait this.ctx.storage.put({ \"git:size-refusal\": refusal, \"git:error\": refusal });\n+\t\t\t}\n+\t\t\tthrow error;\n+\t\t});\n \t\tif (!found || found.commits.length === 0) {\n \t\t\tif (found) await this.ctx.storage.put(\"git:head\", found.head);\n \t\t\treturn null;\n@@ -597,15 +653,30 @@\n \t\tif (!artifacts) return;\n \t\tconst name = await this.ctx.storage.get<string>(\"name\");\n \t\tif (!name || !this.useProject((p) => p.exists())) return;\n+\t\tlet intakeFailed = false;\n \t\tawait this.gitSync().then(\n-\t\t\t() => this.ctx.storage.delete(\"git:error\"),\n-\t\t\t(e) =>\n-\t\t\t\tthis.ctx.storage.put(\"git:error\", {\n+\t\t\tasync () => {\n+\t\t\t\tawait this.ctx.storage.delete(\"git:error\");\n+\t\t\t\tawait this.ctx.storage.delete(\"git:retry-attempts\");\n+\t\t\t},\n+\t\t\tasync (e) => {\n+\t\t\t\tintakeFailed = true;\n+\t\t\t\tconst attempts = ((await this.ctx.storage.get<number>(\"git:retry-attempts\")) ?? 0) + 1;\n+\t\t\t\tawait this.ctx.storage.put(\"git:retry-attempts\", attempts);\n+\t\t\t\tawait this.ctx.storage.put(\"git:error\", {\n \t\t\t\t\tat: new Date().toISOString(),\n \t\t\t\t\terror: e instanceof Error ? e.message : String(e),\n-\t\t\t\t}),\n+\t\t\t\t});\n+\t\t\t\tawait this.soon(Date.now() + (attempts === 1 ? 1 : attempts === 2 ? 5 : 15) * 60_000);\n+\t\t\t},\n \t\t);\n-\t\tconst shared = this.useProject((p) => p.shared());\n+\t\t// Never export over a remote head whose changes could not be taken in.\n+\t\tif (intakeFailed) return;\n+\t\tconst shared = pushSnapshot(\n+\t\t\tthis.useProject((p) => p.sharedPushMetadata()),\n+\t\t\t(version, path) => this.useProject((current) => current.fileTextAt(version, path)),\n+\t\t\t(version, paths) => this.useProject((current) => current.fileTextsAt(version, paths)),\n+\t\t);\n \t\tconst done = await this.ctx.storage.get<PushResult>(\"pushed\");\n \t\tif (done && done.version >= shared.version) return;\n \t\tconst pushedAt = (await this.ctx.storage.get<number>(\"pushedAt\")) ?? 0;\n@@ -615,7 +686,20 @@\n \t\t}\n \t\tlet result: PushResult;\n \t\ttry {\n-\t\t\tresult = await pushShared(artifacts, name, shared, (sha) => this.blobs.read(sha));\n+\t\t\tresult = await pushShared(\n+\t\t\t\tartifacts,\n+\t\t\t\tname,\n+\t\t\t\tshared,\n+\t\t\t\t(sha) => this.blobs.read(sha),\n+\t\t\t\tthis.env.ABSO_DISK_FIRST === \"on\"\n+\t\t\t\t\t? {\n+\t\t\t\t\t\t\tstorage: this.ctx.storage,\n+\t\t\t\t\t\t\tmaxPackBytes: GIT_PACK_MAX_BYTES,\n+\t\t\t\t\t\t\tmaxObjectBytes: GIT_OBJECT_MAX_BYTES,\n+\t\t\t\t\t\t\tmaxDecodedBytes: GIT_DECODED_MAX_BYTES,\n+\t\t\t\t\t\t}\n+\t\t\t\t\t: undefined,\n+\t\t\t);\n \t\t} catch (e) {\n \t\t\t// Kept for /out, and tried again with a backoff of our own (a thrown alarm is retried only six times).\n \t\t\tconst was = await this.ctx.storage.get<{ attempts?: number }>(\"pushError\");"}],"unmatched":[]}