Skip to content

Add --transitive: settle on what only dead code references - #72

Draft
Komoszek wants to merge 1 commit into
claude/issue-58-split-finderfrom
claude/issue-58-transitive
Draft

Komoszek wants to merge 1 commit into
claude/issue-58-split-finderfrom
claude/issue-58-transitive

Conversation

@Komoszek

@Komoszek Komoszek commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Closes #58. Stacked on #71.

The text a removal deletes keeps nothing alive. With --transitive each round drops the references inside the previous round's removable findings and classifies again, until nothing changes. One run, no new reference queries (the cross-library probe covers only newly emptied names; override and superclass lookups are memoized), works in a plain report too. Default output is unchanged.

  • dead_spans.dart: the deleted text as a per-file span index. Only non-removalBlocked findings contribute, so the set the report assumes deleted is exactly what --remove deletes.
  • settler.dart: settle loops _round until the span set is stable (cap 16; the set only grows); _liveRefs, _onlyReferencedFrom, memoized overrides and probe names.
  • CrossLibraryReferences.merged / .where.
  • A finding dead only because its container is goes unreported with the container.
  • UnusedDeclaration.onlyReferencedFrom: every dead declaration it hangs on, in source order (text and -f github show the first plus a count; -f json the list).
  • --[no-]transitive, transitive: in ciach.yaml. Off by default.
  • Fixture scenarios/transitive.dart + tests, including: after --remove on a copy, a second run has nothing left to remove; a helper two dead roots call names both. A mutually recursive pair stays — Report dead reference cycles (reachability from live roots) #65.

🤖 Generated with Claude Code

https://claude.ai/code/session_011fqaUyaQtY7AkuTYBjAUJv

@Komoszek
Komoszek added this pull request to stack #73 September 22, 2026 06:17
@Komoszek
Komoszek removed this pull request from stack #73 September 22, 2026 06:20
@Komoszek
Komoszek added this pull request to stack #74 September 22, 2026 06:21
The text a removal deletes keeps nothing alive. With `--transitive`,
the settler runs in rounds: each drops the references inside the
previous round's removable findings and classifies again, until
nothing changes — one run, no new reference queries: the cross-library
probe covers only newly emptied names, override and superclass lookups
are memoized. Round one is the plain result, so the default output is
unchanged.

Only findings `--remove` would delete count as gone, so the set the
report assumes deleted is the set removed. A finding dead only because
its container is goes unreported with the container. Each finding this
adds names every dead declaration it hangs on (`onlyReferencedFrom`),
in source order — several may reference the same one.

Off by default: a false positive takes everything only it referenced
with it. A cycle keeps itself alive; that is #65.

Closes #58.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011fqaUyaQtY7AkuTYBjAUJv
@Komoszek
Komoszek force-pushed the claude/issue-58-transitive branch from 55c60ee to d03cf17 Compare September 22, 2026 06:28

This branch has not been deployed

No deployments
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.

ciach should report (and remove) transitively dead code

2 participants