Repository navigation
Uncomputed graph metrics are None, and zero-dependency mode computes PageRank (#3027) - #3032
Merged
Merged
Conversation
#3027) A graph metric that was never computed was written as 0.0 -- every networkx-only metric in zero-dependency mode, closeness above 1,500 files in every mode, everything on a convergence failure -- and consumers read it as a measurement: a false "Containment (Low Risk)" AI verdict, bottleneck rankings of five zero-score files, a 0.0 macro table, zeroed archetype features, a HITL flag and --max-systemic-threat that could never fire. - network_risk_sensor: pure-Python _pagerank() (nx.pagerank's parameters and conventions; max |delta| 6.6e-16 on the crucible graph, identical at the stored 6 dp) so zero-dependency PageRank, blast radius and systemic_threat_vector match full precision. Everything still not computed is None via a shared _network_metrics(). - Consumers made None-aware: AI topology skips insights it can't evaluate; each bottleneck ranking holds only files whose metric was computed; the LLM brief renders n/a; supply_chain_firewall and the --max-systemic-threat gate no longer crash on None. #3030's gate skip is removed -- blast radius is computed in every mode now. - record_keeper reads network columns straight from the sensor instead of NULLing them on the zero-dependency flag (the network half of #3028). - Docs/messages: zero_dependency_mode.md, banner, SARIF, LLM banner, README, wiki, CLAUDE.md, self_scan.py's zero-dep detector. - Golden masters re-blessed. Full precision: 1 diff (fragile_dependency_ chain -> []). Zero-dependency: 2,360 diffs, all from real PageRank -- its composition archetypes / fit z-scores / distribution now equal the full-precision fixture's exactly (52 + 2,275 mismatches -> 0). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
Both graph builders now call one _native_pagerank(), fed identical node and edge order, so the two modes produce the same floats and no networkx release can move them. nx.pagerank is no longer called: in networkx 3.x it dispatches to a numpy/scipy backend networkx does not install, so with networkx alone it raised and every file's PageRank was silently lost. PageRank is also computed outside the networkx try-block now, so a centrality failure can't take it down. Golden masters: both modes unchanged (crucible_check --mode both PASS). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
8 tasks done
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 #3027. Also fixes the network half of #3028.
Why
A graph metric that was never computed was written as
0.0, and every consumer read that as a measurement. This happened in three places:systemic_threat_vector.Consumers then drew conclusions from those zeros:
Modularity 0.0 / Cyclic Density 0.0%requires_hitland--max-systemic-threatthat could never fireWhat
1. Zero-dependency mode computes PageRank instead of skipping it
network_risk_sensor._pagerank()is a pure-Python weighted PageRank withnx.pagerank's parameters and conventions: alpha 0.85, uniform teleport, dangling mass spread uniformly, out-weight normalisation, and the N·tol L1 stopping rule. It was checked against networkx before writing any code:Full precision runs the same implementation. Both graph builders call
_native_pagerank(), fed identical node and edge order, so the two modes produce the same floats, not merely the same rounding.nx.pagerankis no longer called at all. That also closes a hidden failure: networkx declares no dependencies, butnx.pagerank(3.x) needs numpy/scipy. With networkx alone it raised, and every file's PageRank was silently lost, which no zero-dependency flag reported. No networkx release can move these numbers now.So
pagerank_score,normalized_blast_radiusandsystemic_threat_vectorare now identical in both modes. That in turn means the following work without networkx, exactly as with it:--max-systemic-threat, so Zero-dependency mode: exact degree counts + document what the mode costs (#3024) #3030's warn-and-skip helper is removed2. Whatever still isn't computed is
None, never0.0_network_metrics()builds each file's metrics for both graph builders. Closeness skipped above 1,500 nodes, a failed computation, and betweenness/closeness without networkx are allNone.signal_processorAI topology skips any insight whose metric is missing.n/a: the §3.5 macro table showsn/a (not computed)per cell, and per-file topology showsn/a.supply_chain_firewalland the--max-systemic-threatgate no longer crash onNone. A failed PageRank is reported as "not evaluated" for that file.record_keeper(the network half of Zero-dependency mode: DB NULLs network + ML columns on the global flag, not per package (a missing pyyaml discards real PageRank); pandas/numpy never reported #3028): network columns are read straight from the sensor, soNonebecomes NULL. Previously they were NULLed whenever the scan ran in zero-dependency mode, which would have discarded the new native PageRank, andproducer_ratio/ecosystem_roletoo, although those are exact.ai_threat_scorekeeps its mode gate until Zero-dependency mode: DB NULLs network + ML columns on the global flag, not per package (a missing pyyaml discards real PageRank); pandas/numpy never reported #3028's ML half.3. Docs and messages
docs/zero_dependency_mode.mdis rewritten for the new behaviour; most Zero-dependency mode: exact degree counts + document what the mode costs (#3024) #3030 caveats are gone.GG-SYS-ZERO-DEPnote and LLM-brief banner now say that PageRank is computed and uncomputed metrics aren/a.02-16wiki (which now mentions the >1,500-file closeness gap in full precision), CLAUDE.md, andself_scan.py. Its post-scan check used "PageRank NULL for every file" as the zero-dependency detector; it now readsrepo_data.is_zero_dependency_mode.Golden masters
Both fixtures were re-blessed. Each was scoped by an uncapped diff of a fresh language-crucible
v1.2.0scan against the committed fixture.Full precision: 1 difference.
systemic_bottlenecks.fragile_dependency_chainwent from five abapGit files scoring0.0to[]. That ranking multiplies closeness, which is skipped above 1,500 files, and the corpus has 2,817. Nothing else moved.Zero-dependency: 2,360 differences. All of them come from PageRank now being real instead of
0.0:Composition Fit (Z-Score)log_pagerank/log_blast_radiusfeatures were zerosComposition ArchetypeFile Composition Distributionrowspagerank_ginicoupling featuresystemic_bottlenecksThe check that this is the right movement: the zero-dependency composition output should now equal full precision's, since the two modes' PageRank is identical.
The zero-dependency bottleneck changes:
undocumented_critical_pathis now identical to full precision (jquerycore.js664.3, fastapiexceptions.py572.5, ...). It used to be five zero-score files.cascading_state_mutationandfragile_dependency_chainare[]. They need betweenness and closeness, which are not computed without networkx.No coordinate ripple and no risk-score ripple in either mode.
Verification
tests/core_engine/test_uncomputed_graph_metrics.py:nx.pagerankon 3 seeded random weighted graphs (<1e-12, identical at 6 dp), plus the edge cases (empty, edgeless, non-convergence)Nonewithout networkxNone, not0.0producer_ratio, with NULL betweenness/closeness and topologyn/a, and real values unchangedNoneNonecentralities; the centrality-failure test now fails betweenness (not PageRank) and checks PageRank survives; a new test covers a PageRank failuretest_full_precision_runs_the_native_pagerank_not_networkx: full precision never callsnx.pagerank, and both modes' PageRank fields are equal as floatstests/core_engine/test_zero_dependency_gate.py, because the gate it covered is no longer skipped.pytest tests/: 8,896 passed, 4 skipped, 9 xfailed, 3 xpassed.ruff_audit --ci(record_keeper baseline keys line-shifted),mypy_audit --ci,dead_key_audit --ci,ruff format --check: pass.Follow-ups
Nonehere, because networkx's sampled betweenness needs a design call.ai_threat_scoreis gated on the global flag, the ML columns carry'Safe'/0placeholders, and pandas/numpy aren't reported.Cross-repo
Temporal-crucible history recorded before this merge has zero-dependency PageRank as NULL (DB) or
0.0, and full-precision closeness above 1,500 files as0.0.docs/zero_dependency_mode.md's caveats say so.🤖 Generated with Claude Code