{"version":183,"agent":"codex-capacity-chair","message":"Skip whole reads of binaries over the blob limit on disk intake","time":1791977400174,"timeIso":"2026-10-14T11:30:00.174Z","changes":4,"change":2954,"files":["server/src/ingest.ts","server/src/project-object.ts","server/test/git-disk-clone.test.ts"],"draft":null,"diff":[{"path":"server/src/ingest.ts","added":9,"removed":0,"diff":"--- a/server/src/ingest.ts\n+++ b/server/src/ingest.ts\n@@ -109,6 +109,7 @@\n \t\tmaxPackBytes: number;\n \t\tmaxObjectBytes: number;\n \t\tmaxDecodedBytes?: number;\n+\t\tmaxBinaryBytes?: number;\n \t\thttp?: HttpClient;\n \t\tretainFileChunks?: RetainFileChunks;\n \t},\n@@ -165,6 +166,7 @@\n \t\t\t\tcache,\n \t\t\t\tintake,\n \t\t\t\tdisk?.retainFileChunks,\n+\t\t\t\tdisk?.maxBinaryBytes,\n \t\t\t)),\n \t\t});\n \treturn {\n@@ -192,6 +194,7 @@\n \tcache: object = {},\n \tintake?: GitDiskIntake,\n \tretainFileChunks?: RetainFileChunks,\n+\tmaxBinaryBytes?: number,\n ): Promise<{\n \tfiles: Record<string, string>;\n \tmodes: FileModes;\n@@ -233,6 +236,12 @@\n \t\t\t\t\tmodes[path] = { exec: mode === EXEC, link: null };\n \t\t\t\t\treturn true;\n \t\t\t\t}\n+\t\t\t\tif (storeBlob && maxBinaryBytes !== undefined && stored.byteLength > maxBinaryBytes) {\n+\t\t\t\t\ttooBig.add(path);\n+\t\t\t\t\tconst kept = oldBlob(path);\n+\t\t\t\t\tif (kept) blobs[path] = kept;\n+\t\t\t\t\treturn true;\n+\t\t\t\t}\n \t\t\t}\n \t\t\tconst bytes = await entry.content();\n \t\t\tif (!bytes) return true;"},{"path":"server/src/project-object.ts","added":1,"removed":0,"diff":"--- a/server/src/project-object.ts\n+++ b/server/src/project-object.ts\n@@ -577,6 +577,7 @@\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,"},{"path":"server/test/git-disk-clone.test.ts","added":12,"removed":6,"diff":"--- a/server/test/git-disk-clone.test.ts\n+++ b/server/test/git-disk-clone.test.ts\n@@ -15,13 +15,14 @@\n \treturn Buffer.concat([Buffer.from((body.length + 4).toString(16).padStart(4, \"0\")), body]);\n };\n \n-for (const mode of [\"success\", \"limit\", \"fatal\", \"server-intake\", \"text-intake\"])\n+for (const mode of [\"success\", \"limit\", \"fatal\", \"server-intake\", \"text-intake\", \"binary-limit\"])\n \ttest(`actual disk clone handles ${mode}`, async (t) => {\n \t\tconst rejectPack = mode === \"limit\";\n \t\tconst source = new MemoryFS(),\n \t\t\tdir = \"/repo\";\n \t\tawait git.init({ fs: source, dir, defaultBranch: \"main\" });\n \t\tconst blob = mode === \"text-intake\" ? Buffer.from(\"x\".repeat(16383) + \"🚀é中\".repeat(20000)) : randomBytes(400000);\n+\t\tif (mode === \"binary-limit\") blob[0] = 255;\n \t\tconst blobOid = await git.writeBlob({ fs: source, dir, blob });\n \t\tconst tree = await git.writeTree({\n \t\t\tfs: source,\n@@ -127,12 +128,12 @@\n \t\t\treturn write(path, ...args);\n \t\t};\n \t\ttry {\n-\t\t\tif (mode === \"server-intake\" || mode === \"text-intake\") {\n+\t\t\tif (mode === \"server-intake\" || mode === \"text-intake\" || mode === \"binary-limit\") {\n \t\t\t\tconst trees = new GitIntakeTrees(storage);\n-\t\t\t\tif (mode === \"text-intake\") {\n+\t\t\t\tif (mode === \"text-intake\" || mode === \"binary-limit\") {\n \t\t\t\t\tconst original = GitDiskIntake.prototype.read;\n \t\t\t\t\tt.mock.method(GitDiskIntake.prototype, \"read\", function (this: GitDiskIntake, oid: string) {\n-\t\t\t\t\t\tif (oid === blobOid) throw Error(\"whole text blob read forbidden\");\n+\t\t\t\t\t\tif (oid === blobOid) throw Error(\"whole blob read forbidden\");\n \t\t\t\t\t\treturn original.call(this, oid);\n \t\t\t\t\t});\n \t\t\t\t}\n@@ -148,15 +149,17 @@\n \t\t\t\t\t\"fixture\",\n \t\t\t\t\tundefined,\n \t\t\t\t\tasync (bytes) => {\n+\t\t\t\t\t\tassert.notEqual(mode, \"binary-limit\", \"oversized binary must not reach the store\");\n \t\t\t\t\t\tassert.deepEqual(Buffer.from(bytes), blob);\n \t\t\t\t\t\treturn \"fixture-blob\";\n \t\t\t\t\t},\n+\t\t\t\t\tmode === \"binary-limit\" ? () => \"previous-blob\" : undefined,\n \t\t\t\t\tundefined,\n-\t\t\t\t\tundefined,\n \t\t\t\t\t{\n \t\t\t\t\t\tstorage,\n \t\t\t\t\t\tmaxPackBytes: 2000000,\n \t\t\t\t\t\tmaxObjectBytes: 1000000,\n+\t\t\t\t\t\tmaxBinaryBytes: mode === \"binary-limit\" ? 100000 : undefined,\n \t\t\t\t\t\thttp,\n \t\t\t\t\t\tretainFileChunks: (files, path, chunks, oid) => trees.retainChunks(files, path, chunks, oid),\n \t\t\t\t\t},\n@@ -164,7 +167,10 @@\n \t\t\t\tassert.equal(found!.base, 0);\n \t\t\t\tassert.equal(found!.commits.length, 1);\n \t\t\t\tif (mode === \"text-intake\") assert.equal(found!.commits[0]!.files[\"large.bin\"], blob.toString(\"utf8\"));\n-\t\t\t\telse assert.equal(found!.commits[0]!.blobs[\"large.bin\"], \"fixture-blob\");\n+\t\t\t\telse if (mode === \"binary-limit\") {\n+\t\t\t\t\tassert.equal(found!.commits[0]!.blobs[\"large.bin\"], \"previous-blob\");\n+\t\t\t\t\tassert.deepEqual(found!.tooBig, [\"large.bin\"]);\n+\t\t\t\t} else assert.equal(found!.commits[0]!.blobs[\"large.bin\"], \"fixture-blob\");\n \t\t\t\ttrees.dispose();\n \t\t\t\tfor (const table of [\"git_pack_spool\", \"git_pack_resolve\", \"git_object_meta\", \"git_object_bytes\"])\n \t\t\t\t\tassert.equal(storage.db.prepare(`SELECT COUNT(*) AS n FROM ${table}`).get()!.n, 0);"}],"ci":null}