code wiki / _hdl_build / nx_pm_roi_lib.nx

nx_pm_roi_lib.nx

buildroot/runtime/_hdl_build/nx_pm_roi_lib.nx

46754 B819 linesdepth 5pulls 8 transitivereach 2 importersview sourcekind librarytopic pm
docsdependenciesstructsconstsfunctions

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

nx_ecomat_lib.nx nx_store_seed_lib.nx nx_pm_roi_lib.nx nx_pm_cockpit.nx nx_pm_cockpit_gate.nx

imports: nx_ecomat_lib.nxnx_store_seed_lib.nx

imported by: nx_pm_cockpit.nxnx_pm_cockpit_gate.nx

structs

none

consts

20const PM_PLANE_CAP: i64 = 524288 // frontier-/debt-/roi- plane text cap (real planes ~15-60KB)
21const PM_CONF_CAP: i64 = 262144 // registry conf cap (tool_allowlist/cron.reg/daemons.reg)
22const PM_OUT_CAP: i64 = 262144 // emitted JSON/HTML cap
23const PM_MAXCOLS: i64 = 16 // per-row column pairs parsed
24const PM_TOP_ROCKS: i64 = 8 // top open frontier rocks listed
25const PM_TOP_DEBTS: i64 = 6 // top gating debts listed
26const PM_TOP_NEXT: i64 = 3 // maturity next-rung feedback lines
27const PM_NOTE_CAP: i64 = 140 // per-listed-row text slice cap (truncation visible by design)
28const PM_ROCK_W_MIN: i64 = 8 // "big rock" weight floor
29const PM_DEBT_GATE_SEV: i64 = 6 // gating severity floor (mirrors cycle store CONFIG global-sev-min)
30const PM_DEBT_HI_SEV: i64 = 7 // "top debt" listing floor
31const PM_TAB: i64 = 9
32const PM_NL: i64 = 10
33const PM_HASH: i64 = 35
34const PM_ZERO: i64 = 48
35const PM_NINE: i64 = 57
36const PM_B10: i64 = 10
37const PM_LEGACY_IDLEN: i64 = 8 // col0 all-digits len>=8 => legacy 5-col debt row (epoch id)
39const S_MAT: i64 = 0
40const S_DOM: i64 = 1
41const S_TRI: i64 = 2
42const S_CON: i64 = 3
43const S_SNG: i64 = 4
44const S_DNG: i64 = 5
45const S_AUT: i64 = 6
46const S_LIAR: i64 = 7
47const S_SCLASS: i64 = 8
48const S_FTOT: i64 = 10
49const S_FDONE: i64 = 11
50const S_FEXT: i64 = 12
51const S_FOPEN: i64 = 13
52const S_DTOT: i64 = 20
53const S_DOPEN: i64 = 21
54const S_DSEV: i64 = 22
55const S_D3P: i64 = 23
56const S_ROIAV: i64 = 30
57const S_ROICENTS: i64 = 31
58const S_ROILINES: i64 = 32
59const S_ROISUPER: i64 = 34
60const S_ROICFG: i64 = 35
61const S_ROIRES: i64 = 36
62const S_TOOLS: i64 = 40
63const S_CRONS: i64 = 41
64const S_FLEET: i64 = 42
65const S_JRNLB: i64 = 43
66const S_RACILANES: i64 = 44
67const PM_TOP_RACI: i64 = 40
68const RC_STRIDE: i64 = 12
280const RR_STRIDE: i64 = 12

functions

70func pm_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
73func pm_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 1: sys_read
89func pm_count_rows(buf: *u8, n: i64) -> i64
called by 1: main
103func pm_cols(buf: *u8, ls: i64, le: i64, sp: *i64) -> i64
118func pm_slice_int(buf: *u8, a: i64, b: i64) -> i64
128func pm_slice_eq(buf: *u8, a: i64, b: i64, lit: *u8) -> i64
called by 2: pmc_count_greenpm_debt_scan calls 1: pm_len
136func pm_is_legacy(buf: *u8, a: i64, b: i64) -> i64
called by 1: pm_debt_scan
148func pm_has_lc(buf: *u8, a: i64, b: i64, pat: *u8) -> i64
called by 1: pm_is_3p calls 1: pm_len
166func pm_is_3p(buf: *u8, a: i64, b: i64) -> i64
called by 2: mainpm_debt_scan calls 1: pm_has_lc
184func pm_debt_scan(buf: *u8, n: i64, m: *i64, topv: *i64) -> i64
231func pm_frontier_scan(buf: *u8, n: i64, m: *i64, topv: *i64) -> i64
called by 2: mainmain calls 2: pm_colspm_slice_int
282func pm_col_starts(buf: *u8, a: i64, b: i64, lit: *u8) -> i64
289func pm_all_digits(buf: *u8, a: i64, b: i64) -> i64
called by 1: pm_roi_bucket
295func pm_row_superseded(buf: *u8, sp: *i64, nc: i64) -> i64
300func pm_roi_bucket(buf: *u8, sp: *i64, nc: i64) -> i64
308func pm_roi_scan(buf: *u8, n: i64, m: *i64, rrow: *i64, maxrows: i64) -> i64
376func pm_maturity_next(prefix: *u8, nextv: *i64, maxn: i64) -> i64
415func pm_raci_scan(buf: *u8, n: i64, m: *i64, rrow: *i64, maxrows: i64) -> i64
called by 1: main calls 1: pm_cols
446func pm_jesc(dst: *u8, off: i64, src: *u8, a: i64, b: i64, maxb: i64) -> i64
462func pm_hesc(dst: *u8, off: i64, src: *u8, a: i64, b: i64, maxb: i64) -> i64
478func pm_money(dst: *u8, off: i64, cents: i64) -> i64
called by 1: pm_emit_html
489func pm_next_str(dst: *u8, off: i64, h: *i64, keyidx: i64, html: i64) -> i64
509func 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
656func 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