nx_shard.nx
buildroot/runtime/nx_shard.nx
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
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
| 47 | struct Shard { |
| 56 | struct ShardPlan { |
consts
| 54 | const NX_SHARD_BYTES: i64 = 32 |
functions
| 62 | func nx_shard_plan_alloc(n_shards: i64) -> *ShardPlan { |
| 71 | func nx_shard_at(p: *ShardPlan, i: i64) -> *Shard { |
| 77 | func nx_shard_plan_build(db: *QedDb, n_shards: i64) -> *ShardPlan { |
| 96 | func nx_shard_run(db: *QedDb, s: *Shard, targets: *i64, |
| 129 | func nx_shard_run_all(db: *QedDb, p: *ShardPlan, targets: *i64, |
| 143 | func nx_shard_aggregate(p: *ShardPlan, out: *VerifyStats) -> i64 { |