code wiki / _hdl_build / nx_lineage_complete.nx

nx_lineage_complete.nx

buildroot/runtime/_hdl_build/nx_lineage_complete.nx

12160 B251 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic lineage
docsdependenciesstructsconstsfunctions

about

nx_lineage_complete.nx -- the GENEALOGIST's RECORD-HINTS + RE-PARENT organ (genealogist spec item 6: "proactively suggest a node's missing parent link"; the root-trace SIL's PROPOSER leg). nx_root_trace measures which organs FAIL to trace to the spore. This organ CLOSES those gaps the only sovereign-honest way: every .sov.elf is begotten by the build engine nx_sov_build_run (BOOTSTRAP_MAP rung7), so that build-parent edge is the universal true ancestry. It: 1. loads the children + parent-references already in lineage.tsv, 2. finds MISSING-PARENT organs (referenced as a parent, organ-like, no '.', not yet a child) and LOCATES each on disk (runtime/_hdl_build, runtime, runtime/bin) -- a parent that is NOT a real file is NOT authored (never invent a node; report it NOTFOUND), 3. finds FLOATING-ROOTS (parents "-" but not the spore) and RE-PARENTS them to nx_sov_build_run, 4. writes lineage.tsv.bak, then atomically rewrites lineage.tsv: existing rows verbatim (floaters re-parented) + one record-hint row per located missing-parent. Each authored row asserts ONLY the true build-parent edge and marks rich genetics "pending" -- a record-hint, never a fabricated lineage. The independent PROOF is nx_root_trace (a wrong edge can't make it trace). Idempotent (rerun: no floaters, no missing-parents -> byte-identical). Additive in spirit + reversible (.bak), per the nx_epic_rollup mutate precedent. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_lineage_complete.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap sys_openat_rd lc_w sys_write sys_exit sys_read sys_close lc_field0 lc_tabs lc_is_organ lc_has_dot lc_in_set lc_streq lc_locate lc_try sys_mmap ↻ lc_cat sys_openat_rd ↻ sys_close ↻ sys_openat_wr sys_write ↻ lc_wrange sys_write ↻ lc_streq ↻ lc_emit_hint lc_w ↻ sys_renameat sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real lc_report lc_w ↻ lc_wn sys_mmap ↻ sys_write ↻ sys_openat_append

structs

none

consts

19const LC_MAGIC_1048576: i64 = 1048576
20const LC_MAGIC_1048575: i64 = 1048575
22const LC_LIN: *u8 = "knowledge/registry/lineage.tsv"
23const LC_BAK: *u8 = "knowledge/registry/lineage.tsv.bak"
24const LC_TMP: *u8 = "knowledge/registry/.nx_lineage_complete.tmp" // SIBLING of lineage.tsv: renameat must stay on one filesystem (cross-device /tmp->/mnt/c = EXDEV)
25const LC_LOG: *u8 = "knowledge/status/lineage_complete.log"
26const LC_SPORE: *u8 = "rv64im_min_sim"
27const LC_WOMB: *u8 = "nx_sov_build_run"
28const LC_IDCAP: i64 = 48
29const LC_MAXC: i64 = 900

functions

31func lc_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 3: lc_emit_hintlc_reportmain calls 1: sys_write
32func lc_wn(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48 as u8;k=1}; while m>0 {t[k]=(48+(m%10)) as u8; m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(fd, bb, k); return 0 }
called by 1: lc_report calls 2: sys_mmapsys_write
33func lc_wrange(fd: i64, buf: *u8, a: i64, b: i64) -> i64 { sys_write(fd, (buf as i64 + a) as *u8, b - a); return 0 }
called by 1: main calls 1: sys_write
35func lc_streq(a: *u8, b: *u8) -> i64
called by 2: lc_in_setmain
40func lc_in_set(arena: i64, cnt: i64, idcap: i64, name: *u8) -> i64
called by 1: main calls 1: lc_streq
45func lc_has_dot(s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { if s[i] == (46 as u8) { return 1 } i = i + 1 } return 0 }
called by 1: lc_is_organ
48func lc_is_organ(t: *u8) -> i64
called by 1: main calls 1: lc_has_dot
56func lc_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i }
called by 1: lc_try
57func lc_try(dir: *u8, name: *u8) -> i64
67func lc_locate(name: *u8) -> i64
called by 1: main calls 1: lc_try
74func lc_field0(buf: *u8, ls: i64, le: i64, out: *u8, cap: i64) -> i64
called by 1: main
84func lc_tabs(buf: *u8, ls: i64, le: i64, out: *i64) -> i64
called by 1: main
97func lc_emit_hint(fd: i64, name: *u8) -> i64
called by 1: main calls 1: lc_w
109func lc_report(fd: i64, children: i64, missing: i64, located: i64, notfound: i64, reparented: i64, epoch: i64, ok: i64) -> i64
called by 1: main calls 2: lc_wlc_wn
120func main() -> i64