code wiki / (root) / nx_sov_ledger.nx

nx_sov_ledger.nx

buildroot/runtime/nx_sov_ledger.nx

3926 B82 linesdepth 3pulls 3 transitivereach 66 importersview sourcekind librarytopic sov
docsdependenciesstructsconstsfunctions

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

nx_seg_store.nx nx_syscalls.nx nx_sov_ledger.nx nx_eco_graph.nx nx_forge_cascade.nx nx_forge_curves.nx nx_forge_os_readiness.nx nx_forge_rag_ab.nx nx_gate_mutation_sweep.nx nx_mcp_coverage.nx nx_sov.nx nx_sov_ledger_gate.nx nx_sovereign_format_census.nx

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

26func sov_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: sov_put_strlg_streq
29func sov_put(prefix: *u8, key: *u8, val: *u8, vlen: i64) -> i64
36func sov_put_str(prefix: *u8, key: *u8, val: *u8) -> i64
40func sov_has(prefix: *u8, key: *u8) -> i64
called by 5: mainmainmainmainmain calls 2: sys_mmapss_get
47func sov_get(prefix: *u8, key: *u8, ptrout: *i64, lenout: *i64) -> i64
calls 1: ss_get
52func sov_get_copy(prefix: *u8, key: *u8, out: *u8, cap: i64) -> i64
65func sov_put_ints(prefix: *u8, key: *u8, vals: *i64, n: i64) -> i64
called by 5: eg_savecv_rowab_rowmainmain calls 1: sov_put
70func sov_get_ints(prefix: *u8, key: *u8, out: *i64, maxn: i64) -> i64
called by 2: eg_loadmain calls 2: sys_mmapss_get