code wiki / _hdl_build / nx_ale_exec.nx

nx_ale_exec.nx

buildroot/runtime/_hdl_build/nx_ale_exec.nx

21480 B483 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic ale
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_ale_exec.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 ae_read sys_openat_rd sys_read sys_close ae_field_val ae_find_line ae_len ae_is_bol ae_match ae_len ↻ ae_plan_find ae_is_bol ↻ ae_match ↻ ae_vocab_build ae_plan_step sys_mmap ↻ ae_plan_find ↻ ae_streq ae_join ae_write_file sys_openat_wr sys_write sys_close ↻ ae_vocab_lookup ae_starts ae_transform_kv ae_is_bol ↻ ae_match ↻ ae_transform_copy ae_transform_count sys_mmap ↻ ae_transform_sum sys_mmap ↻ ae_transform_reduce ae_rd_skipword ae_rd_skipsp ae_rd_atoi

structs

none

consts

25const K_MAGIC_262144: i64 = 262144
26const K_MAGIC_8192: i64 = 8192
27const K_MAGIC_16384: i64 = 16384

functions

30func ae_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
45func ae_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
48func ae_match(buf: *u8, n: i64, pos: i64, pat: *u8, pl: i64) -> i64
59func ae_is_bol(buf: *u8, pos: i64) -> i64
66func ae_find_line(buf: *u8, n: i64, prefix: *u8) -> i64
81func ae_field_val(buf: *u8, n: i64, prefix: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 2: ae_find_lineae_len
101func ae_join(a: *u8, b: *u8, out: *u8) -> i64
called by 1: main
113func ae_write_file(path: *u8, buf: *u8, n: i64) -> i64
124func ae_transform_kv(inb: *u8, n: i64, out: *u8) -> i64
called by 1: main calls 2: ae_is_bolae_match
155func ae_transform_copy(inb: *u8, n: i64, out: *u8) -> i64
called by 1: main
166func ae_transform_count(inb: *u8, n: i64, out: *u8) -> i64
called by 1: main calls 1: sys_mmap
186func ae_plan_find(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64
called by 2: ae_plan_stepmain calls 2: ae_is_bolae_match
199func ae_plan_step(buf: *u8, n: i64, num: i64, vbuf: *u8, abuf: *u8, cap: i64) -> i64
called by 1: main calls 2: sys_mmapae_plan_find
245func ae_streq(a: *u8, b: *u8) -> i64
called by 1: main
256func ae_starts(s: *u8, p: *u8) -> i64
called by 1: ae_vocab_lookup
270func ae_transform_sum(inb: *u8, n: i64, out: *u8) -> i64
called by 1: main calls 1: sys_mmap
298func 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
299func 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
300func 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
307func ae_transform_reduce(inb: *u8, n: i64, out: *u8, args: *u8) -> i64
354func ae_vocab_build(toks: *i64, ids: *i64, cap: i64) -> i64
called by 1: main
366func ae_vocab_lookup(s: *u8, toks: *i64, ids: *i64, cnt: i64) -> i64
called by 1: main calls 1: ae_starts
376func main(argc: i64, argv: *i64) -> i64