code wiki / _hdl_build / nx_ale_harness.nx

nx_ale_harness.nx

buildroot/runtime/_hdl_build/nx_ale_harness.nx

12402 B281 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic ale
docsdependenciesstructsconstsfunctions

about

nx_ale_harness.nx -- ALE-R1: THE sovereign ALE-style MEASURE harness organ. Composes the existing green phase organs into the end-to-end deployer loop on a task spec: ingest task -> run agent (produce artifact) -> resolve the DECLARED reference (post-run, from the task's grader| field, NEVER staged into the sandbox = no leakage) -> INDEPENDENT deterministic grade -> [0,1] (milli 0..1000) score + log. The harness's reported score is the INDEPENDENT nx_ale_grade of (task's grader|reference|, agent artifact) -- NOT the agent's self_score: the measure is owned by the rubric, not the agent. Reuses _offc/nx_ale_agent.elf (ALE-R2d, itself plan->exec->verify) + _offc/nx_ale_grade.elf (ALE-R1a) via fork/execve (DRY -- no duplicated phase logic). Deterministic (no clock/rand in the loop); no-leakage (the reference is a grader| field resolved AFTER the agent finished). args mode: nx_ale_harness <task> <sandbox> <outdir> <scoreout> -> runs the measure, writes the milli-score to <scoreout>, prints HARNESS score=<n> mode=RUN. no-arg mode: SELF-GATE on the golden fixture (ale_exec_examples/task_exec.txt) with baked controls -> C1 SCORES-0to1 (good->1000, bounded into [0,1000]), C2 NO-LEAKAGE (a decoy reference.txt planted in the sandbox is ignored -> score unchanged), C3 DETERMINISTIC (re-run identical), C4 DISCRIMINATES (a WRONG artifact grades <1000 -> the measure bites, not vacuous) -> HARNESSGATE verdict=GREEN/RED to knowledge/status/ale_harness.log + stdout. Landmines: nested ifs (no &&/||), flat exprs, <=6 args/func, no empty-string literal, strings via Write, openat_wr no O_TRUNC (unlink the scoreout before each grade so a shorter score can't leave trailing digits). license_tier: ORIGINAL module: nishi-core.ale.harness depends: nishi-core.sys.syscalls capability: ALE_MEASURE_HARNESS

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_ale_harness.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 h_measure sys_mkdir sys_mmap h_read sys_openat_rd sys_read sys_close h_field_value h_len h_len ↻ h_run_agent sys_fork sys_openat_wr sys_dup3 sys_mmap ↻ sys_execve sys_exit sys_wait4 h_join h_unlink h_run_grade sys_fork ↻ sys_openat_wr ↻ sys_dup3 ↻ sys_mmap ↻ sys_execve ↻ sys_exit ↻ sys_wait4 ↻ h_score_of sys_mmap ↻ h_read ↻ h_p sys_write h_fn sys_mmap ↻ sys_write ↻ sys_exit ↻ sys_mkdir ↻ h_write_file

structs

none

consts

26const K_MAGIC_262144: i64 = 262144
27const K_MAGIC_2048: i64 = 2048
28const K_MAGIC_4096: i64 = 4096

functions

30func h_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
31func h_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
32func h_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
33func h_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
38func h_read(path: *u8, buf: *u8, cap: i64) -> i64
53func h_score_of(path: *u8) -> i64
called by 2: h_measuremain calls 2: sys_mmaph_read
66func h_write_file(path: *u8, buf: *u8, n: i64) -> i64
78func h_field_value(buf: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64
called by 2: h_measuremain calls 1: h_len
112func h_join(dst: *u8, a: *u8, b: *u8) -> i64
called by 1: h_measure
124func h_run_agent(task: *u8, sandbox: *u8, outdir: *u8) -> i64
146func h_run_grade(ref: *u8, art: *u8, scoreout: *u8) -> i64
169func h_measure(task: *u8, sandbox: *u8, outdir: *u8, scoreout: *u8) -> i64
191func main(argc: i64, argv: *i64) -> i64