code wiki / (root) / nx_shard.nx

nx_shard.nx

buildroot/runtime/nx_shard.nx

6183 B160 linesdepth 6pulls 8 transitivereach 2 importersview sourcekind librarytopic shard
docsdependenciesstructsconstsfunctions

about

nx_shard.nx -- parallelism-ready work-sharding primitive. Splits a QED database into N independent work shards. Each shard processes a contiguous range of entries [start, end). Shards are independent: their auto-verify results commute associatively (aggregate stats are just sums), so they can be dispatched to threads / processes / SLURM jobs without coordination beyond the final aggregate step. Phase S0 (this commit): sequential dispatcher. Interface compatible with future thread-pool dispatcher; substrate's commutativity invariant means swapping the dispatcher doesn't change results. genealogy_id: cilk_blumofe_1996 + map_reduce_dean_ghemawat_2004 lineage_id: data_parallelism + commutative_aggregation axioms: NX_AX_ALG_ASSOCIATIVITY (sharded ops compose) nx_safety_envelope: intended_use: "Shard container + replication record -- the partitioning primitive substrate-shipped data services (Data Vault, time-series, telemetry) compose against" sil_target: SIL2 (sharding errors = data corruption or replica divergence) asil_target: QM dal_target: DAL C iec_62304_class: A evidence: [Algebraic_Associativity_axiom_tagged, deterministic_shard_key_function, sealed_replica_status_enum] hazard_register: [bug-tape-shard-key-collision-causing-loss, bug-tape-replica-stale-after-split-brain, bug-tape-key-distribution-skew] residual_risk: "Split-brain handling is upstream consensus protocol responsibility. Substrate shard provides bytes-only; semantics layered." verdict: NOT_YET_EVALUATED

dependencies 5 imports · 2 importers

nx_syscalls.nx nx_axioms.nx nx_qed_db.nx nx_prover.nx nx_auto_verify.nx nx_shard.nx nx_validation_cycle.nx nx_validation_cycle_test.nx

imports: nx_syscalls.nxnx_axioms.nxnx_qed_db.nxnx_prover.nxnx_auto_verify.nx

imported by: nx_validation_cycle.nxnx_validation_cycle_test.nx

structs

47struct Shard {
56struct ShardPlan {

consts

54const NX_SHARD_BYTES: i64 = 32

functions

62func nx_shard_plan_alloc(n_shards: i64) -> *ShardPlan {
called by 1: nx_shard_plan_build calls 1: sys_mmap
71func nx_shard_at(p: *ShardPlan, i: i64) -> *Shard {
77func nx_shard_plan_build(db: *QedDb, n_shards: i64) -> *ShardPlan {
96func nx_shard_run(db: *QedDb, s: *Shard, targets: *i64,
129func nx_shard_run_all(db: *QedDb, p: *ShardPlan, targets: *i64,
143func nx_shard_aggregate(p: *ShardPlan, out: *VerifyStats) -> i64 {
called by 2: nx_vc_runmain calls 1: nx_shard_at