code wiki / _hdl_build / nx_gramdec_gate.nx

nx_gramdec_gate.nx

buildroot/runtime/_hdl_build/nx_gramdec_gate.nx

10262 B238 linesdepth 11pulls 29 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_gramdec_gate.nx -- NB10 gate: grammar-constrained decode (nx_gramdec_lib) teeth. T1-T8 = automaton ruler teeth (no model). T9 = LIVE no-op equivalence: on an already-grammatical greedy generation the constrained decode must be BIT-EXACT (prefix) with nsv_generate, zero rejections, accept-stop. T10 = LIVE mask-fires (anti-vacuity + escape): an else-if-baited prompt must (a) make the UNCONSTRAINED model emit `else if` (proves the bait bites -- the vacuity guard), (b) under the mask produce grammar-VALID output with >=1 rejection and NO `else if`. MUTATION PROOF (rung 5): flip GD_NEG_ALLOW_ELSEIF=1 in nx_gramdec_lib.nx, rebuild, run -> T3 accepts the else-if text and T10 sees the escape -> verdict=RED exit 1. Restore -> GREEN. argv: [model.gguf] [probe] (default model /home/elderwesto/nx_stage/nx_15b_model.gguf; "probe" prints raw outputs for tooth calibration instead of judging). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 0 importers

nx_gramdec_lib.nx nx_gate_verdict.nx nx_gramdec_gate.nx

imports: nx_gramdec_lib.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

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

main gg_w gg_tooth gg_w ↻ gg_wn gg_w ↻ gg_val gg_slen gd_validate gd_reset gd_mem gd_step gd_isws gd_isid gd_word_end gd_word_in gd_isdig gd_accepting gd_mem ↻ gg_cat gd_validate ↻ nsv_init_i8 nsv_init sys_now_ms 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 nxa_dump_sizes sys_clock_gettime_mono nsv_log sys_write ↻

structs

none

consts

15const GG_MAXNEW: i64 = 120
16const GG_OCAP: i64 = 4000

functions

18func gg_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 3: gg_wngg_toothmain
19func gg_wn(v: i64) -> i64
called by 2: gg_toothmain calls 1: gg_w
32func gg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: gg_findgg_val
33func gg_cat(b: *u8, off: i64, s: *u8) -> i64
39func gg_find(hay: *u8, hn: i64, needle: *u8, from: i64) -> i64
called by 1: main calls 1: gg_slen
56func gg_tooth(name: *u8, got: i64) -> i64
called by 1: main calls 2: gg_wgg_wn
66func gg_val(s: *u8) -> i64 { let n: i64 = gg_slen(s); return gd_validate(s, n) }
called by 1: main calls 2: gg_slengd_validate
69func gg_prompt_clean(pb: *u8) -> i64
called by 1: main calls 1: gg_cat
81func gg_prompt_bait(pb: *u8) -> i64
called by 1: main calls 1: gg_cat
96func gg_gen(which: i64, tx: *u8, mt: *i64) -> i64
called by 1: main calls 2: gdx_generatensv_generate
115func main(argc: i64, argv: *i64) -> i64