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/seed/authority/reserve.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 / seed / authority / reserve.om` 308 lines ยท 6105 bytes Raw Blame History 1 note SC1-R pure serial transitions. No authentication, locking, persistence or allocator. 2 note Fresh implementation; old AGPL action/delegate/reuse contracts read, not copied. 3 note State64: B[0:8], U[8:16], slot charges[16:32], slot metadata[32:56]. 4 note Metadata12: id,phase,request,owner,grant,object,version,epoch, four zero words. 5 note Phase0 idle,1 reserved,2 uncertain,3 committed attributable used stock. 6 note Header56: next-id,spent-fuel,fuel-bound,request-highwater0/1,owner0/1,format1. 7 note Token8: slot,id,request,owner,grant,object,version,epoch. IDs/requests never wrap. 8 note Owners are fixed public partitions. Per-owner request sequence must strictly increase. 9 note Caller validates originals and trusted identities inside existing serialized writer. 10 note Zero return success; 1 invalid state/input,2 binding/replay,3 capacity,4 unknown. 11 note Arrays passed to one operation must not alias. Snapshot state is authoritative, not a client copy. 12 note Local subtraction guards implement SC1-Q boundary rule without struct provenance claims. 13 14 fn rv_meta slot ulong to ulong 15 ret add 32 mul slot 12 16 end 17 fn rv_charge slot ulong to ulong 18 ret add 16 mul slot 8 19 end 20 fn rv_phase s view ulong 64 slot ulong to ulong 21 ret get s add rv_meta slot 1 22 end 23 fn rv_valid s view ulong 64 to ulong 24 if ne get s 63 1 25 ret 1 26 end 27 if or eq get s 56 0 gt get s 57 get s 58 28 ret 1 29 end 30 if or eq get s 61 0 or eq get s 62 0 eq get s 61 get s 62 31 ret 1 32 end 33 for j ulong 2 34 m = rv_meta j 35 p = get s add m 1 36 if gt p 3 37 ret 1 38 end 39 for k ulong 4 40 if ne get s add m add 8 k 0 41 ret 1 42 end 43 end 44 if ne p 0 45 if or eq get s m 0 ge get s m get s 56 46 ret 1 47 end 48 if ne get s add m 3 get s add 61 j 49 ret 1 50 end 51 if ne get s add m 2 get s add 59 j 52 ret 1 53 end 54 for k ulong 6 55 if eq get s add m add 2 k 0 56 ret 1 57 end 58 end 59 else 60 for k ulong 12 61 if ne get s add m k 0 62 ret 1 63 end 64 end 65 end 66 end 67 if and ne rv_phase s 0 0 ne rv_phase s 1 0 68 if eq get s 32 get s 44 69 ret 1 70 end 71 end 72 for d ulong 8 73 left = get s d 74 used = get s add 8 d 75 if gt used left 76 ret 1 77 end 78 left = sub left used 79 for j ulong 2 80 q = get s add rv_charge j d 81 p = rv_phase s j 82 if eq p 0 83 if ne q 0 84 ret 1 85 end 86 end 87 if or eq p 1 eq p 2 88 if gt q left 89 ret 1 90 end 91 left = sub left q 92 end 93 if eq p 3 94 if gt q used 95 ret 1 96 end 97 used = sub used q 98 end 99 end 100 end 101 ret 0 102 end 103 fn rv_init s edit ulong 64 b view ulong 8 owners view ulong 2 fuel ulong to ulong 104 for i ulong 64 105 if ne get s i 0 106 ret 1 107 end 108 end 109 if eq get owners 0 0 110 ret 1 111 end 112 if eq get owners 1 0 113 ret 1 114 end 115 if eq get owners 0 get owners 1 116 ret 1 117 end 118 for i ulong 8 119 put s i get b i 120 end 121 put s 56 1 122 put s 58 fuel 123 put s 61 get owners 0 124 put s 62 get owners 1 125 put s 63 1 126 ret 0 127 end 128 fn rv_bind s view ulong 64 t view ulong 8 to ulong 129 if ne rv_valid s 0 130 ret 1 131 end 132 if gt get t 0 1 133 ret 2 134 end 135 m = rv_meta get t 0 136 if eq get s add m 1 0 137 ret 2 138 end 139 if ne get s m get t 1 140 ret 2 141 end 142 for i ulong 6 143 if ne get s add m add 2 i get t add 2 i 144 ret 2 145 end 146 end 147 ret 0 148 end 149 fn rv_room s view ulong 64 d ulong to ulong 150 left = sub get s d get s add 8 d 151 for j ulong 2 152 p = rv_phase s j 153 if or eq p 1 eq p 2 154 left = sub left get s add rv_charge j d 155 end 156 end 157 ret left 158 end 159 fn rv_reserve s edit ulong 64 t view ulong 8 q view ulong 8 fuel ulong to ulong 160 if ne rv_valid s 0 161 ret 1 162 end 163 if gt get t 0 1 164 ret 2 165 end 166 j = get t 0 167 if ne rv_phase s j 0 168 ret 2 169 end 170 if or ne get t 1 get s 56 eq get s 56 `18446744073709551615` 171 ret 2 172 end 173 if ne get t 3 get s add 61 j 174 ret 2 175 end 176 if le get t 2 get s add 59 j 177 ret 2 178 end 179 for i ulong 6 180 if eq get t add i 2 0 181 ret 2 182 end 183 end 184 if gt fuel sub get s 58 get s 57 185 ret 3 186 end 187 for d ulong 8 188 if gt get q d rv_room s d 189 ret 3 190 end 191 end 192 note Mutation begins only after all eight stocks and all bindings validate. 193 for d ulong 8 194 put s add rv_charge j d get q d 195 end 196 m = rv_meta j 197 put s m get t 1 198 put s add m 1 1 199 for i ulong 6 200 put s add m add 2 i get t add 2 i 201 end 202 put s add 59 j get t 2 203 put s 56 add get s 56 1 204 put s 57 add get s 57 fuel 205 ret 0 206 end 207 fn rv_uncertain s edit ulong 64 t view ulong 8 to ulong 208 r = rv_bind s t 209 if ne r 0 210 ret r 211 end 212 if eq rv_phase s get t 0 3 213 ret 4 214 end 215 put s add rv_meta get t 0 1 2 216 ret 4 217 end 218 fn rv_clear s edit ulong 64 slot ulong to void 219 for i ulong 8 220 put s add rv_charge slot i 0 221 end 222 for i ulong 12 223 put s add rv_meta slot i 0 224 end 225 end 226 note quiet and public are authoritative adapter facts, never client flags. 227 note No completion/cancel/error calls this until actual effects and public release permit. 228 fn rv_commit s edit ulong 64 t view ulong 8 actual view ulong 8 quiet bool public bool to ulong 229 r = rv_bind s t 230 if ne r 0 231 ret r 232 end 233 j = get t 0 234 if eq rv_phase s j 3 235 ret 2 236 end 237 if not and quiet public 238 ret 4 239 end 240 for d ulong 8 241 if gt get actual d get s add rv_charge j d 242 ret 3 243 end 244 end 245 for d ulong 8 246 put s add 8 d add get s add 8 d get actual d 247 put s add rv_charge j d get actual d 248 end 249 put s add rv_meta j 1 3 250 ret 0 251 end 252 note Internal apply helper requires rv_reclaim preflight; not an admission API. 253 fn rv_reclaimed s edit ulong 64 gone view ulong 8 j ulong to void 254 bits = ulong 0 255 for d ulong 8 256 q = sub get s add rv_charge j d get gone d 257 put s add rv_charge j d q 258 put s add 8 d sub get s add 8 d get gone d 259 bits = or bits q 260 end 261 if eq bits 0 262 rv_clear s j 263 end 264 end 265 note Reclaim vector denotes stock actually reclaimed with required durability. 266 note Stock is attributable to this slot; cannot release somebody else's used charge. 267 fn rv_reclaim s edit ulong 64 t view ulong 8 gone view ulong 8 durable bool public bool to ulong 268 r = rv_bind s t 269 if ne r 0 270 ret r 271 end 272 j = get t 0 273 if ne rv_phase s j 3 274 ret 2 275 end 276 if not and durable public 277 ret 4 278 end 279 for d ulong 8 280 if gt get gone d get s add rv_charge j d 281 ret 3 282 end 283 end 284 rv_reclaimed s gone j 285 ret 0 286 end 287 note Recovery raises used to max(ledger,observed), never discounts missing evidence. 288 note Caller supplies authoritative complete retained+temporary physical stock census. 289 note Reservations stay charged; inconsistent capacity leaves snapshot untouched and refuses admission. 290 fn rv_recover s edit ulong 64 actual view ulong 8 to ulong 291 if ne rv_valid s 0 292 ret 1 293 end 294 for d ulong 8 295 old = get s add 8 d 296 if gt get actual d old 297 if gt sub get actual d old rv_room s d 298 ret 3 299 end 300 end 301 end 302 for d ulong 8 303 if gt get actual d get s add 8 d 304 put s add 8 d get actual d 305 end 306 end 307 ret 0 308 end