nx_dr_conductor.nx source
↩ module page · 75 lines · 3374 B
1// nx_dr_conductor.nx -- the Co-Scientist async research CONDUCTOR (DR-4).
2// Composes the five live DR organs into ONE deterministic pipeline (not reimplemented --
3// it IMPORTS nx_dr_elo + nx_dr_ocm and calls them):
4// stage 1 VERIFY-YIELD quality[i] = supported/total (the surviving claims from the
5// DR-3 entailment loop + DR-2 refutation kill = each research vector's grounded yield)
6// stage 2 TOURNAMENT Elo (DR-1): round-robin, vector a "beats" b iff quality[a]>quality[b]
7// stage 3 OPP-COST DISPATCH (DR-6): priority=(Elo-rating * quality)/cost -> rank -> budget-
8// aware greedy select = which vectors earn deep compute (FutureWeaver budget-feasibility)
9// (the selected vectors' verified claims then feed the DR-0 DRBench/DEER scorer.)
10// Deterministic/integer/bit-exact = the sovereign exceed axis; imports drift-immune organs.
11// No hardware writes (Rule 26).
12//
13// module: nishi-core.research.dr_conductor
14// depends: nx_dr_elo.nx, nx_dr_ocm.nx, nx_syscalls.nx
15// genealogy_id: coscientist_2026_supervisor + futureweaver_2026_dispatch
16import "nx_dr_elo.nx"
17import "nx_dr_ocm.nx"
18import "nx_syscalls.nx"
19const K_MAGIC_1500: i64 = 1500
20
21// verified-claim yield of a research vector (DR-3/DR-2 stage output), permille.
22func cond_quality(supported: i64, total: i64) -> i64 {
23 if total < 1 { return 0 }
24 return (supported * 1000) / total
25}
26
27// run the full pipeline over n research vectors. `out` is a single caller-allocated
28// buffer of (5*n + 1) i64 laid out as consecutive blocks (6 register-fit params -- no
29// stack-arg spill, which the NAS nx_cc mishandles):
30// [0,n)=quality [n,2n)=Elo rating [2n,3n)=priority [3n,4n)=rank order [4n,5n)=selected [5n]=spent
31// Returns the number of vectors selected under budget.
32func cond_run(supported: *i64, total: *i64, cost: *i64, n: i64, budget: i64, out: *i64) -> i64 {
33 let ql: *i64 = out
34 let rt: *i64 = ((out as i64) + n * 8) as *i64
35 let pri: *i64 = ((out as i64) + n * 16) as *i64
36 let ord: *i64 = ((out as i64) + n * 24) as *i64
37 let sel: *i64 = ((out as i64) + n * 32) as *i64
38 let spent: *i64 = ((out as i64) + n * 40) as *i64
39
40 // stage 1: verify-yield
41 var i: i64 = 0
42 while i < n { ql[i] = cond_quality(supported[i], total[i]); i = i + 1 }
43
44 // stage 2: Tournament of Ideas (DR-1) -- round-robin, outcome by quality
45 i = 0
46 while i < n { rt[i] = K_MAGIC_1500; i = i + 1 }
47 let tab: *i64 = el_make_etab()
48 let maxm: i64 = n * n + 1
49 let ma: *i64 = sys_mmap(maxm * 8) as *i64
50 let mb: *i64 = sys_mmap(maxm * 8) as *i64
51 let mo: *i64 = sys_mmap(maxm * 8) as *i64
52 var mc: i64 = 0
53 var a: i64 = 0
54 while a < n {
55 var b: i64 = a + 1
56 while b < n {
57 ma[mc] = a; mb[mc] = b
58 if ql[a] > ql[b] { mo[mc] = 1000 }
59 else { if ql[a] < ql[b] { mo[mc] = 0 } else { mo[mc] = 500 } }
60 mc = mc + 1
61 b = b + 1
62 }
63 a = a + 1
64 }
65 el_run_tournament(rt, n, ma, mb, mo, mc, 32, tab)
66
67 // stage 3: opportunity-cost dispatch (DR-6) -- value=Elo rating, momentum=quality
68 i = 0
69 while i < n { pri[i] = ocm_priority(rt[i], ql[i], cost[i]); i = i + 1 }
70 ocm_rank(pri, n, ord)
71 let sp: *i64 = sys_mmap(8) as *i64
72 let cnt: i64 = ocm_select(pri, cost, ord, n, budget, sel, sp)
73 spent[0] = sp[0]
74 return cnt
75}