feat(audit): dead-code deletion_safety cross-check (closes #238) - #243
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…afety (closes #238) `audit --check dead-code` reported `status: dead` from the registry with no signal about whether a finding is actually safe to delete — an agent had to manually chain a separate `context --check trace --direction up` call per finding to rule out entry points (exactly the caveat already documented in CONTEXT.md: "status: dead != aman dihapus"). `impact_engine.analyze_impact(name, action="delete")` already computes this exact signal (risk level from real dependents), it just wasn't wired into the dead-code command output. Each finding (capped at --verify-impact-limit, default 20, across all categories combined) now gets a `deletion_safety` field: safe / caution / entry_point_likely / unknown (on a per-item analyze_impact failure — never crashes the whole report). Opt out entirely with --no-verify-impact. Verified on a real workspace: AdGate.tsx's default export (flagged unused_exports — genuinely never imported directly, confirmed earlier this session) is correctly tagged entry_point_likely because analyze_impact finds 6 real direct dependents through other paths, exactly the false-confidence trap this issue set out to close.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #238.
Summary
audit --check dead-codefindings now carry adeletion_safetyfield (safe/caution/entry_point_likely/unknown), computed by cross-referencing the already-existingimpact_engine.analyze_impact(action="delete")— no new analysis engine, just wiring two existing pieces together.--verify-impact-limit(default 20, across all categories combined) to bound cost on large result sets;--no-verify-impactopts out entirely.deletion_safety: "unknown").Test plan
pytest tests/test_dead_code_command.py— 4/4 new tests (entry-point flagging, opt-out flag, limit cap, failure isolation)pytest tests/test_deadcode_engine.py tests/test_issue195_consolidation.py tests/test_command_registry.py— 58/58 passAdGate.tsx's default export (genuinely unused as a direct import, confirmed earlier this session) now correctly showsdeletion_safety: entry_point_likelybecauseanalyze_impactfinds 6 real dependents through other paths — exactly the false-confidence trap this closes.