nx_research_journal.nx
buildroot/runtime/nx_research_journal.nx
about
nx_research_journal.nx -- RES-R6: a CRASH-RESUMABLE research session journal.
module: nishi-core.research.journal
capability: CORE_COMPUTE (a durable, replay-able research progress log)
WHAT this builds (one capability): a research session records each phase
(FETCH / EXTRACT / VERIFY / SYNTH) and per-source progress as ATOMIC FRAMED
LINES. On restart after a crash, the journal is REPLAYED: the highest phase
that has a DONE record becomes the resume high-water mark, and every phase at
or below it is SKIPPED -- the completed FETCH/EXTRACT work is NOT re-done.
WHY it is correct under crash: every journal line is written by the WMS-R0
primitive fa_append (nx_framed_append.nx) -- the whole record is assembled in
ONE buffer and emitted as EXACTLY ONE sys_write() to an O_APPEND fd, so a
crash can never produce a half-written record that interleaves with another.
A crash CAN leave the very last record absent (it was never reached) or, on
other channels, torn; the replay therefore credits a phase DONE ONLY when it
reads a WELL-FORMED line ("RJ " head + " END" tail + matching sid + ev=DONE).
A torn / truncated last line is ignored -> replay can never SKIP work that did
not actually complete (proven by the gate's torn-line tamper row).
REUSE / lineage (rule 15 DRY, check-registries): this organ adds NO new write
primitive. It COMPOSES fa_append / fa_cat / fa_catn from nx_framed_append.nx
(the WMS-R0 floor) for writing, and the count_torn-style line+token byte-walk
idiom from nx_framed_append_gate.nx for replay parsing. Sovereign: only
nx_syscalls + nx_framed_append.
license_tier: ORIGINAL
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_framed_append.nx
imported by: nx_research_journal_gate.nx
structs
| none |
consts
| 32 | const RJ_REC_CAP: i64 = 256 |
| 36 | const RJ_FETCH: i64 = 1 |
| 37 | const RJ_EXTRACT: i64 = 2 |
| 38 | const RJ_VERIFY: i64 = 3 |
| 39 | const RJ_SYNTH: i64 = 4 |
| 42 | const RJ_BEGIN: i64 = 1 |
| 43 | const RJ_DONE: i64 = 2 |
functions
| 51 | func rj_log(path: *u8, sid: i64, phase: i64, src_idx: i64, event: i64) -> i64 called by 3: rj_phase_beginrj_phase_donerj_source_done calls 5: sys_mmapfa_catfa_catnsys_now_realtime_secfa_append |
| 69 | func rj_phase_begin(path: *u8, sid: i64, phase: i64) -> i64 |
| 72 | func rj_phase_done(path: *u8, sid: i64, phase: i64) -> i64 |
| 75 | func rj_source_done(path: *u8, sid: i64, phase: i64, src: i64) -> i64 |
| 87 | func rj_field(b: *u8, ls: i64, le: i64, tok: *u8, dflt: i64) -> i64 called by 1: rj_replay |
| 126 | func rj_wellformed(b: *u8, ls: i64, le: i64) -> i64 called by 1: rj_replay |
| 153 | func rj_replay(path: *u8, sid: i64, out: *i64) -> i64 |
| 216 | func rj_should_skip(phase: i64, last_done_phase: i64) -> i64 called by 1: main |