code wiki / _hdl_build / nx_ownership_map.nx
nx_ownership_map.nx source
↩ module page · 114 lines · 5803 B
1// nx_ownership_map.nx -- the LIBRARIAN auto-maps every capability to its owning role by name pattern, and
2// FLAGS orphans (caps no role claims) -- workstream-2 of the parallel run, fully team-doable (no authoring,
3// so the team does it autonomously, not Claude). Keyword->role in priority order; an unmatched cap is an
4// ORPHAN the Librarian surfaces for assignment. license_tier: ORIGINAL Composes nx_team_roster.
5
6import "nx_syscalls.nx"
7
8const OM_CONDUCTOR: i64 = 1
9const OM_ENGINEER: i64 = 2
10const OM_BUILDER: i64 = 3
11const OM_DOCTOR: i64 = 4
12const OM_RESEARCHER:i64 = 5
13const OM_LIBRARIAN: i64 = 6
14const OM_REFEREE: i64 = 7
15const OM_PM: i64 = 8
16const OM_COUNCIL: i64 = 9
17const OM_HUB: i64 = 10
18const OM_ORPHAN: i64 = 0
19
20// substring search.
21func om_has(hay: *u8, ndl: *u8) -> i64 {
22 var hn: i64 = 0; while hay[hn] != (0 as u8) { hn = hn + 1 }
23 var nn: i64 = 0; while ndl[nn] != (0 as u8) { nn = nn + 1 }
24 if nn == 0 { return 1 }
25 var i: i64 = 0
26 while i <= hn - nn {
27 var j: i64 = 0; var ok: i64 = 1
28 while j < nn { if hay[i+j] != ndl[j] { ok = 0; j = nn } j = j + 1 }
29 if ok == 1 { return 1 }
30 i = i + 1
31 }
32 return 0
33}
34
35// assign a role by keyword (priority order: specific role markers first).
36func om_role(name: *u8) -> i64 {
37 if om_has(name, "hub_spoke" as *u8) == 1 { return OM_HUB }
38 if om_has(name, "lineage" as *u8) == 1 { return OM_HUB }
39 if om_has(name, "ingest_governed" as *u8) == 1 { return OM_COUNCIL }
40 if om_has(name, "council" as *u8) == 1 { return OM_COUNCIL }
41 if om_has(name, "doctor" as *u8) == 1 { return OM_DOCTOR }
42 if om_has(name, "heal" as *u8) == 1 { return OM_DOCTOR }
43 if om_has(name, "research" as *u8) == 1 { return OM_RESEARCHER }
44 if om_has(name, "browse" as *u8) == 1 { return OM_RESEARCHER }
45 if om_has(name, "library" as *u8) == 1 { return OM_RESEARCHER }
46 if om_has(name, "corroborate" as *u8) == 1 { return OM_RESEARCHER }
47 if om_has(name, "librarian" as *u8) == 1 { return OM_LIBRARIAN }
48 if om_has(name, "self_model" as *u8) == 1 { return OM_LIBRARIAN }
49 if om_has(name, "cap_register" as *u8) == 1 { return OM_LIBRARIAN }
50 if om_has(name, "roster" as *u8) == 1 { return OM_LIBRARIAN }
51 if om_has(name, "ownership" as *u8) == 1 { return OM_LIBRARIAN }
52 if om_has(name, "doc_" as *u8) == 1 { return OM_LIBRARIAN }
53 if om_has(name, "referee" as *u8) == 1 { return OM_REFEREE }
54 if om_has(name, "auditor" as *u8) == 1 { return OM_REFEREE }
55 if om_has(name, "maturity" as *u8) == 1 { return OM_REFEREE }
56 if om_has(name, "ecosystem_compare" as *u8) == 1 { return OM_REFEREE }
57 if om_has(name, "landscape" as *u8) == 1 { return OM_REFEREE }
58 if om_has(name, "cost_oracle" as *u8) == 1 { return OM_REFEREE }
59 if om_has(name, "dep_retire" as *u8) == 1 { return OM_REFEREE }
60 if om_has(name, "critic" as *u8) == 1 { return OM_REFEREE }
61 if om_has(name, "pm_" as *u8) == 1 { return OM_PM }
62 if om_has(name, "maint" as *u8) == 1 { return OM_PM }
63 if om_has(name, "winwinwin" as *u8) == 1 { return OM_PM }
64 if om_has(name, "loop_monitor" as *u8) == 1 { return OM_PM }
65 if om_has(name, "opportunity" as *u8) == 1 { return OM_PM }
66 if om_has(name, "builder" as *u8) == 1 { return OM_BUILDER }
67 if om_has(name, "compose" as *u8) == 1 { return OM_BUILDER }
68 if om_has(name, "eqsat" as *u8) == 1 { return OM_BUILDER }
69 if om_has(name, "spec_ingest" as *u8) == 1 { return OM_BUILDER }
70 if om_has(name, "semantic" as *u8) == 1 { return OM_BUILDER }
71 if om_has(name, "governor" as *u8) == 1 { return OM_CONDUCTOR }
72 if om_has(name, "sysload" as *u8) == 1 { return OM_CONDUCTOR }
73 if om_has(name, "dispatcher" as *u8) == 1 { return OM_CONDUCTOR }
74 if om_has(name, "console" as *u8) == 1 { return OM_CONDUCTOR }
75 if om_has(name, "workstream" as *u8) == 1 { return OM_CONDUCTOR }
76 if om_has(name, "merge_queue" as *u8) == 1 { return OM_CONDUCTOR }
77 if om_has(name, "raci" as *u8) == 1 { return OM_CONDUCTOR }
78 if om_has(name, "warden" as *u8) == 1 { return OM_CONDUCTOR }
79 if om_has(name, "conductor" as *u8) == 1 { return OM_CONDUCTOR }
80 if om_has(name, "run_timeout" as *u8) == 1 { return OM_CONDUCTOR }
81 if om_has(name, "asm" as *u8) == 1 { return OM_ENGINEER }
82 if om_has(name, "toolchain" as *u8) == 1 { return OM_ENGINEER }
83 if om_has(name, "superopt" as *u8) == 1 { return OM_ENGINEER }
84 if om_has(name, "byte" as *u8) == 1 { return OM_ENGINEER }
85 if om_has(name, "engineer" as *u8) == 1 { return OM_ENGINEER }
86 if om_has(name, "build_orch" as *u8) == 1 { return OM_ENGINEER }
87 if om_has(name, "retire_gcc" as *u8) == 1 { return OM_ENGINEER }
88 if om_has(name, "power_iter" as *u8) == 1 { return OM_ENGINEER }
89 if om_has(name, "bm25" as *u8) == 1 { return OM_ENGINEER }
90 if om_has(name, "ppmi" as *u8) == 1 { return OM_ENGINEER }
91 if om_has(name, "simd" as *u8) == 1 { return OM_ENGINEER }
92 return OM_ORPHAN
93}
94
95func om_role_name(r: i64) -> *u8 {
96 if r == OM_CONDUCTOR { return "CONDUCTOR" as *u8 }
97 if r == OM_ENGINEER { return "ENGINEER" as *u8 }
98 if r == OM_BUILDER { return "BUILDER" as *u8 }
99 if r == OM_DOCTOR { return "DOCTOR" as *u8 }
100 if r == OM_RESEARCHER { return "RESEARCHER" as *u8 }
101 if r == OM_LIBRARIAN { return "LIBRARIAN" as *u8 }
102 if r == OM_REFEREE { return "REFEREE" as *u8 }
103 if r == OM_PM { return "PM" as *u8 }
104 if r == OM_COUNCIL { return "COUNCIL" as *u8 }
105 if r == OM_HUB { return "HUB" as *u8 }
106 return "ORPHAN(unassigned)" as *u8
107}
108
109// count orphans over a list of cap names.
110func om_count_orphans(names: *i64, n: i64) -> i64 {
111 var c: i64 = 0; var i: i64 = 0
112 while i < n { if om_role((names[i]) as *u8) == OM_ORPHAN { c = c + 1 } i = i + 1 }
113 return c
114}