FunnyEnough

Engineering notes & expertise

Reading

Size
Theme
Motion
For long-form reading
Type
Width
Space
Aids

Refactor under a net – pin the behaviour, then change it

RefactorFreshModel-agnosticverified 2026-06-21sha 756ca8a52073

Born in: the post where it earned its place →

Vendor “refactor this for me” prompts read the code, decide what it “should” do, and rewrite it – quietly changing behaviour while calling it cleanup, with no net under the change. This contract inverts that. You build the net FIRST by pinning what the code actually does today (including outputs you believe are wrong), prove the net holds against the unchanged code, and only then move structure – one mechanical step at a time, re-verifying after each. The un-clonable part is the discipline a rewrite-happy assistant resists: you inventory the real behaviour surface before you touch anything, you deliberately lock in behaviour you may think is a bug, you treat zero behaviour change as the goal rather than the constraint, and you verify per move with evidence instead of per batch on faith – so the exact step that broke parity is the one you revert.

Fill in: target_code test_cmd

Shared as is, for reference. Read it and decide what it will do before you run it; using it is your responsibility, under the terms.