code wiki / _hdl_build / nx_media_inventory_lib.nx

nx_media_inventory_lib.nx

buildroot/runtime/_hdl_build/nx_media_inventory_lib.nx

27289 B489 linesdepth 3pulls 3 transitivereach 2 importersview sourcekind librarytopic media
docsdependenciesstructsconstsfunctions

about

nx_media_inventory_lib.nx -- the audited 'what media we have' surface (Phase 1A organ, per SPEC knowledge/store/media-inventory/nx_media_inventory.SPEC.txt). Sovereign census over recordings + movies + books: OWNS its seg_store keys (store-law), emits VIEW files, reconciles catalog-vs-disk into an id-STABLE stale-set (the gallery serve consults it to skip rotated recordings WITHOUT renumbering ids), and tags a privacy CATEGORY (recordings default NSFW, fail-closed). LOCAL only, metadata-only, ZERO external calls. The count is whatever the getdents WALK measures -- nothing hardcoded (anti-fabrication). license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_seg_store.nx nx_media_inventory_lib.nx nx_media_inventory.nx nx_media_inventory_gate.nx

imports: nx_syscalls.nxnx_seg_store.nx

imported by: nx_media_inventory.nxnx_media_inventory_gate.nx

structs

none

consts

9const INV_MAGIC_1048576: i64 = 1048576
10const INV_MAGIC_8192: i64 = 8192
11const INV_MAGIC_4000000: i64 = 4000000
12const INV_MAGIC_1048640: i64 = 1048640
13const INV_MAGIC_8388608: i64 = 8388608
14const INV_MAGIC_2097152: i64 = 2097152
15const INV_MAGIC_524288: i64 = 524288
16const INV_MAGIC_65536: i64 = 65536
17const INV_MAGIC_2097000: i64 = 2097000
18const INV_MAGIC_12582912: i64 = 12582912
19const INV_MAGIC_8190: i64 = 8190
20const INV_MAGIC_4194304: i64 = 4194304
21const INV_MAGIC_4096: i64 = 4096
22const INV_MAGIC_1024: i64 = 1024
25const INV_PREFIX: *u8 = "knowledge/store/media-inventory/inv-" as *u8
26const INV_ROOT_LOGS: *u8 = "/volume1/logs" as *u8
27const INV_ROOT_LOGGING:*u8 = "/volume1/logging" as *u8
28const INV_ROOT_MOVIES: *u8 = "/volume1/movies" as *u8
29const INV_ROOT_BOOKS: *u8 = "/volume1/homes/elderwesto/books" as *u8
30const INV_CATALOG: *u8 = "/volume1/ai/galx/knowledge/status/galx_vid_paths.tsv" as *u8
31const INV_STALEBIN: *u8 = "/volume1/ai/galx/knowledge/status/galx_stale.bin" as *u8
32const INV_STALEBIN_ALT:*u8 = "knowledge/store/media-inventory/galx_stale.bin" as *u8
33const INV_VIEW_REC: *u8 = "knowledge/store/media-inventory/rec_by_performer.tsv" as *u8
34const INV_VIEW_SUM: *u8 = "knowledge/store/media-inventory/inventory_summary.txt" as *u8
272const IV_ARENA_CAP: i64 = 33554432
273const IV_STK_CAP: i64 = 1000000

functions

37func iv_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
38func iv_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i }
called by 2: iv_buildiv_show
39func iv_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
40func iv_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, iv_slen(s)); return 0 }
called by 1: iv_p calls 2: sys_writeiv_slen
41func iv_n(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(32); var m: i64 = v; if m < 0 { m = 0 - m; sys_write(fd, "-" as *u8, 1) } let t: *u8 = sys_mmap(32); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { bb[i] = t[k-1-i]; i = i + 1 } sys_write(fd, bb, k); return 0 }
called by 1: iv_pn calls 2: sys_mmapsys_write
42func iv_p(s: *u8) -> i64 { iv_w(1, s); return 0 }
called by 4: mainiv_buildiv_showiv_audit calls 1: iv_w
43func iv_pn(v: i64) -> i64 { iv_n(1, v); return 0 }
calls 1: iv_n
45func iv_ntoa(dst: *u8, off: i64, v: i64) -> i64 { var o: i64 = off; var m: i64 = v; if m < 0 { dst[o] = 45 as u8; o = o + 1; m = 0 - m } let t: *u8 = sys_mmap(32); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { dst[o+i] = t[k-1-i]; i = i + 1 } return o + k }
called by 1: iv_build calls 1: sys_mmap
47func iv_ends_ts(nm: *u8) -> i64 { let n: i64 = iv_slen(nm); if n < 3 { return 0 } if nm[n-3] != (46 as u8) { return 0 } if nm[n-1] != (115 as u8) { return 0 } if nm[n-2] != (116 as u8) { return 0 } return 1 }
calls 1: iv_slen
49func iv_is_recext(nm: *u8) -> i64
called by 1: iv_count_ts calls 1: iv_slen
61func iv_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
called by 1: iv_build calls 2: sys_openat_rdsys_close
63func iv_read_all(path: *u8, buf: *u8, cap: i64) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 - 1 } var tot: i64 = 0; var done: i64 = 0; while done == 0 { if tot >= cap { done = 1 } else { let n: i64 = sys_read(fd, (buf as i64 + tot) as *u8, cap - tot); if n <= 0 { done = 1 } else { tot = tot + n } } } sys_close(fd); return tot }
67func iv_count_ts(dpath: *u8, dirbuf: *u8) -> i64
94func iv_merge_perf(name: *u8, cnt: i64, rootbit: i64, pnames: *u8, pnoff: *i64, pcount: *i64, pmask: *i64, npc: *i64, pusedc: *i64) -> i64
called by 1: iv_walk_rec_root calls 1: iv_streq
118func iv_walk_rec_root(root: *u8, rootbit: i64, dirbuf: *u8, cbuf: *u8, child: *u8, pnames: *u8, pnoff: *i64, pcount: *i64, pmask: *i64, npc: *i64, pusedc: *i64) -> i64
157func iv_ext_match(extlc: *u8, kind: i64) -> i64
called by 1: iv_walk_count calls 1: iv_streq
188func iv_walk_count(root: *u8, kind: i64, dirbuf: *u8, parena: *u8, stkoff: *i64, arenacap: i64, stkcap: i64) -> i64
265func iv_category(kind: *u8) -> i64 { if iv_streq(kind, "recordings" as *u8) == 1 { return 1 } return 0 }
called by 1: main calls 1: iv_streq
267func iv_get(key: *u8, ptrout: *i64, lenout: *i64) -> i64 { return ss_get(INV_PREFIX, key, ptrout, lenout) }
called by 3: mainiv_showiv_audit calls 1: ss_get
269func iv_put_i64(buf: *u8, off: i64, v: i64) -> i64 { var i: i64 = 0; var m: i64 = v; while i < 8 { buf[off+i] = (m & 255) as u8; m = m / 256; i = i + 1 } return off + 8 }
called by 1: iv_build
277func iv_build(mode: *u8) -> i64
468func iv_show(kind: *u8) -> i64
481func iv_audit() -> i64
called by 1: main calls 4: sys_mmapiv_piv_getsys_write