review_diff grades an edited top-level Rust #[test] function as an untested production change #577
Labels
No labels
code-review
correctness
dos
performance
security
severity/high
severity/low
severity/medium
tech-debt
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
h-dv/code-index#577
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found by a worker in the v0.41.51 train (dogfood batch 18) and reproduced by the lead on the installed release, 0.41.50 (
3d0a584c), in a small git fixture.Reproduction:
lib.rsat the base revision holds a few ordinary functions and one unit test at file level, with no enclosing#[cfg(test)]module:The only change adds
validate_values();to the test body. Then:Actual: one finding,
severity: "medium",reason: "untested_change",name: "standalone_test";summary.changed_test_files: []. Nothing is degraded:classification_degraded: false, resolution 100 %, no truncation.Control:
rustc --test lib.rsruns and passes exactly that test. A changed file undertests/is recognised as a changed test file in the same fixture.Expected: a function annotated
#[test]has the test role wherever it stands. Editing only it raises no productionuntested_change, and it counts as changed-test evidence without making the other symbols of the file tests.Impact: a test-only edit gets a medium production-risk finding and contributes no counter-evidence. The usual low-confidence disclosures do not apply here, so a reader has no reason to doubt the finding.
Scope note: not measured whether the same holds for other languages' file-level test markers (for example a pytest function in a non-test file, or a C#
[Fact]method in a production class).Investigated in the v0.41.51 train; not fixable in the host alone, so it is not in that release.
Where the test role is decided: in the host, by one rule for all seven languages: the file's path (test directories and file-name patterns per language,
crates/indexer/src/test_paths.rs), then the names of enclosing modules, namespaces or classes (test,tests,*_test,*_tests;crates/mcp-server/src/server.rs,symbol_is_test_role). A symbol's own attributes, decorators or name are never read. The container rule is a name heuristic and does not inspect#[cfg(test)], so a#[cfg(test)] mod checks { … }is affected in the same way as the file-level test in the report.Why the host cannot fix it: the language packages emit, per symbol, the line where its attributes start, but not the attributes themselves. A line number cannot tell
#[test]from#[inline].What a fix needs: the packages emit a per-symbol test marker (or normalized attribute/decorator names) through the fact ABI, the index stores it, and the grader uses it next to the path and container rules. That is a change to the ABI and a release of every language package; it belongs with the extraction work in #540.
The same gap applies to the other languages (pytest functions in a non-test file,
[Fact]/[Test]methods in a production class): no language's own markers are read.Merged into #540.
Host symbol_is_test_role in crates/mcp-server/src/server.rs still uses path/container evidence. No package-marker fix shipped.
Remaining: Per-symbol test facts; the ABI, storage, grader and package releases belong together.