code wiki / _hdl_build / nx_doctor_serve.nx

nx_doctor_serve.nx

buildroot/runtime/_hdl_build/nx_doctor_serve.nx

4210 B59 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind servicetopic doctor
docsdependenciesstructsconstsfunctions

about

nx_doctor_serve.nx -- SERVE-WRAPPER making the DOCTOR role's capability MCP-callable (operator 2026-07-10: "each role owns its raci capabilities and gets them to be mcp apis"). 6th wrapper. nx_doctor_apply's main() needs argv files (usage exit 2 on no-arg dispatch), but its CORE doc_apply_mem(target, old, oldlen, new, newlen) is importable -- the graceful conflict-safe atomic apply (lock + exact-once match + tmp+rename). Self-test on /tmp (idempotent: equal-length rewrite each run): (1) HEAL -- apply BROKEN->HEALED, then BYTE-VERIFY the file really says HEALED (never claimed, read back); (2) CONFLICT -- a non-matching oldstr is REFUSED (DA_CONFLICT) and the file is UNTOUCHED (never clobber); (3) AMBIG -- an oldstr matching twice is REFUSED (DA_AMBIG, will not guess). Clean exit 0 + JSON so nishi_crew dispatches `doctor fix`. Import ONLY nx_doctor_apply.nx (brings nx_syscalls + nx_arbiter; the flock dir /home/elderwesto/.nishi/locks already exists on the NAS from the arbiter rung). license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_doctor_apply.nx nx_doctor_serve.nx

imports: nx_doctor_apply.nx

imported by: nobody (leaf or entry point)

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

main dsv_put sys_openat_wr dsv_slen doc_apply_mem fl_acquire fl_try fl_mkdir sys_mmap fl_path sys_openat_wr ↻ sys_flock sys_close fl_nap sys_mmap ↻ sys_mmap ↻ da_read sys_openat_rd sys_read sys_close ↻ fl_release sys_flock ↻ sys_close ↻ da_count da_match_at da_find da_match_at ↻ sys_openat_wr ↻ sys_write sys_close ↻ sys_renameat da_read ↻ dsv_contains dsv_slen ↻ dsv_w2 dsv_bit

structs

none

consts

11const K_MAGIC_4096: i64 = 4096

functions

13func dsv_w2(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){ if s[n]==(39 as u8) { let q: *u8=sys_mmap(1); q[0]=34 as u8; sys_write(1,q,1) } else { sys_write(1,(s as i64+n) as *u8,1) } n=n+1 } return 0 }
called by 1: main
14func dsv_bit(b: i64) -> i64 { let d: *u8=sys_mmap(1); d[0]=(48+b) as u8; sys_write(1,d,1); return 0 }
called by 1: main
15func dsv_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: dsv_putdsv_contains
16func dsv_put(path: *u8, s: *u8) -> i64
called by 1: main calls 2: sys_openat_wrdsv_slen
20func dsv_contains(hay: *u8, hn: i64, needle: *u8) -> i64
called by 1: main calls 1: dsv_slen
28func main() -> i64