Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion scripts/backfill-calibration-corpus-phase2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,13 @@ async function runRawContextPass(args: Args, budget: RequestBudget, state: Curso
state.rawContextResumeFrom = row.target_key;
continue;
}
const patched = patchFiredMetadataWithDiff(row.metadata_json, await diffResponse.text());
const diffText = await diffResponse.text();
// The D1 CLI driver inlines the UPDATE as literal SQL (wrangler --command cannot bind parameters), and
// quote-doubling can double the payload: a full 120KB diff exceeds D1's per-statement length
// (SQLITE_TOOBIG, hit live at row 37 of the first cloud apply). Cap the literal path with a
// self-describing marker; the pg driver binds parameters and keeps the full bound diff.
const bounded = pgSession || diffText.length <= 45_000 ? diffText : `${diffText.slice(0, 45_000)}\n[diff truncated: D1 CLI statement-length limit]`;
const patched = patchFiredMetadataWithDiff(row.metadata_json, bounded);
if (patched === null) {
report.alreadyPatched += 1;
} else if (args.apply) {
Expand Down