code wiki / _hdl_build / nx_pm_roi_lib.nx
nx_pm_roi_lib.nx
buildroot/runtime/_hdl_build/nx_pm_roi_lib.nx
about
nx_pm_roi_lib.nx -- shared core for the PM COCKPIT (operator 2026-07-18: "the pm gives us, based on my
executive, management, and operations layer, a dashboard and feedback ... and the return on investment
that's being driven with non-fake numbers but real estimates").
DESIGN LAWS honored here:
- READER, never a second truth: every tier is measured from the SAME live artifact its owning organ
writes (ecomat seg-store via em_rollup_store, frontier- plane via sts_load, debt- plane via sts_load,
tool_allowlist.conf / cron.reg / daemons.reg registries). No forks (NAS OOM hygiene), no duplicated
rollup logic -> the cockpit can never disagree with /compare/maturity or /frontier.
- ROI IS AN ESTIMATE BY CONSTRUCTION: monthly value = COUNT (measured live from a named artifact)
x RATE (a data row in the knowledge/store/roi- plane, operator-editable, each row carrying its own
basis note). Missing roi- plane -> status UNSEEDED and ZERO dollar output -- fabrication is
structurally impossible. (rule 11: rates are data, never code.)
- SCALE LAW: every read is bounded by a NAMED cap and the envelope is DECLARED in the output;
truncation is marked, never silent.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 2 imports · 2 importers
imports: nx_ecomat_lib.nxnx_store_seed_lib.nx
imported by: nx_pm_cockpit.nxnx_pm_cockpit_gate.nx
structs
| none |
consts
| 20 | const PM_PLANE_CAP: i64 = 524288 // frontier-/debt-/roi- plane text cap (real planes ~15-60KB) |
| 21 | const PM_CONF_CAP: i64 = 262144 // registry conf cap (tool_allowlist/cron.reg/daemons.reg) |
| 22 | const PM_OUT_CAP: i64 = 262144 // emitted JSON/HTML cap |
| 23 | const PM_MAXCOLS: i64 = 16 // per-row column pairs parsed |
| 24 | const PM_TOP_ROCKS: i64 = 8 // top open frontier rocks listed |
| 25 | const PM_TOP_DEBTS: i64 = 6 // top gating debts listed |
| 26 | const PM_TOP_NEXT: i64 = 3 // maturity next-rung feedback lines |
| 27 | const PM_NOTE_CAP: i64 = 140 // per-listed-row text slice cap (truncation visible by design) |
| 28 | const PM_ROCK_W_MIN: i64 = 8 // "big rock" weight floor |
| 29 | const PM_DEBT_GATE_SEV: i64 = 6 // gating severity floor (mirrors cycle store CONFIG global-sev-min) |
| 30 | const PM_DEBT_HI_SEV: i64 = 7 // "top debt" listing floor |
| 31 | const PM_TAB: i64 = 9 |
| 32 | const PM_NL: i64 = 10 |
| 33 | const PM_HASH: i64 = 35 |
| 34 | const PM_ZERO: i64 = 48 |
| 35 | const PM_NINE: i64 = 57 |
| 36 | const PM_B10: i64 = 10 |
| 37 | const PM_LEGACY_IDLEN: i64 = 8 // col0 all-digits len>=8 => legacy 5-col debt row (epoch id) |
| 39 | const S_MAT: i64 = 0 |
| 40 | const S_DOM: i64 = 1 |
| 41 | const S_TRI: i64 = 2 |
| 42 | const S_CON: i64 = 3 |
| 43 | const S_SNG: i64 = 4 |
| 44 | const S_DNG: i64 = 5 |
| 45 | const S_AUT: i64 = 6 |
| 46 | const S_LIAR: i64 = 7 |
| 47 | const S_SCLASS: i64 = 8 |
| 48 | const S_FTOT: i64 = 10 |
| 49 | const S_FDONE: i64 = 11 |
| 50 | const S_FEXT: i64 = 12 |
| 51 | const S_FOPEN: i64 = 13 |
| 52 | const S_DTOT: i64 = 20 |
| 53 | const S_DOPEN: i64 = 21 |
| 54 | const S_DSEV: i64 = 22 |
| 55 | const S_D3P: i64 = 23 |
| 56 | const S_ROIAV: i64 = 30 |
| 57 | const S_ROICENTS: i64 = 31 |
| 58 | const S_ROILINES: i64 = 32 |
| 59 | const S_ROISUPER: i64 = 34 |
| 60 | const S_ROICFG: i64 = 35 |
| 61 | const S_ROIRES: i64 = 36 |
| 62 | const S_TOOLS: i64 = 40 |
| 63 | const S_CRONS: i64 = 41 |
| 64 | const S_FLEET: i64 = 42 |
| 65 | const S_JRNLB: i64 = 43 |
| 66 | const S_RACILANES: i64 = 44 |
| 67 | const PM_TOP_RACI: i64 = 40 |
| 68 | const RC_STRIDE: i64 = 12 |
| 280 | const RR_STRIDE: i64 = 12 |
functions
| 70 | func pm_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 73 | func pm_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 89 | func pm_count_rows(buf: *u8, n: i64) -> i64 called by 1: main |
| 103 | func pm_cols(buf: *u8, ls: i64, le: i64, sp: *i64) -> i64 |
| 118 | func pm_slice_int(buf: *u8, a: i64, b: i64) -> i64 |
| 128 | func pm_slice_eq(buf: *u8, a: i64, b: i64, lit: *u8) -> i64 |
| 136 | func pm_is_legacy(buf: *u8, a: i64, b: i64) -> i64 called by 1: pm_debt_scan |
| 148 | func pm_has_lc(buf: *u8, a: i64, b: i64, pat: *u8) -> i64 |
| 166 | func pm_is_3p(buf: *u8, a: i64, b: i64) -> i64 |
| 184 | func pm_debt_scan(buf: *u8, n: i64, m: *i64, topv: *i64) -> i64 |
| 231 | func pm_frontier_scan(buf: *u8, n: i64, m: *i64, topv: *i64) -> i64 |
| 282 | func pm_col_starts(buf: *u8, a: i64, b: i64, lit: *u8) -> i64 |
| 289 | func pm_all_digits(buf: *u8, a: i64, b: i64) -> i64 called by 1: pm_roi_bucket |
| 295 | func pm_row_superseded(buf: *u8, sp: *i64, nc: i64) -> i64 |
| 300 | func pm_roi_bucket(buf: *u8, sp: *i64, nc: i64) -> i64 |
| 308 | func pm_roi_scan(buf: *u8, n: i64, m: *i64, rrow: *i64, maxrows: i64) -> i64 |
| 376 | func pm_maturity_next(prefix: *u8, nextv: *i64, maxn: i64) -> i64 |
| 415 | func pm_raci_scan(buf: *u8, n: i64, m: *i64, rrow: *i64, maxrows: i64) -> i64 |
| 446 | func pm_jesc(dst: *u8, off: i64, src: *u8, a: i64, b: i64, maxb: i64) -> i64 |
| 462 | func pm_hesc(dst: *u8, off: i64, src: *u8, a: i64, b: i64, maxb: i64) -> i64 |
| 478 | func pm_money(dst: *u8, off: i64, cents: i64) -> i64 called by 1: pm_emit_html |
| 489 | func pm_next_str(dst: *u8, off: i64, h: *i64, keyidx: i64, html: i64) -> i64 |
| 509 | func pm_emit_json(out: *u8, m: *i64, frbuf: *u8, frtop: *i64, nfr: i64, dbbuf: *u8, dbtop: *i64, ndb: i64, roibuf: *u8, roiline: *i64, nroi: i64, ecoprefix: *u8, nextv: *i64, nnext: i64, racibuf: *u8, raciline: *i64, nraci: i64) -> i64 |
| 656 | func pm_emit_html(out: *u8, m: *i64, frbuf: *u8, frtop: *i64, nfr: i64, dbbuf: *u8, dbtop: *i64, ndb: i64, roibuf: *u8, roiline: *i64, nroi: i64, ecoprefix: *u8, nextv: *i64, nnext: i64, racibuf: *u8, raciline: *i64, nraci: i64) -> i64 |