code wiki / _hdl_build / nx_ale_plan.nx

nx_ale_plan.nx

buildroot/runtime/_hdl_build/nx_ale_plan.nx

6523 B155 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic ale
docsdependenciesstructsconstsfunctions

about

nx_ale_plan.nx -- sovereign ALE agent-core PLAN-phase organ (rung ALE-R2a). THE decompose step the whole ALE-R2 agent-core routes through: the smallest load-bearing slice (deterministic, grounded, artifact-terminal decomposition). PURE function of one file: argv[1] = TASK spec path (ALE-format "contract|field|value" lines; ale_format.spec grammar) argv[2] = PLAN OUT path (the ordered plan is written here as "step|<n>|<verb>|<arg>" lines) CONTRACT (data-driven; no magic numbers -- the step shape comes from ale_plan.spec): REQUIRED task fields = instruction, input_stage, artifact_path. If ANY is absent the planner REFUSES: exit 1, emits NOTHING (grounding check bites = rule-4 made mechanical). Otherwise it emits exactly this ordered, grounded, artifact-terminal plan: step|1|stage_input|<task.input_stage value> step|2|run_organ|<task.instruction value> step|3|write_artifact|<task.artifact_path value> Every <arg> is COPIED VERBATIM from a task field VALUE actually present in the spec (GROUNDED: the planner never synthesizes a value the spec did not declare). Step numbers start at 1 and increase by 1 with no gaps (ORDERED). The FINAL step is write_artifact whose <arg> is the declared artifact_path (ARTIFACT-TERMINAL). No clock, no rand -> two runs on the same spec emit a BYTE-IDENTICAL plan (DETERMINISTIC). Landmines respected: nested ifs (no &&/||), flat exprs, <=6 args/func, no empty-string literal, strings via Write, openat_wr has no O_TRUNC (gate uses a fresh scratch path). Helpers reuse the ALE-R0a line-grammar (av_*) and the ALE-R1a decimal writer (ap_wn). license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_ale_plan.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 ap_read sys_openat_rd sys_read sys_close ap_field_val ap_find_line ap_len ap_is_bol ap_match ap_len ↻ sys_openat_wr ap_step sys_write ap_wn nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap ap_len ↻ sys_close ↻

structs

none

consts

24const K_MAGIC_262144: i64 = 262144
25const K_MAGIC_8192: i64 = 8192

functions

28func ap_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
43func ap_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
46func ap_match(buf: *u8, n: i64, pos: i64, pat: *u8, pl: i64) -> i64
called by 1: ap_find_line
57func ap_is_bol(buf: *u8, pos: i64) -> i64
called by 1: ap_find_line
64func ap_find_line(buf: *u8, n: i64, prefix: *u8) -> i64
80func ap_field_val(buf: *u8, n: i64, prefix: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 2: ap_find_lineap_len
104func ap_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 1: ap_step calls 1: nxi_fd
108func ap_step(fd: i64, n: i64, verb: *u8, arg: *u8) -> i64
called by 1: main calls 3: sys_writeap_wnap_len
121func main(argc: i64, argv: *i64) -> i64