code wiki / (root) / nx_gate_discover.nx

nx_gate_discover.nx

buildroot/runtime/nx_gate_discover.nx

11314 B267 linesdepth 6pulls 6 transitivereach 2 importersview sourcekind librarytopic gate
docsdependenciesstructsconstsfunctions

about

nx_gate_discover.nx -- SOVEREIGN gate discovery (NishiLang, no .sh, no grep). The gate runner (nx_gate_runner.nx) hardcodes N=19 names[]/gates[] entries. That list ROTS: a gate added under _hdl_build/ that nobody hand-enrolls is silently never run. This organ is the DYNAMIC FEED for the runner: it scans _hdl_build/ for *_test.nx gate files and returns the discovered count + the list of absolute paths. The runner (or any consumer) iterates the result instead of a frozen array -- self-REGISTRATION, not hand-maintenance. SINGLE RESPONSIBILITY: this organ DISCOVERS (enumerate + filter + path-join + fail-loud-on-implausible-count). It does NOT run gates. A consumer feeds the returned NxGateList to gr_gate(). The discovery is ADDITIVE: it does not edit the runner; the runner opts in later. VERIFY-BEFORE-ENROLL (cardinal: a discovered gate must be a real, compilable gate): the FAIL-LOUD floor (nx_gate_discover_floor_ok) refuses an implausibly low count -- if the scan returns fewer gates than the known floor, the directory was mis-pathed / the getdents call failed / the filesystem is not where we think it is. A 0-or-tiny count is NEVER a healthy discovery; it is a silent-skip waiting to happen, so we surface it loudly. The COMPILABILITY half of verify-before-enroll is the gate-runner's gr_gate() the consumer calls on each discovered path (nx_gate_runner.nx) -- this organ proves the candidate SET is plausible; gr_gate proves each candidate COMPILES + PROVES. REUSES (concept-not-copy, DRY): nx_dir.nx -- nx_dir_list (getdents enumeration into rows+arena), nx_dir_name_ends_with (suffix filter), nx_dir_row_at, NxDirRow/NxDirResult, NX_DIR_OK/NX_DIR_EMPTY/... (transitively) -- syscalls.nx -> nx_syscalls.nx (sys_write/mmap/exit), nx_fcntl.nx, nx_dirent.nx license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_dir.nx nx_gate_discover.nx nx_gate_discover_test.nx nx_gate_runner.nx

imports: nx_dir.nx

imported by: nx_gate_discover_test.nxnx_gate_runner.nx

structs

64struct NxGateList

consts

38const NX_GD_OK: i64 = 0 // discovered a plausible, non-empty gate set
39const NX_GD_EMPTY: i64 = 1 // directory readable but no *_test.nx gates
40const NX_GD_IMPLAUSIBLE: i64 = 2 // count below the fail-loud floor (mis-path / FS fault)
41const NX_GD_SCAN_FAILED: i64 = 3 // underlying nx_dir_list failed (open/getdents)
42const NX_GD_TRUNCATED: i64 = 4 // more gates than out_capacity (raise the cap)
43const NX_GD_BAD_ARGS: i64 = 5
50const NX_GD_PLAUSIBLE_FLOOR: i64 = 10
54const NX_GD_MAX_GATES: i64 = 256
55const NX_GD_NAME_ARENA: i64 = 32768 // 256 names * ~128 bytes headroom
56const NX_GD_PATH_ARENA: i64 = 131072 // 256 abs-paths * ~512 bytes headroom
75const NX_GATE_LIST_BYTES: i64 = 72

functions

79func gd_strlen(s: *u8) -> i64
87func gd_arena_append(src: *u8, len: i64, arena: *u8, cap: i64, off: i64) -> i64
called by 1: nx_gate_discover
99func gd_streq(a: *u8, b: *u8) -> i64
112func gd_suffix() -> *u8 { return "_test.nx" as *u8 }
called by 1: nx_gate_discover
120func nx_gate_discover(dir_path: *u8, out: *NxGateList, enforce_floor: i64) -> i64
227func nx_gate_discover_find(out: *NxGateList, want: *u8) -> i64
called by 1: main calls 1: gd_streq
239func nx_gate_discover_print(out: *NxGateList) -> i64
called by 1: main calls 1: gd_strlen