optimize refactor-system: d4 — no-tests STOP gate (agent) + user arbitration loop (dispatcher) + mid-run test-failure revert; code-cleaner inline carve-out
This commit is contained in:
+12
-2
@@ -19,9 +19,18 @@ Improve code without ever changing its external behavior.
|
|||||||
|
|
||||||
1. Analyze the target — list ALL violations
|
1. Analyze the target — list ALL violations
|
||||||
2. Produce the report BEFORE touching anything
|
2. Produce the report BEFORE touching anything
|
||||||
3. Check that tests exist (if not — report before modifying)
|
3. Check that tests exist covering the target.
|
||||||
|
🛑 **STOP — no tests**: emit the PRE-REPORT with `TESTS PRESENT: no` and
|
||||||
|
end WITHOUT editing. Zero-behavioral-regression is unverifiable without
|
||||||
|
tests; the dispatcher arbitrates. Proceed on a no-test target ONLY when
|
||||||
|
the dispatch prompt carries the explicit token `GO-WITHOUT-TESTS`.
|
||||||
|
(Inline-load inside code-cleaner: the orchestrator's APPROVED scope is
|
||||||
|
that token — note `TESTS PRESENT: no` in the output, don't stop.)
|
||||||
4. Refactor function by function
|
4. Refactor function by function
|
||||||
5. Verify tests pass after each modification
|
5. Run the tests after each modification.
|
||||||
|
Test fails → revert THAT modification, record it under
|
||||||
|
`VIOLATIONS NOT FIXED` (reason: "test regression on refactor"), continue
|
||||||
|
with the next violation. Never leave the suite red between steps.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -60,6 +69,7 @@ TESTS PRESENT: yes / no
|
|||||||
|
|
||||||
- Zero behavioral regression
|
- Zero behavioral regression
|
||||||
- Existing tests must pass
|
- Existing tests must pass
|
||||||
|
- No tests on the target → PRE-REPORT + STOP (unless dispatched with `GO-WITHOUT-TESTS`)
|
||||||
- Do not modify business logic under the guise of refactoring
|
- Do not modify business logic under the guise of refactoring
|
||||||
- Do not refactor unrelated parts
|
- Do not refactor unrelated parts
|
||||||
|
|
||||||
|
|||||||
@@ -18,3 +18,9 @@ $ARGUMENTS"
|
|||||||
|
|
||||||
If the refactorer agent is unavailable, emit `Refactorer agent missing.` and
|
If the refactorer agent is unavailable, emit `Refactorer agent missing.` and
|
||||||
STOP — never improvise, silent behavior change is unsafe.
|
STOP — never improvise, silent behavior change is unsafe.
|
||||||
|
|
||||||
|
🔴 **No-tests gate**: when the agent returns `TESTS PRESENT: no` and stopped
|
||||||
|
(its contract on a test-less target), do NOT re-dispatch on your own. Surface
|
||||||
|
its PRE-REPORT and ask the user: add tests first / proceed anyway / abort.
|
||||||
|
Only an explicit "proceed" re-dispatches with the `GO-WITHOUT-TESTS` token —
|
||||||
|
behavior preservation is unverifiable on that path and the user owns that risk.
|
||||||
|
|||||||
Reference in New Issue
Block a user