code wiki / _hdl_build / nx_ale_harness.nx
nx_ale_harness.nx
buildroot/runtime/_hdl_build/nx_ale_harness.nx
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
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
| 26 | const K_MAGIC_262144: i64 = 262144 |
| 27 | const K_MAGIC_2048: i64 = 2048 |
| 28 | const K_MAGIC_4096: i64 = 4096 |
functions
| 30 | func 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 } |
| 31 | func 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 } |
| 32 | func 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 } |
| 33 | func h_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 35 | func h_unlink(path: *u8) -> i64 { return __syscall(263, AT_FDCWD, path, 0, 0, 0, 0) } |
| 38 | func h_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 53 | func h_score_of(path: *u8) -> i64 |
| 66 | func h_write_file(path: *u8, buf: *u8, n: i64) -> i64 |
| 78 | func h_field_value(buf: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 112 | func h_join(dst: *u8, a: *u8, b: *u8) -> i64 called by 1: h_measure |
| 124 | func h_run_agent(task: *u8, sandbox: *u8, outdir: *u8) -> i64 |
| 146 | func h_run_grade(ref: *u8, art: *u8, scoreout: *u8) -> i64 |
| 169 | func h_measure(task: *u8, sandbox: *u8, outdir: *u8, scoreout: *u8) -> i64 |
| 191 | func main(argc: i64, argv: *i64) -> i64 |