code wiki / _hdl_build / nx_lineage_complete.nx
nx_lineage_complete.nx
buildroot/runtime/_hdl_build/nx_lineage_complete.nx
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
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
structs
| none |
consts
| 19 | const LC_MAGIC_1048576: i64 = 1048576 |
| 20 | const LC_MAGIC_1048575: i64 = 1048575 |
| 22 | const LC_LIN: *u8 = "knowledge/registry/lineage.tsv" |
| 23 | const LC_BAK: *u8 = "knowledge/registry/lineage.tsv.bak" |
| 24 | const 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) |
| 25 | const LC_LOG: *u8 = "knowledge/status/lineage_complete.log" |
| 26 | const LC_SPORE: *u8 = "rv64im_min_sim" |
| 27 | const LC_WOMB: *u8 = "nx_sov_build_run" |
| 28 | const LC_IDCAP: i64 = 48 |
| 29 | const LC_MAXC: i64 = 900 |
functions
| 31 | func 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 } |
| 32 | func 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 } |
| 33 | func lc_wrange(fd: i64, buf: *u8, a: i64, b: i64) -> i64 { sys_write(fd, (buf as i64 + a) as *u8, b - a); return 0 } |
| 35 | func lc_streq(a: *u8, b: *u8) -> i64 |
| 40 | func lc_in_set(arena: i64, cnt: i64, idcap: i64, name: *u8) -> i64 |
| 45 | func 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 |
| 48 | func lc_is_organ(t: *u8) -> i64 |
| 56 | func 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 |
| 57 | func lc_try(dir: *u8, name: *u8) -> i64 |
| 67 | func lc_locate(name: *u8) -> i64 |
| 74 | func lc_field0(buf: *u8, ls: i64, le: i64, out: *u8, cap: i64) -> i64 called by 1: main |
| 84 | func lc_tabs(buf: *u8, ls: i64, le: i64, out: *i64) -> i64 called by 1: main |
| 97 | func lc_emit_hint(fd: i64, name: *u8) -> i64 |
| 109 | func lc_report(fd: i64, children: i64, missing: i64, located: i64, notfound: i64, reparented: i64, epoch: i64, ok: i64) -> i64 |
| 120 | func main() -> i64 |