code wiki / _hdl_build / nx_hub_ws_register.nx

nx_hub_ws_register.nx source

↩ module page · 67 lines · 3897 B

1// nx_hub_ws_register.nx -- COORDINATE with other workstreams: register this session's workstreams into the 2// WMS registry SSOT (knowledge/store/ws-, via nx_workstream_store / nx_seg_store), so the resume manifest + 3// other empires SEE them (closes the lost-things bug). Additive+idempotent (rule #10): reads the live ws:ids 4// index, appends our ids if absent, and commits our ws:<id> records. Mirrors nx_workstream_seed's writer. 5// Our streams touch E-WEB (games), E-DOCTRINE (format migration -- part of the consistency sweep), E-DEPLOY 6// (the reusable store-sync tool). license_tier: ORIGINAL 7import "nx_workstream_store.nx" 8import "nx_seg_store.nx" 9import "nx_syscalls.nx" 10const K_MAGIC_262144: i64 = 262144 11 12func rw_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 13func rw_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 14 15// append "\t<id>" to idsbuf at olenp[0] iff id is not already a TAB-member. keeps the index de-duped. 16func rw_addid(idsbuf: *u8, olenp: *i64, id: *u8) -> i64 { 17 if ws_member(idsbuf, olenp[0], id) == 1 { return 0 } 18 var o: i64 = olenp[0] 19 if o > 0 { idsbuf[o] = 9 as u8; o = o + 1 } 20 var i: i64 = 0 21 while id[i] != (0 as u8) { idsbuf[o] = id[i]; o = o + 1; i = i + 1 } 22 olenp[0] = o 23 return 1 24} 25 26func rw_rec(w: *i64, key: *u8, val: *u8) -> i64 { return ss_add(w, 1, key, val, rw_len(val)) } 27 28func main() -> i64 { 29 let w: *i64 = ss_begin() 30 let pq: *i64 = sys_mmap(16) as *i64 31 let lq: *i64 = sys_mmap(16) as *i64 32 let idsbuf: *u8 = sys_mmap(K_MAGIC_262144) 33 let olenp: *i64 = sys_mmap(8) as *i64 34 olenp[0] = 0 35 // read the LIVE ws:ids index (the full enumeration; ~1265 streams) and copy it in. 36 if ws_get("ws:ids\x00" as *u8, pq, lq) == 1 { 37 let src: *u8 = pq[0] as *u8 38 let n: i64 = lq[0] 39 var i: i64 = 0 40 while i < n { idsbuf[i] = src[i]; i = i + 1 } 41 olenp[0] = n 42 } 43 rw_addid(idsbuf, olenp, "HUB-GAMES-UNIFY\x00" as *u8) 44 rw_addid(idsbuf, olenp, "HUB-NATIVE-FORMAT\x00" as *u8) 45 rw_addid(idsbuf, olenp, "GAMES-UPDATE-API\x00" as *u8) 46 rw_addid(idsbuf, olenp, "STORE-SYNC\x00" as *u8) 47 ss_add(w, 1, "ws:ids\x00" as *u8, idsbuf, olenp[0]) 48 // the workstream records (id \t empire \t state \t last_touched \t memory \t code \t deps). 49 rw_rec(w, "ws:HUB-GAMES-UNIFY\x00" as *u8, "HUB-GAMES-UNIFY\tE-WEB\tDONE\t0\tnishi-games-infra-map-2026-07-01.md\truntime/nx_games_portal.nx\t-\x00" as *u8) 50 rw_rec(w, "ws:HUB-NATIVE-FORMAT\x00" as *u8, "HUB-NATIVE-FORMAT\tE-DOCTRINE\tDONE\t0\tnishi-games-infra-map-2026-07-01.md\truntime/nx_hub_legacy_migrate.nx\tHUB-GAMES-UNIFY\x00" as *u8) 51 rw_rec(w, "ws:GAMES-UPDATE-API\x00" as *u8, "GAMES-UPDATE-API\tE-WEB\tACTIVE\t0\tnishi-games-infra-map-2026-07-01.md\truntime/nx_games_manifest_native.nx\tHUB-GAMES-UNIFY\x00" as *u8) 52 rw_rec(w, "ws:STORE-SYNC\x00" as *u8, "STORE-SYNC\tE-DEPLOY\tDONE\t0\tnishi-games-infra-map-2026-07-01.md\truntime/nx_store_sync.nx\t-\x00" as *u8) 53 let segid: i64 = ws_seg_next(WS_PREFIX) 54 let rc: i64 = ss_commit(WS_PREFIX, w, segid) 55 if rc != 0 { rw_w("nx_hub_ws_register: COMMIT FAILED\n\x00" as *u8); return 1 } 56 // verify each reads back. 57 var ver: i64 = 0 58 if ws_get("ws:HUB-GAMES-UNIFY\x00" as *u8, pq, lq) == 1 { ver = ver + 1 } 59 if ws_get("ws:HUB-NATIVE-FORMAT\x00" as *u8, pq, lq) == 1 { ver = ver + 1 } 60 if ws_get("ws:GAMES-UPDATE-API\x00" as *u8, pq, lq) == 1 { ver = ver + 1 } 61 if ws_get("ws:STORE-SYNC\x00" as *u8, pq, lq) == 1 { ver = ver + 1 } 62 rw_w("nx_hub_ws_register: registered 4 workstreams in the WMS SSOT (ws-); verified=\x00" as *u8) 63 let bb: *u8 = sys_mmap(8); bb[0] = (48 + ver) as u8; sys_write(1, bb, 1) 64 rw_w("/4; ws:ids index updated -> coordinated with E-WEB/E-DOCTRINE/E-DEPLOY.\n\x00" as *u8) 65 if ver == 4 { return 0 } 66 return 1 67}