code wiki / _hdl_build / nx_ims_typemap_seed.nx

nx_ims_typemap_seed.nx source

↩ module page · 39 lines · 2417 B

1// nx_ims_typemap_seed.nx -- seed the Diataxis typemap into the NATIVE seg_store (no TSV). 2// 3// Migration step (operator: "stop using tsv, nishi ecosystem only"): writes the 4 Diataxis layout 4// rows that nx_ims_page reads, into the content-addressed store knowledge/store/ims-typemap- via 5// nx_native_config (tag "tm"), so ip_typemap_load reads the native store instead of ims_typemap.tsv. 6// Authored-by-organ; re-run after editing the rows. No hardware writes (#26). license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_native_config.nx" 9 10func tm_prefix() -> *u8 { return "knowledge/store/ims-typemap-\x00" as *u8 } 11func tm_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 12 13// one typemap row: doc_type / label / show_toc / show_infobox / show_steps (flags as "0"/"1"). 14func tm_row(w: *i64, idx: i64, dt: *u8, label: *u8, toc: *u8, ib: *u8, steps: *u8) -> i64 { 15 let keys: *i64 = sys_mmap(8 * 8) as *i64 16 let vals: *i64 = sys_mmap(8 * 8) as *i64 17 keys[0] = ("doc_type\x00") as i64; vals[0] = (dt as i64) 18 keys[1] = ("label\x00") as i64; vals[1] = (label as i64) 19 keys[2] = ("show_toc\x00") as i64; vals[2] = (toc as i64) 20 keys[3] = ("show_infobox\x00") as i64; vals[3] = (ib as i64) 21 keys[4] = ("show_steps\x00") as i64; vals[4] = (steps as i64) 22 return ncfg_add_row(w, "tm\x00" as *u8, idx, keys, vals, 5) 23} 24 25func main() -> i64 { 26 tm_w("=== IMS TYPEMAP SEED: Diataxis layout -> native seg_store (no TSV) ===\n\x00" as *u8) 27 tm_w(" store=\x00" as *u8); tm_w(tm_prefix()); tm_w("\n\x00" as *u8) 28 let w: *i64 = ncfg_begin() 29 tm_row(w, 0, "reference\x00" as *u8, "Reference\x00" as *u8, "1\x00" as *u8, "1\x00" as *u8, "0\x00" as *u8) 30 tm_row(w, 1, "explanation\x00" as *u8, "Explanation\x00" as *u8, "1\x00" as *u8, "1\x00" as *u8, "0\x00" as *u8) 31 tm_row(w, 2, "tutorial\x00" as *u8, "Tutorial\x00" as *u8, "1\x00" as *u8, "1\x00" as *u8, "1\x00" as *u8) 32 tm_row(w, 3, "howto\x00" as *u8, "How-to guide\x00" as *u8, "1\x00" as *u8, "1\x00" as *u8, "1\x00" as *u8) 33 ncfg_set_count(w, "tm\x00" as *u8, 4) 34 let rc: i64 = ncfg_commit(tm_prefix(), w) 35 if rc != 0 { tm_w(" SEED FAILED\n\x00" as *u8); sys_exit(1); return 1 } 36 tm_w(" seeded 4 Diataxis rows under tag 'tm'. typemap now lives in the native store.\n\x00" as *u8) 37 sys_exit(0) 38 return 0 39}