code wiki / _hdl_build / nx_ale_aggregate.nx

nx_ale_aggregate.nx

buildroot/runtime/_hdl_build/nx_ale_aggregate.nx

7377 B199 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic ale
docsdependenciesstructsconstsfunctions

about

nx_ale_aggregate.nx -- sovereign ALE AGGREGATE fold organ (rung ALE-R1c). ALE's HEADLINE measure: folds N per-task milli-scores (each a deterministic [0,1000] grade from nx_ale_grade) into ONE clamped mean on [0,1000] -- the single capability number on the leaderboard (frontier ~26% = ~260 milli). PURE function of one file: argv[1] = FIXTURE path (per-task lines "task|<id>|<milli>"; # / blanks ignored) argv[2] = scratch OUT path: the organ writes agg|<agg>\n # the single clamped headline mean task|<id>|<milli>\n x N # re-foldable per-task breakdown so the gate reads back the aggregate + breakdown WITHOUT hitting the 0..255 process-exit-code ceiling. FOLD (milli-units, 1000 == 1.0), data-driven, NO magic numbers: per-task milli is clamped to [0,1000] ON READ (defensive at the boundary, rule 12: a corrupt out-of-range per-task value can never inflate the aggregate) sum = sum over tasks of clamp(milli, 0, 1000) # data-driven, from the fixture N = count of "task|" lines in the fixture # the fixture owns the count mean = sum / N # integer division (floor) agg = clamp(mean, 0, 1000) # BOUNDED into [0,1] inclusive N == 0 -> agg 0 (degenerate empty task set; no divide-by-zero) Deterministic by construction: no clock, no rand -- only the fixture decides the agg. Landmines respected: nested ifs (no &&/||), flat exprs, <=6 args/func, no empty-string literal, strings via Write, openat_wr has no O_TRUNC (scratch is fresh per gate run). license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_ale_aggregate.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 sys_exit sys_mmap aa_read sys_openat_rd sys_read sys_close aa_len aa_is_bol aa_pfx_eq aa_line_end aa_milli_start aa_parse_int aa_clamp sys_openat_wr sys_write aa_wd sys_mmap ↻ sys_write ↻ sys_close ↻

structs

none

consts

24const K_MAGIC_262144: i64 = 262144

functions

27func aa_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
42func aa_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: main
45func aa_is_bol(buf: *u8, pos: i64) -> i64
called by 1: main
52func aa_line_end(buf: *u8, n: i64, start: i64) -> i64
called by 1: main
62func aa_pfx_eq(pfx: *u8, plen: i64, buf: *u8, pos: i64) -> i64
called by 1: main
73func aa_milli_start(buf: *u8, start: i64, end: i64) -> i64
called by 1: main
84func aa_parse_int(buf: *u8, from: i64, end: i64) -> i64
called by 1: main
98func aa_clamp(v: i64) -> i64
called by 1: main
106func aa_wd(fd: i64, v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
120func main(argc: i64, argv: *i64) -> i64