mechanical-refactor-verify

Make mechanical refactoring (file splits, function moves, module extractions, renames) machine-checkable instead of eyeballed. Reproduce a relocation commit byte-for-byte from faithful primitives, and split an extraction into a verifiable prepare + move + postpare. Use when doing or reviewing such changes.

Install
npx skills add 'https://github.com/sgl-project/sglang/tree/main/.claude/skills/mechanical-refactor-verify'
Download bundle ↓
main · a9fb1c3Scanned 2026-09-17

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗

scripts/tests/proof_generator/test_main_single_commit.py

scripts/tests/proof_generator/test_main_single_commit.pyBrowse 41 files
View on GitHub
← Back to SKILL.md
import sysfrom pathlib import Path import pytest sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from generator_testlib import _commit, _write  # noqa: F401from mechanical_refactor_proof_generator import _main  def _extract_function_commit(repo: Path) -> str:    _write(        repo,        **{            "kv.py": (                "class C:\n"                "    def dispatch(self, n):\n"                "        x = self.a\n"                "        y = x + n\n"                "        return y\n"                "\n"                "    def keep(self):\n"                "        return 0\n"            )        },    )    _commit(repo, "base")    _write(        repo,        **{            "kv.py": (                "class C:\n"                "    def dispatch(self, n):\n"                "        y = self._combine(n=n)\n"                "        return y\n"                "\n"                "    def _combine(self, *, n):\n"                "        x = self.a\n"                "        y = x + n\n"                "        return y\n"                "\n"                "    def keep(self):\n"                "        return 0\n"            )        },    )    return _commit(repo, "extract _combine from dispatch")  def test_single_commit_extract_function_reproduces_instead_of_unsupported(    repo: Path, monkeypatch: pytest.MonkeyPatch) -> None:    """A pure intra-file extract_function commit run in single-commit mode reproduces (exit 0),    not UNSUPPORTED -- the relocates check must count extract_functions like the range path.    """    sha = _extract_function_commit(repo)    monkeypatch.chdir(repo)    assert _main([sha]) == 0  def test_single_commit_pure_rename_is_unsupported(    repo: Path, monkeypatch: pytest.MonkeyPatch) -> None:    """A commit that relocates no definition (a bare rename) stays UNSUPPORTED with exit 1."""    _write(repo, **{"m.py": "def foo():\n    return 1\n"})    _commit(repo, "base")    _write(repo, **{"m.py": "def bar():\n    return 1\n"})    sha = _commit(repo, "rename foo to bar")    monkeypatch.chdir(repo)    assert _main([sha]) == 1