code wiki / _hdl_build / nx_doctor_serve.nx
nx_doctor_serve.nx
buildroot/runtime/_hdl_build/nx_doctor_serve.nx
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
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
structs
| none |
consts
| 11 | const K_MAGIC_4096: i64 = 4096 |
functions
| 13 | func 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 |
| 14 | func 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 |
| 15 | func dsv_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 16 | func dsv_put(path: *u8, s: *u8) -> i64 |
| 20 | func dsv_contains(hay: *u8, hn: i64, needle: *u8) -> i64 |
| 28 | func main() -> i64 |