Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/runtime/rx_aien.h # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / runtime / rx_aien.h` 191 lines · 8908 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* 18 * rx_aien.h -- AIEN as a resident cognitive faculty (ADR 0016 §44, R11). 19 * 20 * AIEN is not a service. Nothing calls AIEN and waits, and AIEN calls no 21 * other faculty. Its cognition is a set of reactions on the shared world. 22 * It observes what other faculties publish, keeps its own beliefs and 23 * predictions as world objects, and publishes hypotheses and plans. Omega, 24 * or any other faculty holding a read capability, may react to a plan. 25 * 26 * aien.observe demand interval, selection -> belief 27 * aien.predict belief -> prediction 28 * aien.explain prediction state -> hypothesis 29 * aien.assess goal, prediction state -> assessment 30 * aien.plan hypothesis state, assessment -> plan, memory, hypothesis 31 * 32 * What it reasons about here: the cost of one operation the body runs. 33 * Omega's selection record is a claim ("this realization costs this much"). 34 * AIEN learns what production actually pays under that record, predicts it 35 * keeps paying that, and notices when the prediction fails. It explains the 36 * failure from what else it observed (a change of core class, or nothing), 37 * and publishes one experiment per untried condition. It does not re-plan a 38 * condition it has already had explored. 39 * 40 * The inputs are object references only. This file includes no Omega header 41 * and calls no Omega function; the build checks that rx_aien.o has no 42 * undefined omega_* or rx_omega_* symbol. 43 * 44 * The reasoning is a small explicit statistical model (interval means, 45 * tolerance bands, streaks). It is not a neural model. The claim is the 46 * faculty's form: when cognition happens, what it reads, what it publishes, 47 * and that the body's behaviour changes because of it. 48 */ 49 #ifndef RX_AIEN_H 50 #define RX_AIEN_H 51 52 #include "rx_world.h" 53 54 #include 55 56 /* Object types (RxObject.type). */ 57 enum { 58 RX_OT_PLACEMENT = 0x5311u, RX_OT_GOAL, RX_OT_BELIEF, RX_OT_PREDICTION, 59 RX_OT_HYPOTHESIS, RX_OT_PLAN, RX_OT_ASSESSMENT, RX_OT_MEMORY, 60 RX_OT_EXPERIMENT_BELIEF 61 }; 62 63 /* placement: 0 seq, 1 core class (MIDR part number, 0 = unknown), 2 cpus (external) 64 * goal: 0 seq, 1 regime, 2 target ns per call (external, human) 65 * belief: 0 selection epoch, 1 realization word 0, 2 demand calls at last 66 * interval, 3 demand ns at last interval, 4 baseline mean ns, 67 * 5 intervals seen, 6 last interval mean ns, 7 miss streak 68 * prediction: 0 seq, 1 selection epoch, 2 regime, 3 hit streak, 4 core class, 69 * 5 expected ns per call, 6 state, 7 observed ns when it failed 70 * hypothesis: 0 seq, 1 kind, 2 prediction seq, 3 class then, 4 class now, 71 * 5 expected ns, 6 observed ns, 7 state 72 * plan: 0 seq, 1 action, 2 regime, 3 condition (core class), 73 * 4 hypothesis seq (0 = none), 5 reason, 6 goal seq (0 = none) 74 * assessment: 0 goal seq, 1 regime, 2 target ns, 3 expected ns, 4 status, 75 * 5 core class, 6 prediction seq 76 * memory: 0 count, 1..7 explored condition keys (rx_aien_key) 77 * 78 * The demand and selection objects are Omega's (rx_omega.h): 79 * demand 0 regime calls, 1 regime ns, 4 M, 5 N, 6 realization in use 80 * selection 0 epoch, 1 realization word 0, 6 regime 81 * regime = (M << 32) | N. */ 82 83 enum { RX_AIEN_PRED_HOLDING = 1, RX_AIEN_PRED_CONFIRMED, RX_AIEN_PRED_FAILED }; 84 85 enum { RX_AIEN_HYP_CORE_CLASS = 1, /* the record was made on another core class */ 86 RX_AIEN_HYP_DRIFT }; /* nothing observed changed; the record may be stale */ 87 88 enum { RX_AIEN_HYP_OPEN = 1, 89 RX_AIEN_HYP_TESTING, /* a plan is out for it */ 90 RX_AIEN_HYP_SUPPORTED, /* the new record under the condition holds */ 91 RX_AIEN_HYP_UNSUPPORTED, /* a prediction under the condition failed again */ 92 RX_AIEN_HYP_EXHAUSTED }; /* the condition was already explored; no new plan */ 93 94 enum { RX_AIEN_ACT_RESEARCH = 1 }; /* re-evaluate realizations for a regime, where it runs now */ 95 96 enum { RX_AIEN_WHY_CORE_CLASS = 1, RX_AIEN_WHY_DRIFT, RX_AIEN_WHY_GOAL }; 97 98 enum { RX_AIEN_GOAL_UNKNOWN = 1, /* no confirmed prediction for the regime yet */ 99 RX_AIEN_GOAL_MET, 100 RX_AIEN_GOAL_UNMET, /* and the condition is unexplored: plan wakes */ 101 RX_AIEN_GOAL_UNMET_EXPLORED };/* already explored here; nothing to try */ 102 103 enum { RX_AIEN_EXP_SUPPORTED = 1, /* every replicate matched its expected value */ 104 RX_AIEN_EXP_REFUTED }; /* at least one did not */ 105 106 #define RX_AIEN_MEMORY_SLOTS 7u 107 108 typedef struct { 109 uint32_t baseline_intervals; /* intervals averaged into the baseline; they must 110 agree within tolerance_pct or it starts again */ 111 uint32_t tolerance_pct; /* an interval outside +/- this is a miss */ 112 uint32_t misses_to_fail; /* consecutive misses that fail a prediction */ 113 uint32_t confirm_intervals; /* consecutive hits that confirm it */ 114 uint32_t min_calls; /* fewer calls in an interval: too little evidence */ 115 } RxAienConfig; 116 117 /* Objects other faculties own that AIEN observes. */ 118 typedef struct { 119 RxObjRef demand, selection; 120 } RxAienInputs; 121 122 typedef struct { 123 RxObjRef placement, goal; /* written from outside */ 124 RxObjRef belief, prediction, hypothesis, plan, assessment, memory; 125 RxObjRef experiment_belief; /* R13: physical consequence accepted by AIEN */ 126 } RxAienObjects; 127 128 /* Resources: RX_AIEN_RES_BASE + index; the caller mints against them. */ 129 #define RX_AIEN_RES_BASE 0x5311000ull 130 enum { 131 RX_AIEN_RES_PLACEMENT = 0, RX_AIEN_RES_GOAL, RX_AIEN_RES_BELIEF, RX_AIEN_RES_PREDICTION, 132 RX_AIEN_RES_HYPOTHESIS, RX_AIEN_RES_PLAN, RX_AIEN_RES_ASSESSMENT, RX_AIEN_RES_MEMORY, 133 RX_AIEN_RES_EXPERIMENT_BELIEF, 134 RX_AIEN_RES_COUNT 135 }; 136 137 enum { RX_AIEN_SUBJ = 31 }; 138 139 /* One capability reference per AIEN-owned resource, plus the two read-only 140 * references to what AIEN observes. The root decides at run time whether each 141 * still grants what the reaction declares. */ 142 typedef struct { 143 RxCapRef own[RX_AIEN_RES_COUNT]; 144 RxCapRef demand, selection; 145 RxCapRef experiment_evidence; 146 } RxAienCaps; 147 148 typedef struct { 149 RxWorld *w; 150 RxAienConfig cfg; 151 RxAienInputs in; 152 RxAienObjects o; 153 uint32_t r_observe, r_predict, r_explain, r_assess, r_plan; 154 uint32_t r_experiment; 155 RxObjRef experiment_evidence; 156 /* R16 C5: this faculty's caller credentials (rx_caller.h); null in a 157 * world without bound callers. Held here, never published. */ 158 const RxCallerKeyring *keys; 159 } RxAienFaculty; 160 161 void rx_aien_default_config(RxAienConfig *cfg); 162 163 int rx_aien_create_objects(RxAienFaculty *f, RxWorld *w, const RxAienConfig *cfg, 164 const RxAienInputs *in); 165 166 int rx_aien_register(RxAienFaculty *f, const RxAienCaps *caps); 167 168 /* R13. Optional reaction on physical experiment evidence (an object another 169 * faculty publishes). Evidence fields: 0 search epoch (set when the 170 * experiment ends), 1 expected, 2 observed, 3 all replicates matched (1), 171 * 4 replicates matched. Experiment belief: 0 epoch, 1 last observed, 172 * 2 RX_AIEN_EXP_SUPPORTED or RX_AIEN_EXP_REFUTED, 3 replicates. */ 173 int rx_aien_register_experiment(RxAienFaculty *f, RxObjRef evidence, 174 RxCapRef evidence_read, RxCapRef belief_write); 175 176 /* Restart. Publishes `n` (1..RX_AIEN_MEMORY_SLOTS) explored condition keys into 177 * the memory object as an outside publication (`memory_write` is WRITE on 178 * RX_AIEN_RES_MEMORY for the outside subject), before any goal. The caller 179 * decides what may be remembered: only conditions with a promoted lesson 180 * (rx_living_explored_keys), never a candidate. */ 181 int rx_aien_seed_explored(RxAienFaculty *f, RxCapRef memory_write, const uint64_t *keys, uint32_t n); 182 183 static inline uint64_t rx_aien_regime(uint64_t M, uint64_t N) { return (M << 32) | N; } 184 185 /* One explored condition: core class and regime. */ 186 static inline uint64_t rx_aien_key(uint64_t core_class, uint64_t regime) { 187 uint64_t M = regime >> 32, N = regime & 0xffffffffu; 188 return ((core_class & 0xfffu) << 40) | ((M & 0xfffffu) << 20) | (N & 0xfffffu); 189 } 190 191 #endif /* RX_AIEN_H */