code wiki / (root) / nx_dimret.nx

nx_dimret.nx source

↩ module page · 68 lines · 3949 B

1// nx_dimret.nx -- the LAW OF DIMINISHING RETURNS (a Warden/PM team function): 2// decide whether to INVEST in pushing a work piece past competitive toward 3// exceed, or DEFER it. Institutionalizes the operator's rule so it is CLEAR, 4// every time, whether an edge investment is worth it. 5// 6// The rule (operator, 2026-06-02): INVEST iff the gain CASCADES downstream 7// (core/low-layer fundamentals multiply upstream value -- a 5x gap on the 8// divider is NOT a 1% chase; it feeds crypto -> the LLM -> all advanced work) OR 9// there is a real gap to close. DEFER only when we are AT PARITY *and* the 10// research says further gains need EXTREME ENGINEERING *and* there is no cascade 11// (true diminishing returns -- don't dump a billion dollars into a 1% leaf gain 12// until the whole stack is up and we have the bandwidth). 13// 14// Sovereign NishiLang, integer-only, pure (KAT-able). Data-driven thresholds. 15// license_tier: ORIGINAL 16 17import "nx_syscalls.nx" 18 19const DR_DEFER: i64 = 0 20const DR_INVEST: i64 = 1 21 22// thresholds (svc-config candidates; here as named constants, not magic numbers) 23const DR_CASCADE_HIGH: i64 = 60 // cascade score >= this => fundamental, multiplies upstream 24const DR_GAP_SIGNIFICANT: i64 = 50 // (gap_x100 - 100) >= this => >=1.5x behind = a real gap, not parity 25const DR_COST_EXTREME: i64 = 80 // eng-cost >= this => "extreme engineering" territory 26 27// gap_x100: distance to the frontier x100 (100 = at parity/1x; 500 = lapped 5x). 28// cascade : downstream cascade score 0..100 (core low-layer = high; edge/leaf = low). 29// eng_cost: engineering cost to close 0..100 (known-better-algorithm = low; extreme = high). 30func nx_dimret_decide(gap_x100: i64, cascade: i64, eng_cost: i64) -> i64 { 31 var gap_benefit: i64 = 0 32 if gap_x100 > 100 { gap_benefit = gap_x100 - 100 } 33 // (1) cascades downstream -> invest regardless of cost (it multiplies layers up) 34 if cascade >= DR_CASCADE_HIGH { return DR_INVEST } 35 // (2) a real gap (not parity) -> invest (closing a 5x core gap is not a 1% chase) 36 if gap_benefit >= DR_GAP_SIGNIFICANT { return DR_INVEST } 37 // (3) at/near parity + low cascade: DEFER only if it needs extreme engineering 38 if eng_cost >= DR_COST_EXTREME { return DR_DEFER } 39 // (4) cheap gain at parity -> take it 40 return DR_INVEST 41} 42 43func dr_putn(n: i64) -> i64 { 44 if n == 0 { sys_write(1, "0" as *u8, 1); return 0 } 45 var m: i64 = n; let d: *u8 = sys_mmap(24); var k: i64 = 0 46 while m > 0 { d[k] = (0x30 + (m % 10)) as u8; m = m / 10; k = k + 1 } 47 var i: i64 = k - 1; while i >= 0 { let o: *u8 = sys_mmap(1); o[0] = d[i]; sys_write(1, o, 1); i = i - 1 } 48 return 0 49} 50func dr_sp() -> i64 { sys_write(1, " " as *u8, 1); return 0 } 51 52func main() -> i64 { 53 // Known-answer cases (FAIL LOUD). Expected: "1 0 1 1 1 " 54 let divider: i64 = nx_dimret_decide(500, 90, 40) // 5x gap, CORE arithmetic (cascades), known algos -> INVEST 55 let parity_edge: i64 = nx_dimret_decide(101, 20, 95) // at parity, leaf, EXTREME eng -> DEFER (diminishing returns) 56 let cheap_parity: i64 = nx_dimret_decide(110, 20, 20)// near parity, cheap -> INVEST 57 let casc_small: i64 = nx_dimret_decide(120, 80, 50) // small gap but HIGH cascade -> INVEST 58 let big_gap_leaf: i64 = nx_dimret_decide(200, 20, 40)// 2x gap on a leaf, moderate cost -> INVEST (real gap) 59 dr_putn(divider); dr_sp(); dr_putn(parity_edge); dr_sp(); dr_putn(cheap_parity); dr_sp() 60 dr_putn(casc_small); dr_sp(); dr_putn(big_gap_leaf); dr_sp(); sys_write(1, "\n" as *u8, 1) 61 62 if divider != DR_INVEST { sys_exit(1); return 1 } // the divider 5x cascade IS worth closing 63 if parity_edge != DR_DEFER { sys_exit(2); return 2 } // the only DEFER case: parity + extreme eng + no cascade 64 if cheap_parity != DR_INVEST { sys_exit(3); return 3 } 65 if casc_small != DR_INVEST { sys_exit(4); return 4 } 66 if big_gap_leaf != DR_INVEST { sys_exit(5); return 5 } 67 sys_exit(0); return 0 68}