nx_packmirror_lib.nx
buildroot/runtime/nx_packmirror_lib.nx
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
imports: nx_syscalls.nx
imported by: nx_packmirror.nxnx_packmirror_gate.nx
structs
| none |
consts
| 15 | const PM_MAX_FILES: i64 = 4096 // a pack beyond this REFUSES loudly (partial-manifest announce), never truncates silently |
| 16 | const PM_NAME_CAP: i64 = 512 // one sanitized dest name |
| 17 | const PM_UNPARSED_SLOT: i64 = 0 // counts[] slot: entries missing a required field |
| 196 | const PM_HASH_CAP: i64 = 48 // base64 of a 32-byte digest = 44 chars + NUL, with margin |
| 197 | const PM_ID_PAD: i64 = 6 // BepisDB zero-pads card ids to 6 digits in file URLs (measured) |
| 198 | const PM_CT_MAX: i64 = 16 // longest cardType code observed is KKCLOTHING (10); 16 refuses garbage |
functions
| 19 | func pm_b(buf: *u8, o: i64) -> i64 { return buf[o] as i64 & 0xff } |
| 20 | func pm_findn(buf: *u8, start: i64, end: i64, needle: *u8) -> i64 |
| 33 | func pm_rfindn(buf: *u8, start: i64, limit: i64, needle: *u8) -> i64 |
| 43 | func pm_int_after(buf: *u8, at: i64, end: i64) -> i64 |
| 54 | func pm_sanitize(src: *u8, soff: i64, send: i64, dst: *u8, dcap: i64) -> i64 |
| 78 | func pm_parse_manifest(buf: *u8, n: i64, ids: *i64, sizes: *i64, names: *u8, maxn: i64, counts: *i64) -> i64 |
| 123 | func pm_parse_thread(buf: *u8, n: i64, ids: *i64, sizes: *i64, names: *u8, maxn: i64, counts: *i64) -> i64 |
| 176 | func pm_dest_ok(path: *u8, declared: i64) -> i64 |
| 199 | func pm_parse_bepis(buf: *u8, n: i64, ids: *i64, sizes: *i64, names: *u8, maxn: i64, counts: *i64, hashes: *u8) -> i64 |