code wiki / _hdl_build / nx_ale_agent.nx

nx_ale_agent.nx

buildroot/runtime/_hdl_build/nx_ale_agent.nx

10341 B232 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic ale
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_ale_agent.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 sys_exit sys_mmap ag_read sys_openat_rd sys_read sys_close ag_field_val ag_find_line ag_len ag_is_bol ag_match ag_len ↻ ag_join ag_run_plan sys_fork sys_openat_wr sys_dup3 sys_mmap ↻ sys_execve sys_exit ↻ sys_wait4 ag_run_exec sys_fork ↻ sys_openat_wr ↻ sys_dup3 ↻ sys_mmap ↻ sys_execve ↻ sys_exit ↻ sys_wait4 ↻ ag_run_verify sys_fork ↻ sys_openat_wr ↻ sys_dup3 ↻ sys_mmap ↻ sys_execve ↻ sys_exit ↻ sys_wait4 ↻

structs

none

consts

33const K_MAGIC_262144: i64 = 262144
34const K_MAGIC_8192: i64 = 8192
35const K_MAGIC_16384: i64 = 16384

functions

38func ag_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
53func ag_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
56func ag_match(buf: *u8, n: i64, pos: i64, pat: *u8, pl: i64) -> i64
called by 1: ag_find_line
67func ag_is_bol(buf: *u8, pos: i64) -> i64
called by 1: ag_find_line
74func ag_find_line(buf: *u8, n: i64, prefix: *u8) -> i64
89func ag_field_val(buf: *u8, n: i64, prefix: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 2: ag_find_lineag_len
109func ag_join(a: *u8, b: *u8, out: *u8) -> i64
called by 1: main
121func ag_run_plan(task: *u8, planout: *u8) -> i64
142func ag_run_exec(plan: *u8, task: *u8, sandbox: *u8) -> i64
164func ag_run_verify(task: *u8, art: *u8, scoreout: *u8) -> i64
185func main(argc: i64, argv: *i64) -> i64