code wiki / (root) / nx_sweepgate.nx

nx_sweepgate.nx

buildroot/runtime/nx_sweepgate.nx

23063 B431 linesdepth 5pulls 5 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_sweepgate.nx -- ASK A POPULATION QUESTION BY ITS INVARIANT, AND SEE EVERY SPELLING OF IT. WHY THIS EXISTS, from a measured failure on 2026-08-14. An out-of-bounds allocation bug was swept for with the pattern `sys_mmap(128) as *NxEGraph`. That returned 9 sites in 5 files, and the number was published as the population. It was the population OF ONE SPELLING: the same struct was also being allocated at 256 and at 96, and the 96-byte sites overran a 280-byte struct by 184 bytes -- the WORST sites in the estate, left live by a sweep that reported a clean, confident, complete-looking answer. The true population was 27 sites in 16 files. What eventually surfaced the miss was not another grep; it was the arena's ring detector printing ARENA-OVERRUN while the gate reported 15/15 GREEN. -- A SWEEP THAT MATCHES THE WRONG VALUE REPORTS A CLEAN POPULATION AND LEAVES THE WORST SITES LIVE. THE RULE THIS MAKES MECHANICAL: query by the INVARIANT (`as *NxEGraph`), never by an INSTANCE (`sys_mmap(128) as *NxEGraph`). An instance pattern cannot answer a question about its own siblings, and it fails in the direction of looking finished. So this organ takes the invariant, finds every line, and reports the DISTINCT NUMERIC LITERALS across those lines with their counts. On the real case its first line of output would have been: shapes=3 128 x9 256 x11 96 x6 and the 17 hidden sites are visible before anyone acts on the 9. IT ALSO REFUSES TO CENSUS THROUGH A PARTIAL SCAN. nx_shelltool already prints coverage_complete and corpus_complete; on 2026-08-14 a `matches=0` was read as absence while corpus_complete was 0, and the wrong conclusion was published. Those flags are fields a reader may ignore, so this organ reads them FOR the reader and returns UNPROVEN rather than a number it cannot stand behind. -- A NUMBER THAT MIGHT BE PARTIAL IS MORE DANGEROUS THAN NO NUMBER. COMPOSES nx_shelltool; adds no second scanner. exit 0 SINGLE-SHAPE - 1 SPLIT (the finding) - 3 UNPROVEN (partial coverage, or the tool could not be reached) - 2 usage. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_tool_run.nx nx_sweepgate.nx

imports: nx_tool_run.nx

imported by: nobody (leaf or entry point)

structs

none

consts

33const SG_MAX_SHAPES: i64 = 64
34const SG_CAP: i64 = 1048576
35const SG_COLON: i64 = 58
36const SG_NL: i64 = 10
37const SG_D0: i64 = 48
38const SG_D9: i64 = 57

functions

40func sg_w(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 2: sg_nsg_selftest
41func sg_n(v: i64) -> i64
calls 1: sg_w
48func sg_has(buf: *u8, n: i64, needle: *u8) -> i64 { return tr_contains(buf, n, needle) }
calls 1: tr_contains
54func sg_tally(buf: *u8, n: i64, vals: *i64, cnts: *i64, lines_out: *i64) -> i64
131func sg_selftest() -> i64
calls 1: sg_w
189func sg_census(inv: *u8, dir: *u8, ext: *u8) -> i64
296func sg_dig(b: *u8, o: i64, v: i64, tmp: *u8) -> i64
306func sg_put(b: *u8, o: i64, s: *u8) -> i64
313func sg_log(rows: i64, splits: i64, unproven: i64, verdict: *u8) -> i64
348func sg_watch() -> i64
412func main(argc: i64, argv: *i64) -> i64