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 / tests / action.om

290 lines · 5247 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note Tests call the production transition functions. Provider/store I/O is not simulated as durable.
3global checks ulong 1
4global fails ulong 1
5global report uchar 64
6text title "action checks="
7
8fn check got ulong want ulong to void
9put checks 0 add get checks 0 1
10if ne got want
11put fails 0 add get fails 0 1
12end
13end
14
15fn plan r edit ulong 32 to void
16for i ulong 32
17put r i 0
18end
19put r 0 1
20put r 1 1
21put r 3 3
22put r 4 7
23put r 5 9
24put r 6 100
25for i ulong 24
26put r add i 8 add i 100
27end
28end
29
30fn context c edit ulong 32 to void
31for i ulong 32
32put c i 0
33end
34put c 0 1
35put c 1 1
36put c 2 50
37put c 4 7
38put c 5 9
39for i ulong 24
40put c add i 8 add i 100
41end
42end
43
44fn receipt s edit ulong 32 n ulong outcome ulong to void
45context s
46put s 1 outcome
47put s 2 n
48put s 3 1
49end
50
51fn summary to int
52for i ulong len title
53put report i get title i
54end
55n = get checks 0
56at = len title
57put report at uchar add 48 div n 100
58put report add at 1 uchar add 48 rem div n 10 10
59put report add at 2 uchar add 48 rem n 10
60put report add at 3 32
61put report add at 4 uchar add 48 div get fails 0 100
62put report add at 5 uchar add 48 rem div get fails 0 10 10
63put report add at 6 uchar add 48 rem get fails 0 10
64put report add at 7 10
65w = write 1 report 0 add at 8
66if ne w long add at 8
67ret 2
68end
69if ne get fails 0 0
70ret 1
71end
72ret 0
73end
74
75fn main to int
76r = new ulong 32 0
77c = new ulong 32 0
78s = new ulong 32 0
79plan r
80context c
81check actstart r c 0
82check get r 1 2
83check get r 2 1
84check actstart r c 20
85check get r 2 1
86check actlost r 0
87check get r 1 3
88check actlost r 0
89check actstart r c 21
90receipt s 1 0
91check actrecon r s 21
92check get r 1 3
93check actstart r c 21
94receipt s 1 2
95check actrecon r s 0
96check get r 1 4
97check actstart r c 22
98check actrecon r s 20
99
100note An observed uncertain outcome also moves an in-flight record to unknown.
101plan r
102check actstart r c 0
103receipt s 1 0
104check actrecon r s 21
105check get r 1 3
106check actstart r c 21
107
108note Confirmed not performed enables a new attempt only after a fresh admission check.
109plan r
110check actstart r c 0
111check actlost r 0
112receipt s 1 1
113check actrecon r s 0
114check get r 1 1
115check get r 2 1
116put c 1 0
117check actstart r c 30
118check get r 2 1
119context c
120put c 4 8
121check actstart r c 31
122context c
123put c 5 10
124check actstart r c 32
125context c
126put c 2 100
127check actstart r c 33
128context c
129check actstart r c 0
130check get r 2 2
131receipt s 1 2
132check actrecon r s 35
133check get r 1 2
134receipt s 2 2
135check actrecon r s 0
136check actstart r c 22
137
138note Every word of every identity is checked before mutating the record.
139for i ulong 24
140plan r
141context c
142put c add i 8 add get c add i 8 1
143check actstart r c add 40 div i 4
144check get r 1 1
145check get r 2 0
146end
147note Receipt binding includes all identities and cannot resolve a different attempt.
148for i ulong 24
149plan r
150context c
151check actstart r c 0
152receipt s 1 1
153put s add i 8 add get s add i 8 1
154check actrecon r s add 40 div i 4
155check get r 1 2
156end
157
158plan r
159context c
160put r 2 3
161check actstart r c 23
162put r 2 18446744073709551615
163check actstart r c 12
164check get r 2 18446744073709551615
165plan r
166put r 3 0
167check actstart r c 12
168plan r
169put r 3 1025
170check actstart r c 12
171plan r
172put r 7 1
173check actstart r c 12
174plan r
175put r 0 2
176check actstart r c 11
177plan r
178put r 1 99
179check actstart r c 12
180plan r
181put r 1 2
182check actstart r c 12
183plan r
184context c
185put c 0 2
186check actstart r c 11
187context c
188put c 1 2
189check actstart r c 30
190context c
191put c 3 1
192check actstart r c 12
193context c
194for group ulong 6
195plan r
196for j ulong 4
197put r add 8 add mul group 4 j 0
198end
199check actstart r c 12
200end
201
202note A zero generation or epoch is the missing-value sentinel, even when the context matches it.
203plan r
204context c
205put r 4 0
206put c 4 0
207check actstart r c 12
208check get r 1 1
209plan r
210context c
211put r 5 0
212put c 5 0
213check actstart r c 12
214note Reconciliation refuses a record whose expiry is the zero sentinel, without mutating it.
215plan r
216context c
217check actstart r c 0
218put r 6 0
219receipt s 1 2
220check actrecon r s 12
221check get r 1 2
222put r 6 100
223note A ready record cannot be reconciled, so a receipt can never mark an unstarted or released attempt performed.
224plan r
225context c
226receipt s 0 2
227check actrecon r s 20
228check get r 1 1
229check get r 2 0
230check actstart r c 0
231check actlost r 0
232receipt s 1 1
233check actrecon r s 0
234check get r 1 1
235receipt s 1 2
236check actrecon r s 20
237check get r 1 1
238check get r 2 1
239note Reserved words of the authority facts and of the receipt must be zero.
240plan r
241context c
242put c 6 1
243check actstart r c 12
244context c
245put c 7 1
246check actstart r c 12
247check get r 1 1
248context c
249check actstart r c 0
250receipt s 1 1
251put s 7 1
252check actrecon r s 12
253check get r 1 2
254
255plan r
256check actstart r c 0
257receipt s 1 1
258put s 3 0
259check actrecon r s 36
260check get r 1 2
261receipt s 1 1
262put s 4 8
263check actrecon r s 31
264receipt s 1 1
265put s 5 10
266check actrecon r s 32
267receipt s 1 3
268check actrecon r s 12
269receipt s 1 1
270put s 6 1
271check actrecon r s 12
272check actlost r 0
273check actstart r c 21
274receipt s 1 1
275check actrecon r s 0
276check actlost r 20
277check get r 1 1
278
279note Limit is enforced across reconciliation cycles, without rotating operation identity.
280plan r
281for i ulong 3
282check actstart r c 0
283receipt s add i 1 1
284check actrecon r s 0
285end
286check actstart r c 23
287check get r 2 3
288check get r 8 100
289ret summary
290end