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 / core / rsi / om / governance / promotion_gate.om

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