code wiki / (root) / nx_orchestrate_gate.nx

nx_orchestrate_gate.nx source

↩ module page · 86 lines · 6316 B

1// nx_orchestrate_gate.nx -- ORCH-R3 GATE: the orchestrator resolves RACI from the REAL SSOT (nishi_raci.tsv), 2// binds the workstream organ, records the engagement durably, and DENIES unknown activities (never fabricates 3// a role). Proves the "call -> resolve RACI -> engage the accountable team -> run the workstream" spine on the 4// librarian's own activity (organize) + the researcher's (research). Exits 0 iff ALL pass. license_tier: ORIGINAL 5import "nx_gate_verdict.nx" 6import "nx_syscalls.nx" 7import "nx_seg_store.nx" 8import "nx_orchestrate_raci.nx" // seq1789: the RACI CONDUCTOR. Was nx_orchestrate.nx until a 9 // name-matching dedupe pass retired it as a "duplicate" of the unrelated 10 // deploy-queue poller _hdl_build/nx_orchestrate.nx. This gate then could 11 // not compile and kept running a STALE binary that HANGS -- which in turn 12 // hung nx_swcompare_evidence for the whole librarian domain. 13 14func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 15func g_putn(v: i64) -> i64 { if v==0{sys_write(1,"0" as *u8,1);return 0} var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let d: *u8=sys_mmap(24); var k: i64=0; while m>0{d[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let r: *u8=sys_mmap(24); var i: i64=0; while k>0{k=k-1;r[i]=d[k];i=i+1} sys_write(1,r,i); return 0 } 16func chk(name: *u8, got: i64, want: i64, st: *i64) -> i64 { 17 if got==want { st[0]=st[0]+1; g_puts(" PASS " as *u8); g_puts(name); g_puts("\n" as *u8) } 18 else { st[1]=st[1]+1; g_puts(" FAIL " as *u8); g_puts(name); g_puts(" got=" as *u8); g_putn(got); g_puts(" want=" as *u8); g_putn(want); g_puts("\n" as *u8) } 19 return 0 20} 21func has(hay: *u8, needle: *u8) -> i64 { 22 var m: i64=0; while needle[m]!=(0 as u8){m=m+1} 23 var i: i64=0; while hay[i]!=(0 as u8){ var j: i64=0; var ok: i64=1; while j<m { if hay[i+j]!=needle[j]{ok=0;j=m}else{j=j+1} } if ok==1 {return 1} i=i+1 } 24 return 0 25} 26func 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 } 27 28func main() -> i64 { 29 let st: *i64 = sys_mmap(16) as *i64; st[0]=0; st[1]=0 30 31 // ---- RACI resolution from the REAL SSOT ---- 32 let acct: *u8 = sys_mmap(128) 33 chk("organize has an Accountable role (librarian's workstream)" as *u8, orch_accountable("organize\x00" as *u8, acct), 1, st) 34 chk(" organize Accountable == librarian" as *u8, streq(acct, "librarian\x00" as *u8), 1, st) 35 chk("research has an Accountable role" as *u8, orch_accountable("research\x00" as *u8, acct), 1, st) 36 chk(" research Accountable == researcher" as *u8, streq(acct, "researcher\x00" as *u8), 1, st) 37 38 let roles: *u8 = sys_mmap(256) 39 orch_roles("organize\x00" as *u8, 67 as u8, roles) // Consulted 40 chk("organize Consulted includes researcher (teams work together)" as *u8, has(roles, "researcher\x00" as *u8), 1, st) 41 orch_roles("curate\x00" as *u8, 67 as u8, roles) 42 chk("curate Consulted includes librarian" as *u8, has(roles, "librarian\x00" as *u8), 1, st) 43 44 // ---- DENY: unknown activity never fabricates a role ---- 45 chk("NEG unknown activity -> no accountable (deny)" as *u8, orch_accountable("florblegork\x00" as *u8, acct), 0, st) 46 chk("NEG orch_engage(unknown) -> -1 DENY" as *u8, orch_engage("florblegork\x00" as *u8, 0), 0-1, st) 47 48 // ---- workstream organ binding ---- 49 let organ: *u8 = sys_mmap(128) 50 chk("organize binds a runnable organ" as *u8, orch_organ("organize\x00" as *u8, organ), 1, st) 51 chk(" organize organ == nx_librarian_review_gate" as *u8, streq(organ, "nx_librarian_review_gate\x00" as *u8), 1, st) 52 53 // ---- engage (plan, no run) resolves + records durably ---- 54 chk("engage organize (plan) -> 1 engaged" as *u8, orch_engage("organize\x00" as *u8, 0), 1, st) 55 let pq: *i64 = sys_mmap(16) as *i64 56 let lq: *i64 = sys_mmap(16) as *i64 57 let hit: i64 = ss_get(OR_STORE, "orch:engage:organize\x00" as *u8, pq, lq) 58 chk("engagement recorded on the seg-store" as *u8, hit, 1, st) 59 var carriesR: i64 = 0 60 if hit==1 { 61 let b: *u8 = pq[0] as *u8; let bn: i64 = lq[0] 62 let cp: *u8 = sys_mmap(600); var i: i64=0; while i<bn { cp[i]=b[i]; i=i+1 } cp[bn]=0 as u8 63 if has(cp, "accountable=librarian\x00" as *u8)==1 { if has(cp, "organ=nx_librarian_review_gate\x00" as *u8)==1 { carriesR=1 } } 64 } 65 chk("record carries accountable=librarian + the organ" as *u8, carriesR, 1, st) 66 67 g_puts("nx_orchestrate_gate: PASS=" as *u8); g_putn(st[0]); g_puts(" FAIL=" as *u8); g_putn(st[1]); g_puts("\n" as *u8) 68 if st[1]==0 { g_puts("ORCH-R3 nx_orchestrate: GREEN\n" as *u8) } else { g_puts("ORCH-R3 nx_orchestrate: RED\n" as *u8) } 69 // D001 MIGRATION 2026-08-01 -- and the reason is NOT promote-time hygiene. 70 // MEASURED: this gate is genuinely GREEN (PASS=13 FAIL=0, exit 0, verified from the serving root on 71 // both the promoted binary and a fresh build) -- yet nx_gate_bite scored it 72 // `gate_exit=0 green=0 judge=verdict-line` -> UNCONTROLLED, because it announced itself as 73 // "ORCH-R3 nx_orchestrate: GREEN" instead of the contract line every judge in the ecosystem reads. 74 // Consequence: librarian could not reach NON-VACUITY (stuck redseen=3/4) and therefore could not 75 // reach PROVEN -- a domain held below the top verdict by a gate's OUTPUT FORMAT, not its quality. 76 // ★★★★★★THE EMIT CONTRACT IS WHAT MAKES A GATE JUDGEABLE BY THE NON-VACUITY CLAUSE -- D001 is not 77 // hygiene, it gates the TOP VERDICT. Any gate still rolling its own verdict reads UNCONTROLLED to 78 // every bite run no matter how good it is. 79 // Hand-migrated because nx_gate_dry_apply recognises only a `verdict=GREEN` tail, which this shape 80 // never had. The original lines are KEPT above: they are this gate's long-standing public signature 81 // and removing them would break any reader that greps for ORCH-R3. 82 let ctr: *i64 = gv_ctr() 83 gv_check("ORCH-R3 RACI conductor: all declared checks pass" as *u8, (st[1] == 0) as i64, ctr) 84 let rc: i64 = gv_verdict("ORCHESTRATE-GATE" as *u8, ctr, "RACI resolve+dispatch+durable record, 13 checks" as *u8) 85 return rc 86}