code wiki / _hdl_build / nx_batt_bizplan.nx

nx_batt_bizplan.nx source

↩ module page · 145 lines · 16935 B

1// nx_batt_bizplan.nx -- R4 BUSINESS-PLAN ASSEMBLER. EMITS (author-by-organ, [[feedback-author-by-organ-not-claude]]) 2// a complete, self-contained HTML business plan for the Li-ion reclamation shop, COMPOSING the prior work: the 3// planner's model choice (HYBRID), the finmodel's grounded numbers (via the shared nx_batt_econ core = no drift), 4// and the chart (the real SVG is READ from disk and embedded inline = real composition). Every figure tagged 5// VERIFIED vs assumption; the adversarial fragility is stated, not hidden. Zero 3rd-party JS. Output -> 6// knowledge/library/ (foundationable via nx_library_foundation). Build: _offc/nx_sov_build_run.elf nx_batt_bizplan 7// license_tier: ORIGINAL 8import "nx_debt_payoff.nx" // -> nx_money (mny_format) + nx_syscalls (file IO) 9import "nx_batt_econ.nx" // shared economic core (the plan computes from the SAME source as nx_batt_finmodel) 10 11func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 12func gn(v0: i64) -> i64 { var v: i64=v0; if v<0{sys_write(1,"-" as *u8,1);v=0-v} let b: *u8=sys_mmap(24); var k: i64=0; if v==0{b[0]=48 as u8;k=1} while v>0{b[k]=(48+(v%10)) as u8;v=v/10;k=k+1} let o: *u8=sys_mmap(24); var j: i64=0; while j<k{o[j]=b[k-1-j];j=j+1} sys_write(1,o,k); return 0 } 13func ws(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return n } 14func wn(fd: i64, v0: i64) -> i64 { var v: i64=v0; var c: i64=0; if v<0{sys_write(fd,"-" as *u8,1);c=c+1;v=0-v} let b: *u8=sys_mmap(24); var k: i64=0; if v==0{b[0]=48 as u8;k=1} while v>0{b[k]=(48+(v%10)) as u8;v=v/10;k=k+1} let o: *u8=sys_mmap(24); var j: i64=0; while j<k{o[j]=b[k-1-j];j=j+1} sys_write(fd,o,k); return c+k } 15func wm(fd: i64, c0: i64) -> i64 { var x: i64=c0; if x<0{sys_write(fd,"-$" as *u8,2);x=0-x}else{sys_write(fd,"$" as *u8,1)} let buf: *u8=sys_mmap(32); let n: i64=mny_format(x,buf); sys_write(fd,buf,n); return 0 } 16func rdcopy(fd_out: i64, path: *u8) -> i64 { 17 let rfd: i64=sys_openat_rd(path); if rfd<0 { return 0 } 18 let buf: *u8=sys_mmap(32768); var total: i64=0 19 var n: i64=sys_read(rfd,buf,32768) 20 while n>0 { sys_write(fd_out,buf,n); total=total+n; n=sys_read(rfd,buf,32768) } 21 sys_close(rfd); return total 22} 23func have(p: *u8) -> i64 { let fd: i64=sys_openat_rd(p); if fd<0 { return 0 } sys_close(fd); return 1 } 24// adversarial table row: name + net (colored) + survive/killed 25func arow(fd: i64, name: *u8, net: i64, capex: i64) -> i64 { 26 ws(fd,"<tr><td>" as *u8); ws(fd,name); ws(fd,"</td><td class='" as *u8) 27 if net>0 { ws(fd,"pos'>" as *u8) } else { ws(fd,"neg'>" as *u8) } 28 wm(fd,net); ws(fd,"/mo</td><td>" as *u8) 29 if net>0 { ws(fd,"survives (payoff " as *u8); wn(fd,be_payoff_months(capex,net)); ws(fd," mo)" as *u8) } 30 else { ws(fd,"KILLED" as *u8) } 31 ws(fd,"</td></tr>\n" as *u8) 32 return 0 33} 34 35func main() -> i64 { 36 let path: *u8 = "knowledge/library/battery-reclamation-business-plan-grounded-2026-06-23.html" as *u8 37 let svgp: *u8 = "knowledge/research/2026-06-23-battery-reclaim-finmodel.svg" as *u8 38 let fd: i64 = sys_openat_wr(path, 0x1a4) 39 if fd<0 { gp("FAIL open plan\n" as *u8); sys_exit(1); return 1 } 40 41 let capex: i64 = BE_CAPEX_TOTAL 42 let opex: i64 = BE_OPEX_TOTAL 43 let net: i64 = be_base_net() 44 let gross: i64 = be_gross_base() 45 let po: i64 = be_payoff_months(capex, net) 46 let s1: i64 = be_scenario_net(794,100,100,0) 47 let s2: i64 = be_scenario_net(529,75,100,0) 48 let s3: i64 = be_scenario_net(529,100,60,0) 49 let s4: i64 = be_scenario_net(529,100,100,200000) 50 let s5: i64 = be_scenario_net(635,90,80,0) 51 52 ws(fd,"<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width,initial-scale=1'><title>Li-ion Battery Reclamation -- Business Plan</title>\n" as *u8) 53 ws(fd,"<style>body{font-family:system-ui,Arial,sans-serif;max-width:920px;margin:0 auto;padding:26px;color:#1a1a1a;line-height:1.55}h1{font-size:27px;margin-bottom:2px}h2{font-size:19px;border-bottom:2px solid #2e8b57;padding-bottom:4px;margin-top:34px}.sub{color:#555;margin-top:0}.cards{display:flex;gap:12px;flex-wrap:wrap;margin:18px 0}.card{flex:1;min-width:150px;background:#f4f7f5;border:1px solid #d8e0db;border-radius:8px;padding:12px}.card .v{font-size:23px;font-weight:700;color:#2e8b57}.card .l{font-size:12px;color:#555}table{border-collapse:collapse;width:100%;margin:12px 0}th,td{border:1px solid #ccc;padding:6px 10px;text-align:left;font-size:14px}th{background:#eef3f0}.vt{color:#2e8b57;font-weight:600;font-size:11px}.at{color:#b06a00;font-weight:600;font-size:11px}.warn{background:#fdf3f3;border-left:4px solid #c0392b;padding:10px 14px;margin:14px 0}.ok{background:#f0f7f2;border-left:4px solid #2e8b57;padding:10px 14px;margin:14px 0}.neg{color:#c0392b;font-weight:600}.pos{color:#2e8b57;font-weight:600}figure{margin:14px 0;text-align:center}footer{margin-top:34px;font-size:12px;color:#777;border-top:1px solid #ddd;padding-top:12px}</style></head><body>\n" as *u8) 54 55 ws(fd,"<h1>Li-ion Battery Reclamation -- Business Plan</h1>\n" as *u8) 56 ws(fd,"<p class='sub'>A safe, laundromat-style shop that restores power-tool, e-bike &amp; cordless battery packs to spec -- engineered so a Li-ion fire cannot happen. Assembled by the Nishi finance member, 2026-06-23. Figures tagged <span class='vt'>VERIFIED</span> (sourced) or <span class='at'>assumption</span> (not yet sourced).</p>\n" as *u8) 57 58 ws(fd,"<div class='cards'>" as *u8) 59 ws(fd,"<div class='card'><div class='v'>" as *u8); wm(fd,capex); ws(fd,"</div><div class='l'>initial investment</div></div>" as *u8) 60 ws(fd,"<div class='card'><div class='v'>" as *u8); wm(fd,net); ws(fd,"</div><div class='l'>net / month (base)</div></div>" as *u8) 61 ws(fd,"<div class='card'><div class='v'>" as *u8); wn(fd,po); ws(fd," mo</div><div class='l'>base payoff</div></div>" as *u8) 62 ws(fd,"<div class='card'><div class='v'>4 / 5</div><div class='l'>stress shocks turn it negative</div></div>" as *u8) 63 ws(fd,"</div>\n" as *u8) 64 65 ws(fd,"<h2>1. Executive summary</h2>\n" as *u8) 66 ws(fd,"<p>People throw away &quot;dead&quot; lithium packs that are often just BMS-locked or have a few weak cells. This shop diagnoses each pack and restores the recoverable ones to spec -- BMS reset, rebalance, cell replacement, or full re-cell -- and safely retires + recycles the rest. The differentiator is safety <em>by construction</em>: a battery management substrate (Nishi <code>nx_battery_safety</code>) that structurally refuses any charge/discharge/thermal command that could drive thermal runaway. The model is a HYBRID: supervised express self-service for simple test/reset/balance, plus a back-of-house tech bench for re-cells.</p>\n" as *u8) 67 ws(fd,"<p>The grounded numbers: an initial investment of about " as *u8); wm(fd,capex); ws(fd,", roughly " as *u8); wm(fd,net); ws(fd," net per month at full demand, and a base payoff near " as *u8); wn(fd,po); ws(fd, " months. <strong>But the margin is thin and the base case is fragile</strong> -- see the adversarial stress (Section 6): four of five realistic shocks turn it cash-negative. This is a real business, won on cell-cost control, labor pricing power, throughput, and the safety moat -- not on easy margin.</p>\n" as *u8) 68 69 ws(fd,"<h2>2. Concept &amp; value proposition</h2>\n" as *u8) 70 ws(fd,"<p>Honest scope: &quot;EGO-grade top capacity&quot; means rebuilt-to-spec, <em>not</em> un-aging a worn cell (capacity fade is largely irreversible). Intake triage assigns each pack one verdict: <strong>UNSAFE-REJECT</strong> (swollen / over-discharged / out-of-temp -- recycled, never charged), <strong>RETIRE-RECYCLE</strong>, <strong>RE-CELL</strong> (replace bad cells + rebalance), <strong>BMS-RESET</strong> (the &quot;dead but fine&quot; pack -- cheapest, highest-margin recovery), <strong>RECONDITION</strong> (balance charge), or <strong>PASS-HEALTHY</strong>. The customer keeps their pack and saves vs a new OEM battery; the planet keeps cells out of landfill.</p>\n" as *u8) 71 72 ws(fd,"<h2>3. The safety thesis (the moat)</h2>\n" as *u8) 73 ws(fd,"<div class='ok'><strong>Never ignite, by construction.</strong> Every charge/discharge/thermal command passes the safety envelope (hard ceilings on rate, cell voltage, and temperature) plus a thermal-runaway pattern detector that refuses a rising-thermal command sequence outright. Safety is screened <em>before</em> any economic decision -- a pack that could ignite is refused, never processed. This is the same &quot;never-brick&quot; discipline applied to cells, and it directly lowers the fire-liability tail risk that drives this industry's insurance and the verified ~" as *u8); wm(fd,329900); ws(fd,"-per-cabinet safety capex.</div>\n" as *u8) 74 75 ws(fd,"<h2>4. Market &amp; demand</h2>\n" as *u8) 76 ws(fd,"<p>Demand is <span class='vt'>VERIFIED real</span>: re-cell and rebuild shops exist and transact today (e.g. mail-in services price a DeWalt 20V re-cell at $61.50 and an e-bike rebuild at $120-$190 + parts). Power tools and e-bikes are a large, growing installed base with steady pack-failure replacement and a strengthening right-to-repair tailwind. <span class='at'>Assumption / open:</span> the precise US market size, growth rate, and local demand density did <strong>not</strong> survive verification and must be sized locally before committing capital. Competitors: Batteries Plus, local repair shops, and mail-in re-cell services -- none combining storefront convenience with safety-by-construction.</p>\n" as *u8) 77 78 ws(fd,"<h2>5. Operations -- the hardware-up ladder</h2>\n" as *u8) 79 ws(fd,"<p><strong>R0 Safety substrate</strong> (built): the never-ignite envelope. <strong>R1 Intake &amp; diagnosis</strong> (built): SoH + electrical screen -&gt; triage verdict. <strong>R2 Recondition</strong> (next): staged restore, every step safety-validated. <strong>R3 Fire-safe facility</strong> (next): fire-rated charging bays, thermal auto-isolation, self-service interlock. <strong>R4 Economics &amp; plan</strong> (this document). <strong>R5 Market &amp; program</strong>: competitive positioning + launch.</p>\n" as *u8) 80 81 ws(fd,"<h2>6. Unit economics &amp; financials</h2>\n" as *u8) 82 ws(fd,"<table><tr><th>Line</th><th>Amount</th><th>Basis</th></tr>\n" as *u8) 83 ws(fd,"<tr><td>Initial investment (capex)</td><td>" as *u8); wm(fd,capex); ws(fd,"</td><td>itemized; safety cabinet, analyzers &amp; cell inventory <span class='vt'>VERIFIED</span>, rest <span class='at'>assumption</span></td></tr>\n" as *u8) 84 ws(fd,"<tr><td>Operating cost</td><td>" as *u8); wm(fd,opex); ws(fd,"/mo</td><td>rent / labor / insurance / utilities / disposal -- <span class='at'>assumption</span> (unverified)</td></tr>\n" as *u8) 85 ws(fd,"<tr><td>Gross contribution</td><td>" as *u8); wm(fd,gross); ws(fd,"/mo</td><td>pricing <span class='vt'>VERIFIED</span>, job volume <span class='at'>assumption</span></td></tr>\n" as *u8) 86 ws(fd,"<tr><td><strong>Net</strong></td><td class='pos'>" as *u8); wm(fd,net); ws(fd,"/mo</td><td>base case (full demand month 1)</td></tr>\n" as *u8) 87 ws(fd,"<tr><td><strong>Payoff</strong></td><td>" as *u8); wn(fd,po); ws(fd," months</td><td>initial investment / net</td></tr>\n" as *u8) 88 ws(fd,"</table>\n" as *u8) 89 ws(fd,"<p>The verified hard truth: at ~$5.29/cell and 5-15 cells per pack, cell COGS often approaches the rebuild price, so <strong>labor and throughput carry the business</strong>, with higher-value e-bike rebuilds and diagnostic fees doing the heavy lifting.</p>\n" as *u8) 90 91 ws(fd,"<h2>7. Adversarial stress -- can it survive?</h2>\n" as *u8) 92 ws(fd,"<figure>\n" as *u8) 93 let svgbytes: i64 = rdcopy(fd, svgp) 94 ws(fd,"\n</figure>\n" as *u8) 95 ws(fd,"<table><tr><th>Scenario</th><th>Net / month</th><th>Verdict</th></tr>\n" as *u8) 96 ws(fd,"<tr><td>Base (full demand)</td><td class='pos'>" as *u8); wm(fd,net); ws(fd,"/mo</td><td>payoff " as *u8); wn(fd,po); ws(fd," mo</td></tr>\n" as *u8) 97 arow(fd,"S1 cell cost +50% (raw-material spike)" as *u8, s1, capex) 98 arow(fd,"S2 OEM 'just buy new' price -25%" as *u8, s2, capex) 99 arow(fd,"S3 demand -40% (slow ramp / thin market)" as *u8, s3, capex) 100 arow(fd,"S4 compliance + insurance shock +$2,000/mo" as *u8, s4, capex) 101 arow(fd,"S5 combined (cell +20% / price -10% / demand -20%)" as *u8, s5, capex) 102 ws(fd,"</table>\n" as *u8) 103 ws(fd,"<div class='warn'><strong>Four of five shocks turn it cash-negative.</strong> Top three killers (from the verified research): (1) thin/negative cell margin vs OEM new-pack pricing; (2) shipping/disposal compliance friction -- UN38.3 retest on rebuilt packs, DDR special-permit rules, partial recycling-program coverage, hazmat penalties; (3) catastrophic fire-liability tail risk -- which is exactly what the never-ignite safety design and the safety-cabinet capex exist to contain.</div>\n" as *u8) 104 105 ws(fd,"<h2>8. Why HYBRID (the model the numbers picked)</h2>\n" as *u8) 106 ws(fd,"<p>The profit/risk planner scored four models. Full self-service (a literal &quot;battery laundromat&quot;) is the highest fire-safety and capital risk -- unattended public charging. Pure drop-off loses money at low volume. Core-exchange is capital-heavy. <strong>HYBRID drop-off + supervised express</strong> was the only model with no risk flags and the best net -- balancing accessibility against the safety burden.</p>\n" as *u8) 107 108 ws(fd,"<h2>9. Roadmap &amp; milestones</h2>\n" as *u8) 109 ws(fd,"<p><strong>Done:</strong> safety substrate, intake triage, profit/risk planner, grounded financial model, this plan. <strong>Next to de-risk the numbers:</strong> get real local quotes for the unverified items (rent, <strong>insurance availability/cost</strong>, wages) and a local market sizing, then re-run the model. <strong>Then build:</strong> R2 recondition workflow, R3 fire-safe facility design, and a battery-market competitive matrix.</p>\n" as *u8) 110 111 ws(fd,"<h2>10. Honesty note &amp; sources</h2>\n" as *u8) 112 ws(fd,"<p>This plan mixes <span class='vt'>VERIFIED</span> market data (adversarially verified, 2-of-3 refutes kills a claim) with clearly-labeled <span class='at'>assumptions</span> for items that could not be sourced. The payoff is the optimistic base case; the adversarial section is the realistic test. Do not commit capital until the open items are sourced locally. Full cost basis with per-figure sources: <code>knowledge/research/2026-06-23-battery-reclaim-cost-basis.md</code>.</p>\n" as *u8) 113 114 ws(fd,"<footer>Generated by nx_batt_bizplan (Nishi finance member) -- sovereign, no third-party code. Composes nx_batt_planner (model choice), nx_batt_finmodel + nx_batt_econ (numbers), nx_batt_chart (figure). Numbers are estimates for planning, not investment advice.</footer>\n" as *u8) 115 ws(fd,"</body></html>\n" as *u8) 116 sys_close(fd) 117 118 gp("wrote " as *u8); gp(path); gp("\n embedded SVG bytes=" as *u8); gn(svgbytes); gp("\n" as *u8) 119 120 // ===== self-gate ===== 121 var pass: i64=0; var fail: i64=0 122 // emitted + well-formed 123 let rfd: i64 = sys_openat_rd(path) 124 if rfd<0 { fail=fail+1; gp(" FAIL reopen\n" as *u8) } 125 else { 126 let buf: *u8 = sys_mmap(16); let n: i64 = sys_read(rfd, buf, 2); sys_close(rfd) 127 if n==2 { if buf[0]==(60 as u8) { if buf[1]==(33 as u8) { pass=pass+1 } else { fail=fail+1; gp(" FAIL not-doctype\n" as *u8) } } else { fail=fail+1 } } else { fail=fail+1 } 128 } 129 // chart really embedded (composition proven) 130 if svgbytes > 1500 { pass=pass+1 } else { fail=fail+1; gp(" FAIL svg-not-embedded\n" as *u8) } 131 // numbers locked to the shared econ core (plan == model) 132 if net==480200 { pass=pass+1 } else { fail=fail+1; gp(" FAIL net-drift\n" as *u8) } 133 if po==9 { pass=pass+1 } else { fail=fail+1; gp(" FAIL payoff-drift\n" as *u8) } 134 // adversarial fragility preserved 135 if s1<0 { if s2<0 { if s3<0 { if s5<0 { pass=pass+1 } else { fail=fail+1 } } else { fail=fail+1 } } else { fail=fail+1 } } else { fail=fail+1; gp(" FAIL fragility\n" as *u8) } 136 if s4>0 { pass=pass+1 } else { fail=fail+1; gp(" FAIL s4-liarcheck\n" as *u8) } 137 // grounding: the composed sources exist on disk 138 if have("knowledge/research/2026-06-23-battery-reclaim-cost-basis.md" as *u8)==1 { pass=pass+1 } else { fail=fail+1; gp(" FAIL cost-basis-absent\n" as *u8) } 139 if have("runtime/_hdl_build/nx_batt_finmodel.nx" as *u8)==1 { pass=pass+1 } else { fail=fail+1; gp(" FAIL finmodel-absent\n" as *u8) } 140 if have(svgp)==1 { pass=pass+1 } else { fail=fail+1; gp(" FAIL svg-absent\n" as *u8) } 141 142 gp("BATT-BIZPLAN pass=" as *u8); gn(pass); gp(" fail=" as *u8); gn(fail) 143 if fail==0 { gp(" verdict=GREEN (full HTML plan emitted, chart embedded, numbers locked to econ core, grounded)\n" as *u8); sys_exit(0); return 0 } 144 gp(" verdict=RED\n" as *u8); sys_exit(1); return 1 145}