code wiki / (root) / nx_fin_ledger_gate.nx

nx_fin_ledger_gate.nx

buildroot/runtime/nx_fin_ledger_gate.nx

8025 B134 linesdepth 8pulls 10 transitivereach 0 importersview sourcekind gate/prooftopic fin
docsdependenciesstructsconstsfunctions

about

nx_fin_ledger_gate.nx -- R2 GATE: proves the double-entry ledger is exact, append-only, idempotent, and never records a corrupt (unbalanced) entry. Dogfooded on the operator's HELOC crisis: accounts: Home(asset), HELOC(liability), Cash(asset), OpeningEquity(equity), InterestExpense(expense) txn1 opening balances -> net worth = Home + Cash + HELOC(neg) = $210,000.00 txn2 HELOC paydown $5,000 from Cash -> net worth INVARIANT (asset down == liability up) = THE PROOF txn3 HELOC interest $1,000 from Cash -> net worth DOWN by $1,000 (expense, no offset) Then: unbalanced txn REJECTED + never recorded (never-brick); re-post = idempotent DUP; history retrievable + intact; and the live HELOC balance feeds nx_money for an exact monthly-interest figure. Hermetic: a fresh per-run /tmp prefix, so the gate never touches the real ledger store. Exits 0 iff ALL pass. license_tier: ORIGINAL

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_money.nx nx_canon_cid.nx nx_uxf_decode.nx nx_fin_ledger.nx nx_fin_ledger_gate.nx

imports: nx_syscalls.nxnx_money.nxnx_canon_cid.nxnx_uxf_decode.nxnx_fin_ledger.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap fl_cpy sys_now_us sys_mmap ↻ sys_clock_gettime_mono fl_acct_open fl_len sys_mmap ↻ ss_open ss_open2 sys_mmap ↻ ss_manifest_dyn ss_manifest_file_dyn sys_mmap ↻ ss_cat ss_readall sys_munmap ss_cat ↻ ss_loadfile sys_map_file sys_openat_rd sys_lseek sys_close ss_readall ↻ ss_load_aux2 sys_mmap ↻ ss_cat ↻ ss_loadfile ↻ ss_r32 sys_munmap ↻ ssl_total_keys ss_r32 ↻ ssl_pow2 ssl_build ss_r32 ↻ ssl_hash_entry ss_r32 ↻ ssl_key_eq ss_r32 ↻

structs

none

consts

none

functions

17func g_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: chkmain calls 1: sys_write
18func g_putn(v: i64) -> i64
called by 2: chkmain calls 2: sys_writesys_mmap
28func chk(name: *u8, got: i64, want: i64, st: *i64) -> i64
called by 1: main calls 2: g_putsg_putn
34func main() -> i64