Skip to content

Add opt-in debug diagnostics for rstest companion-module detection decisions in src/hir/mod.rs #229

@coderabbitai

Description

@coderabbitai

Summary

collect_rstest_companion_test_functions in src/hir/mod.rs marks functions as test-context based on companion-module detection heuristics, but emits no logging, diagnostics, or spans when it does so. Maintainers cannot observe which functions were marked, which qualification path was taken, or detect false positives at runtime.

Problem

Adding unconditional per-function diagnostic notes (e.g. via cx.span_note()) would be prohibitively verbose in normal use. However, the absence of any observability makes it difficult to:

  • Diagnose false positives or false negatives in companion-module detection.
  • Validate that the correct qualification path (descriptor-only, fn/const pair, etc.) was taken for a given function.
  • Investigate CI failures where a lint fires or is silenced unexpectedly.

Proposed resolution

Add an opt-in debug diagnostic mode, gated on either an environment variable (e.g. WHITAKER_DEBUG_COMPANION_DETECTION=1) or a dylint.toml configuration key. When enabled:

  1. Emit an info-level note for each function marked as test-context, including the function name, module path, and which qualification pattern matched.
  2. Emit a debug-level note for edge cases (empty candidate modules, modules with no harness items, false-positive sibling modules that were rejected).
  3. Optionally, warn when a module's item count exceeds a configurable threshold (e.g. ~100 items per scope) to surface the O(n²) complexity concern tracked by issue #225.

Context

Identified during review of PR #221. The companion-module detection heuristic and its acknowledged false-positive risks are documented in docs/developers-guide.md under Regression infrastructure → Test-context ancestry detection.

Raised by @leynos.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions