Skip to content

Native graph engine: remove networkx from the runtime (#3041) - #3054

Merged
squid-protocol merged 2 commits into
mainfrom
fix/3041-remove-networkx
Sep 15, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/3041-remove-networkx

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #3041. Closes #3033 (the native graph engine epic): this is its last sub-issue.

What changed

networkx is no longer a runtime dependency. Since #3034–#3040, every graph metric has been computed by gitgalaxy/core/graph_engine.py, so networkx no longer computed anything. It still did two things, and this PR removes both:

  1. It chose the builder. NetworkRiskSensor had a networkx DiGraph builder and a pure-Python one, and the two already produced identical output: degrees since internal_dependency_links / popularity count import statements in zero-dependency mode but distinct neighbours with networkx #3024, every metric since Native graph engine: cyclic density (SCC) and articulation points in O(V+E) #3035–Native graph engine: exact security_auditor reach counts (no 500 cap) #3040. The DiGraph builder, the HAS_NETWORKX flag and the import networkx are gone. build_dependency_graph is now the single linear builder.
  2. It decided the scan mode. A missing networkx used to turn on Zero-Dependency Mode. galaxyscope.py now leaves networkx out of all of the following:
    • the mode flag
    • the start-of-run banner and end-of-run note
    • both missing_dependencies maps, and so the audit JSON, GPU JSON, SARIF, SBOM and LLM brief
    • the pip install hint

Zero-Dependency Mode now means only that tiktoken, xgboost/pandas/numpy or PyYAML is missing.

Packaging and tooling:

  • pyproject.toml: networkx is removed from the full extra.
  • self_scan.py no longer requires networkx.
  • The crucible_check.py full-precision venv no longer installs it.
  • test_golden_crucible.py and update_golden_master.py detect the mode without it.

CI install lines:

  • networkx is removed from golden-crucible (full leg), gitgalaxy.yml (self-scan), release-crucible-archive, and rosetta-audit (PR build).
  • It is kept:
    • in the smoke-test and full-suite test jobs, as the test-only parity oracle for tests/tools/graph_parity.py, as the issue asks
    • in rosetta-audit's baseline venv, because that runs the pre-Native graph engine: remove networkx from the runtime #3041 main build, which still reads networkx to choose its mode

gitgalaxy/requirements.txt (a frozen dev environment, not the install contract) is left alone.

Tests:

  • New test_no_networkx_runtime.py covers the acceptance criterion. With networkx made unimportable in a subprocess, it checks that:
    • gitgalaxy.galaxyscope imports
    • every graph metric and both reach counts are computed
    • neither module exposes a networkx mode flag
  • The paired "networkx vs. zero-dependency" tests collapse into single-path tests (every metric computed; rebuilds give identical floats). The patch-networkx-to-prove-it-unused tests are replaced by that real acceptance test.
  • graph_parity.py's two bare nx.closeness_centrality / nx.betweenness_centrality oracles become named functions again. The CodeQL lambda cleanup had made the module read networkx at import, so without networkx it crashed instead of letting its tests skip. Named defs satisfy both.

Docs:

  • zero_dependency_mode.md: the networkx section becomes "Graph metrics: no optional package", and there's an older-snapshots note.
  • README, CLAUDE.md, the 02-16 wiki page, and the LLM brief's Zero-Dependency banner text.

Golden masters

I diffed fresh scans of each mode against the committed fixtures with an uncapped golden_diff.deep_compare. The scans used GITGALAXY_DISABLE_GIT_HISTORY=1 and the same flags as test_golden_crucible.py. I also checked that the scan imported this branch: HAS_NETWORKX is absent.

  • Each mode: exactly 1 difference, the intended one. Forensic Trail / Analysis Context / Missing Dependencies no longer has a networkx key. It was false in the full-precision fixture and true in the zero-dependency one.
  • Every graph metric is unchanged in both modes. The single remaining builder was already producing the same values.

Both fixtures are re-blessed in the second commit.

Verification

  • pytest passes on the 13 affected suites (633 passed), including the new acceptance test run from an unrelated working directory.
  • audit_check.py: all clear.
  • No module under gitgalaxy/ imports networkx (grep).

🤖 Generated with Claude Code

squid-protocol and others added 2 commits September 14, 2026 20:56
Every graph metric has been native since #3034-#3040, so networkx computed
nothing. It still chose the sensor's builder and decided the scan mode;
this removes both.

- network_risk_sensor: the DiGraph builder, HAS_NETWORKX and
  `import networkx` are gone. build_dependency_graph is the single linear
  builder; its output was already identical (#3024, #3035-#3040).
- galaxyscope: networkx leaves the Zero-Dependency Mode flag, the banner and
  end note, and both missing_dependencies maps (audit/GPU JSON, SARIF, SBOM,
  LLM brief). The mode now means only tiktoken, xgboost/pandas/numpy or
  PyYAML is missing.
- pyproject `full` extra, self_scan.py, crucible_check.py's full venv, and
  the golden-master tooling's mode detection all drop networkx.
- CI installs drop networkx from: golden-crucible full leg, gitgalaxy.yml,
  release-crucible-archive, rosetta-audit PR build. It is kept in the test
  jobs (the parity oracle) and rosetta-audit's baseline venv (a pre-#3041
  build still reads it).
- New test_no_networkx_runtime.py: with networkx unimportable in a
  subprocess, galaxyscope imports and every graph metric plus the reach
  counts are computed.
- Paired networkx-vs-zero-dependency tests collapse to single-path tests.
- graph_parity.py oracles are named functions, so the harness imports and
  skips without networkx.
- Docs: zero_dependency_mode.md, README, CLAUDE.md, 02-16 wiki, and the
  brief's Zero-Dependency banner text.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ndencies)

Uncapped golden_diff scope: exactly 1 difference per mode -- the audit
JSON's Forensic Trail / Analysis Context / Missing Dependencies no longer
carries a networkx key (false in full precision, true in zero-dependency).
Every graph metric is unchanged. The full-precision fixture was blessed
from a venv without networkx installed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@squid-protocol squid-protocol added enhancement New feature, sensor, or structural signature metrics Heuristics, risk exposures, and topological math updates core-engine Modifications to the central physics and parsing engine labels Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit e252458 into main Sep 15, 2026
38 of 44 checks passed
@squid-protocol
squid-protocol deleted the fix/3041-remove-networkx branch September 15, 2026 01:14
squid-protocol added a commit that referenced this pull request Sep 15, 2026
… (#3056)

#3054 removed networkx from the engine; these still installed or cited it.

- action.yml full_precision step + description, templates/{azure,bitbucket,
  github,gitlab}, templates/scan.yml, azure-/bitbucket-pipelines.yml: stop
  installing networkx.
- rosetta-audit baseline venv: drop networkx (the baseline is post-#3041
  main now).
- gitgalaxy/requirements.txt: drop the networkx==3.6.1 pin.
- Comments and test docstrings: None now means "past its work budget" or
  "a failed computation", never "no networkx".

Kept: networkx in the smoke/full-suite test installs (the parity oracle).
numpy stays: the ML threat model (pandas/xgboost) requires it.

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-engine Modifications to the central physics and parsing engine enhancement New feature, sensor, or structural signature metrics Heuristics, risk exposures, and topological math updates

Projects

None yet

1 participant