code wiki / _hdl_build / nx_bld_cache_cas_gate.nx
nx_bld_cache_cas_gate.nx
buildroot/runtime/_hdl_build/nx_bld_cache_cas_gate.nx
about
nx_bld_cache_cas_gate.nx -- VERDICT gate for rung B2 of /compare/toolchain: the content-addressed
build cache in nx_sov_build_run (watch symbol bld_cache_cas). Runs the REAL builder binary end to end
inside an ISOLATED fixture tree under <buildroot>/_build/nx_bld_cache_cas_gate/ (its own runtime/, its own _offc/
copy of the live toolchain, its own _build/cache) so nothing here touches the estate's cache, its
toolchain, or its knowledge/ confs -- and so the gate is idempotent: the fixture is wiped at SETUP,
never at teardown (a teardown does not run when a run crashes).
DONE-RULE UNDER TEST (toolchain.plan B2, verbatim): an unchanged rebuild returns byte-identical bytes
with ZERO compiler invocation, and a one-byte source edit MISSES; a hit is byte-verified before use; a
key miss on any input change is the tooth; determinism re-proven by byte-identical cold rebuilds.
THE ZERO-INVOCATION WITNESS IS STATE, NOT A MESSAGE: the builder writes _build/<t>.s ONLY inside its
compile loop (sys_openat_wr(spath) immediately before it forks nx_cc). The gate deletes that file
before a rebuild; if the artifact comes back and the .s is still ABSENT, the compiler was not forked.
A tooth asserts the .s IS present after a real build, so the absence witness cannot pass vacuously.
Subject: argv[1] = builder elf (absolute or cwd-relative), else the first of
<nishihost>/nx_sov_build_run.sov.elf.new (STAGED -- what the next promote installs)
<buildroot>/_build/nx_sov_build_run.sov.elf (the last build)
<buildroot>/_offc/nx_sov_build_run.elf (LIVE)
and the chosen path + its sha256 are PRINTED, so the reader knows which binary was judged.
Bounded by the subject's OWN declared per-step deadline (it time-boxes compile and assemble); the
gate passes ms=0 so that bound is inherited rather than copied. license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_sha256.nxnx_gate_verdict.nxnx_gatekit_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
| 35 | const CG_SHA_HEX: i64 = 64 |
| 36 | const CG_PATH: i64 = 4096 |
| 37 | const CG_OUT: i64 = 1048576 // one builder run prints well under this; = GK_BUF |
| 38 | const CG_DIRBUF: i64 = 65536 |
| 39 | const CG_DENT_RECLEN_OFF: i64 = 16 // linux_dirent64: d_reclen u16 at +16, d_name at +19 (gk_dirscan uses the same) |
| 40 | const CG_DENT_NAME_OFF: i64 = 19 |
| 41 | const CG_MODE_X: i64 = 493 // 0755 |
| 42 | const CG_FX_EXIT_A: i64 = 42 // fixture v1 exit code |
| 43 | const CG_FX_EXIT_B: i64 = 43 // fixture v2 exit code (ONE byte differs: '2' -> '3') |
| 44 | const CG_MAXOUT_SHOW: i64 = 4096 // how much of a captured run to echo into the report on a failure |
| 46 | const CG_FX: *u8 = "casfx" |
| 47 | const CG_FXREL: *u8 = "_build/nx_bld_cache_cas_gate" |
functions
| 63 | func cgp_mk(base: *u8, tail: *u8) -> i64 |
| 70 | func cgp_init(buildroot: *u8) -> i64 |
| 88 | func cgp_root() -> *u8 { return cgp_root_p as *u8 } called by 1: main |
| 89 | func cgp_tree() -> *u8 { return cgp_tree_p as *u8 } |
| 90 | func cgp_know() -> *u8 { return cgp_know_p as *u8 } |
| 91 | func cgp_conf() -> *u8 { return cgp_conf_p as *u8 } called by 1: main |
| 92 | func cgp_fxsrc() -> *u8 { return cgp_fxsrc_p as *u8 } called by 1: cg_write_fixture |
| 93 | func cgp_fxs() -> *u8 { return cgp_fxs_p as *u8 } called by 1: main |
| 94 | func cgp_fxelf() -> *u8 { return cgp_fxelf_p as *u8 } |
| 95 | func cgp_cache() -> *u8 { return cgp_cache_p as *u8 } called by 1: main |
| 96 | func cgp_cc() -> *u8 { return cgp_cc_p as *u8 } called by 1: main |
| 97 | func cgp_asm() -> *u8 { return cgp_asm_p as *u8 } called by 1: main |
| 98 | func cgp_lock() -> *u8 { return cgp_lock_p as *u8 } called by 1: main |
| 99 | func cgp_rt() -> *u8 { return cgp_rt_p as *u8 } called by 1: main |
| 100 | func cgp_hdl() -> *u8 { return cgp_hdl_p as *u8 } called by 1: main |
| 101 | func cgp_offc() -> *u8 { return cgp_offc_p as *u8 } called by 1: main |
| 102 | func cgp_build() -> *u8 { return cgp_build_p as *u8 } called by 1: main |
| 105 | func cg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 106 | func cg_p(s: *u8) -> i64 { sys_write(1, s, cg_len(s)); return 0 } |
| 107 | func cg_nl() -> i64 { let b: *u8 = sys_mmap(2); b[0] = 10 as u8; sys_write(1, b, 1); sys_munmap(b, 2); return 0 } |
| 108 | func cg_pn(v: i64) -> i64 { gv_num(v); return 0 } |
| 111 | func cg_sha(path: *u8, out: *u8) -> i64 |
| 131 | func cg_hexeq(a: *u8, b: *u8) -> i64 called by 1: main |
| 138 | func cg_copy(src: *u8, dst: *u8, mode: i64) -> i64 |
| 156 | func cg_clear_dir(dir: *u8) -> i64 |
| 188 | func cg_count_suffix(dir: *u8, suffix: *u8) -> i64 |
| 219 | func cg_write_fixture(exit_code: i64) -> i64 |
| 254 | func cg_build(subject: *u8, extra: *u8, out: *u8, outlen: *i64, ctr: *i64) -> i64 |
| 274 | func cg_run_fx() -> i64 { return gk_run(cgp_fxelf(), 0 as *u8, 0 as *u8, 0 as *u8, 0 as *u8) } |
| 277 | func cg_key_of(out: *u8, n: i64, keyout: *u8) -> i64 |
| 291 | func cg_file_has(path: *u8, needle: *u8) -> i64 |
| 302 | func cg_needle_anm(out: *u8) -> *u8 |
| 308 | func cg_show_on_fail(cond: i64, out: *u8, n: i64) -> i64 |
| 318 | func cg_append_byte(path: *u8) -> i64 |
| 330 | func cg_flip_last(path: *u8) -> i64 |
| 346 | func main(argc: i64, argv: *i64) -> i64 |