interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / spec / action-graph-ir.md

199 lines · 9629 bytes Raw Blame History Rendered
1# Omega action graph IR (OMEGA_ACTION_GRAPH_IR)
2
3Code: `src/runtime/rx_graph.{c,h}`. Test: `tests/runtime/rx_action_graph.c`,
4`make test-action-graph`. Receipt: `evidence/ACTION_GRAPH/`.
5
6## Purpose
7
8Routine multi-step behaviour should not return to deliberation at every
9step. AIEN states a goal. Omega compiles the goal, the World, the capabilities
10the principal already holds, and the goal's constraints into a typed action
11graph. Omega checks the graph, optimizes it, and lowers it onto resident
12reactions. After that the graph runs by readiness alone, every time its run
13token moves.
14
15This is not a tool-call DAG. Nodes are typed semantic operations over World
16objects, Cortex memory, Skill Net procedures and effects. Nothing in the
17graph is prompt text, JSON, shell or source code. A backend may later lower a
18node into one of those. The graph stays typed Omega state.
19
20## Boundaries
21
22| Faculty | Role here |
23|---|---|
24| AIEN | states the goal (goal kind + World objects). Not changed by this work. |
25| Omega | compiles, validates, optimizes, lowers. Has no admin handle. |
26| AEGIS | decides policy when authority is missing (R8 slow path). |
27| Aienux | the only minter (native C capability authority). |
28| World | cells, run token, effect objects; readiness drives execution. |
29
30Omega gains no authority. `rx_graph.o` is linked alone first and the build
31fails if it references any `aienos_cap_*` admin operation.
32
33## Integration map (what is reused)
34
35| Need | Existing mechanism |
36|---|---|
37| concurrency from dependencies | rx_world dependency index + worker pool (R3) |
38| typed authority at start and publish | rx_world `validate_caps` twice per activation (R3/R7) |
39| missing authority | AEGIS request/decision/slot, root.install mints (R8) |
40| resource admission | rx_world `RxResourceNeed` / budget (R5) |
41| stale references | object generations; `RX_ERR_STALE_GEN` invalidation (R3/R9) |
42| causal record | content-addressed crumbs with parents and episodes (R4/R6) |
43| pure operations | `omega_eval_pure_binary_uint` (Omega core) |
44
45New: the IR, its validation and identity, compile, passes, lowering, and the
46sequential reference. The engine is unchanged.
47
48## The graph
49
50```
51AgGraph {
52 nodes[] kind, out type, params, bound World object, cost
53 data[] typed edges (DATA or ON_FAIL) into numbered ports
54 deps[] GUARD (branch, polarity) and ORDER edges
55 auth[] authority requirements (resource, rights)
56 res[] resource requirements (RxResourceNeed)
57 success[], failure[] outcome conditions (node, status)
58 evidence[] nodes whose evidence must exist after a run
59 effects[] effect boundaries in their required total order
60}
61```
62
63Node kinds: CONST, PURE (Omega op, possibly fused), WORLD_READ,
64WORLD_PUBLISH, RECALL (Cortex memory), CAP_RESOLVE, PHYSICAL, SKILL,
65EFFECT_PROPOSE, EFFECT_PERFORM, VERIFY, BRANCH, JOIN, RETRY.
66
67Types: U64, BOOL, PROPOSAL, VERDICT, RECEIPT. EFFECT_PERFORM takes exactly a
68PROPOSAL and a VERDICT; a raw number cannot be performed.
69
70### Status per run
71
72Every node ends each run OK, FAILED or SKIPPED, or stays PENDING (blocked).
73Rules, in order: a failed or skipped guard, or a guard of the other polarity,
74gives FAILED / SKIPPED; a FAILED order source gives FAILED; JOIN takes the one
75OK input; otherwise a SKIPPED input gives SKIPPED, then a FAILED input gives
76FAILED; an ON_FAIL input runs the node only when its source FAILED. One
77function (`semantics()`) implements this for both the lowered reaction and the
78reference.
79
80### Validation
81
82- types per kind; ports dense from 0; acyclic;
83- effect boundaries (PUBLISH, PERFORM) form one total order;
84- every node that reads an object some boundary writes is ordered against
85 that boundary (no timing-dependent reads);
86- the arms of every JOIN are mutually exclusive (opposite guards, or OK vs
87 FAILED of the same node);
88- at most one guard per node; the lowered dependency count fits
89 `RX_MAX_DEPS`.
90
91### Identity
92
93Node identity is SHA-256 over kind, parameters, bound object and generation,
94fused steps, input identities by port, and control dependencies sorted by
95identity. A World read or recall also folds in every ancestor publication of
96the same object, so reads separated by a publication are different. A
97boundary folds in its position in the effect chain. The graph digest sorts
98node identities and condition/evidence records, so builder order does not
99change it; a semantic change does.
100
101## Compile
102
103`rx_graph_compile(goal, world, caps, constraints, library, optimize)`:
104
1051. choose the procedure for the goal kind (Skill Net template);
1062. bind World parameters to the goal's objects; refuse stale references;
1073. resolve CAP_RESOLVE nodes against the principal's table (a constant);
1084. validate; derive authority from each target's resource and evidence for
109 VERIFY and boundaries;
1105. constraints: max effects, forbidden resources, critical-path deadline;
1116. optimize and check preservation;
1127. report missing authority and resource-blocked nodes.
113
114Missing authority and missing resources do not refuse the graph; they are
115reported and the lowered node waits. Stale references, violated constraints,
116and type or structure errors refuse it.
117
118## Passes
119
120Passes 1–4 repeat until a round changes nothing; then 5.
121
1221. **Constant propagation.** A PURE node whose inputs are unguarded CONSTs
123 becomes a CONST (a fold that would fail is left alone).
1242. **Common subexpressions / redundant World reads.** Identity-equal nodes
125 merge. Never merged: boundaries, evidence nodes, condition nodes, BRANCH,
126 JOIN.
1273. **Pure fusion.** A unary PURE step whose producer is a PURE node with no
128 other consumer folds into it.
1294. **Dependency simplification.** An ORDER edge goes when a strict path
130 (DATA into non-JOIN, or ORDER, through nodes that can never be skipped)
131 already implies it, or when its source can neither fail nor skip and
132 neither end is a boundary. This is the parallelization pass: it removes
133 sequencing the plan stated but the semantics do not need.
1345. **Dead nodes.** Everything not an ancestor of a boundary, evidence or
135 condition node goes.
136
137`rx_graph_check_preserved` then requires the same boundaries in the same
138order, every evidence node, and every condition.
139
140## Lowering
141
142- one run token object (field 0 = run id; outside WRITE, principal READ);
143- one cell per node: 0 run, 1 status, 2 value, 3 evidence, 4 attempts;
144 every field is proposed on every run (`stamp_proposed`);
145- one reaction per node, faculty OMEGA, subject = the principal. Triggers:
146 the cells of its inputs, guard and order sources; source nodes trigger on
147 the run token. Reads: run token, own cell, the World target. Writes: own
148 cell, and the boundary target;
149- a reaction whose inputs are not all in for the current run proposes
150 nothing (NOOP). The last arriving input makes it compute. A node computes
151 once per run.
152
153No function sequences the nodes. Independent nodes are READY together and
154run on whatever workers are free.
155
156Authority per node: cell RW, run R, and the derived requirement. A held
157capability is the resident fast path. A missing one lowers to an unusable
158reference (the engine blocks and records BLOCKED_AUTHORITY), or, with an AEGIS
159binding, to a slotted capability plus an `ag.ask` reaction that files the
160request. AEGIS decides; the root mints into the slot; the slot wakes the
161waiting node.
162
163## Effects
164
165EFFECT_PROPOSE is thought: a value, no authority, no change. EFFECT_PERFORM
166needs R|W|EFFECT on the effect object, a passing verdict, and its place in the
167chain. The effect object holds count, last value, an order chain
168`H(chain, run, value)`, and the last run; the chain proves order.
169
170## Gate evidence (what the test proves)
171
172| Claim | How |
173|---|---|
174| same semantic result as sequential reference | every run: status, value and evidence of every node, outcome, effect chain |
175| lower critical path for parallel graphs | 1 vs 4 workers, same lowered graph, median of 15 runs the machine did not disturb (run-queue delay from schedstat, `tests/runtime/rx_quiet_reps.h`), pinned to one core class |
176| zero authority bypass | every commit to a boundary target comes from a lowered boundary reaction; stolen, revoked, forged and tampered cases blocked; compile mints nothing |
177| zero missing evidence | every evidence node of every successful run has its word |
178| same causal ancestry | per node, crumb parents inside the run's episode reach exactly the graph's ancestors and the run token |
179| deterministic semantic result | 8 runs × worker counts 1, 2, 4, 8, digest of all node results + effect object |
180
181Required scenarios: linear, parallel, diamond, branch/join (both arms),
182failure branch (+ bounded retry, + exhausted retry), effect boundary (+
183proposal only, + constraints), authority-blocked (AEGIS + human approval),
184resource-blocked (and resumed), stale-generation (compile-time and after
185lowering with the slot reused).
186
187## Limits
188
189- Procedures are fixed templates; no learned planner.
190- One AEGIS request per lowered graph.
191- RETRY loops inside its node; attempts do not re-enter the World.
192- A node blocked for authority or resources blocks its dependants even when
193 it would have been SKIPPED (conservative).
194- Up to 64 nodes, 4 data inputs per node.
195- CAP_RESOLVE is decided at compile time; the engine still checks every use.
196- The reference ignores resource budgets; resource scenarios compare after
197 admission.
198- Host processor only. The authority is the native C library, not the
199 Aienux kernel.