Docs/Architecture
Workspace and Crate Map
11 implementation crates, all under crates/fnp-*. 10 of the 11 declare #![forbid(unsafe_code)] and stay entirely on the safe-Rust path (enforced by no_unsafe_code_blocks_or_items in codebase_hygiene.rs). fnp-python is the lone exception: PyO3's procedural macros may expand into unsafe, and crates/fnp-python/src/lib.rs has 67 audited unsafe blocks/items (consolidated from 1,250 in bead deadlock-audit-rc0923-epic-71qy3.21 by encapsulating borrowed PyBuffer / ReadOnlyCell / PyArrayObject slice views behind readonly_cells_as_slice, slice_as_readonly_cells, PyBufferExt, and NdarrayRaw, leaving 24 from_raw_parts* calls inside the helpers plus get_unchecked, transmute, and target-feature functions in some kernels; 4 unsafe fn, 1 unsafe impl, and 3 unsafe extern "C" blocks declaring 35 glibc libm functions plus feclearexcept, fetestexcept, and dlsym). All of it is confined to fnp-python, 100% documented with // SAFETY: comments (#![forbid(unsafe_op_in_unsafe_fn)], #![deny(clippy::undocumented_unsafe_blocks)]), and structurally bounded by fnp_python_unsafe_blocks_are_encapsulated_and_documented in codebase_hygiene.rs.
External crate dependencies are pinned at the workspace root in [workspace.dependencies]: serde 1.0.229 (3 consumer crates), serde_json 1.0.151 (3 consumers), criterion 0.8.2 with html_reports (9 consumer bench crates — every crate except fnp-runtime), and pyo3 0.29.3 with auto-initialize (1 consumer — fnp-python). Each consumer references the pin via .workspace = true. Verified 2026-09-03 against the root manifest.
| Crate | Lines (src/) | Purpose |
|---|---|---|
fnp-dtype |
4,697 | 18 dtype variants, deterministic const fn promotion table covering all 324 pairs, 5 cast policies, ArrayStorage taxonomy. (The IntegerSidecar mentioned later in this README lives in fnp-ufunc, not here, because it travels with UFuncArray.) |
fnp-ndarray |
2,079 | Stride Calculus Engine: shape→element_count, shape+order→strides, broadcast legality, reshape with -1 inference, alias-sensitive transitions |
fnp-iter |
4,030 | Transfer-loop selector, overlap detection, Nditer / NditerPlan / NditerStep state machine with iterindex / multi_index / reset / seek / external-loop chunks, nditer_python* parity bridge |
fnp-ufunc |
84,974 | Largest engine crate. 35 binary ops, 43 unary ops, 30+ reduction methods, masked arrays, string arrays, datetime arrays, polynomial families, FFT primitives, einsum (einsum, einsum_path, einsum_optimized), float error state machine, NaN-correct reductions |
fnp-linalg |
24,020 | ~100 public functions: 2×2 fast paths, NxN decompositions (QR, SVD, eig, eigh, Cholesky, LU), spectral methods (expm, sqrtm, logm, funm, polar, schur), least-squares, 14 batch operations, complex variants |
fnp-random |
25,299 | 5 production bit generators (PCG64, PCG64DXSM, MT19937, Philox, SFC64) + an internal DeterministicRng for tests, full SeedSequence / SeedMaterial hierarchy with spawn lineage, pickle payload round-trip, RandomState legacy wrapper, 40+ oracle-verified distributions. Its Pcg64DxsmRng wraps fnp-random-core's generator |
fnp-random-core |
366 | Dependency-free, forbid(unsafe_code) SeedSequence and the workspace's one PCG64DXSM implementation (seeding, DXSM output, jump-ahead), consumed by fnp-random |
fnp-io |
12,765 | NPY 1.0 / 2.0 read & write, NPZ stored + DEFLATE, text I/O (loadtxt, savetxt, genfromtxt), binary I/O (fromfile, tofile, fromstring), memmap, structured dtype I/O, hardened bounds: MAX_HEADER_BYTES = 65,536, MAX_ARCHIVE_MEMBERS = 4,096, MAX_ARCHIVE_UNCOMPRESSED_BYTES = 2 GiB, MAX_TEXT_ELEMENTS = 16,777,216 |
fnp-runtime |
1,760 | RuntimeMode (Strict / Hardened), CompatibilityClass, DecisionAction, risk-aware decision engine with posterior estimation, DecisionLossModel, EvidenceLedger, OverrideAuditEvent, optional asupersync / frankentui integration |
fnp-conformance |
68,340 | Differential harness, metamorphic identities, adversarial fuzzing, witness stability, oracle capture, diagnostic-oracle harness, divergence ledger checker, cross-version drift matrix, RaptorQ sidecar / scrub / decode-proof tooling, 48 CLI binaries under src/bin/ |
fnp-python |
202,409 | PyO3 (pyo3 = "0.29.3" pinned) bindings exposing 100% of numpy.__all__. 11 registered classes, native fast-paths for hot operations, numpy fallback for everything else, 194 dedicated conformance_*.rs test files |
Total: roughly 431k lines of Rust under crates/*/src (430,739 by wc -l, 2026-10-08; all but fnp-python unsafe-free), plus eight fuzz crates and an extensive tests/ tree.