Skip to content

feat(audit): dead-code deletion_safety cross-check (closes #238) - #243

Merged
Wolfvin merged 1 commit into
mainfrom
feat/issue-238-dead-code-deletion-safety
Jul 12, 2026
Merged

feat(audit): dead-code deletion_safety cross-check (closes #238)#243
Wolfvin merged 1 commit into
mainfrom
feat/issue-238-dead-code-deletion-safety

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Closes #238.

Summary

  • audit --check dead-code findings now carry a deletion_safety field (safe/caution/entry_point_likely/unknown), computed by cross-referencing the already-existing impact_engine.analyze_impact(action="delete") — no new analysis engine, just wiring two existing pieces together.
  • Capped at --verify-impact-limit (default 20, across all categories combined) to bound cost on large result sets; --no-verify-impact opts out entirely.
  • Per-item failures in the cross-check never crash the whole report (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 pass
  • Manual verification on real workspace: AdGate.tsx's default export (genuinely unused as a direct import, confirmed earlier this session) now correctly shows deletion_safety: entry_point_likely because analyze_impact finds 6 real dependents through other paths — exactly the false-confidence trap this closes.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Wolfvin
Wolfvin merged commit 0a5762d into main Jul 12, 2026
1 of 7 checks passed
@Wolfvin
Wolfvin deleted the feat/issue-238-dead-code-deletion-safety branch July 12, 2026 12:41
…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.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(audit): dead-code findings auto-annotated with impact/trace safety verdict

1 participant