code wiki / _hdl_build / nx_hub_roles_seed.nx

nx_hub_roles_seed.nx source

↩ module page · 27 lines · 1638 B

1// nx_hub_roles_seed.nx -- seed the HUB ROLES registry (handle -> access level) into the SOVEREIGN 2// content-addressed store via nx_native_config (ncfg_*), NOT roles.tsv (operator: no tsv; use the nishi 3// ecosystem data management). Row = {handle, level}; nx_hub_gw resolves a session's level from here 4// (hgw_level_native) for the leveled hub index -- replacing the roles.tsv read. level vocab matches 5// nx_maturity_registry mr_level_of: 0=public/anon 1=viewer/family 2=member 3=operator/owner. 6// Additive: add family/member handles with more rows the same way (content-addressed, history-preserving). 7import "nx_syscalls.nx" 8import "nx_native_config.nx" 9 10func hrs_row(w: *i64, idx: i64, handle: *u8, level: *u8) -> i64 { 11 let keys: *i64 = sys_mmap(8 * 4) as *i64 12 let vals: *i64 = sys_mmap(8 * 4) as *i64 13 keys[0] = ("handle\x00") as i64; vals[0] = (handle as i64) 14 keys[1] = ("level\x00") as i64; vals[1] = (level as i64) 15 return ncfg_add_row(w, "role\x00" as *u8, idx, keys, vals, 2) 16} 17func hrs_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 18 19func main() -> i64 { 20 let w: *i64 = ncfg_begin() 21 hrs_row(w, 0, "elderwesto\x00" as *u8, "3\x00" as *u8) // operator/owner (add family handles as more rows) 22 ncfg_set_count(w, "role\x00" as *u8, 1) 23 let rc: i64 = ncfg_commit("knowledge/store/hub-roles-\x00" as *u8, w) 24 if rc == 0 { hrs_w("nx_hub_roles_seed: roles committed to native store knowledge/store/hub-roles- (nx_native_config, no tsv)\n\x00" as *u8) } 25 else { hrs_w("nx_hub_roles_seed: commit FAILED\n\x00" as *u8) } 26 return rc 27}