nx_sov_ledger.nx
buildroot/runtime/nx_sov_ledger.nx
about
nx_sov_ledger.nx -- CANONICAL generic sovereign ledger on nx_seg_store. The DRY primitive that makes
"sovereign is as easy as a TSV" and kills the FRICTION root-cause of the flat-file habit.
WHY THIS EXISTS (census 2026-07-14, runtime+_hdl_build/16029 .nx): ~599 organs write .tsv, ~1407 .log,
~965 .txt for INTERNAL state vs only 324 seg_store adopters -- a ~10:1 flat-file default. Root cause is
not a missing store (nx_seg_store has time-travel history + compaction + postings = SOTA) but (a) no
enforcement sensor and (b) writing a TSV is 3 lines while seg_store means begin/add/commit + segid
discipline + a reader. This lib collapses that to one call. Dependency-light (seg_store + syscalls ONLY)
so ANY organ can adopt without dragging a domain stack.
SOVEREIGN RECORD FORMAT (not burdened by others' non-SOTA decisions): typed BINARY records -- n i64 stored
as raw 8n little-endian bytes, NO tab/comma delimiters, NO stringly-typed parsing. (Even seg_store adopters
like nx_seedlib still pack tab bytes into the value; this is the fix for that too.)
sov_put(prefix,key,val,vlen) KV put, idempotent latest-wins, segid=sys_now_us() (per-op-in-loop
safe -- ms collides & silently drops a record, [[reference-segstore-segid-use-now-us]])
sov_has(prefix,key) 1/0 existence (replaces "does <file>.tsv exist" resume checks)
sov_get(prefix,key,ptrout,lenout) newest value (zero-copy ptr into the store map)
sov_get_copy(prefix,key,out,cap) newest value copied into out (aligned); returns len or -1
sov_put_ints(prefix,key,vals,n) typed record: n i64 -> raw 8n bytes
sov_get_ints(prefix,key,out,maxn) read them back -> count, or -1 if absent (never fabricated)
license_tier: ORIGINAL
dependencies 2 imports · 12 importers
diagram shows first 10 each side; +0 more imports, +2 more importers in the complete lists below.
imports: nx_seg_store.nxnx_syscalls.nx
imported by: nx_eco_graph.nxnx_forge_cascade.nxnx_forge_curves.nxnx_forge_os_readiness.nxnx_forge_rag_ab.nxnx_gate_mutation_sweep.nxnx_mcp_coverage.nxnx_sov.nxnx_sov_ledger_gate.nxnx_sovereign_format_census.nxnx_swarm_queue.nxnx_watch.nx
structs
| none |
consts
| none |
functions
| 26 | func sov_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 29 | func sov_put(prefix: *u8, key: *u8, val: *u8, vlen: i64) -> i64 called by 15: cc_ids_addcc_registerdl_add_iddl_registerlz_reseteg_save+9 calls 4: ss_beginss_addss_commitsys_now_us |
| 36 | func sov_put_str(prefix: *u8, key: *u8, val: *u8) -> i64 |
| 40 | func sov_has(prefix: *u8, key: *u8) -> i64 |
| 47 | func sov_get(prefix: *u8, key: *u8, ptrout: *i64, lenout: *i64) -> i64 calls 1: ss_get |
| 52 | func sov_get_copy(prefix: *u8, key: *u8, out: *u8, cap: i64) -> i64 |
| 65 | func sov_put_ints(prefix: *u8, key: *u8, vals: *i64, n: i64) -> i64 |
| 70 | func sov_get_ints(prefix: *u8, key: *u8, out: *i64, maxn: i64) -> i64 |