fix: strengthen apply-patch v2 mxcx hints

This commit is contained in:
Codex
2026-06-03 14:36:53 +00:00
parent 8dae177795
commit b86bcb3d4d
3 changed files with 48 additions and 3 deletions
+27 -1
View File
@@ -1071,11 +1071,37 @@ export async function runSshArgvGuidanceContract(): Promise<JsonRecord> {
missingPlusLargeInsertVisibleV2.stderr.includes("First expected line appears near target line(s): 2, 5")
&& missingPlusLargeInsertVisibleV2.stderr.includes("Best partial context match: 2 expected line(s) matched")
&& missingPlusLargeInsertVisibleV2.stderr.includes("large insertion whose new lines were written as context")
&& missingPlusLargeInsertVisibleV2.stderr.includes("regenerate the patch instead of editing it with sed"),
&& missingPlusLargeInsertVisibleV2.stderr.includes("regenerate the patch instead of editing it with sed")
&& missingPlusLargeInsertVisibleV2.stderr.includes("handled by apply-patch v2")
&& missingPlusLargeInsertVisibleV2.stderr.includes("do not switch the same patch to apply-patch-v1"),
"v2 missing-plus failure should diagnose the MiniMax sed-regression pattern explicitly",
missingPlusLargeInsertVisibleV2.stderr,
);
const fragmentedEnvelopeFailureV2 = await applyPatchV2FixtureAttempt([
"*** Begin Patch",
"*** Update File: fragment.txt",
"@@",
"-alpha",
"+ALPHA",
"*** End Patch",
"printf '%s\\n' '*** Begin Patch'",
"*** End Patch",
"",
].join("\n"), {
"fragment.txt": "alpha\n",
}, { stderrOutput: true });
assertCondition(fragmentedEnvelopeFailureV2.exitCode === 1 && fragmentedEnvelopeFailureV2.error === null, "v2 should reject non-patch shell fragments with a parser hint", fragmentedEnvelopeFailureV2);
assertCondition(
fragmentedEnvelopeFailureV2.stderr.includes("invalid hunk header")
&& fragmentedEnvelopeFailureV2.stderr.includes("concatenated MiniMax/MXCX fragments")
&& fragmentedEnvelopeFailureV2.stderr.includes("exactly one outer *** Begin Patch / *** End Patch envelope")
&& fragmentedEnvelopeFailureV2.stderr.includes("v2 engine only")
&& fragmentedEnvelopeFailureV2.stderr.includes("do not retry by switching to apply-patch-v1"),
"v2 parser failure should hint the MXCX printf/heredoc envelope fix without falling back to v1",
fragmentedEnvelopeFailureV2.stderr,
);
const nestedEnvelopeV2 = await applyPatchV2FixtureAttempt([
"*** Begin Patch",
"*** Update File: nested-envelope.txt",