code wiki / (root) / nx_asset_prov_clock_candidate_t346.nx

nx_asset_prov_clock_candidate_t346.nx

buildroot/runtime/nx_asset_prov_clock_candidate_t346.nx

10723 B246 linesdepth 5pulls 6 transitivereach 2 importersview sourcekind librarytopic asset
docsdependenciesstructsconstsfunctions

about

nx_asset_prov_lib.nx -- THE PER-ASSET PROVENANCE ROW AND ITS FAIL-CLOSED VERDICT (/compare/modding MD9, 2026-09-06). ONE rights table in this estate (knowledge/model_license.conf, read by nx_licgate_lib) and ONE journal of ingested assets: a row is `asset<TAB>sha256<TAB>source<TAB>licence_id<TAB>origin<TAB>epoch`, APPEND-ONLY -- a later row for the same sha SUPERSEDES the earlier one (a relicence is a new row, never an edit) and the LAST row wins. Field bytes are sanitised on write (a tab or newline inside a source url becomes a space) so no caller can forge a licence column through a url. THE VERDICT IS FAIL-CLOSED BY CONSTRUCTION: no journal or no row -> REFUSE (NO-JOURNAL / NO-ROW); a licence id the rights table does not carry -> REFUSE (UNKNOWN-LICENCE), so "unknown" is never a table row, it is the absence of one; a licence whose weights_redist right is NO -> REFUSE (NON-REDISTRIBUTABLE); CONDITIONAL -> REVIEW; an UNVERIFIED licence is capped at CONDITIONAL, the same law nx_licgate_lib applies to models (a licence nobody read cannot grant an outright YES). Every export and publish door asks pv_verdict in-process; PRIVATE USE IS ALWAYS ALLOWED (res[PV_RES_PRIVATE]=1) -- the refusal is about redistribution, never about looking at what you downloaded. The journal path is a PARAMETER: a gate drives this lib on its own scratch journal and never on the production one. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 2 importers

nx_syscalls.nx nx_licgate_lib.nx nx_sha256.nx nx_asset_prov_clock_candidate_ nx_asset_prov_clock_cli_candidate_ nx_asset_prov_clock_gate_t346.nx

imports: nx_syscalls.nxnx_licgate_lib.nxnx_sha256.nx

imported by: nx_asset_prov_clock_cli_candidate_t346.nxnx_asset_prov_clock_gate_t346.nx

structs

none

consts

18const PV_JRNL_DEFAULT: *u8 = "knowledge/provenance/assets.jrnl"
19const PV_DIR_MODE: i64 = 493
20const PV_FILE_MODE: i64 = 420
21const PV_OPEN_APPEND: i64 = 1089 // O_WRONLY | O_CREAT | O_APPEND
22const PV_SYS_OPENAT: i64 = 257
23const PV_SYS_TIME: i64 = 201
24const PV_SHA_BYTES: i64 = 32
25const PV_SHA_HEX: i64 = 64
26const PV_TAG: *u8 = "asset"
27const PV_TAB: i64 = 9
28const PV_NL: i64 = 10
29const PV_SPACE: i64 = 32
30const PV_SLASH: i64 = 47
31const PV_LIC_CAP: i64 = 128
32const PV_LINE_CAP: i64 = 4096
33const PV_PATH_CAP: i64 = 1024
34const PV_F_TAG: i64 = 0
35const PV_F_SHA: i64 = 1
36const PV_F_SOURCE: i64 = 2
37const PV_F_LIC: i64 = 3
38const PV_F_ORIGIN: i64 = 4
39const PV_F_EPOCH: i64 = 5
41const PV_R_OK: i64 = 0
42const PV_R_NO_ROW: i64 = 1
43const PV_R_UNKNOWN_LIC: i64 = 2
44const PV_R_NON_REDIST: i64 = 3
45const PV_R_CONDITIONAL: i64 = 4
46const PV_R_UNVERIFIED: i64 = 5
47const PV_R_TABLE_UNREADABLE: i64 = 6
48const PV_R_NO_JOURNAL: i64 = 7
49const PV_RES_REASON: i64 = 0
50const PV_RES_REDIST: i64 = 1
51const PV_RES_LICIDX: i64 = 2
52const PV_RES_PRIVATE: i64 = 3
53const PV_RES_ROWS: i64 = 4
54const PV_RES_N: i64 = 8
56const PV_BOX_BUF: i64 = 0
57const PV_BOX_S: i64 = 1
58const PV_BOX_E: i64 = 2
59const PV_BOX_ROWS: i64 = 3
60const PV_BOX_N: i64 = 4

functions

62func pv_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
63func pv_puts(s: *u8) -> i64 { sys_write(1, s, pv_len(s)); return 0 }
64func pv_putn(v: i64) -> i64 { let t: *u8 = sys_mmap(32); var e: i64 = 0; if v < 0 { t[0] = 45 as u8; e = lg_putd(t, 1, 0 - v) } else { e = lg_putd(t, 0, v) } sys_write(1, t, e); return 0 }
65func pv_hexdig(v: i64) -> u8 { if v < 10 { return (48 + v) as u8 } return (87 + v) as u8 }
called by 1: pv_hex
66func pv_hex(dig: *u8, out: *u8) -> i64
called by 1: pv_hash_bytes calls 1: pv_hexdig
77func pv_hash_bytes(b: *u8, n: i64, out: *u8) -> i64
83func pv_hash_file(path: *u8, out: *u8) -> i64
90func pv_now() -> i64 { return sys_now_realtime_sec() }
called by 2: mainmain calls 1: sys_now_realtime_sec
91func pv_is_sha_hex(s: *u8) -> i64
called by 1: main calls 1: pv_len
105func pv_put_field(o: *u8, at: i64, s: *u8, cap: i64) -> i64
called by 1: pv_row_write
118func pv_mkdir_of(jrnl: *u8) -> i64
called by 1: pv_row_write calls 2: sys_mmapsys_mkdir
131func pv_row_write(jrnl: *u8, sha: *u8, source: *u8, lic: *u8, origin: *u8, epoch: i64) -> i64
154func pv_row_find(jrnl: *u8, sha: *u8, box: *i64) -> i64
182func pv_field_copy(buf: *u8, s: i64, e: i64, idx: i64, out: *u8, cap: i64) -> i64
called by 1: pv_verdict calls 2: sys_mmaplg_field
194func pv_verdict(jrnl: *u8, sha: *u8, res: *i64) -> i64
221func pv_verdict_name(rc: i64) -> *u8
called by 1: pv_print
226func pv_reason_name(r: i64) -> *u8
called by 1: pv_print
238func pv_print(sha: *u8, rc: i64, res: *i64) -> i64