code wiki / _hdl_build / nx_markets_member.nx

nx_markets_member.nx source

↩ module page · 94 lines · 5891 B

1// nx_markets_member.nx -- wire the MARKETS-INVESTING finance capabilities into the RACI + TEAM, SOVEREIGNLY 2// (operator 2026-06-24: "make sure these things are wired into the raci and team"; "get us off tsv"). Mirrors 3// nx_raci_bind's sovereign pattern: registers each capability as a row in the nx_role_store seg-store channel 4// "finmkt" (NO TSV) -- id<TAB>label<TAB>activity<TAB>role<TAB>ownership -- where `activity` is the team's RACI 5// work-type (research/build/verify/coordinate) and `role` is the role the RACI contract makes ACCOUNTABLE for 6// that activity. GROUNDED, not asserted: it migrates the RACI contract into the sovereign store (raci_migrate) 7// and VERIFIES each named role is really Accountable (raci_is_accountable) before trusting the binding -- a 8// capability bound to a non-accountable role is flagged. IDEMPOTENT (skips an already-registered id). This is 9// how the markets-investing arc stops being an orphan: the team roster + the RACI both know who owns it. 10// Personal finance is already a member via nx_fin_member; this is its markets-investing sibling. license_tier: ORIGINAL 11import "nx_role_store.nx" 12import "nx_raci_sov.nx" 13import "nx_syscalls.nx" 14 15const MM_CH: *u8 = "finmkt" 16 17func m_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 18func m_putn(v: i64) -> i64 { 19 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 20 var m: i64 = v; if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 21 let d: *u8 = sys_mmap(24); var k: i64 = 0 22 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 23 var j: i64 = k - 1 24 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 25 return 0 26} 27func mm_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 } 28func mm_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } 29 30// is `id` already the field-0 of some row in the channel? (idempotent registration) 31func mm_has(id: *u8) -> i64 { 32 let n: i64 = rs_count(MM_CH) 33 let pq: *i64 = sys_mmap(16) as *i64; let lq: *i64 = sys_mmap(16) as *i64 34 let f0: *u8 = sys_mmap(256) 35 var i: i64 = 0 36 while i < n { 37 if rs_get_seq(MM_CH, i, pq, lq) == 1 { 38 rs_field(pq[0] as *u8, lq[0], 0, f0) 39 if mm_streq(f0, id) == 1 { return 1 } 40 } 41 i = i + 1 42 } 43 return 0 44} 45 46// register a capability bound to (activity, role). Verifies role is RACI-Accountable. Returns 1 if the binding 47// is RACI-grounded (or already present), 0 if the role is NOT accountable (flagged, but still recorded honestly). 48func mm_register(id: *u8, label: *u8, activity: *u8, role: *u8) -> i64 { 49 if mm_has(id) == 1 { m_puts(" already-registered: "); m_puts(id); m_puts("\n"); return 1 } 50 let acct: i64 = raci_is_accountable(role) 51 let row: *u8 = sys_mmap(512) 52 var o: i64 = mm_cat(row, 0, id) 53 row[o] = 9 as u8; o = o + 1; o = mm_cat(row, o, label) 54 row[o] = 9 as u8; o = o + 1; o = mm_cat(row, o, activity) 55 row[o] = 9 as u8; o = o + 1; o = mm_cat(row, o, role) 56 row[o] = 9 as u8; o = o + 1 57 if acct == 1 { o = mm_cat(row, o, "RACI-OWNED" as *u8) } else { o = mm_cat(row, o, "NO-ACCOUNTABLE-ROLE" as *u8) } 58 rs_append(MM_CH, row, o) 59 m_puts(" registered "); m_puts(id); m_puts(" -> "); m_puts(role); m_puts(" / "); m_puts(activity) 60 if acct == 1 { m_puts(" [RACI-accountable]\n") } else { m_puts(" [WARN: role not accountable]\n") } 61 return acct 62} 63 64func main() -> i64 { 65 m_puts("=== NISHI MARKETS-INVESTING -> RACI + TEAM (sovereign roles-store, NO TSV) ===\n") 66 // ensure the sovereign RACI store reflects the coordination contract, so accountability checks are grounded 67 let totp: *i64 = sys_mmap(16) as *i64; let verp: *i64 = sys_mmap(16) as *i64 68 raci_migrate(totp, verp) 69 m_puts("RACI contract -> sovereign store: "); m_putn(verp[0]); m_puts("/"); m_putn(totp[0]); m_puts(" rows verified\n") 70 71 // register the markets-investing arc + its LIVE capabilities, each owned by the RACI-accountable role 72 mm_register("finmkt" as *u8, "Nishi Markets-Investing (team member)" as *u8, "coordinate" as *u8, "pm" as *u8) 73 mm_register("finmkt-research" as *u8, "Markets research: 107 sources (EDGAR/intl/mgmt/valuation)" as *u8, "research" as *u8, "researcher" as *u8) 74 mm_register("finmkt-zscore" as *u8, "Altman Z-score distress predictor (R-MKT1)" as *u8, "build" as *u8, "workstream" as *u8) 75 mm_register("finmkt-zscore-verify" as *u8, "Z-score gate: 12 assertions" as *u8, "verify" as *u8, "engineer" as *u8) 76 mm_register("finmkt-mgmt-grade" as *u8, "Management stewardship grade: handicap the team (R-MKT5)" as *u8, "build" as *u8, "workstream" as *u8) 77 mm_register("finmkt-mgmt-grade-verify" as *u8, "Management-grade gate: 18 assertions" as *u8, "verify" as *u8, "engineer" as *u8) 78 79 let total: i64 = rs_count(MM_CH) 80 m_puts("finmkt roster rows = "); m_putn(total); m_puts("\n") 81 82 // SELF-VERIFY: the 4 members present AND each owning role is genuinely RACI-Accountable (grounding) 83 var ok: i64 = 1 84 if raci_is_accountable("pm" as *u8) != 1 { ok = 0; m_puts(" FAIL pm not accountable\n") } 85 if raci_is_accountable("researcher" as *u8) != 1 { ok = 0; m_puts(" FAIL researcher not accountable\n") } 86 if raci_is_accountable("workstream" as *u8) != 1 { ok = 0; m_puts(" FAIL workstream not accountable\n") } 87 if raci_is_accountable("engineer" as *u8) != 1 { ok = 0; m_puts(" FAIL engineer not accountable\n") } 88 if total >= 6 { if ok == 1 { 89 m_puts("MARKETS-INVESTING: WIRED into RACI + team (sovereign, no TSV) -- 6 members, all RACI-grounded\n") 90 return 0 91 } } 92 m_puts("MARKETS-INVESTING: wiring incomplete\n") 93 return 1 94}