nx_goalmap_lib.nx
buildroot/runtime/nx_goalmap_lib.nx
about
nx_goalmap_lib.nx -- THE GOAL MAPPER (seat-system, 2026-09-05). Operator: "build our mapping setup to
exceed yours so we dont need to reinvest heavy tokens and instead the nishi ecosystem can do the lifts."
MEASURED the day it was built: two Claude workflows spent 5.7M tokens and 1,272 tool calls to map ONE
operator goal onto the boards. This lib does that lift from DATA, deterministically, with no language
model in the path: goal WORDS -> per domain, the rung| rows whose title / done-rule / symbol carry them
(score = DISTINCT words matched, published as a COUNT and never thresholded -- the capsearch law: a ruler
that scores a novel thing highest cannot be thresholded, publish the list), each rung's STATUS derived
from the matrix (a present symbol = PRESENT, an _ABSENT_:<sym> watch = OPEN, neither = UNMAPPED) and from
the operator's own plane (knowledge/store/accept-: a REJECT whose targets name <dom>:<sym> = PRESENT-REJECTED,
an ACCEPT = ACCEPTED), the log| ledger size and last epoch per rung, the matrix WATCH rows the words match
(gaps, with SOURCE / BUILT / PROMOTED probed by open at the three roots), and a dependency ORDER over the
matched rungs (Kahn over the deps column; ties by score then file order; a cycle is ANNOUNCED, never hidden).
Output is ONE capped JSON digest (GM_OUTCAP declared in the output, clipped=1 when the budget bound it) so a
seat reads the decision surface, not the boards. COMPOSES nx_sovjson_lib (emit + spans) and
nx_store_seed_lib (plane load sized from the plane -- never a partial board). Every read declares its true
size beside the window it took. A duplicate rung id is REFUSED BY NAME (the ranker's closure hides a rung
behind one; measured 'rung|GE50|' x2 on gameengine.plan on 2026-09-05). No hw writes (Rule 26).
gm_run(base, domains-csv, words, nwords, out) -> bytes written, or -3 NO-DOMAIN-READABLE, -4 DUPLICATE-RUNG-ID
base = path prefix for a fixture tree ("" in production = the nishihost cwd).
dependencies 4 imports · 3 importers
imports: nx_syscalls.nxnx_sovjson_lib.nxnx_store_seed_lib.nxnx_gauge_lib.nx
imported by: nx_goalmap.nxnx_goalmap_gate.nxnx_goalmap_record_gate.nx
structs
| none |
consts
| 25 | const GM_CAP: i64 = 1048576 |
| 26 | const GM_OUTCAP: i64 = 16384 // v1.1 (2026-09-05): 8192 clipped 3 of 4 real domains on the first real run; a goal map over four boards is read ONCE, so 16 KB is still a ~17x lift over the 270 KB of agent maps it replaces |
| 27 | const GM_RF: i64 = 16 |
| 28 | const GM_MF: i64 = 12 |
| 29 | const GM_PATHB: i64 = 512 |
| 30 | const GM_WORDB: i64 = 64 |
| 31 | const GM_NL: i64 = 10 |
| 32 | const GM_PIPE: i64 = 124 |
| 33 | const GM_COMMA: i64 = 44 |
| 34 | const GM_COLON: i64 = 58 |
| 35 | const GM_TAB: i64 = 9 |
| 36 | const GM_SLASH: i64 = 47 |
| 37 | const GM_DOT: i64 = 46 |
| 38 | const GM_HASH_BYTE: i64 = 35 |
| 39 | const GM_SEEK_SET: i64 = 0 |
| 40 | const GM_SEEK_END: i64 = 2 |
| 41 | const GM_SPAN: i64 = 16 |
| 42 | const GM_SPAN6: i64 = 48 |
| 43 | const GM_ID_ESC: i64 = 24 |
| 44 | const GM_SYM_ESC: i64 = 48 |
| 45 | const GM_LABEL_ESC: i64 = 64 |
| 46 | const GM_DEPS_ESC: i64 = 40 |
| 47 | const GM_TAIL_RESERVE: i64 = 200 |
| 48 | const GM_ROW_RESERVE: i64 = 260 |
| 49 | const GM_MAXVERD: i64 = 8 |
| 50 | const GM_R_NODOM: i64 = 0 - 3 |
| 51 | const GM_R_DUP: i64 = 0 - 4 |
| 52 | const GM_ST_UNMAPPED: i64 = 0 |
| 53 | const GM_ST_OPEN: i64 = 1 |
| 54 | const GM_ST_PRESENT: i64 = 2 |
| 55 | const GM_ST_REJECTED: i64 = 3 |
| 56 | const GM_ST_ACCEPTED: i64 = 4 |
| 57 | const GM_ABSENT_LEN: i64 = 9 |
| 58 | const GM_RUNG_PFX_LEN: i64 = 5 |
| 59 | const GM_LOG_PFX_LEN: i64 = 4 |
| 60 | const GM_LC_A: i64 = 65 |
| 61 | const GM_LC_Z: i64 = 90 |
| 62 | const GM_LC_D: i64 = 32 |
| 72 | const GM_DOM_RESERVE: i64 = 400 |
| 522 | const GR_MAXNAMES: i64 = 65536 // name-set slots; when reached the census prints floor=1 (a FLOOR, never a total) |
| 523 | const GR_NAMEB: i64 = 2097152 // name arena bytes |
| 524 | const GR_MAXCAND: i64 = 32768 // candidate slots; floor printed when reached |
| 525 | const GR_EVB: i64 = 4194304 // candidate board+evidence arena bytes |
| 526 | const GR_OUTB: i64 = 1048576 // the JSON the verb prints (rows inline are capped at GR_SHOWN_CAP; the plane is whole) |
| 527 | const GR_SHOWN_CAP: i64 = 200 |
| 528 | const GR_KIND_ORGAN: i64 = 0 |
| 529 | const GR_KIND_DIRECTIVE: i64 = 1 |
| 530 | const GR_KIND_SYMBOL: i64 = 2 |
| 531 | const GR_KIND_DEFECT: i64 = 3 |
| 532 | const GR_KINDS: i64 = 4 |
| 533 | const GR_PLANE_DEFAULT: *u8 = "knowledge/store/comparegaps-" |
| 534 | const GR_CONF_DEFAULT: *u8 = "knowledge/recordgaps.conf" |
| 535 | const GR_UNDERSCORE: i64 = 95 |
| 536 | const GR_LOW_A: i64 = 97 |
| 537 | const GR_LOW_Z: i64 = 122 |
| 538 | const GR_D0: i64 = 48 |
| 539 | const GR_D9: i64 = 57 |
| 540 | const GR_QUOTE: i64 = 34 |
| 541 | const GR_ABSENT_PFX: i64 = 9 // len("_ABSENT_:") |
| 542 | const GR_MCP_PFX: i64 = 12 // len("mcp__nishi__") |
| 543 | const GR_NXPFX: i64 = 3 // len("nx_") |
| 544 | const GR_ROW_RESERVE_LOCAL: i64 = 1200 |
| 545 | const GM_RBRACE_BYTE: i64 = 125 |
| 546 | const GR_ROWS_SFX: *u8 = ".rows" // the RENDER FEED beside the conf: the same bytes the plane received, truncate-written by the same run, read by the compare emitter with a plain file read (the emitter never links the seg store) |
| 547 | const GR_STAMP_SFX: *u8 = ".stamp" // the gauge heartbeat beside the conf (nx_gauge_lib shape): gauge = candidates total, axes = sources READ of sources DECLARED -- BLIND until every declared source has a reader, by construction; derived from the conf path so a fixture run can never forge the production heartbeat |
| 548 | const GR_CADENCE_DEFAULT: i64 = 86400 // the record beat's declared cadence; a conf row cadence|<secs> overrides it |
| 549 | const GR_MODE_RW: i64 = 420 |
| 551 | const GR_S_INVOKED: i64 = 0 |
| 552 | const GR_S_JOURNAL: i64 = 1 |
| 553 | const GR_S_PLANS: i64 = 2 |
| 554 | const GR_S_GATES: i64 = 3 |
| 555 | const GR_S_DEBT: i64 = 4 |
| 556 | const GR_S_MEMORY: i64 = 5 |
| 557 | const GR_S_TRANSCRIPTS: i64 = 6 |
| 558 | const GR_S_N: i64 = 7 |
functions
| 76 | func gm_ndom(domcsv: *u8) -> i64 |
| 88 | func gm_outbuf(domcsv: *u8) -> i64 { return GM_OUTCAP + gm_ndom(domcsv) * GM_DOM_RESERVE + GM_TAIL_RESERVE } |
| 90 | func gm_count_pfx(q: *u8, n: i64, pfx: *u8) -> i64 |
| 102 | func gm_count_lines(q: *u8, n: i64) -> i64 |
| 110 | func gm_lc(c: i64) -> i64 { if c >= GM_LC_A { if c <= GM_LC_Z { return c + GM_LC_D } } return c } |
| 112 | func gm_span_eq(q: *u8, s1: i64, e1: i64, s2: i64, e2: i64) -> i64 |
| 120 | func gm_has_ci(q: *u8, s: i64, e: i64, w: *u8) -> i64 |
| 138 | func gm_find(q: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 153 | func gm_span_has_span(q: *u8, s: i64, e: i64, n: *u8, ns: i64, ne: i64) -> i64 called by 1: gm_status_accept |
| 168 | func gm_pcol(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64 |
| 186 | func gm_read(path: *u8, buf: *u8, cap: i64, sizep: *i64) -> i64 |
| 205 | func gm_probe(path: *u8) -> i64 |
| 213 | func gm_path(pb: *u8, base: *u8, rel: *u8, q: *u8, s: i64, e: i64, suffix: *u8) -> i64 |
| 227 | func gm_rec(rec: *i64, i: i64, f: i64) -> i64 { return rec[i * GM_RF + f] } |
| 228 | func gm_set(rec: *i64, i: i64, f: i64, v: i64) -> i64 { rec[i * GM_RF + f] = v; return 0 } |
| 230 | func gm_setcol(q: *u8, rec: *i64, i: i64, ls: i64, le: i64, col: i64, fs: i64, sp: *i64) -> i64 |
| 236 | func gm_parse_rungs(q: *u8, n: i64, rec: *i64, cap: i64, dup: *i64, floor: *i64) -> i64 |
| 276 | func gm_log_stats(q: *u8, n: i64, rec: *i64, nr: i64) -> i64 |
| 306 | func gm_str_eq(a: *u8, b: *u8) -> i64 |
| 312 | func gm_word_dup(words: *i64, w: i64) -> i64 |
| 319 | func gm_score(q: *u8, rec: *i64, i: i64, words: *i64, nw: i64) -> i64 |
| 338 | func gm_mrec(m: *i64, i: i64, f: i64) -> i64 { return m[i * GM_MF + f] } |
| 339 | func gm_mset(m: *i64, i: i64, f: i64, v: i64) -> i64 { m[i * GM_MF + f] = v; return 0 } called by 1: gm_parse_matrix |
| 341 | func gm_parse_matrix(q: *u8, n: i64, m: *i64, cap: i64, floor: *i64) -> i64 |
| 372 | func gm_status_matrix(q: *u8, rec: *i64, i: i64, mq: *u8, m: *i64, nm: i64) -> i64 |
| 393 | func gm_status_accept(q: *u8, rec: *i64, i: i64, dom: *u8, ab: *u8, an: i64, st0: i64) -> i64 |
| 422 | func gm_st_lit(c: i64) -> *u8 called by 1: gm_run |
| 431 | func gm_blocked(q: *u8, rec: *i64, i: i64, mi: *i64, nm: i64, em: *i64) -> i64 |
| 460 | func gm_order(q: *u8, rec: *i64, mi: *i64, nm: i64, order: *i64, cycle: *i64) -> i64 |
| 492 | func gm_basename(pb: *u8, q: *u8, s: i64, e: i64) -> i64 called by 1: gm_run |
| 505 | func gm_room(o: i64, need: i64) -> i64 { if o + need + GM_TAIL_RESERVE <= GM_OUTCAP { return 1 } return 0 } called by 1: gm_run |
| 559 | func gr_is_ident(c: i64) -> i64 called by 1: gr_scan_plan_queue |
| 566 | func gr_name_find(nb: *u8, no: *i64, nl: *i64, nn: i64, s: *u8, ss: i64, se: i64) -> i64 |
| 581 | func gr_name_add(nb: *u8, no: *i64, nl: *i64, nnp: *i64, bp: *i64, s: *u8, ss: i64, se: i64, floor: *i64) -> i64 called by 4: gr_names_from_matrixgr_names_from_plangr_names_from_gatesgr_cand_add calls 1: gr_name_find |
| 595 | func gr_organ_span(q: *u8, s: i64, e: i64, out: *i64) -> i64 |
| 608 | func gr_has_nxpfx(q: *u8, s: i64, e: i64) -> i64 |
| 613 | func gr_names_from_matrix(q: *u8, n: i64, nb: *u8, no: *i64, nl: *i64, nnp: *i64, bp: *i64, floor: *i64) -> i64 |
| 633 | func gr_names_from_plan(q: *u8, n: i64, nb: *u8, no: *i64, nl: *i64, nnp: *i64, bp: *i64, floor: *i64) -> i64 |
| 647 | func gr_names_from_gates(q: *u8, n: i64, nb: *u8, no: *i64, nl: *i64, nnp: *i64, bp: *i64, floor: *i64) -> i64 |
| 662 | func gr_cand_add(kind: *i64, cno: *i64, cnl: *i64, cb: *u8, cbp: *i64, ncp: *i64, evo: *i64, evl: *i64, eb: *u8, ebp: *i64, k: i64, q: *u8, ns: i64, ne: i64, ev: *u8, evn: i64, floor: *i64) -> i64 |
| 678 | func gr_atoi(b: *u8, s: i64, e: i64) -> i64 { var v: i64 = 0; var i: i64 = s; while i < e { let c: i64 = b[i] as i64; if c >= GR_D0 { if c <= GR_D9 { v = v * (10 as i64) + (c - GR_D0) } } i = i + 1 } return v } called by 1: gr_conf_load |
| 680 | func gr_conf_load(conf: *u8, paths: *i64, plane: *u8, declared: *i64, unknown: *i64, cad: *i64) -> i64 |
| 736 | func gr_scan_invoked(fq: *u8, fn: i64, nb: *u8, no: *i64, nl: *i64, nn: i64, kind: *i64, cno: *i64, cnl: *i64, cb: *u8, cbp: *i64, ncp: *i64, evo: *i64, evl: *i64, eb: *u8, ebp: *i64, stats: *i64, floor: *i64) -> i64 |
| 785 | func gr_scan_plan_queue(q: *u8, n: i64, dom: *u8, ds: i64, de: i64, nb: *u8, no: *i64, nl: *i64, nn: i64, kind: *i64, cno: *i64, cnl: *i64, cb: *u8, cbp: *i64, ncp: *i64, evo: *i64, evl: *i64, eb: *u8, ebp: *i64, stats: *i64, floor: *i64) -> i64 |
| 834 | func gr_kind_name(k: i64) -> *u8 called by 1: gm_record_gaps |
| 840 | func gr_src_name(s: i64) -> *u8 called by 1: gm_record_gaps |
| 851 | func gm_record_gaps(conf: *u8, out: *u8) -> i64 |
| 1069 | func gm_run(base: *u8, domcsv: *u8, words: *i64, nw: i64, out: *u8) -> i64 |