code wiki / (root) / nx_refdrift.nx

nx_refdrift.nx

buildroot/runtime/nx_refdrift.nx

33275 B600 linesdepth 5pulls 10 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_refdrift.nx -- DOES THE URL STILL SERVE THE BYTES WE PINNED? The refs referee proves the mirror matches its pin, which is a claim about OUR disk. It says so about itself in its own verdict note: "fetch-time provenance proves the mirror is OF the url. It does NOT prove the url still serves those bytes." This organ closes that residual, and it exists because the gap was measured the hard way on 2026-09-04: two pinned standards had MOVED upstream since they were fetched, and a seat only discovered it by re-fetching them for an unrelated reason. A CITATION THAT DRIFTS SILENTLY IS A CLAIM WITH AN EXPIRY DATE NOBODY RECORDED -- the pin still matches the mirror, the mirror still matches the pin, and the source has changed. IT COMPARES BYTES, NOT HASHES, AND THAT IS DELIBERATE. The refs referee already proves pin == filehash of the mirror, so the mirror IS the pinned bytes. Re-fetching and byte-comparing against the mirror therefore answers the drift question exactly, with no second hash implementation to drift from the first. One ruler. IT IS BOUNDED BY CONSTRUCTION AND SAYS SO. The operator's standing law is that hammering the estate is a defect in its own right, so this organ takes ONE refs file and a MAXIMUM number of rows per run, both from argv, and it PRINTS the bound beside the result. A run that stops at its cap declares checked and total, so a partial pass can never read as a clean sweep -- the self-ceiling defect this estate names as law L011. nx_refdrift check <refsfile> [max] -> per-row MATCH / DRIFTED / UNREACHABLE, plus a summing partition nx_refdrift selftest -> teeth, exit 0 GREEN / 1 RED Exit: 0 no drift found | 1 DRIFTED rows exist | 2 usage | 3 UNREADABLE refs file. verdict= is LAST. license_tier: ORIGINAL. Forks the sovereign fetcher, writes one reused temp mirror. No hw writes (Rule 26).

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_tool_run.nx nx_rowparse_lib.nx nx_mirrorintegrity_lib.nx nx_refdrift.nx

imports: nx_syscalls.nxnx_tool_run.nxnx_rowparse_lib.nxnx_mirrorintegrity_lib.nx

imported by: nobody (leaf or entry point)

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

main rp_slen sys_write sys_exit 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 ↻ rp_put rp_slen ↻

structs

none

consts

27const RD_EXIT_OK: i64 = 0
28const RD_EXIT_DRIFT: i64 = 1
29const RD_EXIT_USAGE: i64 = 2
30const RD_EXIT_UNREAD: i64 = 3
31const RD_SPAN: i64 = 8
32const RD_OUT: i64 = 262144
33const RD_REFS_CAP: i64 = 1048576
34const RD_BODY_CAP: i64 = 8388608
35const RD_FETCH_OUT: i64 = 65536
36const RD_PATH: i64 = 4096
37const RD_SEEK_END: i64 = 2
40const RD_MAX_DEFAULT: i64 = 12
41const RD_COL_KEY: i64 = 1
42const RD_COL_URL: i64 = 3
43const RD_COL_MIRROR: i64 = 4
44const RD_ARGV_SLOTS: i64 = 4
45const RD_PROBE: *u8 = "knowledge/fetched/refdrift_probe.tmp"
46const RD_FETCHER: *u8 = "nx_research_fetch.elf"
47const RD_PROBE_NAME: *u8 = "refdrift_probe.tmp"
48const RD_PROBE_B: *u8 = "knowledge/fetched/refdrift_probe_b.tmp"
49const RD_PROBE_B_NAME: *u8 = "refdrift_probe_b.tmp"
71const RD_SPACE: i64 = 32
72const RD_WL_COL_DOM: i64 = 1
73const RD_WL_COL_KEY: i64 = 2
74const RD_WL_COL_MIRROR: i64 = 3
75const RD_WL_COL_CANON: i64 = 4
76const RD_COL_PIN: i64 = 5
77const RD_COL_ACCESSED: i64 = 6
78const RD_REFS_DIR: *u8 = "buildroot/knowledge/compare/"
79const RD_HASHER: *u8 = "nx_filehash.elf"
80const RD_SHA_TAG: *u8 = "sha256"
81const RD_JSON_QCQ: i64 = 3
82const RD_HEXLEN: i64 = 64
83const RD_TMP_SUFFIX: *u8 = ".recite.tmp"
84const RD_WL_TAG: *u8 = "MOVED"
87const RD_KEYARG: *u8 = "key="
89const RD_SECS_PER_DAY: i64 = 86400
90const RD_DAYS_EPOCH_TO_ERA0: i64 = 719468
91const RD_DAYS_PER_ERA: i64 = 146097
92const RD_ERA_YEARS: i64 = 400
93const RD_DOE_4Y: i64 = 1460
94const RD_DOE_100Y: i64 = 36524
95const RD_DOE_ERA_LAST: i64 = 146096
96const RD_DAYS_PER_YEAR: i64 = 365
97const RD_LEAP_4: i64 = 4
98const RD_LEAP_100: i64 = 100
99const RD_MP_SCALE: i64 = 5
100const RD_MP_OFF: i64 = 2
101const RD_MP_DIV: i64 = 153
102const RD_MP_MARCH: i64 = 3
103const RD_MP_WRAP: i64 = 9
104const RD_MP_JAN: i64 = 10
105const RD_TWO_DIGIT: i64 = 10
233const RD_V_MATCH: i64 = 0
234const RD_V_DRIFTED: i64 = 1
235const RD_V_UNREACHABLE: i64 = 2
236const RD_V_DYNAMIC: i64 = 3

functions

52func rd_slurp(path: *u8, buf: *u8, cap: i64) -> i64
106func rd_put2(out: *u8, o: i64, v: i64) -> i64
called by 1: rd_ymd calls 1: rp_putn
111func rd_ymd(epoch: i64, out: *u8) -> i64
calls 2: rp_putnrd_put2
131func rd_basename(p: *u8) -> *u8
138func rd_sha(path: *u8, out: *u8, fo: *u8, folen: *i64, av: *i64) -> i64
162func rd_recite_row(refs: *u8, key: *u8, newurl: *u8, sha: *u8, ymd: *u8, rb: *u8, ob: *u8, c: *i64) -> i64
238func rd_same(mb: *u8, mn: i64, pb: *u8, pn: i64, qb: *u8, qn: i64) -> i64
calls 1: rp_same
246func main(argc: i64, argv: **u8) -> i64