code wiki / _hdl_build / nx_isotope_ingest.nx
nx_isotope_ingest.nx
buildroot/runtime/_hdl_build/nx_isotope_ingest.nx
about
nx_isotope_ingest.nx -- chemistry external-reference loop, ingest stage. Reads the FOUNDATIONED NIST
Atomic Weights data (knowledge/fetched/nist/atomic_weights.raw, CID'd + signed by nx_isotope_foundation)
and MECHANICALLY extracts each isotope's (Atomic Number Z, Mass Number A, Relative Atomic Mass) from the
"key = value" records, converting the mass to Q4 micro-AMU (mass*10000, rounded) to match our periodic
table's iso_mass_q4 scaling. Writes a content-addressed canonical record per isotope into the sovereign
seg_store (prefix knowledge/store/isotope-, key "iso:<Z>:<A>") -- the SSOT, NOT a TSV.
Parse: a record's "Relative Atomic Mass =" line always follows its "Atomic Number =" and "Mass Number ="
lines, so we carry cur_z/cur_a and emit on the mass line. Value like "15.99491461957(72)" -> stop at '(',
Q4 = int*10000 + 4 decimals + round(5th). Baked self-test: iso:1:1 -> 10078 (H-1), iso:6:12 -> 120000
(C-12 exactly). license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_canon_cid.nxnx_seg_store.nxnx_uxf_decode.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
| 16 | const II_MAGIC_10000: i64 = 10000 |
| 17 | const II_MAGIC_262144: i64 = 262144 |
| 19 | const II_RAW: *u8 = "knowledge/fetched/nist/atomic_weights.raw" |
| 20 | const II_STORE: *u8 = "knowledge/store/isotope-" |
functions
| 22 | func iw(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 } |
| 23 | func iwn(fd: i64, v: i64) -> i64 { let b: *u8=sys_mmap(16); var m: i64=v; let t: *u8=sys_mmap(16); 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{b[i]=t[k-1-i];i=i+1}; sys_write(fd,b,k); return 0 } |
| 24 | func ii_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 } called by 1: main |
| 25 | func ii_itoa(v: i64, dst: *u8) -> i64 { var m: i64=v; let t: *u8=sys_mmap(24); 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{dst[i]=t[k-1-i];i=i+1} dst[k]=0 as u8; return k } |
| 27 | func ii_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 38 | func ii_starts(buf: *u8, ls: i64, le: i64, prefix: *u8) -> i64 called by 1: main |
| 49 | func ii_int(buf: *u8, pos: i64, le: i64) -> i64 called by 1: main |
| 57 | func ii_q4(buf: *u8, pos: i64, le: i64) -> i64 called by 1: main |
| 78 | func main() -> i64 |