nx_research_journal_gate.nx
buildroot/runtime/nx_research_journal_gate.nx
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
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
structs
| none |
consts
| 41 | const NSRC: i64 = 3 // sources per FETCH/EXTRACT/VERIFY phase |
| 42 | const SID: i64 = 7 // the research session id under test |
| 43 | const FULL_RUN: i64 = 4 // FETCH+EXTRACT+VERIFY+SYNTH = 4 phase executions |
functions
| 48 | func gp(logfd: i64, s: *u8) -> i64 |
| 55 | func gn(logfd: i64, v: i64) -> i64 |
| 72 | func g_pidp(base: *u8, suffix: *u8, pid: i64, out: *u8) -> i64 |
| 92 | func g_uniq() -> i64 |
| 117 | func do_phase(path: *u8, phase: i64) -> i64 |
| 129 | func do_synth(path: *u8) -> i64 |
| 135 | func main() -> i64 |