Repository navigation
fix: keep indirect consumers in dead-code analysis - #183376
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR models indirect MCP, Python-generated, CLI-shim, and maintained-test consumers in unused-export analysis. Example: The MCP runtime selects projectBundleMcpServerCatalog through its lazy module loader.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs concrete analyzer blind spots using the existing owner, and no introduced correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherRepository dead-code commands feed source files and configuration through Knip compilers, which project otherwise invisible imports into the graph used to report unused files and exports. flowchart LR
A[Source consumers] --> B[Dynamic consumer compiler]
C[CLI shims] --> D[MJS compiler]
E[Maintained tests] --> F[Script scan roots]
B --> G[Knip analysis]
D --> G
F --> G
G --> H[Unused export findings]
Technical reviewBest possible solution: Keep exact source-derived edges in the existing compilers while preserving independent production, full-tree, and script export audits. Do we have a high-confidence way to reproduce the issue? Source inspection confirms live indirect consumers and missing current-main projections; the PR reports their findings disappearing in canonical scans, but this review ran no target code. Is this the best way to solve the issue? The patch uses the existing projection owner and narrowly adds real test roots, preserving typed-export auditing without broad ignores or changes to runtime producers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against de55ea305cbd. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +95, Other +142. Total +237 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 25, 2026, 3:31 AM ET / 07:31 UTC. |
|
Fixed: Dead-code analysis now follows indirect live consumers while preserving genuine unused-export findings. |
Dead-code analysis now follows source-derived MCP, generated Python, typed CLI shim, and maintained test consumers while preserving genuine unused-export findings.
What Problem This Solves
The unused-export checks misclassify live functions when their consumers enter the source graph through MCP namespace selection, Python-emitted imports, a typed CLI shim, or maintained tests outside the script scan's existing roots. That makes the checks recommend deleting behavior that is still exercised while obscuring whether a finding represents a genuinely unused export.
User Impact
There is no runtime or user-visible behavior change. Maintainers can rely on the production, full-tree, and script export scans to retain these real consumers while continuing to report unrelated unused exports; MCP, Python instrumentation, docs tooling, CI routing, Docker pruning, and reliability behavior are unchanged.
Why This Change Was Made
The existing analyzer already owns source-derived projections for generated and dynamically selected imports. This change extends that owner instead of changing producers or adding exceptions:
agent-bundle-mcp-runtime-modules.tsand the members actually selected byagent-bundle-mcp-runtime.ts.edit(...)transformations and the import declarations emitted bysession-row-churn-instrument.py; the instrumenter and benchmark are not executed.runNodeCliShimandrunTsxCliShimimplementations become side-effect imports, so their internal imports are reachable without treating every implementation export as a public entry.srcglob or a new ignore.The compiler contract removes each projected edge when its real source consumer disappears and verifies that typed implementations remain auditable.
Evidence
Remote validation ran on the exact final tree
0a78cf68105a9254f7eb72b9f7e0cd4d9143f316:Hosted CI, independent review, and the repository's exact-head automated review remain pending on the published head. No runtime MCP session or Python benchmark was run because this PR changes only analyzer modeling and its contract tests.