code wiki / (root) / nx_finance_svc.nx

nx_finance_svc.nx

buildroot/runtime/nx_finance_svc.nx

9939 B205 linesdepth 8pulls 18 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_finance_svc.nx -- FINANCE SERVICE FACADE. One agentic MCP tool over the sovereign finance stack. This is the MCP / API / AGENTIC / WORKFLOW-READY / SCALABLE layer the gate-proven libraries did not yet have. It composes the integer-exact finance modules (nx_dcf, nx_bond, nx_taxlot, nx_amort) behind a verb- dispatched JSON contract inherited from nx_service, adding NO new domain logic -- every number comes from a gated module, so the facade cannot drift from the math it exposes (Rule 15 DRY, Rule 6 OOP, Rule 22 compose). MCP-ready: a single fork-exec organ, stable name + argv verb contract, registerable in the allowlist. API-ready: pure stdout JSON, versioned envelope, CORS-safe structured errors (400/404/422). agentic-ready: the `describe` verb emits this facade's verb catalog with arg shapes (tools/list analog). workflow-ready: every verb is a PURE function of its args returning a self-contained JSON object. scalable: stateless; a call is a fork-exec; concurrency is free. *THE FAIL-CLOSED PROPERTY SURVIVES THE FACADE: a domain refusal sentinel (the DCF growth>=rate trap, an unreachable bond yield, a bad tax-lot or amortization input) is mapped to a structured 422 REFUSED / 400 BAD_ARGS error, never a bogus number in the data. An agent sees the refusal as a first-class outcome. USAGE: nx_finance_svc <verb> [args...] genealogy_id: finance_spine + service_infrastructure

dependencies 7 imports · 0 importers

nx_syscalls.nx nx_service.nx nx_grounding.nx nx_dcf_lib.nx nx_bond_lib.nx nx_taxlot_lib.nx nx_amort_lib.nx nx_finance_svc.nx

imports: nx_syscalls.nxnx_service.nxnx_grounding.nxnx_dcf_lib.nxnx_bond_lib.nxnx_taxlot_lib.nxnx_amort_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_json_new sys_mmap nsvc_arg nsvc_streq fin_describe nsvc_ok_open nj_putc nj_kv_int nj_key nj_putstr nj_putc ↻ nj_putc ↻ nj_puti nj_putc ↻ sys_mmap ↻ nj_comma nj_putc ↻ nj_kv_str nj_key ↻ nj_putstr ↻ nj_kv_bool nj_key ↻ nj_puts nj_putc ↻ nj_key ↻ nj_kv_str ↻ nj_comma ↻ nj_kv_int ↻ nj_kv_bool ↻ nj_key ↻ nj_puts ↻ nsvc_ok_close_g nsvc_ground nj_comma ↻ nj_kv_str ↻ gnd_name nj_kv_bool ↻ gnd_is_verified gnd_meaning

structs

none

consts

28const FIN_MAGIC_8192: i64 = 8192
30const FIN_SVC: *u8 = "finance" as *u8

functions

33func fin_describe(j: *NxJson) -> i64
56func fin_dcf_verdict(j: *NxJson, intrinsic: i64, price: i64) -> i64
76func fin_dcf_terminal(j: *NxJson, final_cf: i64, growth_bp: i64, rate_bp: i64) -> i64
89func fin_bond_price(j: *NxJson, coupon_bp: i64, face: i64, periods: i64, ytm_bp: i64) -> i64
104func fin_bond_ytm(j: *NxJson, price: i64, coupon_bp: i64, face: i64, periods: i64) -> i64
121func fin_bond_duration(j: *NxJson, coupon_bp: i64, face: i64, periods: i64, ytm_bp: i64) -> i64
137func fin_taxlot_wash(j: *NxJson, loss: i64, sale_day: i64, repl_day: i64, repl_shares: i64, sold_shares: i64) -> i64
153func fin_amort_schedule(j: *NxJson, principal: i64, annual_bp: i64, term: i64) -> i64
172func main(argc: i64, argv: *i64) -> i64