code wiki / (root) / nx_arcmine.nx

nx_arcmine.nx

buildroot/runtime/nx_arcmine.nx

27072 B468 linesdepth 21pulls 148 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_arcmine.nx -- INDEX-FIRST domain media harvester. The rung that makes a sovereign archive EXCEED the Wayback Machine on media completeness (the 2026-06-29 goal: page3.com / megastar.co.uk day-by-day WITH their media). module: nishi-core.archive.arcmine depends: nx_medrec.nx (admission), nx_cdx_parse.nx (rows/fields), nx_https_fetch_follow.nx usage: nx_arcmine <domain> [page] [min_bytes] [max_fetch] [mime] capability: LIVE FETCH, read-only against the archive. Additive + IDEMPOTENT (Rule 10). *WHY INDEX-FIRST, AND WHY IT BEATS THE PAGE-WALK -- the whole point of this organ: nx_archive_site_viewer discovers media by RENDERING a captured page and reading its <img> tags. That ceiling is structural: it can only ever find media referenced by the pages it happens to render, at the one timestamp it renders them. Every image on a page never rendered, on a page never captured, or referenced only from a since-changed layout, is INVISIBLE to it -- and its absence is invisible too. The CDX index knows every image the crawler EVER saw across the whole host and all time. Enumerating from the index is exhaustive BY CONSTRUCTION rather than by luck of which page we happened to open. That is the difference between browsing an archive and MINING one. *DEDUPE BY DIGEST, MEASURED 2026-08-06: captures of one URL are byte-identical. Real sample -- page3.com/3zine_pages/html_preview/01/ held 21 status-200 capture rows that collapse to just 6 unique digests (01.jpg alone: 6 captures, ONE digest HSTRJJRQ.., sizes 27236..27245 = 9 bytes of WARC record framing, not pixels). Fetching per-capture would spend 3.5x the bandwidth for byte-identical output. collapse=digest is therefore applied at the QUERY, so the redundancy never crosses the network at all. *AND THE COROLLARY THAT KILLED A PLANNED CHANGE: because captures are byte-identical, choosing the LARGEST capture over the EARLIEST buys exactly nothing on this corpus. That tweak was measured, found worthless, and NOT shipped. *TOMBSTONES ARE REJECTED FROM THE INDEX (nx_medrec), before a single byte is fetched -- a host's "image not found" placeholder is a structurally valid JPEG that magic-byte validation cannot fail. *IDEMPOTENT BY CONSTRUCTION: the output filename IS the content digest, so a re-run rewrites identical bytes and can never duplicate or corrupt. Safe to run twice, or to resume a partial page. *PACING: max_fetch bounds one invocation deliberately. The archive is a shared resource and we have rate-limited ourselves off hosts before by sweeping too fast; the operator advances pages at their own cadence. OWED: wire pace_before(host) from nx_crawl_pace so politeness is structural, not procedural. license_tier: ORIGINAL

dependencies 4 imports · 0 importers

nx_medrec.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_https_fetch_follow.nx nx_arcmine.nx

imports: nx_medrec.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main aw s2i an ap nx_trust_store_load_from_c sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close nx_nss_certdata_parse sys_mmap ↻ _pat_class_cert _pat_value_octal _pat_end _find_newline _starts_with _parse_octal_line sys_mmap ↻ _is_space _decode_octal_escape _is_octal

structs

none

consts

42const AM_CAP: i64 = 4194304
43const AM_ROWCAP: i64 = 4000
44const AM_PATH: i64 = 1024
45const AM_URLBUF: i64 = 4096
46const AM_DIRMODE: i64 = 0x1ed
47const AM_FILEMODE: i64 = 0x1a4
48const AM_DEF_MIN: i64 = 2048
49const AM_DEF_MAX: i64 = 40

functions

51func aw(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 1: main
52func an(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m } let t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let o: *u8=sys_mmap(24); var w: i64=0; var q: i64=k-1; while q>=0 { o[w]=t[q]; w=w+1; q=q-1 } sys_write(1,o,w); return 0 }
called by 1: main
53func aslice(buf: *u8, off: i64, len: i64) -> i64 { sys_write(1, ((buf as i64)+off) as *u8, len); return 0 }
54func ap(buf: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8) { buf[off+i]=s[i]; i=i+1 } return off+i }
called by 2: save_filemain
55func apsl(dst: *u8, off: i64, src: *u8, so: i64, sl: i64) -> i64 { var i: i64=0; while i<sl { dst[off+i]=src[so+i]; i=i+1 } return off+sl }
called by 1: main
56func apn(buf: *u8, off: i64, v: i64) -> i64 { if v==0 { buf[off]=0x30 as u8; return off+1 } var m: i64=v; let t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } var o: i64=off; var q: i64=k-1; while q>=0 { buf[o]=t[q]; o=o+1; q=q-1 } return o }
called by 1: main
57func s2i(s: *u8) -> i64 { var v: i64=0; var i: i64=0; var any: i64=0; while s[i]!=(0 as u8) { let c: i64=s[i] as i64; if c<0x30 { return 0-1 } if c>0x39 { return 0-1 } v=v*10+(c-0x30); any=1; i=i+1 } if any==0 { return 0-1 } return v }
called by 1: main
61func is_image(buf: *u8, n: i64) -> i64
77func save_file(path: *u8, buf: *u8, n: i64) -> i64
called by 1: main calls 1: ap
98func have_file(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 { return 0 } sys_close(fd); return 1 }
called by 1: main
111func canon_hash(buf: *u8, off: i64, len: i64) -> i64
calls 1: mr_lc
151func append_file(path: *u8, buf: *u8, n: i64) -> i64
called by 1: main
159func fetch_retry(url: *u8, store: *TrustStore, out: *u8, cap: i64, st: *i64, tries: i64) -> i64
173func ext_for(mime: *u8) -> *u8
called by 1: ext_from_row calls 1: mr_ci_has
187func ext_from_row(buf: *u8, off: i64, len: i64, scratch: *u8) -> *u8
calls 1: ext_for
210func tok_name(dst: *u8, o: i64, src: *u8, so: i64, sl: i64) -> i64
called by 1: main
249func main(argc: i64, argv: *i64) -> i64