code wiki / (root) / nx_refusal_shape_lib.nx

nx_refusal_shape_lib.nx

buildroot/runtime/nx_refusal_shape_lib.nx

49186 B1087 linesdepth 3pulls 3 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gatekit_lib.nx nx_refusal_shape_lib.nx nx_emitmap.nx nx_failclass.nx nx_refusal_shape_gate.nx

imports: nx_syscalls.nxnx_gatekit_lib.nx

imported by: nx_emitmap.nxnx_failclass.nxnx_refusal_shape_gate.nx

structs

none

consts

67const RS_TAB: i64 = 9
68const RS_NL: i64 = 10
69const RS_SP: i64 = 32
70const RS_QUOTE: i64 = 34
71const RS_HASH: i64 = 35
72const RS_MINUS: i64 = 45
73const RS_SLASH: i64 = 47
74const RS_COLON: i64 = 58
75const RS_SEMI: i64 = 59
76const RS_LT: i64 = 60
77const RS_EQ: i64 = 61
78const RS_GT: i64 = 62
79const RS_USCORE: i64 = 95
80const RS_BSLASH: i64 = 92
81const RS_BAR: i64 = 124
82const RS_RBRACE: i64 = 125
83const RS_DOT: i64 = 46
84const RS_MODE_0644: i64 = 420
88const RS_B_SHAPED: i64 = 0
89const RS_B_NOREMEDY: i64 = 1
90const RS_B_NOSUBJECT: i64 = 2
91const RS_B_BARE: i64 = 3
92const RS_B_UNKNOWN: i64 = 4
105const RS_B_TEST: i64 = 5
106const RS_B_USAGE: i64 = 6
107const RS_NBUCKET: i64 = 7
111const RS_R_FILES: i64 = 0
112const RS_R_BYTES: i64 = 1
113const RS_R_BLOCKS: i64 = 2
114const RS_R_POP: i64 = 3
115const RS_R_BUCKET0: i64 = 4 // .. RS_R_BUCKET0 + RS_NBUCKET - 1
116const RS_R_TRUNC: i64 = 11
117const RS_R_UNREADABLE: i64 = 12
118const RS_R_WANTBUCKET: i64 = 13
119const RS_R_WANTLINE: i64 = 14
120const RS_R_WANTHITS: i64 = 15
121const RS_R_OFFENDERS: i64 = 16
122const RS_RLEN: i64 = 20
126const RS_MAXVOC: i64 = 512
127const RS_V_NMARK: i64 = 0
128const RS_V_NREM: i64 = 1
129const RS_V_MAXGAP: i64 = 2
130const RS_V_MINMSG: i64 = 3
131const RS_V_REJECT: i64 = 4
132const RS_V_OVER: i64 = 5 // vocabulary cap reached -> the vocabulary is a FLOOR
133const RS_V_NEXCL: i64 = 6 // declared self-fixture exclusions
134const RS_V_EXCOUNT: i64 = 7 // files actually skipped by those exclusions
135const RS_V_BASE: i64 = 8 // markers: (off,len) pairs from here
136const RS_V_REMBASE: i64 = 1032 // RS_V_BASE + 2 * RS_MAXVOC
137const RS_V_MKHIT: i64 = 2056 // RS_V_REMBASE + 2 * RS_MAXVOC: per-marker first-fired tally
138const RS_V_RMHIT: i64 = 2568 // RS_V_MKHIT + RS_MAXVOC: per-remedy first-fired tally
139const RS_V_EXBASE: i64 = 3080 // RS_V_RMHIT + RS_MAXVOC: exclusion (off,len) pairs
140const RS_V_PASSBASE: i64 = 4104 // RS_V_EXBASE + 2 * RS_MAXVOC: positive-outcome tokens
141const RS_V_FAILBASE: i64 = 5128 // RS_V_PASSBASE + 2 * RS_MAXVOC: negative-outcome tokens
142const RS_V_SRBASE: i64 = 6152 // RS_V_FAILBASE + 2 * RS_MAXVOC: self-remedy (usage) phrases
143const RS_V_NPASS: i64 = 7176 // scalars appended after the tables, never wedged before them
144const RS_V_NFAIL: i64 = 7177
145const RS_V_NSR: i64 = 7178
146const RS_V_LEN: i64 = 7184
151const RS_MAXF: i64 = 32768
152const RS_STRIDE: i64 = 256
153const RS_SLACK: i64 = 65536
154const RS_PREVIEW: i64 = 160
155const RS_ROW_MAX: i64 = 1024
156const RS_OUT_PER_FILE: i64 = 8192 // worklist headroom per source file; a bind ANNOUNCES
157const RS_NUMBUF: i64 = 64
158const RS_PATHBUF: i64 = 4096
159const RS_SMALL: i64 = 16
853const RS_RATCHET_ALLOW: i64 = 0
854const RS_RATCHET_REFUSE: i64 = 1
855const RS_RATCHET_UNMEAS: i64 = 3
902const RS_FNV_OFFSET: i64 = 2166136261
903const RS_FNV_PRIME: i64 = 16777619
904const RS_HASH_MASK32: i64 = 4294967295
905const RS_HASH_LOAD: i64 = 4 // 4x headroom keeps linear probing short

functions

161func 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 }
162func 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 }
called by 2: rs_conf_loadrs_scan calls 1: sys_write
164func rs_putn(v: i64) -> i64
172func rs_lower(c: i64) -> i64
178func rs_wordch(c: i64) -> i64
189func rs_find_word(hay: *u8, hs: i64, he: i64, nee: *u8, nlen: i64) -> i64
225func rs_has_particular(buf: *u8, s: i64, e: i64) -> i64
called by 2: mainrs_block_emit calls 2: rs_wordchrs_lower
281func rs_bucket(blen: i64, minmsg: i64, subj: i64, rem: i64, testassert: i64, usage: i64) -> i64
called by 2: mainrs_block_emit
293func rs_bucket_name(b: i64) -> *u8
308func rs_is_offender(b: i64) -> i64
323func rs_range_eq(buf: *u8, s: i64, e: i64, lit: *u8) -> i64
called by 2: rs_conf_loadrs_bucket_id calls 1: gk_len
334func rs_find_byte(buf: *u8, s: i64, e: i64, b: i64) -> i64
343func rs_atoi(buf: *u8, s: i64, e: i64) -> i64
called by 1: rs_conf_load
361func rs_conf_load(confp: *u8, clen: *i64, voc: *i64) -> *u8
489func rs_vocab_hit(conf: *u8, voc: *i64, base: i64, n: i64, hay: *u8, hs: i64, he: i64) -> i64
called by 2: mainrs_block_emit calls 1: rs_find_word
504func rs_line_lits(buf: *u8, s: i64, e: i64, blk: *u8, bo0: i64, blkcap: i64) -> i64
543func 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
607func rs_file_scan(path: *u8, conf: *u8, voc: *i64, res: *i64, out: *u8, outcap: i64, oo: *i64, want: *u8) -> i64
680func rs_path_is(path: *u8, conf: *u8, off: i64, len: i64) -> i64
called by 1: rs_excluded calls 1: gk_len
698func rs_excluded(path: *u8, conf: *u8, voc: *i64) -> i64
called by 1: rs_scan_list calls 1: rs_path_is
709func rs_scan_list(names: *u8, n: i64, conf: *u8, voc: *i64, res: *i64, out: *u8, outcap: i64, oo: *i64, want: *u8) -> i64
called by 1: rs_scan calls 2: rs_excludedrs_file_scan
721func rs_res_new() -> *i64
731func rs_report(conf: *u8, res: *i64, voc: *i64, outp: *u8, wrote: i64) -> i64
811func rs_scan(confp: *u8, outp: *u8, res: *i64, want: *u8) -> i64
868func rs_bucket_id(buf: *u8, s: i64, e: i64) -> i64
879func rs_row_name(buf: *u8, s: i64, e: i64, span: *i64) -> i64
907func rs_name_hash(buf: *u8, s: i64, e: i64) -> i64
918func rs_name_eq(a: *u8, as0: i64, ae: i64, b: *u8, bs: i64, be: i64) -> i64
929func rs_name_index(bl: *u8, blen: i64, hs: *i64, he: *i64, hcap: i64) -> i64
953func rs_name_in(bl: *u8, hs: *i64, he: *i64, hcap: i64, needle: *u8, ns: i64, ne: i64) -> i64
called by 1: rs_ratchet calls 2: rs_name_hashrs_name_eq
965func rs_ratchet(worklistp: *u8, baselinep: *u8) -> i64