code wiki / (root) / nx_research_journal_gate.nx

nx_research_journal_gate.nx

buildroot/runtime/nx_research_journal_gate.nx

16602 B315 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic research
docsdependenciesstructsconstsfunctions

about

nx_research_journal_gate.nx -- the REFEREE for RES-R6 (crash-resumable journal). Proves nx_research_journal makes a research run RESUME from a crash point by REPLAYING the journal and SKIPPING already-completed phases -- AND proves the test can actually DETECT failure (the mandatory NEGATIVE CONTROL: the old, journal-less path re-runs everything, skipping nothing). GOOD lane (journaled): run 1 ("crash"): execute FETCH (3 sources) + phase_done, EXTRACT (3 sources) + phase_done, then VERIFY begin + 1 source_done, then STOP -- a crash MID-VERIFY (VERIFY never gets its phase_done). work_run1 counts every phase actually executed. run 2 ("restart"): rj_replay(GOOD) -> resume high-water = EXTRACT (VERIFY is NOT complete, so it is correctly NOT skipped). For FETCH..SYNTH: rj_should_skip -> FETCH+EXTRACT SKIPPED (counted), VERIFY+SYNTH executed. PROOF of resume = good_skipped >= 2 AND completed phases re-executed = 0. BAD lane (NEGATIVE CONTROL -- old path, NO journal): same crash, but restart has no journal -> rj_replay on the absent path returns 0 -> resume high-water 0 -> EVERY phase re-executes -> bad_skipped == 0 and bad_refetched == FULL_RUN. If bad_skipped != 0 the detector is worthless -> RED (no false green). TAMPER x2: (a) oversized record (rec_len+1 > cap=8) must be REJECTED with -2. (b) a TORN "RJ ... VERIFY ... DONE" fragment hand-written as a SEQUENCE of separate sys_write()s (no single-write framing) into a victim journal that ALSO holds a real FETCH+EXTRACT phase_done -> rj_replay must NOT let the torn VERIFY-DONE advance the resume point past EXTRACT. Proves a crash that tore the last line can never cause skipped-but-incomplete work. Output: rows -> stdout + evidence log knowledge/status/research_journal_gate.log, then a final verdict line. Exit 0 GREEN / 1 RED. Sovereign: only nx_syscalls + nx_framed_append + nx_research_journal. license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_framed_append.nx nx_research_journal.nx nx_research_journal_gate.nx

imports: nx_syscalls.nxnx_framed_append.nxnx_research_journal.nx

imported by: nobody (leaf or entry point)

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

main sys_openat_append gp sys_write gn sys_mmap sys_write ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real g_uniq sys_now_us sys_mmap ↻ sys_clock_gettime_mono sys_mmap ↻ sys_close sys_mmap ↻ g_pidp sys_mmap ↻ sys_openat_wr sys_close ↻ do_phase rj_phase_begin rj_log sys_mmap ↻ fa_cat fa_catn sys_mmap ↻ sys_now_realtime_sec ↻ fa_append sys_mmap ↻ sys_openat_append ↻ sys_flock fa_write_all sys_write ↻ sys_close ↻ rj_source_done rj_log ↻ rj_phase_done rj_log ↻

structs

none

consts

41const NSRC: i64 = 3 // sources per FETCH/EXTRACT/VERIFY phase
42const SID: i64 = 7 // the research session id under test
43const FULL_RUN: i64 = 4 // FETCH+EXTRACT+VERIFY+SYNTH = 4 phase executions

functions

48func gp(logfd: i64, s: *u8) -> i64
called by 1: main calls 1: sys_write
55func gn(logfd: i64, v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
72func g_pidp(base: *u8, suffix: *u8, pid: i64, out: *u8) -> i64
called by 1: main calls 1: sys_mmap
92func g_uniq() -> i64
called by 1: main calls 3: sys_now_ussys_mmapsys_close
117func do_phase(path: *u8, phase: i64) -> i64
129func do_synth(path: *u8) -> i64
called by 1: main calls 2: rj_phase_beginrj_phase_done
135func main() -> i64