nx_medrec.nx
buildroot/runtime/nx_medrec.nx
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
imports: nx_syscalls.nxnx_cdx_parse.nx
imported by: nx_archive_site_viewer.nxnx_arcmine.nxnx_medrec_gate.nx
structs
| none |
consts
| 40 | const MR_MAGIC_1125899906842597: i64 = 1125899906842597 |
| 42 | const MR_ADMIT: i64 = 1 |
| 43 | const MR_UNKNOWN: i64 = 0 - 1 |
| 44 | const MR_REJ_STATUS: i64 = 0 - 2 |
| 45 | const MR_REJ_TOMBSTONE: i64 = 0 - 3 |
| 46 | const MR_REJ_TOOSMALL: i64 = 0 - 4 |
| 52 | const MR_URL_DIRECT: i64 = 1 |
| 53 | const MR_URL_PAGE: i64 = 2 |
| 54 | const MR_URL_GALLERY: i64 = 3 |
| 55 | const MR_URL_OTHER: i64 = 4 |
| 58 | const MR_F_TS: i64 = 1 |
| 59 | const MR_F_ORIG: i64 = 2 |
| 60 | const MR_F_MIME: i64 = 3 |
| 61 | const MR_F_STATUS: i64 = 4 |
| 62 | const MR_F_DIGEST: i64 = 5 |
| 63 | const MR_F_LENGTH: i64 = 6 |
functions
| 65 | func mr_lc(c: i64) -> i64 |
| 71 | func mr_ci_has(hay: *u8, needle: *u8) -> i64 |
| 92 | func mr_slice_eq(buf: *u8, off: i64, len: i64, s: *u8) -> i64 called by 1: mr_digest_is_tombstone |
| 106 | func mr_slice_int(buf: *u8, off: i64, len: i64) -> i64 |
| 122 | func mr_tombstone_count() -> i64 { return 2 } called by 1: mr_digest_is_tombstone |
| 123 | func mr_tombstone_at(i: i64) -> *u8 called by 1: mr_digest_is_tombstone |
| 132 | func mr_digest_is_tombstone(buf: *u8, off: i64, len: i64) -> i64 |
| 143 | func mr_row_admit(buf: *u8, rs: i64, re: i64, min_bytes: i64, o2: *i64) -> i64 |
| 159 | func mr_row_size(buf: *u8, rs: i64, re: i64, o2: *i64) -> i64 |
| 166 | func mr_rowset_is_tombstone(buf: *u8, rowstarts: *i64, rowends: *i64, rn: i64, small_bytes: i64, o2: *i64) -> i64 |
| 193 | func mr_pick_best(buf: *u8, rowstarts: *i64, rowends: *i64, rn: i64, min_bytes: i64, o2: *i64) -> i64 |
| 214 | func mr_canon_hash(buf: *u8, off: i64, len: i64) -> i64 |
| 246 | func mr_url_kind(url: *u8) -> i64 |