nx_debt_payoff.nx
buildroot/runtime/nx_debt_payoff.nx
about
nx_debt_payoff.nx -- R4 of THE NISHI FINANCIAL ECOSYSTEM: exact debt amortization + payoff strategy.
⚠NAME HISTORY (seq240/seq121, resolved 2026-07-23): this module was ONCE runtime/nx_debt.nx and
COLLIDED with _hdl_build/nx_debt.nx (the debt-plane CLI). Because imports resolve dir-local and the
build probes _hdl_build FIRST, every `import "nx_debt.nx"` from runtime/ silently resolved to the CLI
-- which has no dbt_* symbols -- so the whole finance lane failed with `expand_imports failed`.
The file is now nx_debt_payoff.nx and `nx_debt` unambiguously means the CLI. Do NOT reintroduce the name.
Built on nx_money (no-float, exact i64 cents). This is the operator's MOST URGENT rung: HELOC +
high-interest debt. Everything here is deterministic integer arithmetic -- an amortization schedule
is just iterated (interest = round(balance * monthly_rate); principal = payment - interest) and is
therefore bit-exact and reproducible (floats would drift cent-by-cent over hundreds of months).
CAPABILITIES:
dbt_payoff_months -- simulate one loan at a fixed payment -> months to payoff + total interest,
and DETECT the minimum-payment trap (payment <= interest -> never amortizes).
dbt_strategy -- multi-debt payoff under a fixed monthly budget, avalanche (highest-APR-first,
interest-optimal) vs snowball (lowest-balance-first). Returns total months +
total interest. The avalanche<=snowball interest fact is MEASURED by the gate.
NEVER-BRICK FINANCIAL ANALOG (#26): no schedule can loop forever -- the minimum-payment trap is
detected and reported (-1), an under-funded budget is rejected (-1), and a hard month cap (-2) is a
defensive backstop. Nothing here mutates the caller's input arrays (strategy works on copies).
license_tier: ORIGINAL
dependencies 2 imports · 11 importers
diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.
imports: nx_syscalls.nxnx_money.nx
imported by: nx_batt_bizplan.nxnx_batt_finmodel.nxnx_browser_buyguard.nxnx_climbout_real.nxnx_climbout_real_gate.nxnx_debt_gate.nxnx_fin_finance.nxnx_fin_finance_gate.nxnx_finance_web.nxnx_purchase.nxnx_purchase_gate.nx
structs
| none |
consts
| 25 | const K_MAGIC_12000: i64 = 12000 |
functions
| 31 | func dbt_payoff_months(principal: i64, apr_scaled: i64, payment: i64, out_interest: *i64) -> i64 |
| 64 | func dbt_strategy(bal: *i64, apr: *i64, minp: *i64, n: i64, budget: i64, mode: i64, out_interest: *i64) -> i64 |