code wiki / _hdl_build / nx_ale_aggregate.nx
nx_ale_aggregate.nx
buildroot/runtime/_hdl_build/nx_ale_aggregate.nx
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
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
structs
| none |
consts
| 24 | const K_MAGIC_262144: i64 = 262144 |
functions
| 27 | func aa_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 42 | func aa_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: main |
| 45 | func aa_is_bol(buf: *u8, pos: i64) -> i64 called by 1: main |
| 52 | func aa_line_end(buf: *u8, n: i64, start: i64) -> i64 called by 1: main |
| 62 | func aa_pfx_eq(pfx: *u8, plen: i64, buf: *u8, pos: i64) -> i64 called by 1: main |
| 73 | func aa_milli_start(buf: *u8, start: i64, end: i64) -> i64 called by 1: main |
| 84 | func aa_parse_int(buf: *u8, from: i64, end: i64) -> i64 called by 1: main |
| 98 | func aa_clamp(v: i64) -> i64 called by 1: main |
| 106 | func aa_wd(fd: i64, v: i64) -> i64 |
| 120 | func main(argc: i64, argv: *i64) -> i64 |