code wiki / (root) / nx_replyreserve.nx

nx_replyreserve.nx

buildroot/runtime/nx_replyreserve.nx

13638 B257 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_replyreserve.nx -- CLI for the reply-reserve calibrator (lane E, 2026-08-25). Thin main; the ruler is nx_replyreserve_lib.rr_derive and the quantile machinery is nx_loadceil_lib, so nx_replyreserve_gate composes both in-process on planted buffers. nx_replyreserve [report|apply|beat] [logpath] beat (DEFAULT) Derive and print, then apply ONLY if replyreserve-auto-apply is 1 in the conf. report READ-ONLY. Derive and print; never touches the conf. apply Explicit operator action: rewrite knowledge/edge_window.conf when a ratchet is due. WHY THE DEFAULT IS THE WRITING VERB, deliberately and against least-surprise: the clocksched plane's organ column is a BARE PATH -- every live row is `<name> <interval> <elf>` with no argv -- so the clock forks this organ with no arguments. If the bare invocation were the read-only one, the beat would be structurally inert and this organ could never arm itself no matter how long it ran, which is the whole point of building it. Safety does not come from which verb is default; it comes from the conf switch (replyreserve-auto-apply), the bounded envelope [floor_ms, cap_ms], the refusal that keeps the current value, and the journal line every application writes. `report` is one word away for a read-only look. exit 0 RATCHET(-ready or applied) / 1 HOLD (conf already carries the measured value) / 2 UNREADABLE / 3 INSUFFICIENT-HISTORY (abstain) / 4 REFUSED-OUT-OF-BOUNDS (current value KEPT). HOLD and RATCHET are both successes; they are distinct codes so a beat can tell "changed" from "already right", and INSUFFICIENT is distinct from UNREADABLE so a blind axis never reads as a healthy one. THE LOG IS READ FROM ITS TAIL, NOT ITS HEAD, and that is load-bearing rather than an optimisation: actlog.jrnl is append-only and 30 MB, reply_ms= has only existed since the 2026-08-23 build, so every sample lives in the last few KB. A capped read from offset 0 returns 4 MB of history that predates the field entirely and yields ZERO samples -- an abstention for the wrong reason, from an organ that could then never arm itself no matter how long it ran. Coverage is printed either way. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_replyreserve_lib.nx nx_replyreserve.nx

imports: nx_replyreserve_lib.nx

imported by: nobody (leaf or entry point)

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

main lc_conf_line_num lc_slen lc_first_int rro rrw lc_read_tail sys_openat_rd sys_lseek sys_close sys_read rr_derive lc_recommend_kv 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 ↻ lc_collect_kv lc_line_num lc_slen ↻ lc_line_has lc_slen ↻ lc_sort lc_sift lc_quant rrn rr_catn rr_catc rr_rewrite

structs

none

consts

32const RR_OUTCAP: i64 = 32768

functions

34func rrw(fd: i64, s: *u8) -> i64 { let n: i64 = lc_slen(s); if n > 0 { sys_write(fd, s, n) } return 0 }
called by 1: rro
35func rro(s: *u8) -> i64 { return rrw(1, s) }
called by 1: main calls 1: rrw
36func rrn(v0: i64) -> i64
called by 1: main calls 1: rr_catn
44func rr_word(v: i64) -> *u8
called by 2: rr_status_writemain
54func rr_status_write(out: *i64, verdict: i64, applied: i64, epoch: i64, whole: i64, size: i64) -> i64
called by 1: main calls 4: rr_catrr_catnrr_catcrr_word
86func rr_jrnl_append(oldv: i64, newv: i64, n: i64, epoch: i64) -> i64
called by 1: main calls 3: rr_catrr_catnrr_catc
102func rr_publish(path: *u8, tmp: *u8, b: *u8, n: i64) -> i64
called by 1: main
112func main(argc: i64, argv: *i64) -> i64