code wiki / (root) / nx_packmirror_lib.nx

nx_packmirror_lib.nx

buildroot/runtime/nx_packmirror_lib.nx

12690 B259 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_packmirror_lib.nx -- PACK-MANIFEST PARSE + VERIFY CORE (debt 1787064637; operator 2026-08-18: media archiving by hand-driven 2-step fetches cannot scale and leaves per-file verification unproven). Dialect v1: the pCloud showpublink JSON (the mining pattern's banked manifest). STRUCTURAL FACTS THIS PARSER RESTS ON (read from the real manifest, stated so a format drift is diagnosable): a FILE entry carries "fileid" (folders carry "folderid", which does not contain the quoted needle); within an entry the observed field order is "name" ... "fileid" ... "size", and the next entry's fields follow AFTER this entry's size -- so name = the LAST "name" before the fileid, size = the FIRST "size" after it, both bounded by the neighbouring fileid positions. FAIL-CLOSED: an entry missing either field counts UNPARSED, never a guessed row. The dest-name sanitizer maps every byte outside [A-Za-z0-9._-] to '_' -- a manifest name can therefore never escape the destination directory (path traversal is structurally impossible, not filtered). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_packmirror_lib.nx nx_packmirror.nx nx_packmirror_gate.nx

imports: nx_syscalls.nx

imported by: nx_packmirror.nxnx_packmirror_gate.nx

structs

none

consts

15const PM_MAX_FILES: i64 = 4096 // a pack beyond this REFUSES loudly (partial-manifest announce), never truncates silently
16const PM_NAME_CAP: i64 = 512 // one sanitized dest name
17const PM_UNPARSED_SLOT: i64 = 0 // counts[] slot: entries missing a required field
196const PM_HASH_CAP: i64 = 48 // base64 of a 32-byte digest = 44 chars + NUL, with margin
197const PM_ID_PAD: i64 = 6 // BepisDB zero-pads card ids to 6 digits in file URLs (measured)
198const PM_CT_MAX: i64 = 16 // longest cardType code observed is KKCLOTHING (10); 16 refuses garbage

functions

19func pm_b(buf: *u8, o: i64) -> i64 { return buf[o] as i64 & 0xff }
20func pm_findn(buf: *u8, start: i64, end: i64, needle: *u8) -> i64
33func pm_rfindn(buf: *u8, start: i64, limit: i64, needle: *u8) -> i64
43func pm_int_after(buf: *u8, at: i64, end: i64) -> i64
54func pm_sanitize(src: *u8, soff: i64, send: i64, dst: *u8, dcap: i64) -> i64
called by 1: pm_parse_manifest calls 1: pm_b
78func pm_parse_manifest(buf: *u8, n: i64, ids: *i64, sizes: *i64, names: *u8, maxn: i64, counts: *i64) -> i64
123func pm_parse_thread(buf: *u8, n: i64, ids: *i64, sizes: *i64, names: *u8, maxn: i64, counts: *i64) -> i64
176func pm_dest_ok(path: *u8, declared: i64) -> i64
199func pm_parse_bepis(buf: *u8, n: i64, ids: *i64, sizes: *i64, names: *u8, maxn: i64, counts: *i64, hashes: *u8) -> i64