code wiki / (root) / nx_io_envelope_census.nx

nx_io_envelope_census.nx

buildroot/runtime/nx_io_envelope_census.nx

92249 B1564 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind tooltopic io
docsdependenciesstructsconstsfunctions

about

nx_io_envelope_census.nx -- EVERY CAPPED READER ANNOUNCES OR DERIVES (/compare/dataio DI2, 2026-09-05). THE CLASS: a read into a buffer whose length is a CONSTANT silently returns a PREFIX of anything larger, and the caller reports success. Measured on the day this was written: the literal 4194304 appears 1,430 times in 717 source files; the action miner's mine/freq/harden verbs read a 54 MB journal through a 4 MiB head for weeks; the ledger lib behind the estate's idempotency keys read its ledger through 262,144 bytes. Each was a correct program reading the wrong amount and saying nothing. The fix for a file read is sys_read_file (it sizes from the file and cannot short- read); the fix for a genuinely unknowable size (a stream) is a NAMED cap whose truncation ANNOUNCES itself. THIS ORGAN MEASURES WHERE THE ESTATE STANDS ON THAT, whole population, and makes SILENT the worklist: sys_read( fd, buf, LEN ) call sites, LEN classified as LITERAL a decimal literal -> FIXED NAMED an ALL-CAPS identifier declared `const NAME: i64 = <decimal>` in the same file -> FIXED DYNAMIC anything else (a computed remainder, a variable, an unresolved name) -> NOT JUDGED here a FIXED site is ANNOUNCING when its file carries an envelope token that tells the reader the read may be partial (TRUNCATED, OUTPUT-IS-PARTIAL, coverage_complete, capture_cap, scan_cap, truncated=, partial=), else SILENT. sys_read_file( call sites are counted on a SEPARATE axis as DERIVED (the remedy, adopted). COMPOSES, NEVER DUPLICATES: the walk is nx_shelltool grep (the estate's budgeted, envelope-honest walker -- its own coverage_complete / corpus_complete are read and PROPAGATED, so a partial walk yields UNPROVEN, never a smaller number that reads as better news); code-vs-prose is jc_strip_noncode from nx_cap_detect_lib (the same stripper the silent-cap detector uses), so a `sys_read(` inside a string or a comment is never a site. LOOPED (DI12, 2026-09-06) a read INSIDE a while block, or one whose result variable is the subject of a `while <v> > 0` / `while <v> != 0` in the same file: the streaming idiom that consumes to EOF -> NOT JUDGED. The first census put nx_sizeguard's own read loop on the SILENT worklist -- a correct streaming reader named as a capped one -- so the class is separated and counted, never acquitted (a loop that breaks early is still a cap; the loop's exit is not inspected here). RATCHET (DI12 ie_ratchet): the SILENT set is a NAMED SET in knowledge/status/io_envelope_silent.baseline, one row per site, keyed `path<TAB>k<TAB>text<TAB>line` where text is the stripped, whitespace-collapsed source line and k its ordinal among identical lines in that file -- so an edit ABOVE a site does not change its identity (a file:line key turned every conversion into a spurious rise plus a spurious fall; the line number is carried for humans only). A RISE (a silent site not in the baseline) is RED and NAMED, and the baseline is NOT rewritten (a ratchet that rewrites its baseline on a rise launders itself green); a FALL (a baseline site no longer silent) is NAMED with what it became now (converted / announced / dynamic / looped), journaled to knowledge/status/io_envelope_ratchet.jrnl, and the baseline is TIGHTENED to the rows that remain (a ratchet that does not tighten when you improve is a threshold). --accept rewrites the baseline to the current set deliberately. A legacy `path:line` baseline is matched by line once and MIGRATED to the keyed form. A count-only ratchet on a shared tree reports a regression without saying whose. FALSE-POSITIVE RATE (DI12): derived from the ledger, never asserted. A site that LEFT the set as converted/announced/ dynamic was a true positive (a real capped reader got fixed); one that left as `looped` was the OLD ruler's false positive; a hand row `kind=false site=<path:line> reason=<why>` adjudicates a standing site as bounded by construction. false_positive_permil = fp * 1000 / (tp + fp), printed UNMEASURED while nothing is adjudicated.

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_tool_run.nx nx_gate_verdict.nx nx_cap_detect_lib.nx nx_io_envelope_census.nx

imports: nx_syscalls.nxnx_tool_run.nxnx_gate_verdict.nxnx_cap_detect_lib.nx

imported by: nobody (leaf or entry point)

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

main ie_streq ie_selftest gv_ctr 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 ↻ gv_head gv_puts sys_write ↻ sys_mmap ↻ gv_check_eq gv_check gv_puts ↻ gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap ie_classify_src sys_mmap ↻ jc_strip_noncode ie_classify ie_line_off ie_line_end ie_site_on_line ie_line_end ↻ jc_match_at

structs

none

consts

52const IE_GREP_CAP: i64 = 8388608 // the walker's output is a STREAM of unknown size: a NAMED cap, and hitting it ANNOUNCES (cap_hit=1 -> UNPROVEN)
53const IE_SILENT_CAP: i64 = 1048576 // the silent-site worklist buffer; overflow is COUNTED (silent_overflow), never dropped in silence
54const IE_PATH_CAP: i64 = 1024
55const IE_NAME_CAP: i64 = 128
56const IE_MODE_644: i64 = 420
57const IE_EXIT_GREEN: i64 = 0
58const IE_EXIT_RED: i64 = 1
59const IE_EXIT_UNPROVEN: i64 = 3
60const IE_EXIT_USAGE: i64 = 2
61const IE_BASELINE: *u8 = "knowledge/status/io_envelope_silent.baseline" as *u8
62const IE_LEDGER: *u8 = "knowledge/status/io_envelope_ratchet.jrnl" as *u8
63const IE_STATUS: *u8 = "knowledge/status/io_envelope.status" as *u8
64const IE_TAB: i64 = 9
65const IE_TEXT_CAP: i64 = 1024 // a key's text field; a longer source line is cut here (the cut is deterministic, so the key still identifies the site)
66const IE_ROW_CAP: i64 = 2048
67const IE_FIX_DIR: *u8 = "/tmp/nx_io_envelope_census" as *u8
68const IE_MODE_755: i64 = 493
69const IE_BS_CREATED: i64 = 0
70const IE_BS_PRESENT: i64 = 1
71const IE_BS_REWRITTEN: i64 = 2
72const IE_BS_TIGHTENED: i64 = 3
73const IE_BS_MIGRATED: i64 = 4
74const IE_FP_UNMEASURED: i64 = 0 - 1
75const IE_SHELLTOOL: *u8 = "./nx_shelltool.elf" as *u8
76const IE_DEFAULT_ROOT: *u8 = "buildroot/runtime" as *u8
79const IE_NOT_A_SITE: i64 = 0 // the hit was inside a string or a comment, or the line could not be located
80const IE_LITERAL_ANN: i64 = 1
81const IE_LITERAL_SILENT: i64 = 2
82const IE_NAMED_ANN: i64 = 3
83const IE_NAMED_SILENT: i64 = 4
84const IE_DYNAMIC: i64 = 5
85const IE_LOOPED: i64 = 6
93const IE_LOOP_STREAMING: i64 = 1
94const IE_LOOP_CAPPED: i64 = 2
95const IE_LOOP_UNJUDGED: i64 = 3
96const IE_BOUND_CAP: i64 = 64

functions

98func ie_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
99func ie_putn(v: i64) -> i64
112func ie_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
113func ie_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; var oo: i64 = o; while s[i] != (0 as u8) { d[oo] = s[i]; oo = oo + 1; i = i + 1 } d[oo] = 0 as u8; return oo }
114func ie_catn(d: *u8, o: i64, v: i64) -> i64
126func ie_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] == b[i] { if a[i] == (0 as u8) { return 1 } i = i + 1 } return 0 }
called by 2: ie_now_classmain
127func ie_find(q: *u8, n: i64, lit: *u8) -> i64 { return jc_find_sub(q, n, lit, ie_slen(lit)) }
128func ie_is_digit(c: i64) -> i64 { if c >= 48 { if c <= 57 { return 1 } } return 0 }
129func ie_is_upper_ident(c: i64) -> i64 { if c >= 65 { if c <= 90 { return 1 } } if c == 95 { return 1 } return ie_is_digit(c) }
131func ie_skip_spaces(buf: *u8, e: i64, p: i64) -> i64 { var i: i64 = p; var go: i64 = 1; while go == 1 { if i >= e { go = 0 } else { if buf[i] == (32 as u8) { i = i + 1 } else { go = 0 } } } return i }
133func ie_line_end(buf: *u8, n: i64, p: i64) -> i64 { var i: i64 = p; var go: i64 = 1; while go == 1 { if i >= n { go = 0 } else { if buf[i] == (10 as u8) { go = 0 } else { i = i + 1 } } } return i }
135func ie_line_off(buf: *u8, n: i64, ln: i64) -> i64
154func ie_walker_env(gout: *u8, gn: i64, out: *i64) -> i64
174func ie_int_after(buf: *u8, n: i64, needle: *u8) -> i64
191func ie_file_announces(raw: *u8, n: i64) -> i64
203func ie_const_value(code: *u8, n: i64, name: *u8, nl: i64) -> i64
243func ie_is_ident(c: i64) -> i64 { if c >= 97 { if c <= 122 { return 1 } } return ie_is_upper_ident(c) }
245func ie_span_has(code: *u8, s: i64, e: i64, lit: *u8) -> i64 { if e <= s { return 0 } return jc_find_sub(((code as i64) + s) as *u8, e - s, lit, ie_slen(lit)) }
247func ie_line_start(code: *u8, p: i64) -> i64 { var i: i64 = p; var go: i64 = 1; while go == 1 { if i <= 0 { go = 0 } else { if code[i - 1] == (10 as u8) { go = 0 } else { i = i - 1 } } } return i }
251func ie_in_while(code: *u8, lo: i64) -> i64
269func ie_assigned_var(code: *u8, lo: i64, site: i64, name: *u8) -> i64
312func ie_read_args_running(code: *u8, n: i64, site: i64) -> i64
called by 1: ie_is_looped
331func ie_is_looped(code: *u8, n: i64, lo: i64, site: i64) -> i64
360func ie_is_looped_src(raw: *u8, n: i64, ln: i64) -> i64
370func ie_site_on_line(code: *u8, n: i64, lo: i64) -> i64
378func ie_line_of(buf: *u8, at: i64) -> i64
called by 1: ie_loop_exit
392func ie_canon_span(code: *u8, s: i64, e: i64, out: *u8) -> i64
438func ie_enclosing_while(code: *u8, lo: i64) -> i64
456func ie_block_end(code: *u8, n: i64, ob: i64) -> i64
called by 1: ie_loop_span_end
468func ie_loop_span_end(code: *u8, n: i64, ws: i64) -> i64
476func ie_span_eof(code: *u8, s: i64, e: i64, name: *u8) -> i64
492func ie_is_lower(c: i64) -> i64 { if c >= 97 { if c <= 122 { return 1 } } return 0 }
494func ie_token_is_bound(code: *u8, ts: i64, te: i64) -> i64
513func ie_span_bound(code: *u8, s: i64, e: i64, bound: *u8) -> i64
539func ie_loop_exit(code: *u8, n: i64, ln: i64, bound: *u8) -> i64
570func jc_find_sub_at(code: *u8, n: i64, pat: *u8, pl: i64) -> i64
called by 1: ie_loop_exit calls 1: jc_match_at
575func ie_loop_exit_src(raw: *u8, n: i64, ln: i64, bound: *u8) -> i64
582func ie_loop_worklist(code: *u8, raw: *u8, n: i64, ln: i64, bound: *u8) -> i64
587func ie_loop_worklist_src(raw: *u8, n: i64, ln: i64, bound: *u8) -> i64
592func ie_loop_name(lx: i64) -> *u8
599func ie_key_text(code: *u8, n: i64, ln: i64, dst: *u8) -> i64
621func ie_field(buf: *u8, rs: i64, re: i64, idx: i64, sp: *i64) -> i64
637func ie_span_eq(buf: *u8, s: i64, e: i64, lit: *u8) -> i64 { let ll: i64 = ie_slen(lit); if e - s != ll { return 0 } return jc_match_at(buf, s, lit, ll) }
called by 1: ie_count_same calls 2: ie_slenjc_match_at
639func ie_count_same(silent: *u8, so: i64, path: *u8, text: *u8) -> i64
655func ie_row_put(silent: *u8, so: i64, path: *u8, k: i64, text: *u8, ln: i64) -> i64
called by 2: ie_scanie_selftest calls 2: ie_catie_catn
670func ie_classify(code: *u8, raw: *u8, n: i64, ln: i64, out_val: *i64) -> i64
737func ie_classify_src(raw: *u8, n: i64, ln: i64, out_val: *i64) -> i64
745func ie_file_len(path: *u8) -> i64
called by 1: ie_selftest calls 2: sys_mmapsys_read_file
752func ie_file_eq(path: *u8, s: *u8, n: i64) -> i64
called by 1: ie_selftest calls 2: sys_mmapsys_read_file
761func ie_write_file(path: *u8, s: *u8, n: i64) -> i64
768func ie_ledger_append(ledger: *u8, row: *u8) -> i64
776func ie_class_name(cls: i64) -> *u8
called by 1: ie_now_class
786func ie_now_class(path: *u8, k: i64, text: *u8, ln: i64, legacy: i64) -> *u8
812func ie_rate(ledger: *u8, out: *i64) -> i64
835func ie_ratchet(silent: *u8, so: i64, baseline: *u8, ledger: *u8, accept: i64, out: *i64) -> i64
1043func ie_scan(root: *u8, accept: i64) -> i64
1263func ie_selftest() -> i64
1424func ie_worklist_scan(bb: *u8, n: i64, files: *i64, counts: *i64) -> i64 { return ie_worklist_group(bb, n, 0, files, counts) }
1427func ie_worklist_group(bb: *u8, n: i64, field: i64, files: *i64, counts: *i64) -> i64
1456func ie_worklist(baseline: *u8) -> i64
1547func main(argc: i64, argv: *i64) -> i64