Repository navigation
Native graph engine: exact security_auditor reach counts, no 500 cap (#3040) - #3052
Merged
Merged
Conversation
Contributor
squid-protocol
force-pushed
the
fix/3040-exact-reach-counts
branch
from
September 15, 2026 00:19
352d315 to
fe7e87a
Compare
…3040) - graph_engine.strongly_connected_components(): the iterative Tarjan nodes_in_cycles already ran, now shared. Components are numbered in completion order, i.e. reverse topological order of the condensation. - graph_engine.reach_counts(): exact descendants/ancestors per node, computed by SCC condensation + Python-int reachability bitsets ORed along the condensation. Equal to len(nx.descendants)/len(nx.ancestors): a node is never its own dependency, not even on a cycle. Each OR charges a WorkBudget in 64-bit words, so a huge layered graph fails soft instead of exhausting memory. - security_auditor._resolve_dependency_graph: one native implementation in both modes, replacing min(len(nx.descendants), 500) and the deque-BFS fallback. The fallback counted a cycle file as its own dependency, and its cap check could overshoot. Past the budget, totals and ratios are None; the ML feature matrix maps None to NaN (XGBoost's missing value). - networkx is no longer imported by security_auditor. - language-crucible: exact; 4.3 ms vs 7 ms per direction. - ruff baseline regenerated for one pure line-shift (RUF046, unchanged). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ounts)
Uncapped golden_diff scope: full precision 0 differences (crucible_check
--update: no drift -- the cap never bound on crucible). Zero dependency
exactly 20: 10 files x {Total Upstream, Total Downstream}, each dropping
by exactly 1 to the full-precision value -- the files on import cycles,
which the old BFS fallback counted as their own dependency.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
squid-protocol
force-pushed
the
fix/3040-exact-reach-counts
branch
from
September 15, 2026 00:25
fe7e87a to
cb5cb2d
Compare
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 #3040. Part of #3033 (the native graph engine). Stacked: #3047 (#3036) → #3048 (#3038) → #3049 (#3039) → this PR. The branch carries their commits until they merge. Only the last commit, plus its re-bless, is this PR's own.
What changed
security_auditor._resolve_dependency_graphnow has one native implementation for both modes. It computestotal_upstream, the files a file depends on (directly or transitively), andtotal_downstream, the files that depend on it. It replaces two implementations that disagreed:min(len(nx.descendants), 500)len(nx.descendants)exactlygraph_engine.reach_counts(index, budget)does the work. It condenses strongly connected components, then builds each component's reachable node set as a Python-int bitset:strongly_connected_components()is the iterative Tarjan thatnodes_in_cycles(#3035) already ran, now shared. Its components are numbered in reverse topological order of the condensation.Memory guard: a Python int is as long as its highest set bit, so on a huge, deeply layered graph the bitsets can total O(N²) bits. The old 500 cap existed to prevent exactly that blow-up. Each OR now charges the deterministic
WorkBudget(PATH_METRICS_WORK_BUDGET) in 64-bit words. Past the budget, the totals and ratios areNone, never a placeholder 0 (#3027). The audit JSON then showsnull, and the ML feature matrix mapsNoneto NaN, which XGBoost treats as a missing value.security_auditorno longer imports networkx.Parity and speed
descendants/ancestorsregistered astailoredingraph_parity.py)len(nx.descendants/ancestors)for every file (new test)Golden masters
I diffed fresh scans of each mode against the committed fixtures with an uncapped
golden_diff.deep_compare. The scans usedGITGALAXY_DISABLE_GIT_HISTORY=1and the same flags astest_golden_crucible.py.len(nx.descendants/ancestors).tcl/macports_registry/{portimage,registry}.tclzig/tigerbeetle/{config,constants}.zigzig/zig/{Compilation,InternPool,Type,Zcu}.zigzig/zls/{DocumentStore,analysis}.zigThe zero-dependency fixture is re-blessed in the second commit.
Verification
pytestpasses on the affected suites: graph engine, security auditor, the sensor tests, state rehydrator, signal processor, and the LLM/record/audit recorders (536 passed).Noneaudit_check.py: all clear. The ruff baseline is regenerated for one pure line-shift (RUF046, same finding, moved).zero_dependency_mode.md(the reach row is now identical in both modes; older-snapshots note) and the 02-20 wiki.🤖 Generated with Claude Code