Skip to content

Commit 389f005

Browse files
authored
Merge pull request #85 from Refactron-ai/docs/r4-oracle-and-shadow-guidance
docs(verify): oracle-limit example and shadow sys.path guidance
2 parents cc2b29e + ba91e9f commit 389f005

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎docs/styles/config/vocabularies/Mintlify/accept.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ builtin
2626
bool
2727
subprocess
2828
subprocesses
29+
src
30+
sys

‎docs/verification/verdicts.mdx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ Without that wiring, a change whose only exercise happens inside a subprocess re
106106

107107
Refactron cannot turn a weak suite into a strong one, but it refuses to overstate what a green run proves. That is why `UNPROVEN` exists, and why every uncovered changed line ships with a `missingTests` hint: the path to a `SAFE` you can trust is a suite that actually exercises the behavior you care about.
108108

109+
A worked example from our own hardening runs, on a real library. Jinja2's `truncate` filter guards its early return with `if len(s) <= length + leeway`. Change that `<=` to `<` and the behavior genuinely changes: at the exact boundary the string is now truncated instead of returned whole. All 911 tests in Jinja2's suite still pass, because none of them lands on that precise boundary, and the changed line is covered, so the verdict is `SAFE`.
110+
111+
That verdict is correct about what it claims (the suite ran this line and stayed green) and it is still not a proof of correctness. Boundary conditions are exactly where suites tend to be thin. Read `SAFE` as "your tests approve this change", then decide separately whether your tests are strong where this change lives.
112+
113+
## Make sure the tests run the code being verified
114+
115+
Refactron verifies a change in an isolated copy of your project. If your tests import the package from somewhere else, they will exercise the original code and the run proves nothing about your change.
116+
117+
The common cause is a project installed into the environment, including an editable install (`pip install -e .`), because `import yourpackage` then resolves to the installed location rather than the copy under verification. We hit this on Django: the same diff read `UNPROVEN` when the tests loaded the installed copy, and `UNSAFE` (correctly, since the auth suite catches the change) once the verified copy came first on `sys.path`.
118+
119+
Refactron detects the case rather than guessing: if a changed file is never even measured by coverage, the verdict reports that coverage could not be determined instead of claiming the code is untested. To get a real verdict, make the verified tree win on `sys.path`, for example by exporting `PYTHONPATH=.` (or `PYTHONPATH=src` for a src layout) alongside your test command. Relative paths are resolved from the copy being verified, which is what you want here.
120+
109121
## Exit codes
110122

111123
The verdict maps to a process exit code so it can gate CI directly:

‎docs/verification/verify-diff.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Refactron applies the diff in an isolated shadow tree, runs the syntax, imports,
3333
a `multiprocessing` worker reads as `UNPROVEN` until in-process subprocess coverage lands.
3434
</Warning>
3535

36+
If your project is installed into the environment (an editable `pip install -e .` counts), your tests may import that copy instead of the one being verified, in which case the run proves nothing about your change. Put the verified tree first on `sys.path`, for example `PYTHONPATH=.` (or `PYTHONPATH=src` for a src layout). See [Make sure the tests run the code being verified](/verification/verdicts#make-sure-the-tests-run-the-code-being-verified).
37+
3638
## Install (from source)
3739

3840
<Note>

0 commit comments

Comments
 (0)