code wiki / _hdl_build / nx_raci_bind.nx
nx_raci_bind.nx source
↩ module page · 85 lines · 5570 B
1// nx_raci_bind.nx -- bind the conductor + race team into the RACI SOVEREIGNLY (no TSV). The contract
2// nx_raci reads is still nishi_raci.tsv (legacy); rather than perpetuate it, this writes a sovereign
3// RACI EXTENSION as rows in the roles- seg-store channel "raciext" (role<TAB>activity<TAB>letters),
4// formalizing the two roles' REAL duties: conductor is Accountable for `orchestrate` (it keeps the
5// beat / liveness), race is Accountable for `benchmark` (competitive measurement). Then it CUES each
6// (PENDING activation in its channel) so the section is playing. IDEMPOTENT: adds a role only if the
7// extension does not already list it; cues only an empty channel. nx_team_harmony reads this
8// extension for BOUND/OWNS, so the two sections can reach harmony without a single TSV write.
9// Sovereign. license_tier: ORIGINAL
10import "nx_role_store.nx"
11import "nx_syscalls.nx"
12
13const RB_EXT: *u8 = "raciext"
14
15func rb_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
16// field 0 == role AND field 1 == activity in the TAB-separated rec (role<TAB>activity<TAB>letters)?
17// (2026-07-04: role+activity granularity so a role can be Accountable for MULTIPLE activities/APIs -- the
18// prior role-only match skipped a role's 2nd binding, capping each role at one API. full API coverage needs this.)
19func rb_streq_ra(rec: *u8, rlen: i64, role: *u8, activity: *u8) -> i64 {
20 var i: i64 = 0
21 var r: i64 = 0
22 while role[r] != (0 as u8) { if i >= rlen { return 0 } if rec[i] != role[r] { return 0 } i = i + 1; r = r + 1 }
23 if i >= rlen { return 0 }
24 if rec[i] != (9 as u8) { return 0 } // field 0 (role) must end at a TAB
25 i = i + 1
26 var a: i64 = 0
27 while activity[a] != (0 as u8) { if i >= rlen { return 0 } if rec[i] != activity[a] { return 0 } i = i + 1; a = a + 1 }
28 if i < rlen { if rec[i] != (9 as u8) { return 0 } } // field 1 (activity) must end at a TAB or end of rec
29 return 1
30}
31// is `role`+`activity` already bound in the raciext extension?
32func rb_in_ext(role: *u8, activity: *u8) -> i64 {
33 let n: i64 = rs_count(RB_EXT)
34 let pq: *i64 = sys_mmap(16) as *i64; let lq: *i64 = sys_mmap(16) as *i64
35 var i: i64 = 0
36 while i < n {
37 if rs_get_seq(RB_EXT, i, pq, lq) == 1 { if rb_streq_ra(pq[0] as *u8, lq[0], role, activity) == 1 { return 1 } }
38 i = i + 1
39 }
40 return 0
41}
42func rb_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var i: i64 = 0; while s[i] != (0 as u8) { dst[o] = s[i]; o = o + 1; i = i + 1 } return o }
43
44// add role<TAB>activity<TAB>AR to the extension if absent.
45func rb_bind(role: *u8, activity: *u8) -> i64 {
46 if rb_in_ext(role, activity) == 1 { rb_w(" already bound: " as *u8); rb_w(role); rb_w(" / " as *u8); rb_w(activity); rb_w("\n" as *u8); return 0 }
47 let row: *u8 = sys_mmap(128); var o: i64 = rb_cat(row, 0, role)
48 row[o] = 9 as u8; o = o + 1; o = rb_cat(row, o, activity)
49 row[o] = 9 as u8; o = o + 1; o = rb_cat(row, o, "AR" as *u8); row[o] = 0 as u8
50 rs_append(RB_EXT, row, o)
51 rb_w(" bound -> " as *u8); rb_w(role); rb_w(" Accountable for " as *u8); rb_w(activity); rb_w(" (sovereign, no TSV)\n" as *u8)
52 return 1
53}
54// cue a role's channel (PENDING activation) if empty -> playing.
55func rb_cue(role: *u8, channel: *u8, activity: *u8) -> i64 {
56 if rs_count(channel) > 0 { return 0 }
57 let row: *u8 = sys_mmap(128); var o: i64 = rb_cat(row, 0, role)
58 o = rb_cat(row, o, "\tPENDING\tactivate:" as *u8); o = rb_cat(row, o, activity)
59 o = rb_cat(row, o, "\tby=pm-coordinate" as *u8); row[o] = 0 as u8
60 rs_append(channel, row, o)
61 rb_w(" cue -> " as *u8); rb_w(channel); rb_w(" now live\n" as *u8)
62 return 1
63}
64
65func main(argc: i64, argv: *i64) -> i64 {
66 rb_w("=== RACI BIND: conductor + race + API-surfaces into the score, sovereignly (seg-store, NO TSV) ===\n" as *u8)
67 rb_bind("conductor" as *u8, "orchestrate" as *u8)
68 rb_bind("racing" as *u8, "benchmark" as *u8)
69
70 // API-OWNERSHIP RACI (2026-07-04, operator: "who owns what APIs + why, by logical persons/teams -> FULL
71 // API coverage"). Bind each sovereign API SURFACE as an activity to its ACCOUNTABLE role, so nx_team_harmony
72 // reads OWNS for every API + no API is unowned. Reuses rb_bind (no new organ -- fold into the existing RACI).
73 // WHY each: the accountable role is the one whose duty the API expresses.
74 rb_bind("builder" as *u8, "api:tools-mcp" as *u8) // /api/tools + /mcp (nx_tools_api) -- agent-facing tool registry = Builder's execution surface
75 rb_bind("engineer" as *u8, "api:mgmt-controlplane" as *u8) // /api/{deploy,health,restart,reconcile} (nx_mgmt_api) -- control plane = Engineer's structure/ops
76 rb_bind("racing" as *u8, "api:critic-rollup" as *u8) // nx_ecosystem_maturity_rollup via MCP -- the measured-exceed grader = Racing-team's evidence duty
77 rb_bind("warden" as *u8, "api:cap-auth" as *u8) // /api/cap/{issue,revoke} + cap-token gate -- authority/safety = Warden's cardinal duty
78 rb_bind("engineer" as *u8, "api:edge-hardening" as *u8) // nx_api_edge (CORS/security-headers/rate-limit) -- boundary structure = Engineer
79 rb_bind("doctor" as *u8, "api:health-liveness" as *u8) // /api/health + funcheck flow-mode monitoring -- health/lifecycle = Doctor
80
81 rb_cue("conductor" as *u8, "conductorq" as *u8, "orchestrate" as *u8)
82 rb_cue("racing" as *u8, "racingq" as *u8, "benchmark" as *u8)
83 rb_w("RACI-BIND done (2 sections + 6 API surfaces bound to accountable roles).\n" as *u8)
84 sys_exit(0); return 0
85}