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 / native / control / src / action.om

163 lines · 2706 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note OM-CONTROL-659 action contract v1. See ../README.md for the trusted-caller boundary.
3note No I/O, authority minting or persistence. Caller serializes and durably commits transitions.
4note Record words 0..7: version,state,attempt,limit,generation,epoch,expiry,reserved.
5note Words 8..31: operation,request,scope,provider,policy,grant identities, four words each.
6note State 1 ready,2 in-flight,3 unknown,4 performed. No timeout implies not performed.
7
8fn actvalid r view ulong 32 to ulong
9if ne get r 0 1
10ret 11
11end
12if or lt get r 1 1 gt get r 1 4
13ret 12
14end
15if or eq get r 3 0 gt get r 3 1024
16ret 12
17end
18if gt get r 2 get r 3
19ret 12
20end
21if and ne get r 1 1 eq get r 2 0
22ret 12
23end
24if or eq get r 4 0 eq get r 5 0
25ret 12
26end
27if or eq get r 6 0 ne get r 7 0
28ret 12
29end
30for g ulong 6
31bits = ulong 0
32for j ulong 4
33bits = or bits get r add 8 add mul g 4 j
34end
35if eq bits 0
36ret 12
37end
38end
39ret 0
40end
41
42fn actbind r view ulong 32 c view ulong 32 to ulong
43for g ulong 6
44diff = ulong 0
45for j ulong 4
46at = add 8 add mul g 4 j
47diff = or diff xor get r at get c at
48end
49if ne diff 0
50ret add 40 g
51end
52end
53ret 0
54end
55
56fn actauth r view ulong 32 c view ulong 32 to ulong
57if ne get c 0 1
58ret 11
59end
60if or ne get c 3 0 or ne get c 6 0 ne get c 7 0
61ret 12
62end
63if ne get c 1 1
64ret 30
65end
66if ne get r 4 get c 4
67ret 31
68end
69if ne get r 5 get c 5
70ret 32
71end
72if ge get c 2 get r 6
73ret 33
74end
75ret actbind r c
76end
77
78fn actstart r edit ulong 32 c view ulong 32 to ulong
79err = actvalid r
80if ne err 0
81ret err
82end
83if eq get r 1 3
84ret 21
85end
86if eq get r 1 4
87ret 22
88end
89if ne get r 1 1
90ret 20
91end
92if ge get r 2 get r 3
93ret 23
94end
95err = actauth r c
96if ne err 0
97ret err
98end
99put r 2 add get r 2 1
100put r 1 2
101ret 0
102end
103
104fn actlost r edit ulong 32 to ulong
105err = actvalid r
106if ne err 0
107ret err
108end
109if eq get r 1 3
110ret 0
111end
112if ne get r 1 2
113ret 20
114end
115put r 1 3
116ret 0
117end
118
119note A trusted receipt maps outcome 0 unknown,1 definitely not performed,2 performed.
120note Not-found or timeout is outcome 0 unless the provider proves absence and quiescence.
121note Receipt words 2/3: exact attempt and verification=1. Words 6/7 must be zero.
122note Recording an observed outcome is permitted after expiry; another attempt is not.
123fn actrecon r edit ulong 32 s view ulong 32 to ulong
124err = actvalid r
125if ne err 0
126ret err
127end
128if not or eq get r 1 2 eq get r 1 3
129ret 20
130end
131if ne get s 0 1
132ret 11
133end
134if or gt get s 1 2 or ne get s 6 0 ne get s 7 0
135ret 12
136end
137if ne get s 3 1
138ret 36
139end
140if ne get s 2 get r 2
141ret 35
142end
143if ne get s 4 get r 4
144ret 31
145end
146if ne get s 5 get r 5
147ret 32
148end
149err = actbind r s
150if ne err 0
151ret err
152end
153if eq get s 1 0
154put r 1 3
155ret 21
156end
157if eq get s 1 1
158put r 1 1
159else
160put r 1 4
161end
162ret 0
163end