nx_refusal_shape_lib.nx
buildroot/runtime/nx_refusal_shape_lib.nx
about
nx_refusal_shape_lib.nx -- DOES THIS REFUSAL NAME ITS SUBJECT AND ITS REMEDY?
FM11 of /compare/failmodes: the MECHANIZABLE half of the tenth cell, LOUD-AND-CORRECT. The
taxonomy lane established that EMITTER QUALITY and CALLER RESPONSE are two INDEPENDENT AXES and
proved it with one instance that scores on both at once: nx_fs read declares its truncation cap
AND its remedy in its last line (emitter CORRECT) while the reader filtered that line out and
filed it as a critical defect (caller IGNORED). A single axis keyed on "did the caller obey"
would file that instance under LOUD-AND-IGNORED and exclude the very case that motivated the
cell.
THIS LIBRARY OWNS THE EMITTER HALF ONLY, AND THAT SCOPE IS DELIBERATE.
The caller half -- did anyone act on the refusal -- is CENSUS-ONLY over the call record and is
explicitly OUT OF SCOPE here, because a refusal that callers routinely retry through is
LOUD-AND-IGNORED however well written it is. No function in this file may be read as evidence
about a caller.
WHY A LIBRARY AND NOT A SECOND ORGAN. The census verb lives in nx_failclass (fc_refusal_shape)
and the gate lives in nx_refusal_shape_gate, and the two MUST agree about what "shaped" means.
They agree BY CONSTRUCTION rather than by discipline: there is exactly ONE classifier
(rs_bucket), ONE block builder and ONE vocabulary loader, and both consumers import them.
THE UNIT IS THE COMPOSED EMISSION, NOT THE STRING LITERAL, AND THAT IS THE WHOLE DESIGN.
Measured on the canonical guard before a line was written: nx_tools_api.nx builds the truncation
envelope from THREE pieces --
b = ta_cat(jb, b, " [NX-TRUNCATED OUTPUT-IS-PARTIAL capture_cap=" as *u8)
b = ta_catn(jb, b, xcap)
b = ta_cat(jb, b, " -- narrow the query or re-run with _async=1]" as *u8)
-- so the refusal marker and its remedy live in DIFFERENT LITERALS with a non-literal line
between them. A per-literal checker would flag a KNOWN-GOOD GUARD, and
* A SHAPE CHECKER THAT FLAGS A KNOWN-GOOD GUARD IS WORSE THAN NONE, BECAUSE SOMEONE WILL ACT ON
IT. *
So a MESSAGE here is a BLOCK: a run of consecutive source lines carrying string literals,
tolerating up to max_gap_lines literal-free lines, broken HARD by a blank line, a comment line,
or a line whose first non-space character closes a scope. The brace break is what stops a block
borrowing an unrelated neighbour's remedy, and it is bite-proven in the gate.
COMMENTS ARE NOT SCANNED. A source-scanning detector finds the PROSE DESCRIBING the defect and
accuses the author who documented it -- prose is source bytes too. Comment lines are hard breaks
and no literal is ever harvested from one.
dependencies 2 imports · 3 importers
imports: nx_syscalls.nxnx_gatekit_lib.nx
imported by: nx_emitmap.nxnx_failclass.nxnx_refusal_shape_gate.nx
structs
| none |
consts
| 67 | const RS_TAB: i64 = 9 |
| 68 | const RS_NL: i64 = 10 |
| 69 | const RS_SP: i64 = 32 |
| 70 | const RS_QUOTE: i64 = 34 |
| 71 | const RS_HASH: i64 = 35 |
| 72 | const RS_MINUS: i64 = 45 |
| 73 | const RS_SLASH: i64 = 47 |
| 74 | const RS_COLON: i64 = 58 |
| 75 | const RS_SEMI: i64 = 59 |
| 76 | const RS_LT: i64 = 60 |
| 77 | const RS_EQ: i64 = 61 |
| 78 | const RS_GT: i64 = 62 |
| 79 | const RS_USCORE: i64 = 95 |
| 80 | const RS_BSLASH: i64 = 92 |
| 81 | const RS_BAR: i64 = 124 |
| 82 | const RS_RBRACE: i64 = 125 |
| 83 | const RS_DOT: i64 = 46 |
| 84 | const RS_MODE_0644: i64 = 420 |
| 88 | const RS_B_SHAPED: i64 = 0 |
| 89 | const RS_B_NOREMEDY: i64 = 1 |
| 90 | const RS_B_NOSUBJECT: i64 = 2 |
| 91 | const RS_B_BARE: i64 = 3 |
| 92 | const RS_B_UNKNOWN: i64 = 4 |
| 105 | const RS_B_TEST: i64 = 5 |
| 106 | const RS_B_USAGE: i64 = 6 |
| 107 | const RS_NBUCKET: i64 = 7 |
| 111 | const RS_R_FILES: i64 = 0 |
| 112 | const RS_R_BYTES: i64 = 1 |
| 113 | const RS_R_BLOCKS: i64 = 2 |
| 114 | const RS_R_POP: i64 = 3 |
| 115 | const RS_R_BUCKET0: i64 = 4 // .. RS_R_BUCKET0 + RS_NBUCKET - 1 |
| 116 | const RS_R_TRUNC: i64 = 11 |
| 117 | const RS_R_UNREADABLE: i64 = 12 |
| 118 | const RS_R_WANTBUCKET: i64 = 13 |
| 119 | const RS_R_WANTLINE: i64 = 14 |
| 120 | const RS_R_WANTHITS: i64 = 15 |
| 121 | const RS_R_OFFENDERS: i64 = 16 |
| 122 | const RS_RLEN: i64 = 20 |
| 126 | const RS_MAXVOC: i64 = 512 |
| 127 | const RS_V_NMARK: i64 = 0 |
| 128 | const RS_V_NREM: i64 = 1 |
| 129 | const RS_V_MAXGAP: i64 = 2 |
| 130 | const RS_V_MINMSG: i64 = 3 |
| 131 | const RS_V_REJECT: i64 = 4 |
| 132 | const RS_V_OVER: i64 = 5 // vocabulary cap reached -> the vocabulary is a FLOOR |
| 133 | const RS_V_NEXCL: i64 = 6 // declared self-fixture exclusions |
| 134 | const RS_V_EXCOUNT: i64 = 7 // files actually skipped by those exclusions |
| 135 | const RS_V_BASE: i64 = 8 // markers: (off,len) pairs from here |
| 136 | const RS_V_REMBASE: i64 = 1032 // RS_V_BASE + 2 * RS_MAXVOC |
| 137 | const RS_V_MKHIT: i64 = 2056 // RS_V_REMBASE + 2 * RS_MAXVOC: per-marker first-fired tally |
| 138 | const RS_V_RMHIT: i64 = 2568 // RS_V_MKHIT + RS_MAXVOC: per-remedy first-fired tally |
| 139 | const RS_V_EXBASE: i64 = 3080 // RS_V_RMHIT + RS_MAXVOC: exclusion (off,len) pairs |
| 140 | const RS_V_PASSBASE: i64 = 4104 // RS_V_EXBASE + 2 * RS_MAXVOC: positive-outcome tokens |
| 141 | const RS_V_FAILBASE: i64 = 5128 // RS_V_PASSBASE + 2 * RS_MAXVOC: negative-outcome tokens |
| 142 | const RS_V_SRBASE: i64 = 6152 // RS_V_FAILBASE + 2 * RS_MAXVOC: self-remedy (usage) phrases |
| 143 | const RS_V_NPASS: i64 = 7176 // scalars appended after the tables, never wedged before them |
| 144 | const RS_V_NFAIL: i64 = 7177 |
| 145 | const RS_V_NSR: i64 = 7178 |
| 146 | const RS_V_LEN: i64 = 7184 |
| 151 | const RS_MAXF: i64 = 32768 |
| 152 | const RS_STRIDE: i64 = 256 |
| 153 | const RS_SLACK: i64 = 65536 |
| 154 | const RS_PREVIEW: i64 = 160 |
| 155 | const RS_ROW_MAX: i64 = 1024 |
| 156 | const RS_OUT_PER_FILE: i64 = 8192 // worklist headroom per source file; a bind ANNOUNCES |
| 157 | const RS_NUMBUF: i64 = 64 |
| 158 | const RS_PATHBUF: i64 = 4096 |
| 159 | const RS_SMALL: i64 = 16 |
| 853 | const RS_RATCHET_ALLOW: i64 = 0 |
| 854 | const RS_RATCHET_REFUSE: i64 = 1 |
| 855 | const RS_RATCHET_UNMEAS: i64 = 3 |
| 902 | const RS_FNV_OFFSET: i64 = 2166136261 |
| 903 | const RS_FNV_PRIME: i64 = 16777619 |
| 904 | const RS_HASH_MASK32: i64 = 4294967295 |
| 905 | const RS_HASH_LOAD: i64 = 4 // 4x headroom keeps linear probing short |
functions
| 161 | func rs_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 162 | func rs_err(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(2, s, n); return 0 } |
| 164 | func rs_putn(v: i64) -> i64 |
| 172 | func rs_lower(c: i64) -> i64 |
| 178 | func rs_wordch(c: i64) -> i64 |
| 189 | func rs_find_word(hay: *u8, hs: i64, he: i64, nee: *u8, nlen: i64) -> i64 |
| 225 | func rs_has_particular(buf: *u8, s: i64, e: i64) -> i64 |
| 281 | func rs_bucket(blen: i64, minmsg: i64, subj: i64, rem: i64, testassert: i64, usage: i64) -> i64 |
| 293 | func rs_bucket_name(b: i64) -> *u8 |
| 308 | func rs_is_offender(b: i64) -> i64 |
| 323 | func rs_range_eq(buf: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 334 | func rs_find_byte(buf: *u8, s: i64, e: i64, b: i64) -> i64 |
| 343 | func rs_atoi(buf: *u8, s: i64, e: i64) -> i64 called by 1: rs_conf_load |
| 361 | func rs_conf_load(confp: *u8, clen: *i64, voc: *i64) -> *u8 |
| 489 | func rs_vocab_hit(conf: *u8, voc: *i64, base: i64, n: i64, hay: *u8, hs: i64, he: i64) -> i64 |
| 504 | func rs_line_lits(buf: *u8, s: i64, e: i64, blk: *u8, bo0: i64, blkcap: i64) -> i64 |
| 543 | func rs_block_emit(blk: *u8, bo: i64, bline: i64, path: *u8, conf: *u8, voc: *i64, res: *i64, out: *u8, outcap: i64, oo: *i64, want: *u8) -> i64 called by 1: rs_file_scan calls 9: rs_vocab_hitrs_has_particularrs_bucketrs_is_offenderrs_find_wordgk_len+3 |
| 607 | func rs_file_scan(path: *u8, conf: *u8, voc: *i64, res: *i64, out: *u8, outcap: i64, oo: *i64, want: *u8) -> i64 called by 2: rsg_scan1rs_scan_list calls 7: sys_mmapsys_read_filesys_munmapgk_eolrs_line_litsrs_block_emit+1 |
| 680 | func rs_path_is(path: *u8, conf: *u8, off: i64, len: i64) -> i64 |
| 698 | func rs_excluded(path: *u8, conf: *u8, voc: *i64) -> i64 |
| 709 | func rs_scan_list(names: *u8, n: i64, conf: *u8, voc: *i64, res: *i64, out: *u8, outcap: i64, oo: *i64, want: *u8) -> i64 |
| 721 | func rs_res_new() -> *i64 |
| 731 | func rs_report(conf: *u8, res: *i64, voc: *i64, outp: *u8, wrote: i64) -> i64 |
| 811 | func rs_scan(confp: *u8, outp: *u8, res: *i64, want: *u8) -> i64 called by 2: fc_refusal_shapefc_refusal_beat calls 11: sys_mmaprs_conf_loadgk_corpus_scanrs_errrs_putsrs_putn+5 |
| 868 | func rs_bucket_id(buf: *u8, s: i64, e: i64) -> i64 |
| 879 | func rs_row_name(buf: *u8, s: i64, e: i64, span: *i64) -> i64 |
| 907 | func rs_name_hash(buf: *u8, s: i64, e: i64) -> i64 |
| 918 | func rs_name_eq(a: *u8, as0: i64, ae: i64, b: *u8, bs: i64, be: i64) -> i64 |
| 929 | func rs_name_index(bl: *u8, blen: i64, hs: *i64, he: *i64, hcap: i64) -> i64 |
| 953 | func rs_name_in(bl: *u8, hs: *i64, he: *i64, hcap: i64, needle: *u8, ns: i64, ne: i64) -> i64 |
| 965 | func rs_ratchet(worklistp: *u8, baselinep: *u8) -> i64 called by 3: fc_refusal_beatmainmain calls 12: sys_mmapsys_read_filers_putsgk_eolrs_row_namers_putn+6 |