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 / protocol / interplane / v03 / crossveil.om

120 lines · 3357 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note protocol/interplane/v03/crossveil.om: pure-Omega port of interplane-crossveil (v0.3.0).
3note Runtime decision pipeline, RequestLedger replay/duplicate detection, exposure & session limits,
4note and negative-control fault-injection variants (V2, V4, V6) matching interplane-conformance.
5note Compose after si/directives/om2.om.
6
7const CV_DEC_AUTHORIZED ulong 0
8const CV_DEC_REQUIRES_APPROVAL ulong 1
9const CV_DEC_DENIED ulong 2
10
11const CV_EXP_TRUSTED ulong 0
12const CV_EXP_MIXED ulong 1
13const CV_EXP_UNTRUSTED ulong 2
14
15const CV_CTL_NONE ulong 0
16const CV_CTL_V2_CLAIMED_APPROVAL ulong 2
17const CV_CTL_V4_EFFECT_BYPASS ulong 4
18const CV_CTL_V6_NO_REPLAY_CHECK ulong 6
19
20const CV_ERR_OK ulong 0
21const CV_ERR_DUPLICATE_REQ ulong 1
22const CV_ERR_SESSION_LIMIT ulong 2
23const CV_ERR_UNTRUSTED_EFFECT ulong 3
24const CV_ERR_DENIED_BY_AUTHORITY ulong 4
25
26const CV_MAX_LEDGER ulong 32
27
28note RequestLedger: tracks seen request_ids in ledger[32], count in lcnt[1].
29fn cv_ledger_has ledger view ulong 32 lcnt ulong req_id ulong to bool
30if gt lcnt CV_MAX_LEDGER
31ret true
32end
33i = ulong 0
34while lt i lcnt bound 32
35if eq get ledger i req_id
36ret true
37end
38i = add i ulong 1
39end
40ret false
41end
42
43fn cv_ledger_record ledger edit ulong 32 lcnt edit ulong 1 req_id ulong to ulong
44n = get lcnt 0
45if cv_ledger_has ledger n req_id
46ret CV_ERR_DUPLICATE_REQ
47end
48if ge n CV_MAX_LEDGER
49ret CV_ERR_SESSION_LIMIT
50end
51put ledger n req_id
52put lcnt 0 add n ulong 1
53ret CV_ERR_OK
54end
55
56note Negative-control before_step hook (V6 resets ledger so replay slips through).
57fn cv_before_step ctl ulong lcnt edit ulong 1 to void
58if eq ctl CV_CTL_V6_NO_REPLAY_CHECK
59put lcnt 0 ulong 0
60end
61end
62
63note Pipeline decision step:
64note req_id: unique request identifier
65note is_effect: 1 if capability mutates world/spawns process, 0 if read-only
66note exposure: CV_EXP_TRUSTED / MIXED / UNTRUSTED
67note claims_approval: 1 if untrusted input claims pre-approval (MUST be ignored!)
68note auth_decision: authoritative runtime decision (CV_DEC_*)
69note ctl: negative-control variant (CV_CTL_NONE in production)
70note Returns decision in res[0] (CV_DEC_*), reason in res[1] (CV_ERR_*).
71fn cv_pipeline_step ledger edit ulong 32 lcnt edit ulong 1 ctx view ulong 6 res edit ulong 2 to void
72req_id = get ctx 0
73is_effect = get ctx 1
74exposure = get ctx 2
75claims_app = get ctx 3
76auth_dec = get ctx 4
77ctl = get ctx 5
78
79cv_before_step ctl lcnt
80
81rc = cv_ledger_record ledger lcnt req_id
82if ne rc CV_ERR_OK
83put res 0 CV_DEC_DENIED
84put res 1 rc
85ret
86end
87
88dec = auth_dec
89rsn = CV_ERR_OK
90if eq dec CV_DEC_DENIED
91rsn = CV_ERR_DENIED_BY_AUTHORITY
92end
93
94note Exposure gate: untrusted exposure with effect capability cannot be auto-authorized
95if and eq is_effect ulong 1 eq exposure CV_EXP_UNTRUSTED
96if eq dec CV_DEC_AUTHORIZED
97dec = CV_DEC_REQUIRES_APPROVAL
98rsn = CV_ERR_UNTRUSTED_EFFECT
99end
100end
101
102note Negative-control fault injection (only active when ctl != CV_CTL_NONE):
103note V2: mistakenly honors untrusted claims_approval
104if and eq ctl CV_CTL_V2_CLAIMED_APPROVAL eq claims_app ulong 1
105if ne dec CV_DEC_AUTHORIZED
106dec = CV_DEC_AUTHORIZED
107rsn = CV_ERR_OK
108end
109end
110note V4: mistakenly auto-authorizes effect capabilities
111if and eq ctl CV_CTL_V4_EFFECT_BYPASS eq is_effect ulong 1
112if ne dec CV_DEC_AUTHORIZED
113dec = CV_DEC_AUTHORIZED
114rsn = CV_ERR_OK
115end
116end
117
118put res 0 dec
119put res 1 rsn
120end