mix credence.fix_tests
(credence v0.8.0)
Copy Markdown
Deterministic helper for the tunex rule-gen flow (tunex docs/10).
mix credence.fix_tests test/pattern/foo_fix_test.exs [more_test.exs ...]An LLM building a rule writes assert fix(Rule, input) == expected but can't
byte-predict the rule's exact output, so expected is wrong → the fix test
fails → the Gate rejects the (often correct) rule, and the agent burns turns
guessing. This task removes that class WITHOUT the AI: for each
input = """…""" / expected = """…""" / assert fix(Rule, input) == expected block in a Pattern rule's fix test, it RUNS the rule on input and
rewrites expected to the actual output — which is exactly the project's own
convention ("expected is the rule's REAL output — run it, copy the string").
Safe + conservative:
- Only Pattern rules (it calls
fix_patches/2); the module is derived from the test path and must be loaded (so a rule that doesn't compile is skipped — its failure is a real bug for the agent, not ours). - Only the
fix(Alias, input) == expectedshape with resolvable heredoc operands; anything else is left untouched. - NO-OP fixes (
actual == input) are NOT rewritten — that would create aexpected == inputtest that fails the "real transformation" meta-gate; a no-op fix is a genuine rule bug, left for the agent. - Correctness is still guarded by the rule's equivalence test, not by this
(auto-captured)
expected.
Summary
Functions
Rewrite one fix-test file in place. Best-effort: any problem leaves it untouched.