code wiki / _hdl_build / nx_media_inventory_lib.nx
nx_media_inventory_lib.nx
buildroot/runtime/_hdl_build/nx_media_inventory_lib.nx
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
imports: nx_syscalls.nxnx_seg_store.nx
imported by: nx_media_inventory.nxnx_media_inventory_gate.nx
structs
| none |
consts
| 9 | const INV_MAGIC_1048576: i64 = 1048576 |
| 10 | const INV_MAGIC_8192: i64 = 8192 |
| 11 | const INV_MAGIC_4000000: i64 = 4000000 |
| 12 | const INV_MAGIC_1048640: i64 = 1048640 |
| 13 | const INV_MAGIC_8388608: i64 = 8388608 |
| 14 | const INV_MAGIC_2097152: i64 = 2097152 |
| 15 | const INV_MAGIC_524288: i64 = 524288 |
| 16 | const INV_MAGIC_65536: i64 = 65536 |
| 17 | const INV_MAGIC_2097000: i64 = 2097000 |
| 18 | const INV_MAGIC_12582912: i64 = 12582912 |
| 19 | const INV_MAGIC_8190: i64 = 8190 |
| 20 | const INV_MAGIC_4194304: i64 = 4194304 |
| 21 | const INV_MAGIC_4096: i64 = 4096 |
| 22 | const INV_MAGIC_1024: i64 = 1024 |
| 25 | const INV_PREFIX: *u8 = "knowledge/store/media-inventory/inv-" as *u8 |
| 26 | const INV_ROOT_LOGS: *u8 = "/volume1/logs" as *u8 |
| 27 | const INV_ROOT_LOGGING:*u8 = "/volume1/logging" as *u8 |
| 28 | const INV_ROOT_MOVIES: *u8 = "/volume1/movies" as *u8 |
| 29 | const INV_ROOT_BOOKS: *u8 = "/volume1/homes/elderwesto/books" as *u8 |
| 30 | const INV_CATALOG: *u8 = "/volume1/ai/galx/knowledge/status/galx_vid_paths.tsv" as *u8 |
| 31 | const INV_STALEBIN: *u8 = "/volume1/ai/galx/knowledge/status/galx_stale.bin" as *u8 |
| 32 | const INV_STALEBIN_ALT:*u8 = "knowledge/store/media-inventory/galx_stale.bin" as *u8 |
| 33 | const INV_VIEW_REC: *u8 = "knowledge/store/media-inventory/rec_by_performer.tsv" as *u8 |
| 34 | const INV_VIEW_SUM: *u8 = "knowledge/store/media-inventory/inventory_summary.txt" as *u8 |
| 272 | const IV_ARENA_CAP: i64 = 33554432 |
| 273 | const IV_STK_CAP: i64 = 1000000 |
functions
| 37 | func iv_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 38 | func 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 } |
| 39 | func 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 } |
| 40 | func iv_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, iv_slen(s)); return 0 } |
| 41 | func 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 } |
| 42 | func iv_p(s: *u8) -> i64 { iv_w(1, s); return 0 } |
| 43 | func iv_pn(v: i64) -> i64 { iv_n(1, v); return 0 } calls 1: iv_n |
| 45 | func 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 } |
| 47 | func 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 |
| 49 | func iv_is_recext(nm: *u8) -> i64 |
| 61 | func iv_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } |
| 63 | func 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 } |
| 67 | func iv_count_ts(dpath: *u8, dirbuf: *u8) -> i64 |
| 94 | func iv_merge_perf(name: *u8, cnt: i64, rootbit: i64, pnames: *u8, pnoff: *i64, pcount: *i64, pmask: *i64, npc: *i64, pusedc: *i64) -> i64 |
| 118 | func 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 called by 1: iv_build calls 8: sys_openat_rdiv_slensys_getdents64dirent_reclendirent_nameiv_count_ts+2 |
| 157 | func iv_ext_match(extlc: *u8, kind: i64) -> i64 |
| 188 | func iv_walk_count(root: *u8, kind: i64, dirbuf: *u8, parena: *u8, stkoff: *i64, arenacap: i64, stkcap: i64) -> i64 |
| 265 | func iv_category(kind: *u8) -> i64 { if iv_streq(kind, "recordings" as *u8) == 1 { return 1 } return 0 } |
| 267 | func iv_get(key: *u8, ptrout: *i64, lenout: *i64) -> i64 { return ss_get(INV_PREFIX, key, ptrout, lenout) } |
| 269 | func 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 |
| 277 | func iv_build(mode: *u8) -> i64 called by 2: mainmain calls 22: sys_now_realtime_secsys_mmapiv_walk_rec_rootsys_openat_rdsys_getdents64dirent_reclen+16 |
| 468 | func iv_show(kind: *u8) -> i64 |
| 481 | func iv_audit() -> i64 |