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
omega-mv / spec / cognitive-routing.md
| 1 | # Omega cognitive compute routing (OMEGA_COGNITIVE_ROUTING) |
| 2 | |
| 3 | Code: `src/runtime/rx_route.{c,h}`. Test: `tests/runtime/rx_cognitive_routing.c` |
| 4 | with stand-in engines in `tests/runtime/rx_cog_engines.{c,h}`, |
| 5 | `make test-cognitive-routing`. Receipt: `evidence/COGNITIVE_ROUTING/6731c0d0….json` |
| 6 | (candidate 8ed2d9f). |
| 7 | |
| 8 | ## Purpose |
| 9 | |
| 10 | Choose the cheapest cognitive realization that is expected to meet the |
| 11 | semantic requirement. No engine is assumed to be a language model, and |
| 12 | cognition is not assumed to be one model. An engine is a function with a |
| 13 | declared class, the operations it supports, hard capacities, and a measured |
| 14 | profile. |
| 15 | |
| 16 | ## Objects |
| 17 | |
| 18 | ``` |
| 19 | CognitiveRequirement (RxCogRequirement) |
| 20 | operation_class, minimum_quality, uncertainty_budget, memory_requirement, |
| 21 | temporal_requirement, planning_depth, precision_requirement, |
| 22 | latency_budget, energy_budget, hardware_constraints, escalation_allowed |
| 23 | |
| 24 | CognitiveRealization (RxCogRealization) |
| 25 | cognitive_engine_id, generation, supported_operations (in decl), |
| 26 | quality_profile, uncertainty_profile, resource_cost_model |
| 27 | (latency_model = mean/p99 ns, energy_model = nJ/call), hardware_requirements |
| 28 | (in decl), evidence (SHA-256 of the evidence sample) |
| 29 | ``` |
| 30 | |
| 31 | `escalation_allowed` is a count: the escalations permitted after the first |
| 32 | rung (0 = none). Quality is in parts per million. |
| 33 | |
| 34 | The declaration (`RxCogDeclaration`: class, supported operations, hardware, |
| 35 | memory capacity, temporal horizon, maximum planning depth, precision, |
| 36 | whether answers carry a sound check) is fixed at registration. The SHA-256 of |
| 37 | all declarations is the registry digest; a model is bound to it. |
| 38 | |
| 39 | Realization classes: deterministic compiled procedure, small learned policy, |
| 40 | specialized neural module, general cognition, ensemble, J-Space exploration. |
| 41 | |
| 42 | ## Routing |
| 43 | |
| 44 | 1. **Hard filter.** An engine is eligible if it supports the operation, needs |
| 45 | no hardware the request forbids, and its memory capacity, temporal horizon, |
| 46 | planning depth and precision cover the request. |
| 47 | 2. **Evidence filter.** It must have at least 200 labelled trials for the |
| 48 | operation in the active generation, a measured cost, and a place in the |
| 49 | operation's evidence sample. |
| 50 | 3. **Acceptance.** For each engine the router derives the lowest confidence |
| 51 | bin from which an answer may stop the ladder: the pooled answers at or |
| 52 | above that bin must have a 95% Wilson upper error bound within the |
| 53 | `uncertainty_budget`. A verifiable engine's checked answer is accepted on |
| 54 | its check (a sound check has no error to bound). One checked answer |
| 55 | observed wrong, or none observed, withdraws that. |
| 56 | 4. **Ladders.** Every cost-ordered subset of the eligible engines, of length |
| 57 | at most `escalation_allowed + 1` (and 4), is evaluated on the evidence |
| 58 | sample: for each recorded trial, walk the rungs; stop at the first rung |
| 59 | whose recorded bin is accepted, or at the last rung; count whether that |
| 60 | answer was right and add the mean cost of every rung reached. The sample |
| 61 | is the joint record of all engines on the same requests, so dependence |
| 62 | between engines (hard inputs are hard for all of them) is in the estimate. |
| 63 | 5. **Choice.** Keep ladders whose 95% Wilson lower quality bound meets |
| 64 | `minimum_quality`, whose expected time fits `latency_budget`, and whose |
| 65 | expected energy fits `energy_budget` (an energy budget without an energy |
| 66 | model is not met). Choose the one with the least expected energy (time when |
| 67 | any rung has no metered energy). No ladder: `RX_COG_ERR_UNSATISFIABLE`. |
| 68 | The request is refused, never silently approximated. |
| 69 | 6. **No evidence.** When the active generation has no evidence for the |
| 70 | operation, the operation's reference realization (declared at |
| 71 | registration) runs alone and the ladder says `no_evidence_reference`. |
| 72 | Evidence that disqualifies every engine is a refusal, not a bootstrap. |
| 73 | |
| 74 | The ladder for a requirement is cached per generation. |
| 75 | |
| 76 | ## Escalation |
| 77 | |
| 78 | ``` |
| 79 | rung 0 (cheapest) -> accepted? yes: done |
| 80 | no, or the engine failed: next rung |
| 81 | ... |
| 82 | last rung -> accepted: RX_COG_OK |
| 83 | not accepted: RX_COG_ERR_EXHAUSTED, the answer is still returned |
| 84 | ``` |
| 85 | |
| 86 | The ladder is bounded before it runs: its length and its expected cost are |
| 87 | admission conditions. Nothing measured while it runs changes which rungs run, |
| 88 | only the answers do; a run under scheduling noise takes the same path as a |
| 89 | quiet one. The trace records every rung, its confidence and time, the final |
| 90 | engine and the escalation count. |
| 91 | |
| 92 | ## Learning |
| 93 | |
| 94 | Observations go into a ledger (`RxCogLedger`): labelled joint trials (quality, |
| 95 | failures, confidence bins, per-call time for p99) and batch costs (processor |
| 96 | time per call from a batch, metered energy per call). `rx_route_propose` |
| 97 | serializes the ledger into a generation's `model` blob and proposes it. The |
| 98 | routing does not change until that candidate is promoted by a principal |
| 99 | holding `RX_GEN_RIGHT_PROMOTE` on `RX_GEN_RES_PROMOTION` on the native Aienux |
| 100 | authority, and the proposer may not promote its own candidate |
| 101 | (`rx_generation`). |
| 102 | |
| 103 | The router reads profiles only through `rx_route_load`, which reads the active |
| 104 | generation's `model` blob through its SHA-256 root. A torn blob, or a model |
| 105 | built against another registry, is refused and the loaded profiles are kept. |
| 106 | There is no call that installs profiles from memory. `rx_route.o` is built |
| 107 | alone and the build fails if it references `rx_gen_promote` or any |
| 108 | `aienos_cap_*` / `rx_caproot_mint` / `rx_caproot_revoke` symbol. |
| 109 | |
| 110 | ## Gate |
| 111 | |
| 112 | OMEGA_COGNITIVE_ROUTING_PASS requires, on one held-out workload (20,000 |
| 113 | recognitions, 2,000 plans), run routed and on the always-most-expensive |
| 114 | eligible realization (the one with the highest measured cost, alone): |
| 115 | |
| 116 | - both meet the same `minimum_quality` for every operation (recognition 0.95, |
| 117 | planning 0.998), measured against ground truth; |
| 118 | - routed median processor time is lower, and lower in every one of 9 |
| 119 | back-to-back pairs (order alternating); |
| 120 | - where an energy meter exists (DGX Spark `aien_spbm`, CPU P+E clusters), |
| 121 | routed median metered energy is lower, and lower in every pair; |
| 122 | - escalation never exceeds its bound; no routed request is refused; |
| 123 | - every promotion attempt without the right, or by the proposer, is refused; |
| 124 | - all checks pass (hard constraints, torn and foreign models, engine failure |
| 125 | escalation, learning after damage). |
| 126 | |
| 127 | The meter covers whole CPU clusters, so other work on the machine lands in |
| 128 | both legs of a pair; the receipt records the load average and every pair. |
| 129 | |
| 130 | ## The test's engines |
| 131 | |
| 132 | Stand-ins, not AIEN. Recognition: label a 16-dimensional observation by a |
| 133 | fixed nonlinear rule the engines learn from 20,000 labelled examples. |
| 134 | Engines: small policy (logistic regression on x and x²), neural module |
| 135 | (16-12-1), general (16-96-96-1), ensemble (general + two 16-64-64-1 + neural). |
| 136 | Planning: a path within a length bound on a 96×96 grid with 28% obstacles, or |
| 137 | proof there is none. Engines: greedy best-first (deterministic, checked, |
| 138 | depth 256), weighted A* with an expansion budget (deterministic, checked, |
| 139 | depth 1024), exhaustive breadth-first exploration to the bound (J-Space, |
| 140 | exact). |
| 141 | |
| 142 | Learning scenario: the neural module's weights are perturbed. Under the still |
| 143 | active generation routed recognition quality falls below the requirement. A |
| 144 | fresh labelled ledger is proposed; the routing is unchanged until it is |
| 145 | promoted; after promotion the router stops using the damaged module and |
| 146 | quality meets the requirement again, still cheaper than the most expensive. |
| 147 | |
| 148 | ## Not claimed |
| 149 | |
| 150 | - AIEN cognition (the engines are stand-ins); |
| 151 | - graphics-processor realizations; |
| 152 | - energy below idle (the meter is whole-cluster and includes idle draw); |
| 153 | - routing of concurrent requests (one router per thread); |
| 154 | - learning without labelled trials (the ledger needs ground truth); |
| 155 | - a deadline that preempts a running rung. |