code wiki / _hdl_build / nx_ale_verify.nx
nx_ale_verify.nx
buildroot/runtime/_hdl_build/nx_ale_verify.nx
about
nx_ale_verify.nx -- sovereign ALE agent-core SELF-VERIFY phase organ (rung ALE-R2c).
THE honest self-score step the whole ALE-R2 agent-core routes through: AFTER the executor
(ALE-R2b) produces an artifact, the agent grades its OWN deliverable against the task's
DECLARED grading reference, so it cannot lie about its own score. PURE function of:
argv[1] = TASK spec path (ALE-format "contract|field|value" lines; ale_format.spec grammar)
argv[2] = ARTIFACT path (the agent-produced deliverable to self-grade)
argv[3] = scoreout path (the milli-score is written here as decimal+newline; also stdout)
CONTRACT (data-driven; no magic numbers):
The reference path is read from the task spec's DECLARED grading reference: the
"grader|reference|<path>" field. This is a grader| field, NOT a task| field -- the planner
(ALE-R2a) and executor (ALE-R2b) read ONLY task| fields, so the reference NEVER leaks to the
agent phase. SELF-VERIFY is a POST-completion phase (the agent has already finished), so it
is ALLOWED the reference -- mirrors ALE staging the reference AFTER the agent completes.
If the grader|reference| field is ABSENT the organ REFUSES: exit 1, writes NO score (a self-
verify with no declared rubric cannot certify anything = grounding bite).
Otherwise it forks/execve nx_ale_grade.elf <ref> <artifact> <scoreout> EXACTLY as the
ALE-R2b gate's g_run_grade does, reads the milli-score back from scoreout, and re-emits it to
stdout (so the self-score is the SAME number an independent grade of the same pair yields --
the agent does not lie). NO-LEAKAGE: the reference path comes ONLY from the task spec's
declared field; nx_ale_verify never scans the sandbox for a decoy reference, so the score is
byte-identical whether or not a decoy reference.txt is planted nearby. DETERMINISTIC: the
grader is a pure function of (reference, artifact); no clock, no rand here -> two runs on the
same (task, artifact) yield a byte-identical milli-score.
Landmines respected: nested ifs (no &&/||), flat exprs, <=6 args/func, no empty-string literal,
strings via Write, openat_wr no O_TRUNC (the scoreout/grade scratch is a fresh gate path).
Helpers mirror the ALE-R2a field-grammar (av_*) + the gate's fork/execve discipline.
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
| 30 | const K_MAGIC_262144: i64 = 262144 |
| 31 | const K_MAGIC_8192: i64 = 8192 |
functions
| 34 | func av_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 49 | func av_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 52 | func av_match(buf: *u8, n: i64, pos: i64, pat: *u8, pl: i64) -> i64 called by 1: av_find_line |
| 63 | func av_is_bol(buf: *u8, pos: i64) -> i64 called by 1: av_find_line |
| 70 | func av_find_line(buf: *u8, n: i64, prefix: *u8) -> i64 |
| 85 | func av_field_val(buf: *u8, n: i64, prefix: *u8, out: *u8, cap: i64) -> i64 |
| 109 | func av_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 113 | func av_run_grade(ref: *u8, art: *u8, scoreout: *u8) -> i64 |
| 135 | func av_parse_score(buf: *u8, n: i64) -> i64 called by 1: main |
| 158 | func main(argc: i64, argv: *i64) -> i64 |