code wiki / (root) / nx_varfacts_lib.nx

nx_varfacts_lib.nx

buildroot/runtime/nx_varfacts_lib.nx

29249 B708 linesdepth 6pulls 6 transitivereach 5 importersview sourcekind librarytopic varfacts
docsdependenciesstructsconstsfunctions

about

nx_varfacts_lib.nx -- VaM .var PACKAGE FACT EXTRACTION CORE (conversion tier, VaM lane). A .var is a ZIP archive. THE WALL THIS LANE LIVES BEHIND (standing policy 1785794796 + measure-dont-ship): VaM is a CAPABILITY TARGET -- asset BYTES (meshes/textures/morph deltas) never enter our products or our published plane. What this core reads is the CENTRAL DIRECTORY (file NAMES + sizes = the package's own manifest) and meta.json (the package's own declared license) -- the package describing itself, never its content. Extracted MEASUREMENTS flow to refcorpus behind the k>=8 admission wall like every other reference corpus. COMPOSES INCUMBENTS: EOCD/central-directory walk = the nx_zip_read shape (that organ is a hardwired PyTorch-.bin test, not a library -- the walk is factored HERE as callables); ZIP method-8 members inflate via nx_deflate_inflate, the SAME raw-DEFLATE core under nx_gzip_wrap and nx_zlib_wrap (capacity-bounded; NOT the retired duplicate nx_inflate, debt 1785854636). ★TAIL-WINDOW CONTRACT: the EOCD + central directory live at the END of a ZIP, so a 519MB .var measures from its last few MB. The caller hands the TAIL bytes + the true file size; if the central directory starts before the window, the probe REFUSES (ok=0) -- a partial census is a plausible undercount, which is worse than absence. Fact slots (flat i64, VF_N_SLOTS): [0] ok [1] entries [2] morphs(.vmi) [3] scenes(Saves/scene/*.json) [4] textures(jpg/png/tif) [5] clothing(/Clothing/) [6] hair(/Hair/) [7] plugins(.cs/.cslist/.dll) [8] appearance(.vap) [9] meta_found [10] meta_lho [11] meta_method [12] meta_csize [13] meta_usize ★2026-09-11 EXTENSION (VaM census lane, ADDITIVE -- every legacy slot above keeps its meaning): (1) THE WALK IS FACTORED INTO CALLABLES so vf_probe, the census CLI (nx_varcensus) and the gate share ONE walk: vf_cd_locate reads the EOCD and names the outcome (OK / NO-EOCD / ZIP64 / WINDOW / SHORT) instead of one ok=0 for five different reasons, and WINDOW hands the caller the exact window it must read (file_size - cd_abs, derived from the archive itself, so no tail size has to be guessed); vf_cd_entry reads ONE record. (2) vf_member_data: STORED bytes in place, DEFLATE through the incumbent nx_deflate_inflate sized from the member's DECLARED usize and required to decode to exactly usize -- no capacity constant to tune. CRC is NOT verified here (imprecision chosen: a corrupt meta.json fails its JSON parse and is counted as unparsed, it is never trusted). (3) vf_json_*: a DEPTH-AWARE reader for meta.json. A key is matched only as a DIRECT member of the object it is asked of, so a nested dependency's own licenseType can never answer for the package (vf_license below takes the FIRST occurrence in the byte stream; the census prints both readings so their agreement is measured, not assumed). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 4 importers

nx_syscalls.nx nx_deflate.nx nx_varfacts_lib.nx nx_ingest_audit.nx nx_varcensus.nx nx_varfacts.nx nx_varfacts_gate.nx

imports: nx_syscalls.nxnx_deflate.nx

imported by: nx_ingest_audit.nxnx_varcensus.nxnx_varfacts.nxnx_varfacts_gate.nx

structs

none

consts

39const VF_MAGIC_1024: i64 = 1024
40const VF_MAGIC_4194304: i64 = 4194304
42const VF_N_SLOTS: i64 = 14
45const VF_SIG_EOCD: i64 = 0x06054b50
46const VF_SIG_CD: i64 = 0x02014b50
47const VF_SIG_LOCAL: i64 = 0x04034b50
48const VF_EOCD_LEN: i64 = 22
49const VF_CD_LEN: i64 = 46
50const VF_LOCAL_LEN: i64 = 30
51const VF_COMMENT_MAX: i64 = 65535
52const VF_U16_ALL: i64 = 0xffff
53const VF_U32_ALL: i64 = 0xffffffff
54const VF_EOCD_ENTRIES: i64 = 10
55const VF_EOCD_CDSIZE: i64 = 12
56const VF_EOCD_CDOFF: i64 = 16
57const VF_CD_FLAGS: i64 = 8
58const VF_CD_METHOD: i64 = 10
59const VF_CD_CSIZE: i64 = 20
60const VF_CD_USIZE: i64 = 24
61const VF_CD_FNL: i64 = 28
62const VF_CD_EXL: i64 = 30
63const VF_CD_CML: i64 = 32
64const VF_CD_LHO: i64 = 42
65const VF_LOCAL_FNL: i64 = 26
66const VF_LOCAL_EXL: i64 = 28
67const VF_METHOD_STORE: i64 = 0
68const VF_METHOD_DEFLATE: i64 = 8
71const VF_L_EOCD: i64 = 0
72const VF_L_ENTRIES: i64 = 1
73const VF_L_CDSIZE: i64 = 2
74const VF_L_CDABS: i64 = 3
75const VF_L_CD: i64 = 4
76const VF_L_STATE: i64 = 5
77const VF_L_N: i64 = 8
78const VF_LOC_OK: i64 = 0
79const VF_LOC_NOEOCD: i64 = 1
80const VF_LOC_ZIP64: i64 = 2
81const VF_LOC_WINDOW: i64 = 3
82const VF_LOC_SHORT: i64 = 4
85const VF_E_METHOD: i64 = 0
86const VF_E_CSIZE: i64 = 1
87const VF_E_USIZE: i64 = 2
88const VF_E_NAMELEN: i64 = 3
89const VF_E_LHO: i64 = 4
90const VF_E_NAMEOFF: i64 = 5
91const VF_E_NEXT: i64 = 6
92const VF_E_FLAGS: i64 = 7
93const VF_E_Z64: i64 = 8
94const VF_E_N: i64 = 10
98const VF_CD_DISK: i64 = 34
99const VF_X_ZIP64: i64 = 0x0001
100const VF_X_HDR: i64 = 4
101const VF_U64_LEN: i64 = 8
102const VF_Z64_NONE: i64 = 0
103const VF_Z64_RESOLVED: i64 = 1
104const VF_Z64_UNRESOLVED: i64 = 0 - 1
107const VF_MD_STORED: i64 = 0
108const VF_MD_INFLATED: i64 = 1
109const VF_MD_FAILED: i64 = 2
110const VF_MD_UNSUPPORTED: i64 = 3
113const VF_J_QUOTE: i64 = 34
114const VF_J_BSL: i64 = 92
115const VF_J_COLON: i64 = 58
116const VF_J_COMMA: i64 = 44
117const VF_J_LBRACE: i64 = 123
118const VF_J_RBRACE: i64 = 125
119const VF_J_LBRACK: i64 = 91
120const VF_J_RBRACK: i64 = 93
121const VF_J_SPACE: i64 = 32
122const VF_J_TAB: i64 = 9
123const VF_J_LF: i64 = 10
124const VF_J_CR: i64 = 13
126const VF_JK_BAD: i64 = 0
127const VF_JK_STRING: i64 = 1
128const VF_JK_OBJECT: i64 = 2
129const VF_JK_ARRAY: i64 = 3
130const VF_JK_SCALAR: i64 = 4
132const VF_JM_KS: i64 = 0
133const VF_JM_KE: i64 = 1
134const VF_JM_VS: i64 = 2
135const VF_JM_VE: i64 = 3
136const VF_JM_N: i64 = 4
138const VF_UTF8_CONT: i64 = 128
139const VF_UTF8_LEAD2: i64 = 192
140const VF_UTF8_LEAD3: i64 = 224
141const VF_UTF8_LEAD4: i64 = 240
142const VF_UTF8_SEXTET: i64 = 64
143const VF_UTF8_MAX1: i64 = 128
144const VF_UTF8_MAX2: i64 = 2048
145const VF_UTF8_MAX3: i64 = 65536
146const VF_SURR_HI: i64 = 0xd800
147const VF_SURR_LO: i64 = 0xdc00
148const VF_SURR_END: i64 = 0xe000
149const VF_SURR_BASE: i64 = 0x10000
150const VF_SURR_SPAN: i64 = 1024
151const VF_HEX_DIGITS: i64 = 4
152const VF_HEX_BASE: i64 = 16

functions

154func vf_u16(b: *u8, o: i64) -> i64 { return (b[o] as i64 & 0xff) | ((b[o+1] as i64 & 0xff) << 8) }
155func vf_u32(b: *u8, o: i64) -> i64 { return (b[o] as i64 & 0xff) | ((b[o+1] as i64 & 0xff) << 8) | ((b[o+2] as i64 & 0xff) << 16) | ((b[o+3] as i64 & 0xff) << 24) }
158func vf_ends(name: *u8, nl: i64, suf: *u8) -> i64
called by 1: vf_probe
166func vf_has(name: *u8, nl: i64, sub: *u8) -> i64
called by 1: vf_probe
181func vf_eocd_window(file_size: i64) -> i64
called by 1: vc_window
191func vf_cd_locate(tail: *u8, tailn: i64, file_size: i64, box: *i64) -> i64
called by 3: vc_windowmainvf_probe calls 2: vf_u32vf_u16
228func vf_cd_entry(tail: *u8, tailn: i64, off: i64, rec: *i64) -> i64
248func vf_u64(b: *u8, o: i64) -> i64 { return vf_u32(b, o) | (vf_u32(b, o + 4) << 32) }
called by 1: vf_zip64_extra calls 1: vf_u32
254func vf_zip64_extra(tail: *u8, tailn: i64, xs: i64, xl: i64, rec: *i64) -> i64
called by 1: vf_cd_entry calls 2: vf_u16vf_u64
286func vf_probe(tail: *u8, tailn: i64, file_size: i64, facts: *i64) -> i64
344func vf_member_data(body: *u8, csize: i64, method: i64, usize: i64, out: *i64) -> *u8
called by 1: vc_meta_read calls 1: nx_deflate_inflate
365func vf_json_ws(c: i64) -> i64
372func vf_json_skip(src: *u8, n: i64, p: i64) -> i64
382func vf_json_open(c: i64) -> i64 { if c == VF_J_LBRACE { return 1 } if c == VF_J_LBRACK { return 1 } return 0 }
called by 1: vf_json_value_end
383func vf_json_close(c: i64) -> i64 { if c == VF_J_RBRACE { return 1 } if c == VF_J_RBRACK { return 1 } return 0 }
386func vf_json_str_end(src: *u8, n: i64, p: i64) -> i64
399func vf_json_kind(src: *u8, n: i64, p: i64) -> i64
414func vf_json_value_end(src: *u8, n: i64, p: i64) -> i64
452func vf_json_member(src: *u8, end: i64, p: i64, box: *i64) -> i64
475func vf_span_is(src: *u8, s: i64, e: i64, lit: *u8) -> i64
486func vf_json_find(src: *u8, n: i64, obj: i64, key: *u8, box: *i64) -> i64
505func vf_json_count_members(src: *u8, n: i64, obj: i64) -> i64
525func vf_json_count_elems(src: *u8, n: i64, arr: i64) -> i64
546func vf_hexval(c: i64) -> i64
called by 1: vf_hex4
552func vf_hex4(src: *u8, at: i64) -> i64
called by 1: vf_json_decode calls 1: vf_hexval
563func vf_utf8(out: *u8, o: i64, cp: i64) -> i64
called by 1: vf_json_decode
587func vf_json_decode(src: *u8, s: i64, e: i64, out: *u8) -> i64
638func vf_json_get_str(src: *u8, n: i64, obj: i64, key: *u8, len: *i64) -> *u8
656func vf_license(body: *u8, csize: i64, method: i64, usize: i64, out: *u8) -> i64