code wiki / _hdl_build / nx_ale_verify.nx

nx_ale_verify.nx

buildroot/runtime/_hdl_build/nx_ale_verify.nx

8077 B188 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic ale
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_itoa_lib.nx nx_ale_verify.nx

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

main sys_exit sys_mmap av_read sys_openat_rd sys_read sys_close av_field_val av_find_line av_len av_is_bol av_match av_len ↻ av_run_grade sys_fork sys_openat_wr sys_dup3 sys_mmap ↻ sys_execve sys_exit ↻ sys_wait4 av_parse_score av_wn nxi_fd sys_mmap ↻ ccz_cat_num sys_write sys_munmap

structs

none

consts

30const K_MAGIC_262144: i64 = 262144
31const K_MAGIC_8192: i64 = 8192

functions

34func av_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
49func av_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
52func av_match(buf: *u8, n: i64, pos: i64, pat: *u8, pl: i64) -> i64
called by 1: av_find_line
63func av_is_bol(buf: *u8, pos: i64) -> i64
called by 1: av_find_line
70func av_find_line(buf: *u8, n: i64, prefix: *u8) -> i64
85func av_field_val(buf: *u8, n: i64, prefix: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 2: av_find_lineav_len
109func av_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 1: main calls 1: nxi_fd
113func av_run_grade(ref: *u8, art: *u8, scoreout: *u8) -> i64
135func av_parse_score(buf: *u8, n: i64) -> i64
called by 1: main
158func main(argc: i64, argv: *i64) -> i64