code wiki / _hdl_build / nx_ale_agent.nx
nx_ale_agent.nx
buildroot/runtime/_hdl_build/nx_ale_agent.nx
about
nx_ale_agent.nx -- sovereign ALE agent-core SUBMIT/compose entrypoint (rung ALE-R2d).
THE one agent-attempt entrypoint the whole ALE-R2 agent-core graduates into: it COMPOSES the
PLAN (ALE-R2a, nx_ale_plan) -> EXECUTE (ALE-R2b, nx_ale_exec) -> SELF-VERIFY (ALE-R2c,
nx_ale_verify) phase organs into a SINGLE invocation that takes a task spec and emits the
agent-attempt triple {plan, artifact, self_score}. This IS the ALE-R1b agent phase.
argv[1] = TASK spec path (ALE-format "contract|field|value" lines; ale_format.spec grammar)
argv[2] = SANDBOX dir (the agent's working dir; staged input + the real artifact land here)
argv[3] = OUTDIR dir (the agent's emission dir; plan + self_score land here)
CONTRACT (data-driven; no magic numbers -- phase shapes come from the phase organs themselves):
The agent reads ONLY the task spec for its own grounding check: it extracts the DECLARED
task|artifact_path| value to resolve where the executor will drop the deliverable (sandbox +
"/" + artifact_path). If that REQUIRED field is absent the agent REFUSES UP FRONT: exit 1,
writes NO plan, NO artifact, NO self_score (the grounding bite -- not vacuously green). It
NEVER opens the grader|reference| path during plan/exec; only the SELF-VERIFY phase (run last,
post-completion) resolves the reference -- and that resolution lives inside nx_ale_verify, not
here. So planting a decoy reference.txt in the sandbox cannot change the plan, artifact, or
self_score: NO-LEAKAGE ORDER is preserved end-to-end.
Pipeline (each phase must succeed or the whole attempt fails BEFORE the next phase):
1. PLAN fork/execve nx_ale_plan.elf <task> <outdir>/plan ; rc!=0 -> exit 11
2. EXECUTE fork/execve nx_ale_exec.elf <outdir>/plan <task> <sandbox>; rc!=0 -> exit 12
3. SELF-VERIFY fork/execve nx_ale_verify.elf <task> <sandbox>/<artifact_path> <outdir>/self_score
; rc!=0 -> exit 13 (and the self_score file is the verify organ's own output,
the SAME number an independent nx_ale_grade of the same pair yields -- the agent
does not lie about its own score).
On all three phases OK -> exit 0 (the artifact lives under the sandbox, the plan + self_score
under the outdir). No clock, no rand in this composer -> two runs on the same (task, fresh
sandbox, fresh outdir) yield BYTE-IDENTICAL {plan, artifact, self_score}: DETERMINISTIC.
Landmines respected: nested ifs (no &&/||), flat exprs, <=6 args/func, no empty-string literal,
strings via Write, openat_wr has no O_TRUNC. Helpers copied VERBATIM from the ALE phase organs'
line-grammar (av_*/ae_*) + the gate's fork/execve discipline (ag_run_*).
license_tier: ORIGINAL
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
| 33 | const K_MAGIC_262144: i64 = 262144 |
| 34 | const K_MAGIC_8192: i64 = 8192 |
| 35 | const K_MAGIC_16384: i64 = 16384 |
functions
| 38 | func ag_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 53 | func ag_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 56 | func ag_match(buf: *u8, n: i64, pos: i64, pat: *u8, pl: i64) -> i64 called by 1: ag_find_line |
| 67 | func ag_is_bol(buf: *u8, pos: i64) -> i64 called by 1: ag_find_line |
| 74 | func ag_find_line(buf: *u8, n: i64, prefix: *u8) -> i64 |
| 89 | func ag_field_val(buf: *u8, n: i64, prefix: *u8, out: *u8, cap: i64) -> i64 |
| 109 | func ag_join(a: *u8, b: *u8, out: *u8) -> i64 called by 1: main |
| 121 | func ag_run_plan(task: *u8, planout: *u8) -> i64 |
| 142 | func ag_run_exec(plan: *u8, task: *u8, sandbox: *u8) -> i64 |
| 164 | func ag_run_verify(task: *u8, art: *u8, scoreout: *u8) -> i64 |
| 185 | func main(argc: i64, argv: *i64) -> i64 |