Skip to content

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
masterfrom
fix/reachability-make-get-all-reachable-overwrite-the-cache
Open

fix(reachability): make get_all_reachable() overwrite the cache so a stale bounded False is corrected#100
gadievron wants to merge 1 commit into
masterfrom
fix/reachability-make-get-all-reachable-overwrite-the-cache

Conversation

@gadievron
Copy link
Copy Markdown
Collaborator

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

…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>
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.

1 participant