code wiki / _hdl_build / nx_hub_legacy_migrate.nx

nx_hub_legacy_migrate.nx source

↩ module page · 48 lines · 3624 B

1// nx_hub_legacy_migrate.nx -- migrate the LAST old-format hub data into the sovereign native store, then 2// RETIRE the superseded flat TSVs (operator: "migrate old things into the new s-class formats and retire"). 3// knowledge/hub/maturity.tsv (7-field artifact registry) -> native hub-maturity- (nx_native_config) 4// knowledge/hub/roles.tsv -> already in native hub-roles- (elderwesto=3); just retire 5// RETIRE = overwrite each TSV with a tombstone marker pointing at the new format (soft, rule #13: not 6// deleted, history preserved; the native store is now the SSOT the gateway reads). license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_native_config.nx" 9 10func lm_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 11 12func lm_art(w: *i64, idx: i64, artifact: *u8, maturity: *u8, access: *u8, path: *u8, title: *u8, load: *u8, cur: *u8) -> i64 { 13 let keys: *i64 = sys_mmap(8*8) as *i64 14 let vals: *i64 = sys_mmap(8*8) as *i64 15 keys[0]=("artifact\x00") as i64; vals[0]=(artifact as i64) 16 keys[1]=("maturity\x00") as i64; vals[1]=(maturity as i64) 17 keys[2]=("access\x00") as i64; vals[2]=(access as i64) 18 keys[3]=("path\x00") as i64; vals[3]=(path as i64) 19 keys[4]=("title\x00") as i64; vals[4]=(title as i64) 20 keys[5]=("load_date\x00") as i64; vals[5]=(load as i64) 21 keys[6]=("is_current\x00") as i64; vals[6]=(cur as i64) 22 return ncfg_add_row(w, "art\x00" as *u8, idx, keys, vals, 7) 23} 24 25func lm_tombstone(path: *u8, marker: *u8) -> i64 { 26 let fd: i64 = sys_openat_wr(path, 420) 27 if fd < 0 { return 0 - 1 } 28 var n: i64=0; while marker[n]!=(0 as u8){n=n+1} 29 sys_write(fd, marker, n); sys_close(fd); return 0 30} 31 32func main() -> i64 { 33 // 1. MIGRATE maturity.tsv -> native hub-maturity- (the WHERE+WHO artifact registry the gateway reads). 34 let w: *i64 = ncfg_begin() 35 lm_art(w, 0, "welcome\x00" as *u8, "hub\x00" as *u8, "viewer\x00" as *u8, "welcome.html\x00" as *u8, "Welcome\x00" as *u8, "1781000000\x00" as *u8, "1\x00" as *u8) 36 lm_art(w, 1, "family\x00" as *u8, "hub\x00" as *u8, "member\x00" as *u8, "family.html\x00" as *u8, "Family Area\x00" as *u8, "1781000000\x00" as *u8, "1\x00" as *u8) 37 lm_art(w, 2, "ops\x00" as *u8, "hub\x00" as *u8, "operator\x00" as *u8, "ops.html\x00" as *u8, "Operations\x00" as *u8, "1781000000\x00" as *u8, "1\x00" as *u8) 38 ncfg_set_count(w, "art\x00" as *u8, 3) 39 let rc: i64 = ncfg_commit("knowledge/store/hub-maturity-\x00" as *u8, w) 40 if rc != 0 { lm_w("nx_hub_legacy_migrate: MIGRATION FAILED\n\x00" as *u8); return 1 } 41 lm_w(" migrated 3 artifacts (welcome/family/ops) -> native hub-maturity- store\n\x00" as *u8) 42 // 2. RETIRE the superseded TSVs (tombstone -> the native store is the SSOT). 43 lm_tombstone("knowledge/hub/roles.tsv\x00" as *u8, "# RETIRED 2026-07-02 -- migrated to the sovereign native store (nx_native_config: knowledge/store/hub-roles-). This flat TSV is superseded; the hub gateway reads the native store. Reseed via nx_hub_roles_seed.\n\x00" as *u8) 44 lm_tombstone("knowledge/hub/maturity.tsv\x00" as *u8, "# RETIRED 2026-07-02 -- migrated to the sovereign native store (nx_native_config: knowledge/store/hub-maturity-). This flat TSV is superseded; the hub gateway reads the native store. Reseed via nx_hub_legacy_migrate.\n\x00" as *u8) 45 lm_w(" retired roles.tsv + maturity.tsv (tombstoned; superseded by native hub-roles-/hub-maturity-)\n\x00" as *u8) 46 lm_w("nx_hub_legacy_migrate: DONE -- hub data 100% on the sovereign native store; old TSVs retired\n\x00" as *u8) 47 return 0 48}