Skip to content

COMP: Implement the Phase-3 equivalence check in rewrite-history-merge-preserving.py #6753

Description

@hjmjohnson

rewrite-history-merge-preserving.py documents a four-phase model, but Phase 3 — verifying that the Phase-2 rewritten tip has the same tree as the Phase-1 reference — has no implementing function. The check the script exists to guarantee is left to the operator.

What is and isn't implemented

Verified on upstream/main (script merged via 1f41862f3c3):

Phase Documented at Implemented by
1 — reference tree docstring run_phase_1_reference()
2 — merge-preserving rewrite docstring run_phase_2_rewrite()
3 — VERIFY tip ≡ reference docstring line 36 nothing
4 — Mode A merge docstring assert_topology_preserved() (topology only)

grep -c 'def run_phase_3\|def verify_phase' returns 0.

--phase-1 prints the reference tree hash and exits; the default Phase-2 path
never compares against it. Nothing closes the loop, so a per-commit rewrite
that silently disagrees with the format-once-at-main tree passes unnoticed.

Proposed work

Add a run_phase_3_verify(reference_tree, branch) that diffs the rewritten tip
against the Phase-1 reference and exits non-zero on any difference, and wire it
into the Phase-2 path (or a --verify-against <tree> flag) so the gate is
automatic rather than a documented manual step.

~30 lines. Until it exists, the manual gate is git diff --stat <ref> HEAD,
which must be empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:InfrastructureInfrastructure/ecosystem related changes, such as CMake or buildbots

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions