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 / docs / runtime / COMMIT_A_REACTION_DESIGN.md

183 lines · 15016 bytes Raw Blame History Rendered
1# Commit a reaction: design note
2
3Status: DESIGN NOTE, docs only. No runtime code changes. Nothing here is implemented, qualified or measured.
4Update 2026-10-02: the FORGE question in section 5 is decided (Option B). See "Decision 2026-10-02" at the end.
5Evidence base: omega `origin/main` at 2dc9dd8. Every line number below was checked against that commit.
6Vocabulary (module, interface, seam, adapter, depth) follows the codebase-design skill.
7Owner of `src/runtime`: the M20 program. This note touches no file there.
8
9## 1. The chain today, with evidence
10
11There is no single "commit a reaction" function. The chain is spread over `rx_compose.c` (the only
12module that wires it, 1258 lines), `rx_world.c`, `rx_jspace.c` and `rx_cortex_record.c`. AEGIS in this
13chain is a reaction named `compose.verify`, not a call into `rx_aegis.c`.
14
15| Step | What happens | Evidence |
16|------|--------------|----------|
17| Routing | Alternatives are discovered; routing mints nothing | `rx_compose.c:1130-1131` (`sr_route_alternatives`) |
18| World: goal published | Goal fields are written as an external publish, then the run waits for quiet | `rx_compose.c:1150` calls `rx_world_publish_external` (`rx_world.c:2053`); wait at `rx_compose.c:1155` via `rx_world_wait_quiescent` (`rx_world.c:2405`) or `wait_own` (`rx_compose.c:908`) |
19| J-Space: two candidates | `compose.candidate.0/1` fork a staged branch from the current state branch, run the Skill (a CPU procedure, `rx_compose.c:162`), derive the result into the branch | `candidate_fn` `rx_compose.c:126-188`; fork `:157` (`js_branch_fork_staged`, `rx_jspace.c:1241`); derive `:169` (`js_branch_derive`) |
20| AEGIS: verify | `compose.verify` (faculty `RX_FACULTY_AEGIS`) waits for both candidates, applies the contract, picks the lowest-numbered passer, writes the verdict | reaction desc `rx_compose.c:771-787`; `verify_fn` `rx_compose.c:191-220`; the only subject allowed to write the verdict holds the write cap (`:747`) |
21| Commit: name the winner | `commit_fn` proposes state.REF = winner branch; proposes nothing if there is no winner | `rx_compose.c:223-232` (no-winner refusal `:226`) |
22| Commit: World binder | Before the World accepts the new REF, `bind_check` validates, then `bind_fn` seals the branch (point of no return) | `bind_check` `rx_compose.c:236-249`; `bind_fn` `:251-268` (`js_branch_seal`, `rx_jspace.c:1255`); `bind_abort` `:270`; installed by `rx_world_set_binder` (`rx_world.c:982`, call `rx_compose.c:706`) and `rx_world_bind_field` (`rx_world.c:1010`, call `:803`) |
23| Settle | Reclaim losers, make J-Space durable, write Cortex records, release the old branch, make durable again | `rx_compose.c:1175` (`js_space_reclaim_staged`, `rx_jspace.c:1273`), `:1181` (`js_space_commit`, `rx_jspace.c:1516`), `:1189` (`compose_records`), `:1194` release, `:1195` commit |
24| Cortex | Candidate claims, evidence ref, promotion of the winner, loser admissions; resumable | `compose_records` `rx_compose.c:340-500`; Cortex attached to the World at open by `rx_cortex_attach` or `rx_cortex_attach_scoped` (`rx_cortex_record.c:209`, `:223`; calls `rx_compose.c:805-809`) |
25
26### Ordering rules (all in `rx_compose.c` unless noted)
27
281. Binder is installed before objects, caps and reactions (`:705-706`).
292. Objects are created in fixed slot order GOAL, CAND0, CAND1, VERDICT, STATE; own-World mode requires ids 0..4 (`:718-725`, refusal `RX_ERR_BAD_DESC` at `:724`).
303. Caps are minted before reactions (`:735-750`); Cortex is attached after the field bind (`:803-811`).
314. Open order: machine.id check, `cx_open`, `cx_verify_chain`, J-Space open, `recover()`, then the World is built (`:844-871`, `:961-964`).
325. Verify waits for BOTH candidates to be done for this goal (`:198-199`).
336. A pending, incomplete composition record is completed BEFORE a new goal starts (`:1116-1128`).
347. Settle order is reclaim, durable commit, Cortex records, release old, durable commit (`:1175-1199`).
358. The binder seals, then clears branch ownership so a loser or outsider cannot reuse it (`:265-266`).
36
37### Refusal rules
38
39Error codes are defined at `rx_world.h:112-127`.
40
41- `RX_ERR_BINDING` from the binder (`:239-247`, `:259`, `:265`): wrong object or field; caller is not the commit subject; branch not live; not staged or not local; owner is not a candidate; parent is not the branch the World names now; seal refused.
42- `RX_ERR_REPLAY` on open: Cortex file will not open (`:858`), chain does not verify (`:859`), J-Space will not open (`:869`).
43- `RX_ERR_REPLAY` in `recover()`: missing payload (`:514`); state recorded but none durable (`:530`); a promoted state is missing from the checkpoint (`:540`); admission append fails (`:553`); durable history with no state record (`:563`); genesis root fails (`:569`); durable commit fails (`:574`).
44- `RX_ERR_REPLAY` in run: previous run left `pending == 2` (`:1116`); completing the previous record fails (`:1120`, `:1125`).
45- Outcomes returned as `RX_OK` with a state in the result: `NOT_DURABLE` (`:1181-1184`, then every run refuses until reopened), `RECORD_FAILED` (`:1189`, `:1195`, `:1206`), `NO_WINNER` (`:1211`), `NOT_COMMITTED` (`:1214`); enum at `rx_compose.h:158-162`.
46
47### What the four named mutants guard
48
49`tools/c4_requal_mutants.sh` rows M05, M06, M12, M16 (script lines 24, 25, 31, 35). Each sed pattern was
50checked to match exactly one line. All four guard the recovery path on open, not the live commit above.
51
52| Mutant | Guarded line | Plain meaning |
53|--------|--------------|---------------|
54| M06 | `rx_compose.c:509` | Recovery walks state records newest first, so it picks the latest durable state |
55| M05 | `rx_compose.c:535` | Only records newer than the chosen durable state receive a rollback admission |
56| M16 | `rx_compose.c:540` | Open refuses if Cortex promoted a state that the J-Space checkpoint lost |
57| M12 | `rx_compose.c:574` | The recovered state is made durable before the World starts; a failed save refuses the open |
58
59This note does not claim which mutants guard the live commit order; that mapping was not done (UNVERIFIED).
60
61## 2. Where FORGE exists today
62
63- `js_forge_choose`: `rx_jspace.c:996` (decl `rx_jspace.h:407`). Picks keep, move or drop for one branch under memory pressure.
64- `js_forge_enforce`: `rx_jspace.c:1195` (decl `rx_jspace.h:408`). Applies those choices to stay in a byte budget.
65- `omega_forge_realize` `src/forge_realization.c:22`; also `omega_realization_request_init` `:5`, `omega_forge_submit` `:37`. Note this file is in `src/`, not `src/runtime/`.
66
67Proof it is not on the reaction path (grep over the checkout, `.git` excluded):
68
69- `js_forge_choose`: no callers outside `rx_jspace.c`.
70- `js_forge_enforce`: callers are `tests/runtime/rx_branch_reuse.c:540` and `tests/runtime/rx_jspace_prod.c:238` only. No caller in `src/`.
71- `grep -c js_forge` returns 0 in `rx_compose.c`, `rx_world.c`, `rx_aegis.c` and `rx_cortex.c`.
72- `omega_forge_realize`, `omega_forge_submit`, `omega_realization_request_init`: no callers in `src/` or `tests/*.c` beyond their definitions. The file appears only in two test compile lists (`tests/run_reduce_chip.sh:67`, `tests/run_numeric_gates.sh:160`) and one include (`src/aegis_verification.h:4`).
73- The repo already says so: `tools/c4_requal.sh:84` ("FORGE is not on the composed path ... omega_forge_realize has no caller in src/runtime").
74
75So there are two different things called FORGE here. In J-Space it is a memory-pressure policy. In
76`forge_realization.c` it is the realizer for hardware work. Neither runs when a reaction commits.
77
78## 3. What the architecture records say
79
80Read with `gh` at `aien-spark/aien-architecture` main, commit 26daeedb23c5.
81
82ADR 0016, `docs/adr/0016-resident-reaction-architecture.md` (Accepted by operator, 2026-09-27):
83- It sets no fixed World, J-Space, AEGIS, commit, Cortex order. J-Space is not mentioned.
84- L59-63: "ATLAS AWAKENS ... FORGE REALIZES. AEGIS VERIFIES ..." is "not a runtime turn order". "OMEGA defines" and "FORGE realizes" are reactions that become ready when proposals exist. "Verification reactions gate promotion. AEGIS is not a synchronous call on every step."
85- L51: FORGE realizes; it is not a security gatekeeper. L1484: FORGE is not the kernel and not the policy authority.
86- L78: the generation barrier must commit through the ADR 0015 ordered commit protocol.
87
88ADR 0024, `docs/adr/0024-rust-scaffolding-omega-destination.md` (Accepted 2026-10-01):
89- Physics and FORGE are class B, hardware substrate, "C and asm justified" (table row 26).
90- L38: use the best proven realization regardless of orchestration language. Rule 4: the four-question test before new C.
91- It names no commit module.
92
93`doctrine/ARCHITECTURE.md` (ratified): section 2.6 L191-200 puts FORGE at lowering (step 3) and dispatch
94(step 6). L229 says `rx_world.c` is the only code that orders faculty work. L245: other substrates attach as FORGE capability providers.
95
96Reading: the doctrine says FORGE is a reaction that realizes work, which is closer to Option A than to
97Option B. But it also says FORGE realizes hardware work, and the composed path today runs CPU procedures
98only, so nothing in it needs realizing. No doctrine sentence says FORGE must sit on the commit path.
99
100## 4. Proposed "commit a reaction" module (words only)
101
102Today a caller must understand 15 `rx_world_*` entries, the binder, the J-Space branch calls and the Cortex
103record calls to get one correct commit, and the correct order lives in comments and in `rx_compose.c`
104(deletion test: delete `rx_compose.c` and the ordering rules reappear in every caller).
105
106One interface: "propose a result for a goal, and either commit it or refuse it". The caller supplies the
107goal input, the requirement, and the contract that a result must meet. It gets back one of the existing
108outcomes (committed, no winner, not committed, not durable, record failed), the old and new state
109references, and the winner. The caller never sees a branch, a binder, a verdict object or a Cortex record.
110
111The order it enforces (unchanged from section 1): route, publish the goal, candidates fork from the
112current state, verify against the contract, name the winner, seal through the binder, make durable, write
113Cortex records, release the old state, make durable again. A previous incomplete record is always finished
114first.
115
116Refusal rules it keeps (unchanged): every code in section 1. After `NOT_DURABLE` it refuses everything
117until reopened. It refuses to open over durable history with no state record.
118
119Seams it would keep inside: (a) candidate realizer, where today a CPU Skill runs and where FORGE would
120plug in if Option A is chosen; (b) the contract check; (c) the durable store (J-Space); (d) the Cortex
121record writer; (e) the fault points that tests use (`RXC_FP_*`). The binder, verdict object and slot
122layout become private. This is largely what `rx_compose.h` already is, so the first step would be to
123rename and narrow it, not to rewrite it. The recovery rules (M05, M06, M12, M16) move with it unchanged.
124
125Not decided here: whether open and recovery are part of the same module or a second one.
126
127Note (2026-10-02): the phrase "where FORGE would plug in if Option A is chosen" in seam (a) is closed by the decision below. Option A was not chosen.
128
129## 5. Decision for Drake (plain English) [CLOSED 2026-10-02: Option B chosen, see "Decision 2026-10-02" below]
130
131Where things stand: the review found that the part of Omega that decides "this result is accepted and
132remembered" works as one well-guarded sequence, but the piece called FORGE, which the design documents
133describe as the thing that makes work real, is not part of that sequence. It exists in two places and
134neither runs when a result is accepted.
135
136The decision: should FORGE be part of how a result is accepted?
137
138**Option A: wire FORGE into the path.** Candidates would be produced through FORGE instead of through plain
139CPU procedures.
140- Upside: the code would match what the architecture documents say. GPU work could join the same
141 accept-or-refuse sequence with the same safety rules.
142- Downside: it touches the most guarded code in the runtime, and today there is nothing for FORGE to do on
143 that path, because the work is CPU only. It needs a chip receipt before it can be believed, and the
144 runtime files are owned by the M20 program.
145- If chosen: a follow-up plan, built behind the module in section 4, with FORGE as one swappable piece. The
146 existing recovery tests would have to keep passing unchanged.
147- Reversible: yes, as long as FORGE stays a swappable piece. Putting the old CPU path back is small.
148
149**Option B: amend the doctrine so FORGE is only a memory policy inside J-Space.** The documents would be
150changed to match the code.
151- Upside: no code risk, the records stop promising something the code does not do. Cheapest.
152- Downside: it closes the door on FORGE realizing hardware work through this path. The architecture
153 document, ADR 0016 and the roadmap would each need an edit, and ADR 0024 treats FORGE as the hardware
154 substrate, so the two meanings of FORGE would have to be named separately.
155- If chosen: a documents-only change in the architecture repository.
156- Reversible: yes, but a reversal later means writing the doctrine again and breaking anything that relied on it.
157
158**Option C: leave as is.** Keep the gap, with the known-gap line already in the receipt.
159- Upside: zero cost and zero risk now.
160- Downside: the documents and the code stay in disagreement, and anyone reading them will believe FORGE is
161 involved when it is not. The gap becomes harder to fix as more code is built around the current path.
162- If chosen: nothing changes; the next review will raise it again.
163- Reversible: yes, it can be decided later at no loss except time.
164
165Separately, this note recommends doing the section 4 narrowing under any option, since it changes no
166behavior and makes the order easier to protect. That is an engineering suggestion, not part of this decision.
167
168One question: do you want FORGE to be part of how Omega accepts a result (A), only a memory policy with the
169documents corrected (B), or to leave it for now (C)?
170
171The options text above (A, B, C) is kept as the record of what was offered. Option B was chosen. Options A and C are closed.
172
173## Decision 2026-10-02
174
175Drake chose Option B on 2026-10-02.
176
177- FORGE is a memory and realization policy. It is not a stage of accepting a reaction result.
178- The accept chain is World -> J-Space -> compose.verify -> commit -> Cortex, as documented in section 1.
179- Inside J-Space, FORGE is the memory-pressure policy (`js_forge_choose`, `js_forge_enforce`). Elsewhere it is the hardware realizer (`omega_forge_realize`). Neither is a step of this chain (section 2).
180- If hardware realization later needs a hook on this path, that is a new decision. It is not implied by this one.
181- No runtime code changed. This is a documents-only record.
182- The FORGE question in section 5 is closed.
183- The architecture repository carries a matching ADR 0016 amendment (companion PR in aien-architecture).