code wiki / _hdl_build / nx_ale_exec.nx
nx_ale_exec.nx
buildroot/runtime/_hdl_build/nx_ale_exec.nx
about
nx_ale_exec.nx -- sovereign ALE agent-core EXECUTE/dispatch organ (rung ALE-R2b).
THE execute step the whole ALE-R2 agent-core routes through: it CONSUMES the ALE-R2a ordered
plan and the task spec and DISPATCHES each step IN ORDER over a sandbox working dir to produce a
REAL artifact file -- never re-planning, never opening the reference path. PURE function of:
argv[1] = PLAN path (ALE-R2a plan: "step|<n>|<verb>|<arg>" lines, ordered from 1)
argv[2] = TASK path (ALE-format task spec: "contract|field|value" lines)
argv[3] = SANDBOX dir (the working dir; staged files + the artifact land here)
CONTRACT (data-driven; the step shape comes from ale_exec.spec / ale_plan.spec):
REQUIRED task fields = materials_dir, input_stage, artifact_path. If ANY is absent the
executor REFUSES: exit non-zero, produces NO artifact.
The plan is walked TOP-TO-BOTHOM and consumed STRICTLY in order via a 3-state machine:
step 1 must be stage_input -> copies materials_dir/input_stage VERBATIM into sandbox/input_stage
step 2 must be run_organ -> applies the instruction's named DETERMINISTIC transform over the
staged bytes (extract_kv_to_units: each "kv|k|v" -> "unit|k|v")
step 3 must be write_artifact -> writes the transform output VERBATIM to sandbox/artifact_path
Any out-of-order verb, an unknown transform token, or a plan MISSING write_artifact => REFUSE
(exit non-zero, NO artifact). The executor reads ONLY argv[1..3] + materials_dir/input_stage;
it NEVER opens the reference path -> the artifact is independent of reference presence (no
leakage, enforced end-to-end). No clock, no rand -> two runs on the same (plan,task,fresh
sandbox) yield a BYTE-IDENTICAL artifact (DETERMINISTIC).
Landmines respected: nested ifs (no &&/||), flat exprs, <=6 args/func, no empty-string literal,
strings via Write, openat_wr fresh path. Helpers mirror the ALE-R2a/R1a line-grammar (ae_*).
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
| 25 | const K_MAGIC_262144: i64 = 262144 |
| 26 | const K_MAGIC_8192: i64 = 8192 |
| 27 | const K_MAGIC_16384: i64 = 16384 |
functions
| 30 | func ae_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 45 | func ae_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 48 | func ae_match(buf: *u8, n: i64, pos: i64, pat: *u8, pl: i64) -> i64 |
| 59 | func ae_is_bol(buf: *u8, pos: i64) -> i64 |
| 66 | func ae_find_line(buf: *u8, n: i64, prefix: *u8) -> i64 |
| 81 | func ae_field_val(buf: *u8, n: i64, prefix: *u8, out: *u8, cap: i64) -> i64 |
| 101 | func ae_join(a: *u8, b: *u8, out: *u8) -> i64 called by 1: main |
| 113 | func ae_write_file(path: *u8, buf: *u8, n: i64) -> i64 |
| 124 | func ae_transform_kv(inb: *u8, n: i64, out: *u8) -> i64 |
| 155 | func ae_transform_copy(inb: *u8, n: i64, out: *u8) -> i64 called by 1: main |
| 166 | func ae_transform_count(inb: *u8, n: i64, out: *u8) -> i64 |
| 186 | func ae_plan_find(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64 |
| 199 | func ae_plan_step(buf: *u8, n: i64, num: i64, vbuf: *u8, abuf: *u8, cap: i64) -> i64 |
| 245 | func ae_streq(a: *u8, b: *u8) -> i64 called by 1: main |
| 256 | func ae_starts(s: *u8, p: *u8) -> i64 called by 1: ae_vocab_lookup |
| 270 | func ae_transform_sum(inb: *u8, n: i64, out: *u8) -> i64 |
| 298 | func ae_rd_skipword(s: *u8, i: i64) -> i64 { var p: i64 = i; var g: i64 = 1; while g == 1 { if s[p] == (0 as u8) { g = 0 } else { if s[p] == (32 as u8) { g = 0 } else { p = p + 1 } } } return p } called by 1: ae_transform_reduce |
| 299 | func ae_rd_skipsp(s: *u8, i: i64) -> i64 { var p: i64 = i; while s[p] == (32 as u8) { p = p + 1 } return p } called by 1: ae_transform_reduce |
| 300 | func ae_rd_atoi(s: *u8, i: i64) -> i64 { var p: i64 = i; var neg: i64 = 0; if s[p] == (45 as u8) { neg = 1; p = p + 1 } var v: i64 = 0; var g: i64 = 1; while g == 1 { if s[p] >= (48 as u8) { if s[p] <= (57 as u8) { v = v * 10 + ((s[p] as i64) - 48); p = p + 1 } else { g = 0 } } else { g = 0 } } if neg == 1 { return 0 - v } return v } called by 1: ae_transform_reduce |
| 307 | func ae_transform_reduce(inb: *u8, n: i64, out: *u8, args: *u8) -> i64 |
| 354 | func ae_vocab_build(toks: *i64, ids: *i64, cap: i64) -> i64 called by 1: main |
| 366 | func ae_vocab_lookup(s: *u8, toks: *i64, ids: *i64, cnt: i64) -> i64 |
| 376 | func main(argc: i64, argv: *i64) -> i64 |