Skip to content

Uncomputed graph metrics are None, and zero-dependency mode computes PageRank (#3027) - #3032

Merged
squid-protocol merged 2 commits into
mainfrom
fix/3027-uncomputed-graph-metrics
Sep 14, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/3027-uncomputed-graph-metrics

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

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:

  • Without networkx: PageRank, blast radius, betweenness, closeness and systemic_threat_vector.
  • With networkx: closeness above 1,500 files, which covers the whole crucible corpus.
  • Any convergence failure: every centrality metric.

Consumers then drew conclusions from those zeros:

  • a false "Containment (Low Risk)" AI-topology verdict
  • bottleneck rankings filled with five zero-score files picked by path order
  • the brief's §3.5 table printing Modularity 0.0 / Cyclic Density 0.0%
  • zeroed archetype features
  • requires_hitl and --max-systemic-threat that could never fire

What

1. Zero-dependency mode computes PageRank instead of skipping it

network_risk_sensor._pagerank() is a pure-Python weighted PageRank with nx.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:

graph nodes edges max |Δ| mismatches at stored precision time
self-scan 395 497 1.4e-17 0 17 ms
language-crucible v1.2.0 2,817 1,354 6.6e-16 0 9 ms (nx: 152 ms)

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.pagerank is no longer called at all. That also closes a hidden failure: networkx declares no dependencies, but nx.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_radius and systemic_threat_vector are now identical in both modes. That in turn means the following work without networkx, exactly as with it:

2. Whatever still isn't computed is None, never 0.0

3. Docs and messages

  • docs/zero_dependency_mode.md is rewritten for the new behaviour; most Zero-dependency mode: exact degree counts + document what the mode costs (#3024) #3030 caveats are gone.
  • The console banner, SARIF GG-SYS-ZERO-DEP note and LLM-brief banner now say that PageRank is computed and uncomputed metrics are n/a.
  • Also updated: the README zero-dependency section, the 02-16 wiki (which now mentions the >1,500-file closeness gap in full precision), CLAUDE.md, and self_scan.py. Its post-scan check used "PageRank NULL for every file" as the zero-dependency detector; it now reads repo_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.0 scan against the committed fixture.

Full precision: 1 difference. systemic_bottlenecks.fragile_dependency_chain went from five abapGit files scoring 0.0 to []. 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:

moved count cause
per-file Composition Fit (Z-Score) 2,275 archetype classifier's log_pagerank / log_blast_radius features were zeros
per-file Composition Archetype 52 same
File Composition Distribution rows 28 14 archetype rows, each appearing twice, following the 52 relabels
repo composition fit z-score 2 pagerank_gini coupling feature
systemic_bottlenecks 3 see below

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

vs the full-precision fixture archetype mismatches fit-z mismatches repo fit z / distribution
old zero-dependency fixture 52 2,275 differ
new zero-dependency scan 0 0 identical

The zero-dependency bottleneck changes:

  • undocumented_critical_path is now identical to full precision (jquery core.js 664.3, fastapi exceptions.py 572.5, ...). It used to be five zero-score files.
  • cascading_state_mutation and fragile_dependency_chain are []. They need betweenness and closeness, which are not computed without networkx.

No coordinate ripple and no risk-score ripple in either mode.

Verification

  • New tests/core_engine/test_uncomputed_graph_metrics.py:
    • native PageRank vs nx.pagerank on 3 seeded random weighted graphs (<1e-12, identical at 6 dp), plus the edge cases (empty, edgeless, non-convergence)
    • the PageRank fields are identical across modes on a graph with a repeat import, an entity import, a cycle, a dangling node and an isolated node; betweenness/closeness are None without networkx
    • closeness above 1,500 nodes is None, not 0.0
    • a zero-dependency DB keeps native PageRank and producer_ratio, with NULL betweenness/closeness and topology
    • the brief's §3.5 renders n/a, and real values unchanged
  • Added to existing test files:
    • AI topology skips uncomputed metrics (no "Containment")
    • bottleneck rankings exclude uncomputed metrics
    • supply-chain weighting tolerates None
    • the sensor's fallback test asserts None centralities; the centrality-failure test now fails betweenness (not PageRank) and checks PageRank survives; a new test covers a PageRank failure
    • test_full_precision_runs_the_native_pagerank_not_networkx: full precision never calls nx.pagerank, and both modes' PageRank fields are equal as floats
  • Removed tests/core_engine/test_zero_dependency_gate.py, because the gate it covered is no longer skipped.
  • Full 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

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 as 0.0. docs/zero_dependency_mode.md's caveats say so.

🤖 Generated with Claude Code

#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]>
@squid-protocol squid-protocol added bug Unintended behavior or logic failure in the engine metrics Heuristics, risk exposures, and topological math updates labels Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

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]>
@squid-protocol
squid-protocol merged commit a9ff83d into main Sep 14, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the fix/3027-uncomputed-graph-metrics branch September 14, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unintended behavior or logic failure in the engine metrics Heuristics, risk exposures, and topological math updates

Projects

None yet

1 participant