Prevent Drift Regressions on a Legacy Module
Baseline a legacy module exactly as it is with vg baseline --cwd, then gate it with vg scan --baseline so any change that adds drift to the old code fails. Hold the line without a rewrite.
You can't always rewrite a legacy module, but you can stop it from getting worse. By baselining the module exactly as it is and gating against that baseline, any change that adds drift to the old code fails, while the rest of the codebase keeps improving.
Prerequisites
- Vibgrate CLI installed (
npm i -g @vibgrate/cli) - A legacy module isolated in its own directory
Steps
1. Isolate the legacy module
Identify the directory holding the legacy code, for example src/legacy.
2. Baseline the module as-is
Capture the legacy module's current drift, warts and all, with --cwd:
vg baseline --cwd src/legacy
3. Scan the module against its baseline
Compare the module against its own frozen snapshot:
vg scan --cwd src/legacy --baseline .vibgrate/baseline.json
4. Add a no-worse gate in CI
Add this scoped scan as a CI step. Because it compares against the baseline, it fails only when a change adds new drift to the legacy module, enforcing a no-worse rule.
5. Verify the legacy gate
Make an edit that introduces drift in src/legacy and confirm the step fails; make an unrelated edit elsewhere and confirm it passes.
Verification
The legacy-scoped baseline scan exits zero as long as the module's drift does not increase, and non-zero the moment it does, holding the line without a rewrite.
Next Steps
- Once you do improve the module, re-baseline to lock in the gain.
- Apply per-team budgets so the legacy owner is accountable.