code wiki / (root) / nx_goalmap_lib.nx

nx_goalmap_lib.nx

buildroot/runtime/nx_goalmap_lib.nx

64769 B1303 linesdepth 5pulls 8 transitivereach 3 importersview sourcekind librarytopic goalmap
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_sovjson_lib.nx nx_store_seed_lib.nx nx_gauge_lib.nx nx_goalmap_lib.nx nx_goalmap.nx nx_goalmap_gate.nx nx_goalmap_record_gate.nx

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

25const GM_CAP: i64 = 1048576
26const 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
27const GM_RF: i64 = 16
28const GM_MF: i64 = 12
29const GM_PATHB: i64 = 512
30const GM_WORDB: i64 = 64
31const GM_NL: i64 = 10
32const GM_PIPE: i64 = 124
33const GM_COMMA: i64 = 44
34const GM_COLON: i64 = 58
35const GM_TAB: i64 = 9
36const GM_SLASH: i64 = 47
37const GM_DOT: i64 = 46
38const GM_HASH_BYTE: i64 = 35
39const GM_SEEK_SET: i64 = 0
40const GM_SEEK_END: i64 = 2
41const GM_SPAN: i64 = 16
42const GM_SPAN6: i64 = 48
43const GM_ID_ESC: i64 = 24
44const GM_SYM_ESC: i64 = 48
45const GM_LABEL_ESC: i64 = 64
46const GM_DEPS_ESC: i64 = 40
47const GM_TAIL_RESERVE: i64 = 200
48const GM_ROW_RESERVE: i64 = 260
49const GM_MAXVERD: i64 = 8
50const GM_R_NODOM: i64 = 0 - 3
51const GM_R_DUP: i64 = 0 - 4
52const GM_ST_UNMAPPED: i64 = 0
53const GM_ST_OPEN: i64 = 1
54const GM_ST_PRESENT: i64 = 2
55const GM_ST_REJECTED: i64 = 3
56const GM_ST_ACCEPTED: i64 = 4
57const GM_ABSENT_LEN: i64 = 9
58const GM_RUNG_PFX_LEN: i64 = 5
59const GM_LOG_PFX_LEN: i64 = 4
60const GM_LC_A: i64 = 65
61const GM_LC_Z: i64 = 90
62const GM_LC_D: i64 = 32
72const GM_DOM_RESERVE: i64 = 400
522const GR_MAXNAMES: i64 = 65536 // name-set slots; when reached the census prints floor=1 (a FLOOR, never a total)
523const GR_NAMEB: i64 = 2097152 // name arena bytes
524const GR_MAXCAND: i64 = 32768 // candidate slots; floor printed when reached
525const GR_EVB: i64 = 4194304 // candidate board+evidence arena bytes
526const GR_OUTB: i64 = 1048576 // the JSON the verb prints (rows inline are capped at GR_SHOWN_CAP; the plane is whole)
527const GR_SHOWN_CAP: i64 = 200
528const GR_KIND_ORGAN: i64 = 0
529const GR_KIND_DIRECTIVE: i64 = 1
530const GR_KIND_SYMBOL: i64 = 2
531const GR_KIND_DEFECT: i64 = 3
532const GR_KINDS: i64 = 4
533const GR_PLANE_DEFAULT: *u8 = "knowledge/store/comparegaps-"
534const GR_CONF_DEFAULT: *u8 = "knowledge/recordgaps.conf"
535const GR_UNDERSCORE: i64 = 95
536const GR_LOW_A: i64 = 97
537const GR_LOW_Z: i64 = 122
538const GR_D0: i64 = 48
539const GR_D9: i64 = 57
540const GR_QUOTE: i64 = 34
541const GR_ABSENT_PFX: i64 = 9 // len("_ABSENT_:")
542const GR_MCP_PFX: i64 = 12 // len("mcp__nishi__")
543const GR_NXPFX: i64 = 3 // len("nx_")
544const GR_ROW_RESERVE_LOCAL: i64 = 1200
545const GM_RBRACE_BYTE: i64 = 125
546const 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)
547const 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
548const GR_CADENCE_DEFAULT: i64 = 86400 // the record beat's declared cadence; a conf row cadence|<secs> overrides it
549const GR_MODE_RW: i64 = 420
551const GR_S_INVOKED: i64 = 0
552const GR_S_JOURNAL: i64 = 1
553const GR_S_PLANS: i64 = 2
554const GR_S_GATES: i64 = 3
555const GR_S_DEBT: i64 = 4
556const GR_S_MEMORY: i64 = 5
557const GR_S_TRANSCRIPTS: i64 = 6
558const GR_S_N: i64 = 7

functions

76func gm_ndom(domcsv: *u8) -> i64
88func gm_outbuf(domcsv: *u8) -> i64 { return GM_OUTCAP + gm_ndom(domcsv) * GM_DOM_RESERVE + GM_TAIL_RESERVE }
called by 2: maingg_setup calls 1: gm_ndom
90func gm_count_pfx(q: *u8, n: i64, pfx: *u8) -> i64
called by 1: gm_run calls 3: sj_vlensj_lesj_lit_eq
102func gm_count_lines(q: *u8, n: i64) -> i64
called by 1: gm_run calls 1: sj_le
110func gm_lc(c: i64) -> i64 { if c >= GM_LC_A { if c <= GM_LC_Z { return c + GM_LC_D } } return c }
called by 2: gm_has_cigm_str_eq
112func gm_span_eq(q: *u8, s1: i64, e1: i64, s2: i64, e2: i64) -> i64
120func gm_has_ci(q: *u8, s: i64, e: i64, w: *u8) -> i64
called by 2: gm_scoregm_run calls 2: sj_vlengm_lc
138func gm_find(q: *u8, s: i64, e: i64, lit: *u8) -> i64
called by 3: gg_hasgg_intgm_run calls 1: sj_vlen
153func gm_span_has_span(q: *u8, s: i64, e: i64, n: *u8, ns: i64, ne: i64) -> i64
called by 1: gm_status_accept
168func gm_pcol(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64
186func gm_read(path: *u8, buf: *u8, cap: i64, sizep: *i64) -> i64
205func gm_probe(path: *u8) -> i64
called by 1: gm_run calls 2: sys_openat_rdsys_close
213func gm_path(pb: *u8, base: *u8, rel: *u8, q: *u8, s: i64, e: i64, suffix: *u8) -> i64
called by 2: gm_record_gapsgm_run calls 1: sj_cat
227func gm_rec(rec: *i64, i: i64, f: i64) -> i64 { return rec[i * GM_RF + f] }
228func gm_set(rec: *i64, i: i64, f: i64, v: i64) -> i64 { rec[i * GM_RF + f] = v; return 0 }
230func gm_setcol(q: *u8, rec: *i64, i: i64, ls: i64, le: i64, col: i64, fs: i64, sp: *i64) -> i64
called by 1: gm_parse_rungs calls 2: gm_pcolgm_set
236func gm_parse_rungs(q: *u8, n: i64, rec: *i64, cap: i64, dup: *i64, floor: *i64) -> i64
276func gm_log_stats(q: *u8, n: i64, rec: *i64, nr: i64) -> i64
306func gm_str_eq(a: *u8, b: *u8) -> i64
called by 2: maingm_word_dup calls 1: gm_lc
312func gm_word_dup(words: *i64, w: i64) -> i64
called by 2: gm_scoregm_run calls 1: gm_str_eq
319func gm_score(q: *u8, rec: *i64, i: i64, words: *i64, nw: i64) -> i64
called by 1: gm_run calls 3: gm_word_dupgm_has_cigm_rec
338func gm_mrec(m: *i64, i: i64, f: i64) -> i64 { return m[i * GM_MF + f] }
339func 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
341func gm_parse_matrix(q: *u8, n: i64, m: *i64, cap: i64, floor: *i64) -> i64
372func gm_status_matrix(q: *u8, rec: *i64, i: i64, mq: *u8, m: *i64, nm: i64) -> i64
called by 1: gm_run calls 2: gm_recgm_mrec
393func gm_status_accept(q: *u8, rec: *i64, i: i64, dom: *u8, ab: *u8, an: i64, st0: i64) -> i64
422func gm_st_lit(c: i64) -> *u8
called by 1: gm_run
431func gm_blocked(q: *u8, rec: *i64, i: i64, mi: *i64, nm: i64, em: *i64) -> i64
called by 1: gm_order calls 2: gm_recgm_span_eq
460func gm_order(q: *u8, rec: *i64, mi: *i64, nm: i64, order: *i64, cycle: *i64) -> i64
called by 1: gm_run calls 3: sys_mmapgm_blockedgm_rec
492func gm_basename(pb: *u8, q: *u8, s: i64, e: i64) -> i64
called by 1: gm_run
505func gm_room(o: i64, need: i64) -> i64 { if o + need + GM_TAIL_RESERVE <= GM_OUTCAP { return 1 } return 0 }
called by 1: gm_run
559func gr_is_ident(c: i64) -> i64
called by 1: gr_scan_plan_queue
566func gr_name_find(nb: *u8, no: *i64, nl: *i64, nn: i64, s: *u8, ss: i64, se: i64) -> i64
581func gr_name_add(nb: *u8, no: *i64, nl: *i64, nnp: *i64, bp: *i64, s: *u8, ss: i64, se: i64, floor: *i64) -> i64
595func gr_organ_span(q: *u8, s: i64, e: i64, out: *i64) -> i64
608func gr_has_nxpfx(q: *u8, s: i64, e: i64) -> i64
called by 1: gr_scan_invoked calls 1: sj_lit_eq
613func gr_names_from_matrix(q: *u8, n: i64, nb: *u8, no: *i64, nl: *i64, nnp: *i64, bp: *i64, floor: *i64) -> i64
633func gr_names_from_plan(q: *u8, n: i64, nb: *u8, no: *i64, nl: *i64, nnp: *i64, bp: *i64, floor: *i64) -> i64
647func gr_names_from_gates(q: *u8, n: i64, nb: *u8, no: *i64, nl: *i64, nnp: *i64, bp: *i64, floor: *i64) -> i64
662func 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
678func 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
680func gr_conf_load(conf: *u8, paths: *i64, plane: *u8, declared: *i64, unknown: *i64, cad: *i64) -> i64
736func 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
785func 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
834func gr_kind_name(k: i64) -> *u8
called by 1: gm_record_gaps
840func gr_src_name(s: i64) -> *u8
called by 1: gm_record_gaps
851func gm_record_gaps(conf: *u8, out: *u8) -> i64
1069func gm_run(base: *u8, domcsv: *u8, words: *i64, nw: i64, out: *u8) -> i64