nx_win_ledger.nx
buildroot/runtime/nx_win_ledger.nx
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
imports: nx_syscalls.nxnx_blob_store.nxnx_journal_log.nx
imported by: nx_conductor_live.nxnx_unified_conductor.nxnx_win_ledger_test.nx
structs
| 81 | struct NxWinRecord |
| 95 | struct NxWinLedger |
consts
| 39 | const WL_CC: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/_offc/nx_cc_known_good.elf" |
| 40 | const WL_AS: *u8 = "/usr/bin/as" |
| 41 | const WL_LD: *u8 = "/usr/bin/ld" |
| 45 | const WL_S: *u8 = "/tmp/nx_winl.s" |
| 46 | const WL_O: *u8 = "/tmp/nx_winl.o" |
| 47 | const WL_ELF: *u8 = "/tmp/nx_winl.elf" |
| 48 | const WL_OUT: *u8 = "/tmp/nx_winl.out" |
| 49 | const WL_MODE: i64 = 420 |
| 52 | const WL_STATUS_UNVERIFIED: i64 = 0 |
| 53 | const WL_STATUS_HOLDS: i64 = 1 |
| 54 | const WL_STATUS_REFUTED: i64 = 2 |
| 55 | const WL_STATUS_SUPERSEDED: i64 = 3 |
| 60 | const WL_BUILD_CC_FAIL: i64 = 0 - 1 |
| 61 | const WL_BUILD_AS_FAIL: i64 = 0 - 2 |
| 62 | const WL_BUILD_LD_FAIL: i64 = 0 - 3 |
| 65 | const WL_SCHEMA_RECORD: i64 = 9001 // a win was recorded |
| 66 | const WL_SCHEMA_HOLDS: i64 = 9002 // re-verify confirmed HOLDS |
| 67 | const WL_SCHEMA_REFUTED: i64 = 9003 // re-verify FAILED LOUD -> REFUTED |
| 70 | const WL_MAX_ASSUMPTIONS: i64 = 16 |
| 73 | const WL_CANARY_PRE: i64 = 0x4E5857494E4C5052 // "NXWINLPR" |
| 74 | const WL_CANARY_POST: i64 = 0x4E5857494E4C4550 // "NXWINLEP" |
functions
| 104 | func _wl_strlen(s: *u8) -> i64 |
| 113 | func _wl_contains(hay: *u8, needle: *u8) -> i64 |
| 134 | func nx_win_record_new( |
| 154 | func nx_win_record_is_valid(r: *NxWinRecord) -> i64 |
| 167 | func nx_win_record_add_assumption(r: *NxWinRecord, assumption: *u8) -> i64 |
| 176 | func nx_win_record_assumption(r: *NxWinRecord, idx: i64) -> *u8 |
| 184 | func nx_win_ledger_new() -> *NxWinLedger |
| 193 | func nx_win_ledger_is_valid(L: *NxWinLedger) -> i64 |
| 202 | func nx_win_ledger_count(L: *NxWinLedger) -> i64 |
| 212 | func nx_win_ledger_record(L: *NxWinLedger, r: *NxWinRecord) -> i64 |
| 225 | func _wl_run(path: *u8, argv: *i64, envp: *i64, out_path: *u8) -> i64 |
| 248 | func nx_win_regate(testnx: *u8) -> i64 |
| 276 | func nx_win_reverify(r: *NxWinRecord) -> i64 |
| 311 | func nx_win_ledger_record_and_verify(L: *NxWinLedger, r: *NxWinRecord) -> i64 |