Skip to content

feat(metrics): add orphan-file detection via manifest and configured entry points - #207

Merged
avidianity merged 9 commits into
mainfrom
feat/175-orphan-files
Nov 23, 2026
Merged

avidianity merged 9 commits into
mainfrom
feat/175-orphan-files

Conversation

@avidianity

@avidianity avidianity commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds language-neutral Orphan files detection across all five built-in Language plugins (TypeScript/JavaScript/Vue/Svelte, Rust, Python, PHP, Dart) and external WebAssembly Plugins: extracts standard manifest entry points (package.json, Cargo.toml, pyproject.toml, composer.json, pubspec.yaml), supports optional entry_points path globs in codeint.json, computes Production reachability over resolved runtime imports (annotating files reachable only from Test files as test-only, staying silently inactive when zero entry points exist, and excluding Generated/Vendored Source sets), and integrates Budgets, CODEOWNERS attribution, codeint diff Regression gating, codeint config --resolved, codeint report, codeint schema, and codeint mcp.

Closes #175
Closes #198
Closes #199

Tier

Tier 3 from the tier check: crates/cli/tests/check.rs and crates/cli/tests/schema.rs update existing allowed-key and built-in-metric assertions to include entry_points and orphan_files.

Task

Spec #175 and sub-issues #198, #199:

Fail-first test

  • Test: plugins/languages/{ts,rust,python,php,dart}/tests/entry_points.rs, crates/metrics/src/orphan_files/tests.rs (detects_live_unreferenced_and_test_only_production_files), and crates/cli/tests/orphan_files.rs (ts_check_reports_orphan_files_across_toon_json_sarif_and_markdown_excluding_generated_and_vendored)
  • Before the change: all 5 plugin entry-point tests returned [], all 5 core reachability tests failed (entry point activates orphan-file detection), and all 5 CLI/MCP integration tests failed (left: Null, right: 2)
  • After the change: passed (all workspace unit, integration, reference, schema, config, report, and doc tests green)

Checks

Check Result
cargo test --workspace --locked passed
cargo clippy --workspace --all-targets -- -D warnings passed
cargo fmt --check passed
codeint diff f5f6570 passed (0 regressions)
lefthook pre-commit and commit-msg passed
Merged-result check (cargo run --package xtask -- merged-result) passed

Safety proof

  • Safety fact: Repositories with no manifest-declared entry points and no configured entry_points globs experience zero orphan-file Findings (silent no-op), Generated and Vendored Source sets are excluded, LanguagePluginError propagates without swallowing traps, and no combined score is added (ADR 0003).
  • Proof: crates/cli/tests/orphan_files.rs (silent_no_op_when_no_entry_points_and_activates_via_config_entry_points_globs, monorepo_cross_package_reachability_and_isolated_package_safety), crates/cli/src/check/tests.rs (LanguagePluginError propagation), and codeint diff f5f6570 passing with 0 regressions.
  • interrogate: Round 1 Independent Review and adversarial verification found 4 issues (Production-only orphan roots, manifest parent-traversal rejection, Rust explicit [lib] with autolib = false, TS exports null exclusions), fixed in dd9286f. Round 2 clean rerun verified Fixes 1-3 and caught 3 TS nested-package edge cases, fixed in ddddcd3 alongside merging main (f5f6570) at 7091b7a. Round 3 clean rerun on ddddcd3 passed with Verdict: PASS (0 open verified findings).

Runtime evidence

End-to-end CLI and MCP integration tests executed the compiled codeint binary on revision ddddcd3 across TypeScript, Rust, and Python single-package and monorepo fixtures (orphan_files, entry_points, config, report, schema, mcp, reference test suites all passed, and codeint diff f5f6570 exited 0 with zero regressions).

Gaps

  • Deferred coverage: none
  • Pre-existing failures: none
  • Environmental failures: none

Upgrade wit/language.wit and wit/metric.wit to codeint:plugin@0.2.0, adding function name and cognitive-complexity fields, external(string) and builtin resolution variants, declared-dependencies, and entry-points.

Bind 0.2.0 in crates/model and crates/plugin-host, detect incompatible WIT contract versions (such as 0.1.0) with an actionable IncompatibleContractVersion error, add compiling 0.2.0 stubs across all five built-in Language plugins, update the sample Wasm Plugin and sandbox probes, add 0.2.0 contract and 0.1.0 rejection tests, and update Plugin documentation.

Closes #190
Implement entry_points(repository_paths, manifests) for the TypeScript/JavaScript, Rust, Python, PHP, and Dart built-in Language plugins to extract standard manifest-declared entry files from package.json, Cargo.toml, pyproject.toml, composer.json, and pubspec.yaml.

Return only existing repository-relative paths present in repository_paths, deduplicated and sorted deterministically, returning an empty list cleanly when no standard entry points are declared or when a manifest is malformed.

Closes #198
…ets, diff, and MCP

Implement language-neutral Production reachability in codeint-metrics starting from the union of manifest-discovered entry points and codeint.json entry_points globs, classifying unreachable Production files as unreferenced or test-only, excluding Generated and Vendored Source sets, traversing cross-package monorepo imports, and staying silently inactive when zero entry points exist.

Integrate orphan_files independently across TOON, JSON, SARIF, Markdown, per-Source-set Budgets, stable FindingId Regression gating in codeint diff, and codeint mcp, and update schema/codeint.schema.json and docs/reference.md.

Closes #199
@github-actions github-actions Bot added the tier-3 Tier 3 from the tier check label Nov 23, 2026
- Require SourceSet::Production in orphan_files::collect_roots so generated and vendored files do not activate orphan detection.
- Reject parent-traversal segments in TS, Rust, PHP, and Python manifest entry points, and reject path separators or parent segments in Rust bin names.
- Include src/lib.rs in Rust when autolib = false and an explicit [lib] table omits path.
- Subtract null-excluded subpaths from wildcard package.json exports matches in TS.
@avidianity
avidianity merged commit 4d58538 into main Nov 23, 2026
14 checks passed
@avidianity
avidianity deleted the feat/175-orphan-files branch November 23, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tier-3 Tier 3 from the tier check

Projects

None yet

1 participant