code wiki / _hdl_build / _ale_aggregate_gate.nx

_ale_aggregate_gate.nx

buildroot/runtime/_hdl_build/_ale_aggregate_gate.nx

12444 B322 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic ale
docsdependenciesstructsconstsfunctions

about

_ale_aggregate_gate.nx -- the ALE-R1c gate: sovereign AGGREGATE fold (ALE's headline mean). Diff-lane / no-mocks: runs the REAL sovereign organ nx_ale_aggregate.elf (built by nx_cc_sovereign->nxasm_x86_main, NO gcc) over REAL fixtures and asserts ALL of: (1) MEAN-EXACT -- scores_set (1000,500,0 over 3 tasks) folds to exactly 500 = (1500)/3 (2) BOUNDED -- every emitted aggregate lies in [0,1000]; corrupt_set's out-of-range per-task value (2000) is clamped on read -> 750, never escapes [0,1] (3) BREAKDOWN -- a task|<id>|<milli> line is emitted for every task (N==3 here) and re-folding those EMITTED lines yields the IDENTICAL mean (500) (4) DETERMINISTIC -- two consecutive runs on the SAME fixture emit byte-identical output (5) DEGENERATE -- empty_set (N==0) folds to exactly 0 (no divide-by-zero) (6) TAMPER -- a BROKEN aggregator (drops a task from the denominator + skips the clamp) emits an out-of-[0,1000] / wrong mean on overshoot_set (1050 vs honest 700) and is REJECTED; the real organ folds the same fixture to a bounded 700 -> negative control bites The aggregate + breakdown are read back from a scratch FILE the organ writes ("agg|<n>\n" then "task|<id>|<milli>\n" x N), dodging the 0..255 process-exit-code ceiling. The organ's purity (no clock/rand) IS the oracle. Evidence -> knowledge/status/ale_aggregate.log (ALEAGGGATE row; the queue row's ||MARK= reads it). license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx _ale_aggregate_gate.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main g_p sys_write sys_mmap g_run sys_fork sys_openat_wr sys_dup3 sys_mmap ↻ sys_execve sys_exit sys_wait4 g_read sys_openat_rd sys_read sys_close g_agg_of g_len g_pfx_eq g_line_end g_parse_int g_task_count g_len ↻ g_is_bol g_pfx_eq ↻ g_refold g_len ↻ g_is_bol ↻ g_pfx_eq ↻ g_line_end ↻ g_milli_start g_parse_int ↻ g_buf_eq g_fn sys_mmap ↻ sys_write ↻ sys_openat_append g_fp sys_write ↻ sys_now_realtime_sec

structs

none

consts

none

functions

21func g_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
22func g_fp(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 1: main calls 1: sys_write
23func g_fn(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m }; let t: *u8 = sys_mmap(28); var k: i64 = 0; if m == 0 { t[0] = 48; k = 1 }; while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }; var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 }; sys_write(fd, bb, k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
26func g_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
40func g_is_bol(buf: *u8, pos: i64) -> i64
46func g_line_end(buf: *u8, n: i64, start: i64) -> i64
called by 2: g_agg_ofg_refold
55func g_pfx_eq(pfx: *u8, plen: i64, buf: *u8, pos: i64) -> i64
64func g_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
67func g_milli_start(buf: *u8, start: i64, end: i64) -> i64
called by 1: g_refold
77func g_parse_int(buf: *u8, from: i64, end: i64) -> i64
called by 2: g_agg_ofg_refold
91func g_agg_of(buf: *u8, n: i64) -> i64
101func g_task_count(buf: *u8, n: i64) -> i64
called by 1: main calls 3: g_leng_is_bolg_pfx_eq
119func g_refold(buf: *u8, n: i64) -> i64
157func g_buf_eq(a: *u8, na: i64, b: *u8, nb: i64) -> i64
called by 1: main
169func g_run(elf: *u8, fix: *u8, out: *u8) -> i64
189func main() -> i64