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 / core / rsi / om / governance / promotion_gate.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note core/rsi/om/governance/promotion_gate.om |
| 3 | note Pure OM-2 conversion of spark-rsi-mv/src/safety_envelope.rs, src/promotion_gate.rs, |
| 4 | note src/ratify.rs, and src/meta/three_criteria.rs. |
| 5 | note Fail-closed safety envelope, non-synthetic trust enforcement, branch-only ratification, |
| 6 | note protected-path refusal, and three-criteria meta-improvement promotion gate. |
| 7 | |
| 8 | note Candidate improvement tiers (mirrors meta/tier.rs) |
| 9 | const RSI_TIER_L0_PARAM ulong 0 |
| 10 | const RSI_TIER_L1_KERNEL ulong 1 |
| 11 | const RSI_TIER_L2_ALGO ulong 2 |
| 12 | const RSI_TIER_L3_META ulong 3 |
| 13 | |
| 14 | note Trust input provenance (mirrors test_no_synthetic_trust_inputs.rs) |
| 15 | const RSI_TRUST_SYNTHETIC ulong 0 |
| 16 | const RSI_TRUST_MEASURED_CANARY ulong 1 |
| 17 | const RSI_TRUST_MEASURED_SILICON ulong 2 |
| 18 | |
| 19 | note Deterministic promotion verdicts |
| 20 | const RSI_PROMOTE ulong 0 |
| 21 | const RSI_HOLD_NO_GAIN ulong 1 |
| 22 | const RSI_DENY_SYNTHETIC_TRUST ulong 10 |
| 23 | const RSI_DENY_NOT_BRANCH_ONLY ulong 11 |
| 24 | const RSI_DENY_PROTECTED_PATH ulong 12 |
| 25 | const RSI_DENY_SECURITY ulong 13 |
| 26 | const RSI_DENY_CORRECTNESS ulong 14 |
| 27 | const RSI_DENY_REPLAY ulong 15 |
| 28 | const RSI_DENY_ENVELOPE ulong 16 |
| 29 | const RSI_DENY_REGRESSION ulong 17 |
| 30 | const RSI_DENY_META_THRESHOLD ulong 18 |
| 31 | const RSI_DENY_INVALID_TIER ulong 19 |
| 32 | |
| 33 | note Candidate evaluation record |
| 34 | struct RsiCandidate id ulong tier ulong diff_lines ulong files_changed ulong correctness_bps ulong perf_delta_bps long res_delta_bps long sec_findings ulong replay_pass ulong trust_src ulong touches_protected ulong branch_only ulong end |
| 35 | |
| 36 | note Safety envelope & promotion thresholds: |
| 37 | note [0]=max_diff_lines, [1]=max_files_changed, [2]=min_correctness_bps (out of 10000), |
| 38 | note [3]=max_regression_bps (positive magnitude), [4]=min_perf_gain_bps, [5]=min_res_gain_bps, |
| 39 | note [6]=meta_gain_mult (e.g. 2 for L3_META) |
| 40 | global rsi_env ulong 8 |
| 41 | |
| 42 | note Gate decision counters: [0]=evaluated, [1]=promoted, [2]=held, [3]=denied |
| 43 | global rsi_gate_stats ulong 4 |
| 44 | |
| 45 | fn rsi_gate_init max_diff ulong max_files ulong min_corr ulong max_reg ulong min_perf ulong min_res ulong to void |
| 46 | put rsi_env 0 max_diff |
| 47 | put rsi_env 1 max_files |
| 48 | put rsi_env 2 min_corr |
| 49 | put rsi_env 3 max_reg |
| 50 | put rsi_env 4 min_perf |
| 51 | put rsi_env 5 min_res |
| 52 | put rsi_env 6 2 |
| 53 | put rsi_env 7 1 |
| 54 | for i ulong 4 |
| 55 | put rsi_gate_stats i 0 |
| 56 | end |
| 57 | end |
| 58 | |
| 59 | fn rsi_gate_evaluated to ulong |
| 60 | ret get rsi_gate_stats 0 |
| 61 | end |
| 62 | |
| 63 | fn rsi_gate_promoted to ulong |
| 64 | ret get rsi_gate_stats 1 |
| 65 | end |
| 66 | |
| 67 | fn rsi_gate_held to ulong |
| 68 | ret get rsi_gate_stats 2 |
| 69 | end |
| 70 | |
| 71 | fn rsi_gate_denied to ulong |
| 72 | ret get rsi_gate_stats 3 |
| 73 | end |
| 74 | |
| 75 | fn rsi_record_verdict v ulong to ulong |
| 76 | put rsi_gate_stats 0 add get rsi_gate_stats 0 1 |
| 77 | if eq v RSI_PROMOTE |
| 78 | put rsi_gate_stats 1 add get rsi_gate_stats 1 1 |
| 79 | else |
| 80 | if eq v RSI_HOLD_NO_GAIN |
| 81 | put rsi_gate_stats 2 add get rsi_gate_stats 2 1 |
| 82 | else |
| 83 | put rsi_gate_stats 3 add get rsi_gate_stats 3 1 |
| 84 | end |
| 85 | end |
| 86 | ret v |
| 87 | end |
| 88 | |
| 89 | note Evaluate a candidate against the fail-closed safety envelope and three-criteria gate. |
| 90 | fn rsi_evaluate_candidate cand view RsiCandidate to ulong |
| 91 | note 1. Reject uninitialized envelope (fail-closed) |
| 92 | if eq get rsi_env 7 0 |
| 93 | ret rsi_record_verdict RSI_DENY_ENVELOPE |
| 94 | end |
| 95 | note 2. Validate tier |
| 96 | tier = get cand tier |
| 97 | if gt tier RSI_TIER_L3_META |
| 98 | ret rsi_record_verdict RSI_DENY_INVALID_TIER |
| 99 | end |
| 100 | note 3. Reject synthetic trust inputs unconditionally |
| 101 | tsrc = get cand trust_src |
| 102 | if eq tsrc RSI_TRUST_SYNTHETIC |
| 103 | ret rsi_record_verdict RSI_DENY_SYNTHETIC_TRUST |
| 104 | end |
| 105 | if gt tsrc RSI_TRUST_MEASURED_SILICON |
| 106 | ret rsi_record_verdict RSI_DENY_SYNTHETIC_TRUST |
| 107 | end |
| 108 | note 4. Branch-only ratification invariant |
| 109 | if eq get cand branch_only 0 |
| 110 | ret rsi_record_verdict RSI_DENY_NOT_BRANCH_ONLY |
| 111 | end |
| 112 | note 5. Protected governance/safety path refusal |
| 113 | if ne get cand touches_protected 0 |
| 114 | ret rsi_record_verdict RSI_DENY_PROTECTED_PATH |
| 115 | end |
| 116 | note 6. Zero security findings required |
| 117 | if gt get cand sec_findings 0 |
| 118 | ret rsi_record_verdict RSI_DENY_SECURITY |
| 119 | end |
| 120 | note 7. Correctness floor and longitudinal replay pass required |
| 121 | if lt get cand correctness_bps get rsi_env 2 |
| 122 | ret rsi_record_verdict RSI_DENY_CORRECTNESS |
| 123 | end |
| 124 | if eq get cand replay_pass 0 |
| 125 | ret rsi_record_verdict RSI_DENY_REPLAY |
| 126 | end |
| 127 | note 8. Diff blast-radius safety envelope |
| 128 | if gt get cand diff_lines get rsi_env 0 |
| 129 | ret rsi_record_verdict RSI_DENY_ENVELOPE |
| 130 | end |
| 131 | if gt get cand files_changed get rsi_env 1 |
| 132 | ret rsi_record_verdict RSI_DENY_ENVELOPE |
| 133 | end |
| 134 | note 9. Regression guard (neither performance nor resource efficiency may regress past bound) |
| 135 | max_reg_neg = neg long get rsi_env 3 |
| 136 | pdelta = get cand perf_delta_bps |
| 137 | rdelta = get cand res_delta_bps |
| 138 | if lt pdelta max_reg_neg |
| 139 | ret rsi_record_verdict RSI_DENY_REGRESSION |
| 140 | end |
| 141 | if lt rdelta max_reg_neg |
| 142 | ret rsi_record_verdict RSI_DENY_REGRESSION |
| 143 | end |
| 144 | note 10. Three-criteria positive gain check (stricter multiplier for L3_META) |
| 145 | req_perf = long get rsi_env 4 |
| 146 | req_res = long get rsi_env 5 |
| 147 | if eq tier RSI_TIER_L3_META |
| 148 | mult = long get rsi_env 6 |
| 149 | mperf = mul req_perf mult |
| 150 | mres = mul req_res mult |
| 151 | if or ge pdelta mperf ge rdelta mres |
| 152 | ret rsi_record_verdict RSI_PROMOTE |
| 153 | end |
| 154 | if or ge pdelta req_perf ge rdelta req_res |
| 155 | ret rsi_record_verdict RSI_DENY_META_THRESHOLD |
| 156 | end |
| 157 | ret rsi_record_verdict RSI_HOLD_NO_GAIN |
| 158 | end |
| 159 | if or ge pdelta req_perf ge rdelta req_res |
| 160 | ret rsi_record_verdict RSI_PROMOTE |
| 161 | end |
| 162 | ret rsi_record_verdict RSI_HOLD_NO_GAIN |
| 163 | end |