code wiki / (root) / nx_gen_promptweight_gate.nx

nx_gen_promptweight_gate.nx

buildroot/runtime/nx_gen_promptweight_gate.nx

12193 B183 linesdepth 4pulls 6 transitivereach 0 importersview sourcekind gate/prooftopic gen
docsdependenciesstructsconstsfunctions

about

nx_gen_promptweight_gate.nx -- the REFEREE for gen G13 (cw_prompt_weight): prompt weighting as DATA on the shared photo-prompt composer, on the contract knowledge/gen_prompt_weight.conf declared before the code existed: PERMIL units, a permitted ENVELOPE [min,max] as the first two ints, out-of-envelope REFUSED by named code (never clamped), slot weights as ADDITIVE ints 3..5 with 1000 the identity. IN-PROCESS over nx_companion_wardrobe.nx, GPU-free: the verb emits the engine's own A1111 syntax, 1.000 is the byte-identical identity (feature OFF by default), the parser keeps order and survives bad data, the free-text admission scanner names the first offending group, and -- the compose-level teeth -- the REAL composer run from a scratch cwd with a planted conf produces byte-different prompts for 1000 vs 1300 on the trigger slot, reproduces the off bytes exactly when set back, and falls back to the off bytes (the baseline, never a mutated render) when a DATA slot is out of envelope. FIXTURE LAW: scratch under /tmp/<gate>/ (a planted knowledge/gen_prompt_weight.conf + a planted elara_trigger.txt), recreated at SETUP; the gate chdirs into it so the composer's RELATIVE reads see the fixture and never production. The live-conf tooth runs BEFORE the plant (relative path absent -> the nishihost conf) and asserts only sanity, never a value, so an operator edit to production weights can never turn this gate RED. license_tier: ORIGINAL expect_exit: 0

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_companion_wardrobe.nx nx_gen_promptweight_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_companion_wardrobe.nx

imported by: nobody (leaf or entry point)

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

main gv_head gv_puts sys_write 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 ↻ sys_mmap ↻ cw_weights_load sys_mmap ↻ gc_read2 sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close cw_weights_parse gc_ints gv_check gv_puts ↻ cw_weights_parse ↻ pw_fill cw_prompt_weight cw_weight_admitted cw_cat

structs

none

consts

19const PW_DIR: *u8 = "/tmp/nx_gen_promptweight_gate"
20const PW_KDIR: *u8 = "/tmp/nx_gen_promptweight_gate/knowledge"
21const PW_CONF: *u8 = "/tmp/nx_gen_promptweight_gate/knowledge/gen_prompt_weight.conf"
22const PW_TRIG: *u8 = "/tmp/nx_gen_promptweight_gate/elara_trigger.txt"
23const PW_MODE_DIR: i64 = 511
24const PW_MODE_FILE: i64 = 420
25const PW_CAP: i64 = 32768
26const PW_SENTINEL: i64 = 126
27const PW_SCENE: *u8 = "on the kitchen counter"
28const PW_TRIGGER_WORD: *u8 = "rawphotoword"
29const PW_SEED: i64 = 7
30const PW_CONF_OFF: *u8 = "# planted by nx_gen_promptweight_gate\n100 2000\n1000 1000 1000\n"
31const PW_CONF_ON: *u8 = "# planted by nx_gen_promptweight_gate\n100 2000\n1300 1000 1000\n"
32const PW_CONF_BAD: *u8 = "# planted by nx_gen_promptweight_gate\n100 2000\n9000 1000 1000\n"

functions

34func pw_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
35func pw_find(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: main calls 1: pw_len
49func pw_same(a: *u8, na: i64, b: *u8, nb: i64) -> i64
called by 2: pw_eqmain
56func pw_eq(buf: *u8, n: i64, lit: *u8) -> i64 { return pw_same(buf, n, lit, pw_len(lit)) }
called by 1: main calls 2: pw_samepw_len
57func pw_fill(buf: *u8) -> i64 { var i: i64 = 0; while i < PW_CAP { buf[i] = PW_SENTINEL as u8; i = i + 1 } return 0 }
called by 1: main
58func pw_write(path: *u8, s: *u8) -> i64
67func pw_compose(out: *u8) -> i64 { return go_compose_photo_prompt(PW_SCENE, pw_len(PW_SCENE), "" as *u8, PW_SEED, out) }
called by 1: main calls 2: go_compose_photo_promptpw_len
68func pw_env5(e: *i64, mn: i64, mx: i64, t: i64, c: i64, id: i64) -> i64 { e[CW_W_MIN] = mn; e[CW_W_MAX] = mx; e[CW_W_TRIGGER] = t; e[CW_W_CAMERA] = c; e[CW_W_IDENTITY] = id; return 0 }
called by 1: main
70func main() -> i64