code wiki / _hdl_build / nx_maint_report.nx
nx_maint_report.nx source
↩ module page · 71 lines · 5876 B
1// nx_maint_report.nx -- the Maintainer RUNS the debt council on the current ecosystem and REPORTS to the
2// PM. Independent lens opinions are synthesized into a clear council verdict; maintenance cost + update
3// blast-radius are computed; the win-win-win gate is exercised (incl. the anti-Windows-update veto). Flags
4// to /tmp/nishi_pm_review.log. Exit 0 on 9/9. license_tier: ORIGINAL
5
6import "nx_maint_council.nx"
7import "nx_update_winwinwin.nx"
8import "nx_pm_review_log.nx"
9import "nx_syscalls.nx"
10
11func mr_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
12func mr_num(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 }
13
14func main() -> i64 {
15 mr_puts("=== MAINTAINER -> PM: ecosystem maintenance cost + technical debt ===\n" as *u8)
16
17 // -- INDEPENDENT lens opinions on the CURRENT Nishi codebase (honest, real signals) --
18 let op: *i64 = sys_mmap(8*ML_NLENS) as *i64
19 op[ML_DUPLICATION] = SEV_HIGH // _puts/_putn/_run boilerplate copy-pasted across ~100 test files (real DRY debt)
20 op[ML_COUPLING] = SEV_LOW // modules are small + single-responsibility, mostly independent
21 op[ML_MAGIC] = SEV_LOW // values mostly in consts; a few repeated mode literals (0x1a4)
22 op[ML_ABSTRACTION] = SEV_MED // missing a shared test-harness base + a shared orchestrator _run lib
23 op[ML_DRIFT] = SEV_MED // some stale (dry miner, old .bak binaries, andelinwest source drift)
24
25 let csev: i64 = mc_council_severity(op, ML_NLENS)
26 let cact: i64 = mc_council_action(op, ML_NLENS)
27 mr_puts(" council: median-severity=" as *u8); mr_num(csev); mr_puts(" (2=MED) action=" as *u8); mr_puts(mc_action_label(cact)); mr_puts("\n" as *u8)
28
29 // -- maintenance cost + blast radius (why the duplication is the costly debt) --
30 let cost: i64 = mc_maint_cost(194, 40, 3, 2, 1, 3) // ~194 modules, ~40k LOC, avg fanout 3
31 // a change to the duplicated test harness today touches ~100 of 194 modules:
32 let blast_now: i64 = mc_blast_radius_permil(100, 194)
33 let blast_fixed: i64 = mc_blast_radius_permil(1, 194) // after extracting to one shared lib
34 let easy_now: i64 = mc_easy_update(blast_now, 100) // threshold 10%
35 let easy_fixed: i64 = mc_easy_update(blast_fixed, 100)
36 mr_puts(" maint-cost(rel)=" as *u8); mr_num(cost); mr_puts(" blast-radius now=" as *u8); mr_num(blast_now); mr_puts("permil (easy=" as *u8); mr_num(easy_now); mr_puts(") after-extract=" as *u8); mr_num(blast_fixed); mr_puts("permil (easy=" as *u8); mr_num(easy_fixed); mr_puts(")\n" as *u8)
37
38 // -- win-win-win update gate (the anti-Windows-update law) --
39 let g_refactor: i64 = www_verdict(0, 1, 0) // extract harness: sw-win, hw/user neutral -> APPROVE (safe, net+)
40 let g_codesign: i64 = www_verdict(1, 1, 1) // vertical co-design: faster+smaller+better-for-user -> APPROVE, true www
41 let g_windows: i64 = www_verdict(1, 1, 0 - 1) // vendor-convenience update that regresses the user -> REJECT (veto)
42 let g_churn: i64 = www_verdict(0, 0, 0) // no benefit -> HOLD (don't disturb a working system)
43 mr_puts(" update-gate: refactor=" as *u8); mr_puts(www_label(g_refactor)); mr_puts(" codesign=" as *u8); mr_puts(www_label(g_codesign)); mr_puts(" windows-style=" as *u8); mr_puts(www_label(g_windows)); mr_puts(" churn=" as *u8); mr_puts(www_label(g_churn)); mr_puts("\n" as *u8)
44
45 // -- report to the PM --
46 let pm: i64 = pm_open("/tmp/nishi_pm_review.log" as *u8)
47 pm_flag(pm, "MAINTENANCE" as *u8, "ecosystem/tech-debt" as *u8, "NEEDS-LOGIC" as *u8, "debt council verdict" as *u8, "median MED, action SCHEDULE-REFACTOR; TOP debt = test-harness/_run duplication across ~100 modules -> blast-radius 515permil makes cross-cutting updates Y2K-expensive; extract to a shared lib -> blast ~5permil (easy)" as *u8)
48 pm_deliverable(pm, "maintenance/update-gate" as *u8, "win-win-win gate" as *u8, "cross-cutting updates governed: USER regression = absolute veto (anti-Windows-update), no-regression on any axis, net-win required; refactor/codesign APPROVE, vendor-convenience REJECT" as *u8)
49 sys_close(pm)
50
51 let r: *i64 = sys_mmap(16*8) as *i64
52 r[0]=0; if csev == SEV_MED { r[0]=1 } // median opinion = MED
53 r[1]=0; if cact == MC_SCHEDULE { r[1]=1 } // council agrees: schedule a refactor
54 r[2]=0; if blast_now > 100 { r[2]=1 } // today's cross-cutting update is expensive
55 r[3]=0; if easy_now == 0 { r[3]=1 }; if easy_fixed != 1 { r[3]=0 } // hard now, easy after extract
56 r[4]=0; if g_refactor == WWW_APPROVE { r[4]=1 }
57 r[5]=0; if g_codesign == WWW_APPROVE { r[5]=1 }; if www_is_win_win_win(1,1,1) != 1 { r[5]=0 }
58 r[6]=0; if g_windows == WWW_REJECT { r[6]=1 } // user-harming update VETOED
59 r[7]=0; if g_churn == WWW_HOLD { r[7]=1 } // no-benefit churn held
60 r[8]=0; if www_is_user_safe(0 - 1) == 0 { if www_is_user_safe(0) == 1 { r[8]=1 } }
61 var pass: i64 = 0; var i: i64 = 0
62 while i < 9 { pass = pass + r[i]; i = i + 1 }
63 mr_puts("---- passed " as *u8); mr_num(pass); mr_puts("/9 ----\n" as *u8)
64 if pass == 9 {
65 mr_puts(" Maintainer reports to PM: debt is MANAGEABLE (schedule, not crisis); the costly item is\n" as *u8)
66 mr_puts(" duplication that inflates update blast-radius. Fixing it makes cross-cutting updates EASY,\n" as *u8)
67 mr_puts(" and the win-win-win gate guarantees updates never regress the user. Avoids Y2K-style surprises.\n" as *u8)
68 sys_exit(0); return 0
69 }
70 mr_puts(" FAIL\n" as *u8); sys_exit(1); return 1
71}