code wiki / (root) / nx_emitmap.nx

nx_emitmap.nx

buildroot/runtime/nx_emitmap.nx

20591 B395 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_emitmap.nx -- EMISSION PROVENANCE: which function emits this text, and which constant bounds this buffer. WHY (operator 2026-08-23: "you shouldn't have to do so much finding -- we should have everything including documentation and instructions"): the MCP transport answered a bare `{}` to any tools/call payload >= 63 KB, and locating the cause took a dozen manual reads -- the serve loop's one sys_read at TSV_REQ_CAP, the loop reader it never composed, the edge's 413 path. MEASURED BEFORE BUILDING (the spend gate's own instruments): nx_codewiki_ask ranks prose (json_emit, nx_bodyparts), nx_capsearch ranks tool titles, a literal grep over the whole corpus finds "{}" at 11 sites and NONE in the transport, because that body is a COMPOSED emission (byte codes, not a literal), and nx_forkcensus indexes only `.elf` path literals. No incumbent answers the two questions this organ answers in ONE call each: nx_emitmap find <text> [artifact] -> every source block whose COMPOSED emitted text contains <text>, as file:line function (exit 0 found, 1 none, 3 artifact absent) nx_emitmap bound <CONST> [artifact] -> the definition of a *_CAP / *_MAX constant and every line that reads it, as file:line function (exit 0 found, 1 none, 3 artifact absent) nx_emitmap census [artifact] -> (re)build the index over the WHOLE compile corpus (exit 0; 1 REFUSED when the corpus exceeds the enumerator's declared slot table -- a refusal, never a silently truncated census) COMPOSED, NOT LITERAL: emitted text is harvested per line by nx_refusal_shape_lib's rs_line_lits (the one literal harvester the failmodes census already trusts: in-string state, escapes, `//` inside a url) and glued across CONSECUTIVE emitting lines inside one function, so a message built from three literals is one block -- the same unit fc_refusal_shape proved necessary. DECLARED BLIND SPOT: bytes emitted as numeric codes (wc(123) for '{') carry no literal and are not indexed; `find "{}"` therefore cannot name an emitter that composes braces from codes, and says so rather than answering from the nearest literal. THE ARTIFACT knowledge/status/emitmap.tsv (truncate-write via tmp + fsync + rename; ONE writer): E<TAB>file:line<TAB>function<TAB>preview a composed emission block (preview capped, see stamp) C<TAB>file:line<TAB>function<TAB>CONST<TAB>value a *_CAP/*_MAX constant DEFINITION R<TAB>file:line<TAB>function<TAB>CONST a READ of a *_CAP/*_MAX constant last line, anchored BY POSITION: # asof=<epoch> files=N bytes=N blocks=N consts=N reads=N unreadable=N preview_cap=512 previews_cut=N corpus_complete=1 EVERY BOUND IS NAMED AND ANNOUNCED: the corpus slot table is the enumerator's REFUSE-never-truncate cap (EM_MAXF, the same figure nx_gateadjudicate declares); the preview cap exists because a block can be a whole HTML template and a query needle is a sentence -- every cut block is counted in the stamp and marked. license_tier: ORIGINAL Read-only over the estate except its one artifact. No hw writes (Rule 26).

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gatekit_lib.nx nx_refusal_shape_lib.nx nx_emitmap.nx

imports: nx_syscalls.nxnx_gatekit_lib.nxnx_refusal_shape_lib.nx

imported by: nobody (leaf or entry point)

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

main em_puts sys_write gk_streq em_census sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gk_corpus_scan sys_mmap ↻ gk_corpus_root sys_mmap ↻ gk_cat gk_exists sys_openat_rd sys_close gk_corpus_hdl gk_corpus_root ↻ gk_len gk_cat ↻ gk_dirscan gk_dirscan_ext sys_openat_rd ↻ sys_mmap ↻ gk_ext_is gk_len ↻ gk_cat ↻ gk_exists ↻

structs

none

consts

38const EM_OUT: *u8 = "knowledge/status/emitmap.tsv"
39const EM_MAXF: i64 = 32768 // corpus files: gk_corpus_scan REFUSES past this, it never truncates
40const EM_STRIDE: i64 = 256 // bytes per corpus path slot (gk_dirscan refuses a path that does not fit)
41const EM_PREVIEW: i64 = 512 // bytes of a block kept for matching; a cut is counted and marked
42const EM_ROW_FIXED: i64 = 64 // tabs, kind, the line number and the newline of one row
43const EM_FUNC_CAP: i64 = 128 // a function name slot (a longer name is cut and announced in the row)
44const EM_IDENT_CAP: i64 = 128 // a constant name slot
45const EM_TAB: i64 = 9
46const EM_NL: i64 = 10
47const EM_SP: i64 = 32
48const EM_QUOTE: i64 = 34
49const EM_LPAREN: i64 = 40
50const EM_COLON: i64 = 58
51const EM_EQ: i64 = 61
52const EM_USCORE: i64 = 95
53const EM_RBRACE: i64 = 125
54const EM_SLASH: i64 = 47
55const EM_DOT: i64 = 46
56const EM_EXIT_NONE: i64 = 1
57const EM_EXIT_ABSENT: i64 = 3

functions

59func em_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 3: em_censusem_querymain calls 1: sys_write
60func em_putn(v: i64) -> i64 { let b: *u8 = sys_mmap(32); let n: i64 = gk_catn(b, 0, v); sys_write(1, b, n); sys_munmap(b, 32); return 0 }
61func em_is_ident(c: i64) -> i64
69func em_is_bound_name(buf: *u8, s: i64, e: i64) -> i64
called by 1: em_file_scan
78func em_relpath(p: *u8) -> *u8
called by 1: em_file_scan calls 1: gk_len
92func em_skip_ws(buf: *u8, p: i64, eol: i64) -> i64
104func em_ident_end(buf: *u8, i: i64, eol: i64) -> i64
called by 1: em_file_scan calls 1: em_is_ident
111func em_const_value(buf: *u8, from: i64, eol: i64, out: *u8, o0: i64) -> i64
called by 1: em_file_scan calls 1: em_skip_ws
137func em_field_start(b: *u8, p: i64, eol: i64, f: i64) -> i64
called by 1: em_query
148func em_field_end(b: *u8, s: i64, eol: i64) -> i64
called by 1: em_query
154func em_row_head(o0: i64, out: *u8, kind: i64, rel: *u8, line: i64, fn: *u8) -> i64
167func em_block_row(out: *u8, o0: i64, rel: *u8, bline: i64, fn: *u8, blk: *u8, bo: i64, st: *i64) -> i64
called by 1: em_file_scan calls 2: em_row_headgk_cat
184func em_file_scan(path: *u8, fd: i64, st: *i64) -> i64
284func em_census(outp: *u8) -> i64
330func em_query(artp: *u8, verb: i64, needle: *u8) -> i64
369func main(argc: i64, argv: *i64) -> i64