code wiki / (root) / nx_medrec.nx

nx_medrec.nx

buildroot/runtime/nx_medrec.nx

11195 B254 linesdepth 3pulls 3 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_medrec.nx -- MEDIA-RECOVERY ADMISSION CORE: decide whether an archived capture is REALLY the media, or the host's tombstone wearing a valid image header. module: nishi-core.archive.medrec depends: nx_cdx_parse.nx (rows/fields -- NOT re-parsed here, Rule 15) capability: PURE DECISION CORE (zero I/O) WHY THIS EXISTS -- MEASURED LIVE 2026-08-06 against the Wayback CDX index, never assumed (Rule 4): nx_media_xrecover admits a recovered capture on is_image(): GIF/JPEG/PNG/BMP magic bytes. That is a STRUCTURE test and it CANNOT fail on a host placeholder, because a placeholder IS a structurally valid JPEG. Measured: i.imgur.com "image not found" -> digest VXEDWGPHSNERWHDOUD6YWRWNT4ZOLEX4, status 200, image/jpeg, sizes 335 / 339 / 457 / 789 / 827 B -- the SAME digest across captures 2013-04-20 .. 2026-06-17. Real media recovered from that same host -> 6PYVXUDUV5WT3VSTAK33KZYTSI4BA56Z at 1,090,473 B and INAME2WHG3WPFAVNJ3URHYKXTB6FH46R at 937,110 B -- each digest UNIQUE to its image. So a pipeline gated only on magic bytes reports SUCCESS on an unbounded number of identical ~400-byte "not found" images, and its success count RISES as the host deletes MORE. *A ROW COUNT IS NOT EVIDENCE. Structure is not identity. *TWO SIGNALS, BOTH READ FROM THE CDX ROW ITSELF -- a tombstone is rejected for ZERO bandwidth: (1) DIGEST IDENTITY -- a known placeholder digest is never the media. (2) SIZE FLOOR -- supplied by the CALLER, never baked (Rule 11). *AND THE GENERAL FORM, which needs no list -- but ONLY as a CONJUNCTION, and the reason matters. A placeholder is byte-identical every time it is served, so its captures collapse to ONE digest at a SMALL size. Digest-collapse ALONE proves nothing: measured, the real 1 MB image OT6mUiy.jpg also carries one digest (6PYVXUD..) across all 3 of its captures -- an unchanged file always does. What separates them is SIZE, and note the CDX length column is the COMPRESSED WARC RECORD size, not the payload (OT6mUiy reads 1,090,473 / 1,083,440 / 1,083,439 for bit-identical content), so it is a coarse floor and never an equality test. mr_rowset_is_tombstone therefore requires small AND collapsed, and answers 0 whenever either leg fails. Build intelligence, do not maintain a blocklist (Rule 25) -- but do not let a heuristic claim evidence it does not have. *FAIL-CLOSED: an absent or unparseable field is MR_UNKNOWN, never ADMIT. A CDX length of "-" (revisit records carry it) is UNKNOWN, not zero. "We cannot tell" and "it is the media" are different answers. license_tier: ORIGINAL LIB.

dependencies 2 imports · 3 importers

nx_syscalls.nx nx_cdx_parse.nx nx_medrec.nx nx_archive_site_viewer.nx nx_arcmine.nx nx_medrec_gate.nx

imports: nx_syscalls.nxnx_cdx_parse.nx

imported by: nx_archive_site_viewer.nxnx_arcmine.nxnx_medrec_gate.nx

structs

none

consts

40const MR_MAGIC_1125899906842597: i64 = 1125899906842597
42const MR_ADMIT: i64 = 1
43const MR_UNKNOWN: i64 = 0 - 1
44const MR_REJ_STATUS: i64 = 0 - 2
45const MR_REJ_TOMBSTONE: i64 = 0 - 3
46const MR_REJ_TOOSMALL: i64 = 0 - 4
52const MR_URL_DIRECT: i64 = 1
53const MR_URL_PAGE: i64 = 2
54const MR_URL_GALLERY: i64 = 3
55const MR_URL_OTHER: i64 = 4
58const MR_F_TS: i64 = 1
59const MR_F_ORIG: i64 = 2
60const MR_F_MIME: i64 = 3
61const MR_F_STATUS: i64 = 4
62const MR_F_DIGEST: i64 = 5
63const MR_F_LENGTH: i64 = 6

functions

65func mr_lc(c: i64) -> i64
71func mr_ci_has(hay: *u8, needle: *u8) -> i64
called by 2: ext_formr_url_kind calls 1: mr_lc
92func mr_slice_eq(buf: *u8, off: i64, len: i64, s: *u8) -> i64
106func mr_slice_int(buf: *u8, off: i64, len: i64) -> i64
122func mr_tombstone_count() -> i64 { return 2 }
123func mr_tombstone_at(i: i64) -> *u8
132func mr_digest_is_tombstone(buf: *u8, off: i64, len: i64) -> i64
143func mr_row_admit(buf: *u8, rs: i64, re: i64, min_bytes: i64, o2: *i64) -> i64
159func mr_row_size(buf: *u8, rs: i64, re: i64, o2: *i64) -> i64
166func mr_rowset_is_tombstone(buf: *u8, rowstarts: *i64, rowends: *i64, rn: i64, small_bytes: i64, o2: *i64) -> i64
193func mr_pick_best(buf: *u8, rowstarts: *i64, rowends: *i64, rn: i64, min_bytes: i64, o2: *i64) -> i64
214func mr_canon_hash(buf: *u8, off: i64, len: i64) -> i64
called by 2: mainmain calls 1: mr_lc
246func mr_url_kind(url: *u8) -> i64
called by 1: main calls 1: mr_ci_has