@@ -434,28 +434,12 @@ Execute the patching and verification stage as follows:
434434 is an optimization for the common case where a prior fix still applies with
435435 minor line-number shifts.
436436
437- - ** How:** Locate the prior pass's ` patch_diff ` from the archived finding
438- (the finding JSON in ` workspace/archive/findings_pass_<N-1>/ ` ).
439- ` patch_diff ` is a unified DIFF, not a whole file. Reconstruct the three
440- 3-way-merge inputs as SCRATCH copies (never edit the archived copies or
441- either snapshot in place):
442- - ` base ` = the PRIOR snapshot's unpatched version of the file, copied to
443- a scratch path (requires the prior snapshot dir on disk — see the
444- reachability check; if absent, fall back to fresh generation).
445- - ` ours ` = a copy of ` base ` with the archived ` patch_diff ` applied
446- (` patch <base_copy> < patch_diff ` , or ` git apply ` ). This reconstructs
447- the prior PATCHED file. If the diff does not apply cleanly to ` base ` ,
448- fall back to fresh generation.
449- - ` theirs ` = the CURRENT snapshot's unpatched version of the same file,
450- copied to a scratch path. Then run
451- ` git merge-file -p <ours> <base> <theirs> > <result> ` — the ` -p ` flag
452- writes the merged result to stdout so it does NOT overwrite ` <ours> ` in
453- place (argument order is ours, base, theirs). If ` git ` is unavailable,
454- use ` diff3 -m <ours> <base> <theirs> > <result> ` or any 3-way merge
455- tool that writes to a SEPARATE output. If the merge produces no
456- conflict markers, ` <result> ` is the current file with the fix rebased
457- onto it. If no 3-way merge tool is available, fall back to fresh patch
458- generation (Phase-1 behavior).
437+ - ** How:** If ALL reachability conditions (a)-(d) below hold, read
438+ [ 3-Way Patch Rebasing] ( references/patch_rebasing.md ) with your
439+ file-reading tool for the 3-way merge mechanics (` base ` /` ours ` /` theirs `
440+ scratch copies, ` git merge-file ` / ` diff3 ` invocation, conflict-marker
441+ handling). On ANY uncertainty or if the reference cannot be loaded, fall
442+ back to fresh patch generation (Phase-1 behavior).
459443 - ** When to use (reachability by OBSERVABLE state, not a flag the patcher
460444 cannot read):** attempt rebasing ONLY when ALL hold: (a) the prior pass's
461445 snapshot directory AND the file's prior unpatched version actually EXIST
@@ -485,19 +469,13 @@ Execute the patching and verification stage as follows:
485469 read from ` workspace/.mantis_state.json ` (the same state object read for
486470 ` active_snapshot ` ).
487471
488- - ** When rebasing SUCCEEDS** (clean 3-way merge): use the rebased patch as
489- the starting point for verification. Still run Block G (unpatched baseline
490- \+ post-patch gate) to confirm the rebased patch is correct. Mark the
491- finding with a history note ` patch-rebased-from: pass_<N-1> ` .
492-
493- - ** When rebasing FAILS** (merge conflict, file deleted, file renamed beyond
494- recognition, or the patched function no longer exists): fall back to
495- generating a fresh patch from scratch (Phase-1 behavior). Never use a
496- conflicting or ambiguous rebased patch.
497-
498- - ** Guardrail:** On ANY uncertainty, fall back to Phase-1 patch generation.
499- Never apply a rebased patch that has unresolved conflicts or that touches
500- code unrelated to the original fix.
472+ - ** When rebasing SUCCEEDS / FAILS / Guardrail:** See
473+ [ 3-Way Patch Rebasing] ( references/patch_rebasing.md ) for the success (clean
474+ merge → use rebased patch, still run Block G, history note
475+ ` patch-rebased-from: pass_<N-1> ` ), failure (merge conflict / file deleted /
476+ renamed → fall back to fresh patch generation), and guardrail (on ANY
477+ uncertainty, fall back to Phase-1; never apply a rebased patch with
478+ unresolved conflicts or unrelated changes).
501479
502480 - ** Unpatched-Baseline Re-run in ` --reattack ` (Phase 2):** When the
503481 ` @mantis-reproduce --reattack ` sub-agent is re-attacking a patch on a NEW
0 commit comments