code wiki / _hdl_build / nx_magic_gate.nx

nx_magic_gate.nx

buildroot/runtime/_hdl_build/nx_magic_gate.nx

24037 B380 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_magic_gate.nx -- teeth on THE RULE-11 LITERAL SCANNER (nx_magic_lib.nx), and the first teeth it has ever had. It is IN-PROCESS by construction: the scanner used to live inside nx_magic.nx beside main(), so the only way to reach it was to fork the deployed elf, and every mutant of a fork/exec'd subject comes back NOT-REACHED. Importing the lib puts mg_scan inside this gate's own build closure, which is what makes nx_gate_bite able to kill anything here. EVERY FIXTURE IS BUILT IN MEMORY. A gate that shares a fixture with a production beat measures the beat, and this gate's subject is a scanner whose real inputs are the estate's own sources -- pointing it at one would make it flake whenever a sibling seat edits that file. The single filesystem tooth uses /tmp/nx_magic_gate/ and exists only because nx_magicratchet composes mg_read + mg_scan and a composition nobody exercises is a composition nobody has tested. WHAT WOULD MAKE THIS GATE VACUOUS, AND WHY IT CANNOT BE: - an implementation that counts every occurrence of the bytes `0x` passes the hex teeth and DIES on the comment / string teeth, which each carry a decimal literal on the same fixture so that a scanner returning nothing at all also fails; - an implementation that reads only the leading `0` of `0x1ed` returns a site whose VALUE is 0 and whose LENGTH is 1 -- both asserted, and the length one is not cosmetic: `nx_magic apply` REPLACES slen bytes at the site, so a length of 1 rewrites `0x1ed` into `PFX_MAGIC_0x1ed` and corrupts the source of whatever organ it was aimed at; - an implementation that emits sites unconditionally passes T1 and dies on the threshold tooth, which asserts the SAME fixture yields nothing at the default bar because 0x1ed is 493 < 1024. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_magic_lib.nx nx_magic_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_magic_lib.nx

imported by: nobody (leaf or entry point)

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

main 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 ↻ gv_head gv_puts sys_write ↻ tg_vals sys_mmap ↻ tg_stat sys_mmap ↻ tg_scan sys_mmap ↻ mg_slen tg_dump gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_check gv_puts ↻ eq sys_mmap ↻ sys_mkdir tg_write sys_openat_wr

structs

none

consts

29const TG_HEX_1ED: i64 = 493 // 0x1ed == 1*256 + 14*16 + 13 == 493 == octal 0755
30const TG_HEX_1A4: i64 = 420 // 0x1a4 == 1*256 + 10*16 + 4 == 420 == octal 0644
31const TG_LEN_0X1ED: i64 = 5 // the token `0x1ed` is five bytes; apply replaces exactly these
32const TG_THR_DEFAULT: i64 = 1024 // nx_magic's default bar, above both values above ON PURPOSE
33const TG_CH_G: i64 = 103 // 'g' -- the first letter past 'f', i.e. the hex run's terminator
34const TG_CH_E: i64 = 101 // 'e' -- a letter that IS a hex digit
35const TG_ONE: i64 = 1
36const TG_TWO: i64 = 2
37const TG_ZERO_SITES: i64 = 0
39const TG_NAMES_ROWS: i64 = 5
40const TG_NAMES_SITES: i64 = 6
41const TG_ROW_I64_BYTES: i64 = 0
42const TG_ROW_BITS: i64 = 1
43const TG_ROW_CH_LF: i64 = 2
44const TG_ROW_DECIMAL: i64 = 3
45const TG_ROW_COMMA: i64 = 4
46const TG_LONG_LINE: i64 = 200 // a line longer than MG_CTX, so the window must centre
47const TG_LONG_COL: i64 = 150
48const TG_TWO_DECLS: i64 = 2 // the placeholder fixture plants exactly two declarations whose NAME carries the placeholder

functions

50func eq(a: i64, b: i64) -> i64 { if a == b { return 1 } return 0 }
called by 1: main
51func gt(a: i64, b: i64) -> i64 { if a > b { return 1 } return 0 }
called by 1: main
55func tg_scan(fx: *u8, n: i64, thr: i64, sval: *i64, sbase: *i64, slen: *i64, sstat: *i64) -> i64
called by 1: main calls 1: sys_mmap
63func tg_vals() -> *i64 { return sys_mmap(MG_MAXSITES * MG_I64_BYTES) as *i64 }
called by 1: main calls 1: sys_mmap
64func tg_stat() -> *i64 { return sys_mmap(MG_STAT_N * MG_I64_BYTES) as *i64 }
called by 1: main calls 1: sys_mmap
65func tg_write(path: *u8, s: *u8) -> i64
73func tg_dump(label: *u8, v: i64) -> i64
called by 1: main calls 2: gv_putsgv_num
82func main(argc: i64, argv: *i64) -> i64