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/train/aien-train/native/omegese45/data/gen.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 / train / aien-train / native / omegese45 / data / gen.om` 384 lines ยท 6977 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note omegese45 episode generator (aien-train #45, pipeline lane). It implements the 3 note reference policy of docs/omegese45/CONTRACT.md section 5 and the synthetic outcome 4 note distribution declared in docs/omegese45/PIPELINE.md (grammar coverage, not runtime frequency). Build order: 5 note cat native/omegese45/vocab.om native/omegese45/msg.om native/omegese45/data/gen.om 6 note argv: SEED COUNT OUT.oe45 OUT.ids (SEED, COUNT decimal; COUNT 1..40000). 7 note OUT.oe45: COUNT episodes, each the OE45 v1 text (line `oe45 v1`, one message per line). 8 note OUT.ids: COUNT records, each one byte L (1..176) then the L episode ids, one byte each. 9 note stdout: one line `oe45gen v1 seed=S count=N` followed by the coverage counters. 10 note Deterministic: the only randomness is splitmix64 seeded with SEED. Exits: 0 ok, 2 usage, 11 note 40 a generated message failed the contract validator (a generator defect), 70 file I/O. 12 global oprs ulong 1 13 global opep ulong 256 14 global opel ulong 1 15 global opgp uchar 4096 16 global opgb uchar 256 17 global opgst ulong 64 18 global opgfd ulong 2 19 20 note splitmix64 (Steele, Lea, Flood 2014): state += golden gamma, then the finaliser mix. 21 fn opnext to ulong 22 x = add get oprs 0 `11400714819323198485` 23 put oprs 0 x 24 z = xor x shr x 30 25 z = mul z `13787848793156543929` 26 z = xor z shr z 27 27 z = mul z `10723151780598845931` 28 ret xor z shr z 31 29 end 30 31 note A value in 0 .. n-1: the generator output reduced mod n (declared; bias below 2^-40). 32 fn opbelow n ulong to ulong 33 ret rem opnext n 34 end 35 36 fn oppush id ulong to void 37 n = get opel 0 38 put opep n id 39 put opel 0 add n 1 40 end 41 42 note ushort 0x H H H for v in 0 .. 0xfff. 43 fn oppd v ulong to void 44 oppush 22 45 oppush 24 46 oppush add 25 and shr v 8 15 47 oppush add 25 and shr v 4 15 48 oppush add 25 and v 15 49 end 50 51 note ulong 0x H H H H for v in 0 .. 0xffff. 52 fn opps v ulong to void 53 oppush 23 54 oppush 24 55 oppush add 25 and shr v 12 15 56 oppush add 25 and shr v 8 15 57 oppush add 25 and shr v 4 15 58 oppush add 25 and v 15 59 end 60 61 fn opcnt i ulong to void 62 put opgst i add get opgst i 1 63 end 64 65 note One dimension: 8% an edge 0x000 0x001 0x100 0x101 (2% each), 4% uniform in 66 note 0x101 .. 0xfff, 88% uniform in 0x001 .. 0x100. 67 fn opdim to ulong 68 u = opbelow 100 69 if lt u 8 70 e = opbelow 4 71 opcnt add 40 e 72 if eq e 0 73 ret 0 74 end 75 if eq e 1 76 ret 1 77 end 78 if eq e 2 79 ret 256 80 end 81 ret 257 82 end 83 if lt u 12 84 ret add 257 opbelow 3839 85 end 86 ret add 1 opbelow 256 87 end 88 89 note Synthetic outcome of one job attempt for grammar coverage, as class * 32 + code id: 90 note 55% ok (class 1), 15% fail transport (class 3), 30% split evenly (2% each) over the 91 note 15 other pairs: refused x {replay budget worker transport receipt recomp verdict io} 92 note (class 2) and fail x {replay budget worker receipt recomp verdict io} (class 3). 93 fn opout to ulong 94 u = opbelow 100 95 if lt u 55 96 ret 32 97 end 98 if lt u 70 99 ret add ulong 96 17 100 end 101 c = div sub u 70 2 102 if lt c 8 103 ret add 64 add 14 c 104 end 105 c = sub c 8 106 if ge c 3 107 c = add c 1 108 end 109 ret add 96 add 14 c 110 end 111 112 fn opadim d ulong to bool 113 ret and ge d 1 le d 256 114 end 115 116 note The goal operands of the current episode: pair flag, m, k, n, seed1, seed2. 117 global opgv ulong 6 118 119 note A job attempt: act job mm D D D S end, with seed index j (0 seed1, 1 seed2). 120 fn opact j ulong to void 121 oppush 2 122 oppush 8 123 oppush 6 124 oppd get opgv 1 125 oppd get opgv 2 126 oppd get opgv 3 127 opps get opgv add 4 j 128 oppush 5 129 end 130 131 note The operands as G and P ok carry them: kind word, D D D, S [S]. 132 fn opops to void 133 if eq get opgv 0 1 134 oppush 7 135 else 136 oppush 6 137 end 138 oppd get opgv 1 139 oppd get opgv 2 140 oppd get opgv 3 141 opps get opgv 4 142 if eq get opgv 0 1 143 opps get opgv 5 144 end 145 end 146 147 note Draw the goal (kind, dims, seeds, in this order) and append G. True when admitted. 148 fn opgoal to bool 149 pr = opbelow 2 150 put opgv 0 pr 151 put opgv 1 opdim 152 put opgv 2 opdim 153 put opgv 3 opdim 154 put opgv 4 opbelow 65536 155 put opgv 5 0 156 if eq pr 1 157 put opgv 5 opbelow 65536 158 opcnt 1 159 else 160 opcnt 0 161 end 162 oppush 1 163 opops 164 oppush 5 165 ret and and opadim get opgv 1 opadim get opgv 2 opadim get opgv 3 166 end 167 168 note Job j under the policy: A, then R; one retry after the first fail transport. 169 note Returns the last outcome (class * 32 + code id; 32 = ok). 170 fn opjob j ulong to ulong 171 t = ulong 0 172 o = ulong 0 173 dn = false 174 while not dn bound 3 175 opact j 176 o = opout 177 cl = shr o 5 178 cd = and o 31 179 oppush 3 180 if eq cl 1 181 oppush 10 182 dn = true 183 else 184 oppush add 9 cl 185 oppush cd 186 opcnt add 8 add mul sub cl 2 16 sub cd 13 187 if and and eq cl 3 eq cd 17 eq t 0 188 t = 1 189 opcnt 3 190 else 191 dn = true 192 end 193 end 194 oppush 5 195 end 196 ret o 197 end 198 199 note One episode by the reference policy into opep / opel. 200 fn opgen to void 201 put opel 0 0 202 if not opgoal 203 opcnt 2 204 oppush 2 205 oppush 9 206 oppush 13 207 oppush 5 208 oppush 4 209 oppush 11 210 oppush 13 211 oppush 5 212 ret 213 end 214 for j ulong add get opgv 0 1 215 o = opjob j 216 if ne o 32 217 opcnt 4 218 oppush 4 219 oppush add 9 shr o 5 220 oppush and o 31 221 oppush 5 222 ret 223 end 224 end 225 opcnt 5 226 oppush 4 227 oppush 10 228 opops 229 oppush 5 230 end 231 232 fn opatou n ulong to ulong 233 v = ulong 0 234 if or eq n 0 gt n 18 235 exit 2 236 end 237 for i ulong n 238 c = ulong get opgp i 239 if or lt c 48 gt c 57 240 exit 2 241 end 242 v = add mul v 10 sub c 48 243 end 244 ret v 245 end 246 247 fn oparg i ulong to ulong 248 r = argread i opgp 0 4095 249 if le r 0 250 exit 2 251 end 252 ret ulong r 253 end 254 255 fn opopen i ulong to int 256 n = oparg i 257 fd = fopen opgp 0 n 577 420 258 if lt fd 0 259 exit 70 260 end 261 ret int fd 262 end 263 264 fn opwout fd int n ulong to void 265 o = ulong 0 266 while lt o n bound 4097 267 w = write fd ocout o sub n o 268 if le w 0 269 exit 70 270 end 271 o = add o ulong w 272 end 273 end 274 275 fn opwbuf fd int n ulong to void 276 o = ulong 0 277 while lt o n bound 257 278 w = write fd opgb o sub n o 279 if le w 0 280 exit 70 281 end 282 o = add o ulong w 283 end 284 end 285 286 note Write the episode: text (validated message by message) and its id record. 287 fn opemit tf int bf int to void 288 n = get opel 0 289 put ocout 0 111 290 put ocout 1 101 291 put ocout 2 52 292 put ocout 3 53 293 put ocout 4 32 294 put ocout 5 118 295 put ocout 6 49 296 put ocout 7 10 297 opwout tf 8 298 s = ulong 0 299 for i ulong n 300 if eq get opep i 5 301 c = add sub i s 1 302 for j ulong c 303 put ocids j get opep add s j 304 end 305 if lt ocvids c 0 0 306 exit 40 307 end 308 b = ocdec c 309 if lt b 0 310 exit 40 311 end 312 put ocout ulong b 10 313 opwout tf add ulong b 1 314 s = add i 1 315 end 316 end 317 if ne s n 318 exit 40 319 end 320 put opgb 0 uchar n 321 for i ulong n 322 put opgb add i 1 uchar get opep i 323 end 324 opwbuf bf add n 1 325 end 326 327 note Coverage line: `oe45gen v1 SEED COUNT` then 26 counters in this order: mm pair oob retry 328 note stop okep e000 e001 e100 e101, refused replay budget worker transport receipt recomp 329 note verdict io, fail replay budget worker transport receipt recomp verdict io. 330 text opghd "oe45gen v1" 331 332 fn opstat i ulong to void 333 ocputc 32 334 ocputn get opgst i 335 end 336 337 fn main to int 338 if ne argcnt 5 339 exit 2 340 end 341 seed = opatou oparg 1 342 cnt = opatou oparg 2 343 if or eq cnt 0 gt cnt 40000 344 exit 2 345 end 346 tf = opopen 3 347 bf = opopen 4 348 put oprs 0 seed 349 for e ulong cnt 350 opgen 351 opemit tf bf 352 end 353 if ne fsync tf 0 354 exit 70 355 end 356 if ne fsync bf 0 357 exit 70 358 end 359 if ne fclose tf 0 360 exit 70 361 end 362 if ne fclose bf 0 363 exit 70 364 end 365 w = write 1 opghd 0 len opghd 366 ocputc 32 367 ocputn seed 368 ocputc 32 369 ocputn cnt 370 for i ulong 6 371 opstat i 372 end 373 for i ulong 4 374 opstat add 40 i 375 end 376 for i ulong 8 377 opstat add 9 i 378 end 379 for i ulong 8 380 opstat add 25 i 381 end 382 ocputc 10 383 ret 0 384 end