mix credence.covers
(credence v0.8.0)
Copy Markdown
Behavioural novelty check (Tunex 07 ยง3.7): run a snippet through
Credence.fix/2 + Credence.analyze/2 in the default (helpful)
assumptions: mode (the same mode solve's Validator runs โ never :strict,
else a switch-gated pattern reads NOVEL here but COVERED in solve), and decide
whether a real rule already engaged:
mix credence.covers path/to/snippet.exs
echo 'Enum.map(x, & &1)' | mix credence.coversPrints COVERED iff:
fix.code != inputโ an existing rule actually rewrote the snippet, OR- the snippet COMPILES and
analyze.issueshas a non-parse-error issue (a real check flagged an idiom in valid code).
else NOVEL.
๐ด Two traps this avoids โ both produced false duplicates that silently dropped genuinely-novel rules (tunex docs/10):
- The synthetic
:parse_errorissue is filtered:Pattern.analyzeemits it for any non-parsing input, so a naiveissues != []would read COVERED on every novel syntax snippet and kill all new-syntax-rule creation. - "A rule fired" must mean a rule changed the code, NOT merely matched. A
non-compiling / incomplete
before(e.g. one that calls a helper it forgot to include) makes a brokenness rule likeUndefinedFunctionor the defmodule-wrapper family match without changing anything, and its compile-error diagnostics surface asanalyze.issues. That is the snippet being broken, not the proposed idiom being covered. Soapplied_rules(which counts no-op matches) is not used, andanalyze.issuesonly counts when the snippet actually compiles.
Still accepts non-parsing input (syntax-rule novelty) and names no rule.
Summary
Functions
COVERED | NOVEL for input (the decision the task prints; exposed for tests).