code wiki / _hdl_build / nx_hub_cards_seed.nx
nx_hub_cards_seed.nx source
↩ module page · 49 lines · 3436 B
1// nx_hub_cards_seed.nx -- seed the HUB CARD registry into the SOVEREIGN content-addressed store via
2// nx_native_config (ncfg_*), NOT a .tsv/.cards flat file (operator: "we aren't supposed to use tsv; use
3// the nishi ecosystem data management"). Mirrors nx_asset_visibility's vis_seed. Each card = a row
4// {href, title, access}; nx_hub_render reads these (ncfg_open/row/field) and emits level-gated (no-leak).
5// access vocab matches nx_maturity_registry mr_level_of: public(0)/viewer(1)/member(2)/operator(3).
6// Run once (or on card change) to (re)author the registry; content-addressed + additive by construction.
7import "nx_syscalls.nx"
8import "nx_native_config.nx"
9
10func hcs_prefix() -> *u8 { return "knowledge/store/hub-cards-\x00" as *u8 }
11func hcs_tag() -> *u8 { return "card\x00" as *u8 }
12
13func hcs_row(w: *i64, idx: i64, href: *u8, title: *u8, access: *u8) -> i64 {
14 let keys: *i64 = sys_mmap(8 * 4) as *i64
15 let vals: *i64 = sys_mmap(8 * 4) as *i64
16 keys[0] = ("href\x00") as i64; vals[0] = (href as i64)
17 keys[1] = ("title\x00") as i64; vals[1] = (title as i64)
18 keys[2] = ("access\x00") as i64; vals[2] = (access as i64)
19 return ncfg_add_row(w, hcs_tag(), idx, keys, vals, 3)
20}
21
22func hcs_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
23
24func main() -> i64 {
25 let w: *i64 = ncfg_begin()
26 // ONE "Games" card on the hub (operator: "consolidate all games under /games, not lots of cards on the
27 // main hub"). The individual games (voxels/tictactoe/econsim/pets/...) live UNDER /games (the games
28 // portal + the /hub/games-manifest.json registry), NOT as separate hub cards. Cleaner hub, one gateway.
29 hcs_row(w, 0, "/hub/games\x00" as *u8, "Games\x00" as *u8, "public\x00" as *u8)
30 hcs_row(w, 1, "/video\x00" as *u8, "Video\x00" as *u8, "viewer\x00" as *u8)
31 hcs_row(w, 2, "/listen\x00" as *u8, "Listen\x00" as *u8, "viewer\x00" as *u8)
32 hcs_row(w, 3, "/gallery\x00" as *u8, "Gallery\x00" as *u8, "viewer\x00" as *u8)
33 hcs_row(w, 4, "/vn\x00" as *u8, "Visual Novels\x00" as *u8, "viewer\x00" as *u8)
34 hcs_row(w, 5, "/cad\x00" as *u8, "CAD\x00" as *u8, "viewer\x00" as *u8)
35 hcs_row(w, 6, "/archive\x00" as *u8, "Archive\x00" as *u8, "viewer\x00" as *u8)
36 hcs_row(w, 7, "/account\x00" as *u8, "Account\x00" as *u8, "viewer\x00" as *u8)
37 hcs_row(w, 8, "/wiki\x00" as *u8, "Wiki\x00" as *u8, "member\x00" as *u8)
38 hcs_row(w, 9, "/library\x00" as *u8, "Library\x00" as *u8, "member\x00" as *u8)
39 hcs_row(w, 10, "/studio\x00" as *u8, "Studio\x00" as *u8, "member\x00" as *u8)
40 hcs_row(w, 11, "/docs\x00" as *u8, "Docs\x00" as *u8, "member\x00" as *u8)
41 hcs_row(w, 12, "/torrent\x00" as *u8, "Torrent\x00" as *u8, "operator\x00" as *u8)
42 hcs_row(w, 13, "/gen\x00" as *u8, "Gen\x00" as *u8, "operator\x00" as *u8)
43 hcs_row(w, 14, "/admin\x00" as *u8, "Admin\x00" as *u8, "operator\x00" as *u8)
44 ncfg_set_count(w, hcs_tag(), 15)
45 let rc: i64 = ncfg_commit(hcs_prefix(), w)
46 if rc == 0 { hcs_w("nx_hub_cards_seed: 15 cards committed (1 Games card; games consolidated under /games) to native store hub-cards- (no tsv)\n\x00" as *u8) }
47 else { hcs_w("nx_hub_cards_seed: commit FAILED\n\x00" as *u8) }
48 return rc
49}