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