code wiki / (root) / nx_mirrorintegrity_lib.nx

nx_mirrorintegrity_lib.nx

buildroot/runtime/nx_mirrorintegrity_lib.nx

36220 B666 linesdepth 4pulls 5 transitivereach 6 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_mirrorintegrity_lib.nx -- IS THE EVIDENCE WE PINNED ACTUALLY COMPLETE? WHY THIS EXISTS. The /compare citation register mirrors every reference into knowledge/fetched/ and pins it with a sha256. nx_compare_refs_gate then proves pin==filehash on every declared mirror. That proof is real but it answers a NARROWER question than its name suggests: A PIN PROVES THE BYTES ARE UNCHANGED SINCE THEY WERE STORED. IT CANNOT PROVE THEY WERE EVER COMPLETE. A truncated body hashes perfectly and matches forever. Measured 2026-08-20: nx_research_fetch's TLS-1.2 leg saved 255935 bytes of an 814052-byte PDF, twice, byte-identical, while printing status=200 and a SAVED line that reads as success. That mirror would have passed the refs gate every day for the rest of its life. A TRUNCATED MIRROR IS WORSE THAN NO MIRROR: IT IS A CITATION THAT READS AS VERIFIED. WHAT IT DOES. For every file under a directory it reads only the HEAD and the TAIL (never the whole body, so a 6 MB PDF costs two reads) and asks the body to describe its own completeness: PDF -- a linearized PDF DECLARES ITS OWN TOTAL LENGTH in the header (/L <n>); if that exceeds the file on disk the body is provably short. Otherwise a complete PDF ends in the EOF marker. HTML -- a complete document closes its html element. JSON -- a complete document closes the brace or bracket it opened. PNG -- a complete stream ends with the IEND chunk type. JPEG -- a complete stream ends with the EOI marker FF D9. Anything whose format declares no length and carries no terminator is UNKNOWN. It is NOT counted as complete. AN AXIS THAT CANNOT SEE MUST ABSTAIN, NOT ACQUIT. THE PARTITION IS PRINTED AND MUST SUM: proven + suspect + complete + unknown == files. CAP-EXACT is a SEPARATE AXIS, not a partition member, because a body can be complete AND land on a power-of-two boundary by coincidence -- folding it in would silently break the reconciliation. license_tier: ORIGINAL LIBRARY -- no main. nx_mirrorintegrity.nx and nx_mirrorintegrity_gate.nx BOTH consume it, so the census and its gate share ONE ruler by construction and cannot drift apart.

dependencies 3 imports · 6 importers

nx_syscalls.nx nx_lane_conf.nx nx_html_to_text.nx nx_mirrorintegrity_lib.nx nx_compare_refs_gate.nx nx_fetchfail.nx nx_fetchfail_gate.nx nx_mirrorintegrity.nx nx_mirrorintegrity_gate.nx nx_refdrift.nx

imports: nx_syscalls.nxnx_lane_conf.nxnx_html_to_text.nx

imported by: nx_compare_refs_gate.nxnx_fetchfail.nxnx_fetchfail_gate.nxnx_mirrorintegrity.nxnx_mirrorintegrity_gate.nxnx_refdrift.nx

structs

none

consts

33const MI_DEF_DIR: *u8 = "knowledge/fetched\x00"
34const MI_HEAD: i64 = 4096 // declared: bytes read from the head of every file
35const MI_TAIL: i64 = 4096 // declared: bytes read from the tail of every file
36const MI_PATHCAP: i64 = 4096
37const MI_DIRBUF: i64 = 131072
38const MI_MAXDEPTH: i64 = 8
39const MI_WORKCAP: i64 = 1048576 // worklist accumulation buffer, flushed when near full
40const MI_WORKFLUSH: i64 = 1047000 // flush threshold, leaves room for one long row
41const MI_CAP_FLOOR: i64 = 65536 // below this a power-of-two size is coincidence, not a cap
42const MI_SEEK_SET: i64 = 0
43const MI_SEEK_END: i64 = 2
44const MI_DT_DIR: i64 = 4
46const MI_PROVEN: i64 = 0
47const MI_SUSPECT: i64 = 1
48const MI_COMPLETE: i64 = 2
49const MI_UNKNOWN: i64 = 3
147const MI_CH_GT: i64 = 62 // the byte a finished HTML element always ends on
148const MI_CH_LT: i64 = 60 // opens a tag; met first while scanning BACK, it proves a cut
149const MI_RC_HTML_MIDCONTENT: i64 = 4
150const MI_RC_HTML_OPENTAG: i64 = 10
151const MI_RC_HTML_OPTIONAL: i64 = 11
351const MI_CH_MINUS: i64 = 45
352const MI_CH_ZERO: i64 = 48
353const MI_CH_NINE: i64 = 57
355const MI_COUNTS_SLOTS: i64 = 16
356const MI_COUNTS_BYTES: i64 = 128
358const MI_AXISBUF: i64 = 4096
359const MI_CONTENT_CONF_REL: *u8 = "knowledge/mirror_content.conf\x00"
360const MI_CONTENT_CONF_ABS: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/mirror_content.conf\x00"
361const MI_PROSE_FLOOR_KEY: *u8 = "prose-floor-bytes\x00"
365const MI_DEF_PROSE_FLOOR: i64 = 1
367const MC_OK: i64 = 0
368const MC_JS_SHELL: i64 = 1
369const MC_BOT_CHALLENGE: i64 = 2
370const MC_LOGIN_WALL: i64 = 3
371const MC_HTTP_ERROR: i64 = 4
372const MC_PROSE_EMPTY: i64 = 5
373const MC_NOT_HTML: i64 = 6
425const MI_RENDER_SLACK: i64 = 4096

functions

51func mi_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: mainmain calls 1: sys_write
52func mi_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
53func mi_cat(o: *u8, at: i64, s: *u8) -> i64 { var i: i64=0; var a: i64=at; while s[i]!=(0 as u8){o[a]=s[i]; a=a+1; i=i+1} return a }
54func mi_catn(o: *u8, at: i64, v: i64) -> i64 {
65func mi_find(buf: *u8, from: i64, end: i64, needle: *u8) -> i64 {
80func mi_digits_at(buf: *u8, p: i64, end: i64) -> i64 {
called by 1: mi_classify
91func mi_is_ws(c: i64) -> i64 { if c==32 { return 1 } if c==10 { return 1 } if c==13 { return 1 } if c==9 { return 1 } return 0 }
92func mi_is_pow2(n: i64) -> i64 {
called by 1: mi_walk
99func mi_isdotdot(nm: *u8) -> i64 { if nm[0]==(46 as u8){ if nm[1]==(0 as u8){return 1} if nm[1]==(46 as u8){ if nm[2]==(0 as u8){return 1} } } return 0 }
100func mi_join(buf: *u8, base_n: i64, name: *u8) -> i64 { buf[base_n]=47 as u8; var o: i64=base_n+1; var i: i64=0; while name[i]!=(0 as u8){buf[o]=name[i];o=o+1;i=i+1} return o }
103func mi_read_at(fd: i64, off: i64, buf: *u8, cap: i64) -> i64 {
called by 1: mi_classify calls 2: sys_lseeksys_read
153func mi_html_tail_verdict(tbuf: *u8, tn: i64, rcode: *i64) -> i64 {
called by 1: mi_classify calls 1: mi_is_ws
185func mi_classify(path: *u8, hbuf: *u8, tbuf: *u8, rcode: *i64, sz: *i64, decl: *i64) -> i64 {
305func mi_reason(rc: i64) -> *u8 {
called by 2: crg_mir_rowmi_walk
375func mi_prose_floor() -> i64 { return lc_geti(MI_CONTENT_CONF_REL as *u8, MI_CONTENT_CONF_ABS as *u8, MI_PROSE_FLOOR_KEY as *u8, MI_DEF_PROSE_FLOOR) }
called by 3: mainmainmain calls 1: lc_geti
378func mi_atoi_arg(s: *u8) -> i64 {
called by 1: main
392func mi_pc_lc(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c }
called by 1: mi_pc_find_ci
395func mi_pc_find_ci(buf: *u8, from: i64, end: i64, needle: *u8) -> i64 {
called by 2: mi_hasmi_is_html calls 2: mi_slenmi_pc_lc
410func mi_has(src: *u8, n: i64, needle: *u8) -> i64 { if mi_pc_find_ci(src, 0, n, needle)>=0 { return 1 } return 0 }
called by 2: mainmi_content_class calls 1: mi_pc_find_ci
413func mi_is_html(src: *u8, n: i64) -> i64 {
called by 1: mi_content_class calls 1: mi_pc_find_ci
431func mi_prose_render(src: *u8, n: i64, out: *u8, cap: i64) -> i64 {
436func mi_prose_bytes(src: *u8, n: i64) -> i64 {
448func mi_content_class(path: *u8, floor: i64, prose: *i64, hb: *i64) -> i64 {
526func mi_content_reason(c: i64) -> *u8 {
537func mi_content_remedy(c: i64) -> *u8 {
551func mi_content_walk(p: *u8, pn: i64, depth: i64, floor: i64, ccounts: *i64, work: *u8, wo: *i64) -> i64 {
612func mi_walk(p: *u8, pn: i64, depth: i64, hbuf: *u8, tbuf: *u8, counts: *i64, work: *u8, wo: *i64) -> i64 {