code wiki / (root) / nx_win_ledger.nx

nx_win_ledger.nx

buildroot/runtime/nx_win_ledger.nx

13630 B324 linesdepth 7pulls 7 transitivereach 3 importersview sourcekind librarytopic win
docsdependenciesstructsconstsfunctions

about

nx_win_ledger.nx -- the WIN-LEDGER organ (ADDITIVE; no main, no shared edits). REASON TO EXIST (operator's mandate): a "win" is not a win until it is EXPLAINED (why, cited), PROVEN (a repro gate with a known answer), and FALSIFIABLE (an explicit assumptions[] list, so a bad assumption is catchable). This organ is the bookkeeping layer for those wins, recorded ADDITIVELY over the hash-chained nx_journal_log (which itself stores its payloads content-addressed in nx_blob_store -- the snapshot/attest substrate). A re-verify RE-RUNS a recorded win's repro and asserts the expected known answer -> HOLDS; a regression / broken assumption / a deliberately-wrong expected FAILS LOUD -> REFUTED. The status downgrade is the whole point: the ledger must be able to flip a stale win to REFUTED. SOVEREIGNTY: the re-gate path mirrors nx_gate_runner exactly -- compile the repro *_test.nx via the PINNED nx_cc_known_good.elf (NEVER the active, possibly-poisoned compiler; cf. the g1 regalloc miscompile history), then as + ld, then run capturing stdout, and substring-match the expected known-answer. We capture STDOUT (not just the exit code) so the ledger catches a regression where the gate still exits 0 but emits a DIFFERENT answer -- and so a deliberately-wrong expected string genuinely flips to REFUTED. ADDITIVE: this is a NEW file. It does NOT edit nx_warden_lib / nx_gate_runner / nx_conductor / nx_eqsat. It REUSES, concept-not-copy: * nx_blob_store.nx -- content-addressed snapshot substrate (under journal) * nx_journal_log.nx -- hash-chained append-only win record store * nx_syscalls.nx -- raw fork/exec/wait + file I/O (NOT copied; imported) license_tier: ORIGINAL

dependencies 3 imports · 3 importers

nx_syscalls.nx nx_blob_store.nx nx_journal_log.nx nx_win_ledger.nx nx_conductor_live.nx nx_unified_conductor.nx nx_win_ledger_test.nx

imports: nx_syscalls.nxnx_blob_store.nxnx_journal_log.nx

imported by: nx_conductor_live.nxnx_unified_conductor.nxnx_win_ledger_test.nx

structs

81struct NxWinRecord
95struct NxWinLedger

consts

39const WL_CC: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/_offc/nx_cc_known_good.elf"
40const WL_AS: *u8 = "/usr/bin/as"
41const WL_LD: *u8 = "/usr/bin/ld"
45const WL_S: *u8 = "/tmp/nx_winl.s"
46const WL_O: *u8 = "/tmp/nx_winl.o"
47const WL_ELF: *u8 = "/tmp/nx_winl.elf"
48const WL_OUT: *u8 = "/tmp/nx_winl.out"
49const WL_MODE: i64 = 420
52const WL_STATUS_UNVERIFIED: i64 = 0
53const WL_STATUS_HOLDS: i64 = 1
54const WL_STATUS_REFUTED: i64 = 2
55const WL_STATUS_SUPERSEDED: i64 = 3
60const WL_BUILD_CC_FAIL: i64 = 0 - 1
61const WL_BUILD_AS_FAIL: i64 = 0 - 2
62const WL_BUILD_LD_FAIL: i64 = 0 - 3
65const WL_SCHEMA_RECORD: i64 = 9001 // a win was recorded
66const WL_SCHEMA_HOLDS: i64 = 9002 // re-verify confirmed HOLDS
67const WL_SCHEMA_REFUTED: i64 = 9003 // re-verify FAILED LOUD -> REFUTED
70const WL_MAX_ASSUMPTIONS: i64 = 16
73const WL_CANARY_PRE: i64 = 0x4E5857494E4C5052 // "NXWINLPR"
74const WL_CANARY_POST: i64 = 0x4E5857494E4C4550 // "NXWINLEP"

functions

104func _wl_strlen(s: *u8) -> i64
113func _wl_contains(hay: *u8, needle: *u8) -> i64
called by 2: nx_win_reverifymain calls 1: _wl_strlen
134func nx_win_record_new(
called by 2: cl_journal_winmain calls 1: sys_mmap
154func nx_win_record_is_valid(r: *NxWinRecord) -> i64
167func nx_win_record_add_assumption(r: *NxWinRecord, assumption: *u8) -> i64
176func nx_win_record_assumption(r: *NxWinRecord, idx: i64) -> *u8
called by 1: main calls 1: nx_win_record_is_valid
184func nx_win_ledger_new() -> *NxWinLedger
193func nx_win_ledger_is_valid(L: *NxWinLedger) -> i64
202func nx_win_ledger_count(L: *NxWinLedger) -> i64
212func nx_win_ledger_record(L: *NxWinLedger, r: *NxWinRecord) -> i64
225func _wl_run(path: *u8, argv: *i64, envp: *i64, out_path: *u8) -> i64
248func nx_win_regate(testnx: *u8) -> i64
called by 1: nx_win_reverify calls 2: sys_mmap_wl_run
276func nx_win_reverify(r: *NxWinRecord) -> i64
311func nx_win_ledger_record_and_verify(L: *NxWinLedger, r: *NxWinRecord) -> i64