code wiki / _hdl_build / nx_magic_gate.nx
nx_magic_gate.nx
buildroot/runtime/_hdl_build/nx_magic_gate.nx
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
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
structs
| none |
consts
| 29 | const TG_HEX_1ED: i64 = 493 // 0x1ed == 1*256 + 14*16 + 13 == 493 == octal 0755 |
| 30 | const TG_HEX_1A4: i64 = 420 // 0x1a4 == 1*256 + 10*16 + 4 == 420 == octal 0644 |
| 31 | const TG_LEN_0X1ED: i64 = 5 // the token `0x1ed` is five bytes; apply replaces exactly these |
| 32 | const TG_THR_DEFAULT: i64 = 1024 // nx_magic's default bar, above both values above ON PURPOSE |
| 33 | const TG_CH_G: i64 = 103 // 'g' -- the first letter past 'f', i.e. the hex run's terminator |
| 34 | const TG_CH_E: i64 = 101 // 'e' -- a letter that IS a hex digit |
| 35 | const TG_ONE: i64 = 1 |
| 36 | const TG_TWO: i64 = 2 |
| 37 | const TG_ZERO_SITES: i64 = 0 |
| 39 | const TG_NAMES_ROWS: i64 = 5 |
| 40 | const TG_NAMES_SITES: i64 = 6 |
| 41 | const TG_ROW_I64_BYTES: i64 = 0 |
| 42 | const TG_ROW_BITS: i64 = 1 |
| 43 | const TG_ROW_CH_LF: i64 = 2 |
| 44 | const TG_ROW_DECIMAL: i64 = 3 |
| 45 | const TG_ROW_COMMA: i64 = 4 |
| 46 | const TG_LONG_LINE: i64 = 200 // a line longer than MG_CTX, so the window must centre |
| 47 | const TG_LONG_COL: i64 = 150 |
| 48 | const TG_TWO_DECLS: i64 = 2 // the placeholder fixture plants exactly two declarations whose NAME carries the placeholder |
functions
| 50 | func eq(a: i64, b: i64) -> i64 { if a == b { return 1 } return 0 } called by 1: main |
| 51 | func gt(a: i64, b: i64) -> i64 { if a > b { return 1 } return 0 } called by 1: main |
| 55 | func tg_scan(fx: *u8, n: i64, thr: i64, sval: *i64, sbase: *i64, slen: *i64, sstat: *i64) -> i64 |
| 63 | func tg_vals() -> *i64 { return sys_mmap(MG_MAXSITES * MG_I64_BYTES) as *i64 } |
| 64 | func tg_stat() -> *i64 { return sys_mmap(MG_STAT_N * MG_I64_BYTES) as *i64 } |
| 65 | func tg_write(path: *u8, s: *u8) -> i64 |
| 73 | func tg_dump(label: *u8, v: i64) -> i64 |
| 82 | func main(argc: i64, argv: *i64) -> i64 |