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 / docs / ans / INERTIAL_ALIGNMENT_SPEC_V1.md
| 1 | # Inertial Alignment v1 (ANS, the Alignment Navigation System) |
| 2 | |
| 3 | Status: implemented in `src/ans/`, tested by `make test-inertial-alignment`. |
| 4 | Cites: ARCH-0020 (estimation, EST-0/EST-1), ARCH-0017 (ARGUS observes, never |
| 5 | authorizes), `EVOLUTION_ARENA_SPEC_V1` section 5 (promotion contract), and |
| 6 | ARCH-0032 (the ADR for this module, written in parallel in aien-architecture). |
| 7 | |
| 8 | ## Idea |
| 9 | |
| 10 | An inertial navigation system keeps a position estimate by integrating motion |
| 11 | and goes stale as error accumulates, until an outside fix corrects it. ANS |
| 12 | treats alignment the same way. An agent's drift from its goal, intent, |
| 13 | provenance and scope is a small state estimated by the EST-1 Kalman filter. |
| 14 | Every action is a step that adds uncertainty. Sensors of three trust classes |
| 15 | pull the estimate back. A control law turns the estimate into an autonomy |
| 16 | tier. A promotion gate keeps self-improvement from touching the compass. |
| 17 | |
| 18 | ## What ANS is NOT |
| 19 | |
| 20 | - Not an authority. ANS measures and recommends. It never grants, revokes or |
| 21 | promotes. A verdict is data for the authority to consult (ARCH-0017 shape). |
| 22 | - Not a promotion path. The right to promote stays with the operator-held |
| 23 | principal (Arena spec section 5.1). ANS never calls `rx_gen_promote`; the |
| 24 | purity check forbids any reference to `rx_`. |
| 25 | - Not a new filter. It links `est_kf` and does not reimplement it. |
| 26 | - Not a proof of alignment. Drift is an estimate with declared noise. |
| 27 | - Not wired into the resident runtime, `all` or `test`. |
| 28 | |
| 29 | ## What is frozen |
| 30 | |
| 31 | The reference (the compass) is frozen. `ans_reference_freeze` validates it, |
| 32 | sets `frozen = 1` and returns its SHA-256 digest. Every other API takes a |
| 33 | `const ans_reference *` plus the expected digest and refuses |
| 34 | `ANS_ERR_REFERENCE` if the reference is unfrozen, invalid, or its recomputed |
| 35 | digest differs. The candidate under test never receives a mutable reference. |
| 36 | Atoms (10): AUTHORITY, CONSENT, SCOPE, PROVENANCE, REVERSIBILITY, |
| 37 | RESOURCE_LIMITS, INFORMATION_BOUNDARIES, GOAL_IDENTITY, DELEGATION_LIMITS, |
| 38 | SELF_MODIFICATION_LIMITS. Reference fields: `version` (non-zero), `limit[10]` |
| 39 | (max tolerated drift per atom, finite, > 0), `q[5]` (process noise per action |
| 40 | kind, > 0), `r[3]` (noise per sensor class, > 0, `r[FIX] < r[REFERENCE] < |
| 41 | r[IMU]`), `tier_sigma[3]` (0 < t1 < t2 < t3), `nis_limit` (> 0), |
| 42 | `promote_limit` (> 0). The digest covers all of these and not `frozen`. |
| 43 | |
| 44 | ## State A_t |
| 45 | |
| 46 | `ans_state`: goal, constraints (== reference digest), intent, evidence_root, |
| 47 | drift (an `est_belief`, n = 4, components GOAL, INTENT, PROVENANCE, SCOPE, |
| 48 | dimensionless; x = estimated drift, P = covariance), risk (0..1, |
| 49 | reversibility risk of the pending action), provenance (hash chain over every |
| 50 | record that shaped the state), generation, since_fix, last reference digest |
| 51 | seen, last_nis, disagreement, self_mod_steps, self_mod_unfixed. |
| 52 | Filter model: n = m = 4, F = I, H = I, Q = q[kind] I per step, R = r[class] I |
| 53 | per measurement, `step_ns` = 1. The prior is x = 0, P = r[FIX] I. |
| 54 | Components map to atom limits: GOAL to GOAL_IDENTITY, INTENT to CONSENT, |
| 55 | PROVENANCE to PROVENANCE, SCOPE to SCOPE. |
| 56 | |
| 57 | ## Actions (the inertial step) |
| 58 | |
| 59 | Kinds: OBSERVE, EFFECT, DELEGATE, INGEST_UNTRUSTED, SELF_MODIFY. |
| 60 | `ans_step` predicts one step with Q = q[kind] I, sets risk to the action's |
| 61 | reversibility risk, increments since_fix and generation, and chains the action |
| 62 | digest into provenance. Refused: non-finite input, zero action id, kind or |
| 63 | risk out of range, touches not 0/1, unfrozen or mismatched reference. An action |
| 64 | that touches SELF_MODIFICATION_LIMITS with reversibility risk above |
| 65 | `limit[SELF_MODIFICATION_LIMITS]` returns `ANS_ERR_ATOM`. The output state is |
| 66 | then the input with the refusal chained into provenance and generation |
| 67 | advanced and the drift unchanged: a record of the refusal, never a repair. A |
| 68 | SELF_MODIFY action, or one touching that atom, increments `self_mod_steps` and |
| 69 | `self_mod_unfixed`. |
| 70 | |
| 71 | ## Sensors (the fusion) |
| 72 | |
| 73 | Classes: IMU (least trusted), REFERENCE, FIX (most trusted). |
| 74 | `ans_measure` runs `est_kf_predict` (one tick, Q = 1e-9 I) then `est_kf_update` |
| 75 | with R = r[class] I. A FIX sets since_fix to 0 and self_mod_unfixed to 0. |
| 76 | REFERENCE and FIX record last_nis; a reading with nis above `nis_limit` sets |
| 77 | `disagreement = 1` and is still fused: the disagreement is the signal and is |
| 78 | never hidden. The flag is sticky; only a FIX within the limit clears it. |
| 79 | Refused: zero evidence or source (`ANS_ERR_EVIDENCE`); IMU carrying a |
| 80 | reference digest, or REFERENCE/FIX whose reference digest is zero or not the |
| 81 | frozen one (`ANS_ERR_SENSOR`); non-finite values; an EST refusal |
| 82 | (`ANS_ERR_EST`, with the `est_status` in the out parameter), for example |
| 83 | evidence equal to a belief digest. The filter clock is the state's; |
| 84 | `t_ns` and `seq` are bound into the measurement digest. |
| 85 | |
| 86 | ## Drift and the control law |
| 87 | |
| 88 | `ans_drift`: mean_norm = ||x||2, sigma = sqrt(trace P), D = sqrt(mean_norm^2 + |
| 89 | sigma^2). `ans_autonomy` returns an `ans_verdict` with tier FULL |
| 90 | (sigma < t1), REVERSIBLE_ONLY (t1 <= sigma < t2), SIMULATE_ONLY |
| 91 | (t2 <= sigma < t3), HALT_REQUEST_FIX (sigma >= t3). Any component whose |x| |
| 92 | exceeds its mapped atom limit raises the tier to at least REVERSIBLE_ONLY. |
| 93 | `disagreement == 1` forces HALT_REQUEST_FIX regardless of sigma. The verdict |
| 94 | carries D, mean_norm, sigma, since_fix, disagreement, the state digest, the |
| 95 | reference digest and its own digest. It is advisory. |
| 96 | |
| 97 | ## Promotion gate (RSI may not touch the compass) |
| 98 | |
| 99 | `ans_promotion_check` takes a request (candidate digest, reference at birth, |
| 100 | tests at birth, tests now, candidate state) and writes a digested |
| 101 | `ans_promotion_record` whose `result` is, in this precedence order: |
| 102 | REFUSED_REFERENCE (reference at birth is not the frozen digest: the compass |
| 103 | changed during the candidate's life), REFUSED_TESTS (tests now differ from |
| 104 | tests at birth: the instrument changed in the same transaction), |
| 105 | REFUSED_DISAGREEMENT, REFUSED_DRIFT (D above `promote_limit`), |
| 106 | REFUSED_SELF_MOD (`self_mod_unfixed > 0`: self-modification without a FIX |
| 107 | after it), else OK. The return value is a status; a refusal is a successful |
| 108 | record. The record is data for the holder of the promotion right. |
| 109 | |
| 110 | ## Status codes |
| 111 | |
| 112 | `ans_status`: OK, ERR_NULL, ERR_REFERENCE, ERR_NONFINITE, ERR_EVIDENCE, |
| 113 | ERR_SENSOR, ERR_ATOM, ERR_RANGE, ERR_EST, ERR_ENCODING. Promotion results are |
| 114 | the separate `ans_promo` enum. |
| 115 | |
| 116 | ## Encoding and digests |
| 117 | |
| 118 | Digest = SHA-256(domain || 0x00 || encoding), domains `omega.ans.<record>.v1` |
| 119 | (reference, state, action, measurement, verdict, promotion). Fixed |
| 120 | little-endian layout, doubles as binary64 bits with -0.0 as +0.0, header |
| 121 | `OANS`, kind, version. Verdict and promotion record digests are computed with |
| 122 | their own digest field zeroed. Provenance chain: SHA-256(`omega.ans.provenance.v1` |
| 123 | || 0x00 || prev || tag || record digest). Deterministic (`-ffp-contract=off |
| 124 | -fno-fast-math`), bounded, no allocation, no globals, no I/O. |
| 125 | |
| 126 | ## Tests (`tests/ans/test_ans.c`, plain and ASan/UBSan) |
| 127 | |
| 128 | 1. Freeze and digest determinism; any field change changes the digest; unfrozen refused. |
| 129 | 2. Hostile: a mutated copy of the frozen reference with the old digest is refused by every API. |
| 130 | 3. Drift grows: 50 EFFECT steps, sigma strictly increasing, tier non-decreasing, reaches HALT_REQUEST_FIX. |
| 131 | 4. A FIX restores: sigma below t1, since_fix 0, tier FULL. |
| 132 | 5. IMU alone cannot restore FULL from SIMULATE_ONLY (chosen r and q below). |
| 133 | 6. Disagreement: a REFERENCE with nis above the limit forces HALT with small sigma. |
| 134 | 7. Refusals: zero evidence, IMU with a reference digest, FIX with a wrong digest, non-finite z, action refusals. |
| 135 | 8. Promotion: the OK path and each of the five refusals. |
| 136 | 9. Encodings round trip; golden digests are checked. |
| 137 | 10. Self-modification: promotion refused without a FIX, allowed after one. |
| 138 | |
| 139 | Numbers used in the tests: q 0.001/0.01/0.02/0.03/0.05, r IMU 1.0, REFERENCE 0.1, |
| 140 | FIX 0.01, tier_sigma 0.25/0.5/1.0, nis_limit 13.28, promote_limit 0.6. With |
| 141 | alternating EFFECT and IMU the steady sigma is 0.617, inside the SIMULATE_ONLY band. |
| 142 | |
| 143 | ## Build |
| 144 | |
| 145 | `make test-inertial-alignment` (purity plus unit suite); `make ans-purity` |
| 146 | (`nm -u` on each ans object against the estimation forbidden list and |
| 147 | `rx_gen_promote`); `make test-ans`. CI: `.github/workflows/host-suites.yml`. |