Guide/In production
Reproducibility Recipe
1 min readFrom the README
On this page 6
Bit-for-bit reproducible graph analytics with fnx. The recipe below is usable as the spine of a regression-locked pipeline.
1. Pin the inputs
import os, hashlib, atexit, shutil, tempfile, franken_networkx as fnx
# In your pipeline GRAPH_INPUT is your own dataset:
#
# GRAPH_INPUT = "datasets/snapshot_2026Q2.edgelist"
#
# The recipe below is executable as written, so it stands up a tiny stand-in
# and removes it at exit — later steps in this section read it back.
_pinned_dir = tempfile.mkdtemp(prefix="fnx-readme-")
atexit.register(shutil.rmtree, _pinned_dir, True)
GRAPH_INPUT = os.path.join(_pinned_dir, "snapshot.edgelist")
with open(GRAPH_INPUT, "w") as f:
f.write("a b\nb c\nc a\n")
# Compute and log the SHA-256 of the input. Any drift here is the first
# place to look if reproducibility breaks downstream.
with open(GRAPH_INPUT, "rb") as f:
digest = hashlib.sha256(f.read()).hexdigest()
print(f"input sha256: {digest}")
2. Pin the build
import franken_networkx, networkx, sys
print("fnx: ", franken_networkx.__version__)
print("nx: ", networkx.__version__)
print("python: ", sys.version.split()[0])
# Optionally also pin the Rust commit the wheel was built from. If
# you're using a release wheel, the version is the contract; if you're
# building from source, capture `git rev-parse HEAD` in CI.
3. Pin the runtime mode
# Default is Strict. For ingest of trusted data this is what you want.
# For ingest from a hostile source you may want Hardened; but pick
# one mode per pipeline run and log it.
print("compat mode: Strict (default)")
4. Run the analysis
G = fnx.read_edgelist(GRAPH_INPUT, create_using=fnx.Graph)
pr = fnx.pagerank(G, alpha=0.85, max_iter=100, tol=1e-6)
Insertion-ordered adjacency means the same input, fnx version and seed give the same traversal order and the same tie-breaks. pagerank itself runs its power iteration in SciPy (like nx.pagerank), so its floating-point output is as reproducible as your SciPy/BLAS build is across machines; the CGSE-registered algorithms (see "The V1 policy registry") additionally carry a decision-path hash you can compare.
5. Hash the output
import json
canonical = json.dumps(sorted(pr.items()), sort_keys=True)
out_digest = hashlib.sha256(canonical.encode()).hexdigest()
print(f"output sha256: {out_digest}")
# Lock this digest in a regression test. If it ever changes without a
# version bump, that's a bug in fnx or in your input pipeline.
6. Optional: harvest the CGSE witness
For Rust-side audit, drain WitnessLedger and serialize as JSONL. The hash of the witness JSONL bundle is a stronger reproducibility receipt than the algorithm output alone: two runs that produce the same algorithm output but different witness hashes are suspicious (it usually means the algorithm took a different path through equally-correct choices, indicating a non-determinism leak).
This recipe is what powers the project's own conformance gate (G5) and performance SLO gate (G6).