code wiki / _hdl_build / nx_ale_grade.nx
nx_ale_grade.nx
buildroot/runtime/_hdl_build/nx_ale_grade.nx
about
nx_ale_grade.nx -- sovereign ALE DETERMINISTIC grader-runner core (rung ALE-R1a).
THE scoring engine the whole ALE-R1 harness routes through: the smallest load-bearing
slice (deterministic, code-graded, [0,1], no leakage). PURE function of two files:
argv[1] = REFERENCE path (list of grading-unit lines "unit|<name>|<value>")
argv[2] = ARTIFACT path (the agent-produced deliverable, same line grammar)
argv[3] = scratch OUT path (optional): the milli-score is written here as decimal
text + newline, so the gate reads back a value in 0..1000 WITHOUT hitting
the 0..255 process-exit-code ceiling. The score also goes to stdout.
SCORE (milli-units, 1000 == 1.0), data-driven, NO magic numbers:
total = number of "unit|" grading-unit lines in the REFERENCE (the rubric owns it)
matched= number of reference grading-unit lines that appear VERBATIM (name+value) as a
complete line in the ARTIFACT
raw = (matched * 1000) / total # per-unit weight = 1000/total, DERIVED
score = clamp(raw, 0, 1000) # BOUNDED into [0,1] inclusive
total == 0 -> score 0 (degenerate empty reference: nothing to credit)
Deterministic by construction: no clock, no rand -- only the two files decide the score.
No-leakage: the grader reads argv[1] (reference) ONLY; the score is independent of when/
where the reference existed during the (separate) agent phase. Landmines respected:
nested ifs (no &&/||), flat exprs, <=6 args/func, no empty-string literal, strings via
Write, openat_wr has no O_TRUNC (scratch file is fresh per gate run). license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_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
| 23 | const K_MAGIC_262144: i64 = 262144 |
functions
| 26 | func ag_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 41 | func ag_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: main |
| 44 | func ag_seg_eq(buf1: *u8, seg: i64, seglen: i64, buf2: *u8, pos2: i64) -> i64 |
| 54 | func ag_is_bol(buf: *u8, pos: i64) -> i64 |
| 61 | func ag_line_end(buf: *u8, n: i64, start: i64) -> i64 called by 1: main |
| 73 | func ag_line_in(buf1: *u8, seg: i64, segend: i64, buf2: *u8, n2: i64) -> i64 |
| 97 | func ag_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 99 | func main(argc: i64, argv: *i64) -> i64 |