nx_emitmap.nx
buildroot/runtime/nx_emitmap.nx
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
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
structs
| none |
consts
| 38 | const EM_OUT: *u8 = "knowledge/status/emitmap.tsv" |
| 39 | const EM_MAXF: i64 = 32768 // corpus files: gk_corpus_scan REFUSES past this, it never truncates |
| 40 | const EM_STRIDE: i64 = 256 // bytes per corpus path slot (gk_dirscan refuses a path that does not fit) |
| 41 | const EM_PREVIEW: i64 = 512 // bytes of a block kept for matching; a cut is counted and marked |
| 42 | const EM_ROW_FIXED: i64 = 64 // tabs, kind, the line number and the newline of one row |
| 43 | const EM_FUNC_CAP: i64 = 128 // a function name slot (a longer name is cut and announced in the row) |
| 44 | const EM_IDENT_CAP: i64 = 128 // a constant name slot |
| 45 | const EM_TAB: i64 = 9 |
| 46 | const EM_NL: i64 = 10 |
| 47 | const EM_SP: i64 = 32 |
| 48 | const EM_QUOTE: i64 = 34 |
| 49 | const EM_LPAREN: i64 = 40 |
| 50 | const EM_COLON: i64 = 58 |
| 51 | const EM_EQ: i64 = 61 |
| 52 | const EM_USCORE: i64 = 95 |
| 53 | const EM_RBRACE: i64 = 125 |
| 54 | const EM_SLASH: i64 = 47 |
| 55 | const EM_DOT: i64 = 46 |
| 56 | const EM_EXIT_NONE: i64 = 1 |
| 57 | const EM_EXIT_ABSENT: i64 = 3 |
functions
| 59 | func 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 } |
| 60 | func 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 } |
| 61 | func em_is_ident(c: i64) -> i64 |
| 69 | func em_is_bound_name(buf: *u8, s: i64, e: i64) -> i64 called by 1: em_file_scan |
| 78 | func em_relpath(p: *u8) -> *u8 |
| 92 | func em_skip_ws(buf: *u8, p: i64, eol: i64) -> i64 |
| 104 | func em_ident_end(buf: *u8, i: i64, eol: i64) -> i64 |
| 111 | func em_const_value(buf: *u8, from: i64, eol: i64, out: *u8, o0: i64) -> i64 |
| 137 | func em_field_start(b: *u8, p: i64, eol: i64, f: i64) -> i64 called by 1: em_query |
| 148 | func em_field_end(b: *u8, s: i64, eol: i64) -> i64 called by 1: em_query |
| 154 | func em_row_head(o0: i64, out: *u8, kind: i64, rel: *u8, line: i64, fn: *u8) -> i64 |
| 167 | func em_block_row(out: *u8, o0: i64, rel: *u8, bline: i64, fn: *u8, blk: *u8, bo: i64, st: *i64) -> i64 |
| 184 | func em_file_scan(path: *u8, fd: i64, st: *i64) -> i64 |
| 284 | func em_census(outp: *u8) -> i64 |
| 330 | func em_query(artp: *u8, verb: i64, needle: *u8) -> i64 |
| 369 | func main(argc: i64, argv: *i64) -> i64 |