fix(reachability): make get_all_reachable() overwrite the cache so a stale bounded False is corrected#100
Open
gadievron wants to merge 1 commit into
Conversation
…stale bounded False is corrected ReachabilityAnalyzer has two cache-population paths that disagree: - is_reachable_from_entry_point() is a depth-BOUNDED reverse BFS; for a function farther than max_depth hops from an entry point it caches False -- a false negative; - get_all_reachable() is an UNBOUNDED forward BFS (the complete reachable set). get_all_reachable() updated the shared _reachability_cache only for keys NOT already present, so a stale False seeded by an earlier bounded per-query call was frozen and never corrected -- the complete pass could not fix it (order-dependent wrong result). Overwrite the cache unconditionally: get_all_reachable() is authoritative. Because its forward graph is built from the same reverse edges the bounded BFS walks, this can only flip a stale False->True, never introduce a false positive. Tests: tests/test_reachability_cache.py -- a function reachable only beyond max_depth is cached False by the reverse BFS, then get_all_reachable() corrects it to True (and a disconnected node stays unreachable, a within-depth node stays reachable). RED 1 failed (stale False frozen) -> GREEN 2 passed (venv py3.11); ruff clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
ReachabilityAnalyzer has two cache-population paths that disagree:
hops from an entry point it caches False -- a false negative;
get_all_reachable() updated the shared _reachability_cache only for keys NOT already present, so a stale
False seeded by an earlier bounded per-query call was frozen and never corrected -- the complete pass
could not fix it (order-dependent wrong result). Overwrite the cache unconditionally: get_all_reachable()
is authoritative. Because its forward graph is built from the same reverse edges the bounded BFS walks,
this can only flip a stale False->True, never introduce a false positive.
Tests: tests/test_reachability_cache.py -- a function reachable only beyond max_depth is cached False
by the reverse BFS, then get_all_reachable() corrects it to True (and a disconnected node stays
unreachable, a within-depth node stays reachable). RED 1 failed (stale False frozen) -> GREEN 2 passed
(venv py3.11); ruff clean.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com