code wiki / _hdl_build / nx_ale_plan.nx
nx_ale_plan.nx
buildroot/runtime/_hdl_build/nx_ale_plan.nx
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
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
structs
| none |
consts
| 24 | const K_MAGIC_262144: i64 = 262144 |
| 25 | const K_MAGIC_8192: i64 = 8192 |
functions
| 28 | func ap_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 43 | func ap_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 46 | func ap_match(buf: *u8, n: i64, pos: i64, pat: *u8, pl: i64) -> i64 called by 1: ap_find_line |
| 57 | func ap_is_bol(buf: *u8, pos: i64) -> i64 called by 1: ap_find_line |
| 64 | func ap_find_line(buf: *u8, n: i64, prefix: *u8) -> i64 |
| 80 | func ap_field_val(buf: *u8, n: i64, prefix: *u8, out: *u8, cap: i64) -> i64 |
| 104 | func ap_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 108 | func ap_step(fd: i64, n: i64, verb: *u8, arg: *u8) -> i64 |
| 121 | func main(argc: i64, argv: *i64) -> i64 |