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
omega-mv / seed / qualification / security673 / game / evidence / native-v3 / roundtrip.attempt1.om
| 1 | note SC1-G transport only. No transition or invariant code is shared. |
| 2 | global wire uchar 4096 |
| 3 | global pos ulong 1 |
| 4 | global avail ulong 1 |
| 5 | global digits uchar 32 |
| 6 | global samples ulong 101 |
| 7 | text nl "\n" |
| 8 | text sp " " |
| 9 | text tags "construct_ns=\nsolve_ns=\ncheck_ns=\nstates=\nedges=\nwinning=\nrounds=\narray_bytes=\nPASS SC1-G-v3 finite model only\nFAIL QUANTIFIER_CLOSURE\nFAIL OMITTED_DISTURBANCE_CLOSURE\nFAIL FRESHNESS_AT_RENAME\nFAIL UNCERTAIN_REFUND\nFAIL SELECTED_NOT_SAFE\nFAIL EARLY_STOP_CLOSURE\nFAIL CERTIFICATE\nPASS certified serial witnesses empty-set costs\nFAIL PAIRED_PRODUCT\ndistinct_hidden_states=\ndistinct_hidden_edges=\nsample_ns=\np50_ns=\np95_ns=\np99_ns=\nidentical_zero_states=\nidentical_zero_edges=\nWITNESS source action disturbance raw effective\nFAIL TRANSITION_CONFORMANCE\nFAIL CLOSURE\nFAIL SOURCE_INVARIANT\nFAIL DISABLED_ACTION\nFAIL EXACTNESS\nFAIL SELECTION_COST\n" |
| 10 | fn label id uint to void |
| 11 | p = ulong 0 |
| 12 | n = uint 0 |
| 13 | for j ulong len tags |
| 14 | if eq get tags j 10 |
| 15 | if eq n id |
| 16 | r = write 2 tags p add sub j p 1 |
| 17 | if ne r long add sub j p 1 |
| 18 | exit 90 |
| 19 | end |
| 20 | ret |
| 21 | end |
| 22 | n = add n 1 |
| 23 | p = add j 1 |
| 24 | end |
| 25 | end |
| 26 | exit 90 |
| 27 | end |
| 28 | fn number n ulong to void |
| 29 | p = ulong 0 |
| 30 | while ge n 10 bound 32 |
| 31 | put digits p uchar add rem n 10 48 |
| 32 | n = div n 10 |
| 33 | p = add p 1 |
| 34 | end |
| 35 | put digits p uchar add n 48 |
| 36 | p = add p 1 |
| 37 | for j ulong p |
| 38 | r = write 2 digits sub sub p j 1 1 |
| 39 | if ne r 1 |
| 40 | exit 90 |
| 41 | end |
| 42 | end |
| 43 | r = write 2 nl 0 1 |
| 44 | if ne r 1 |
| 45 | exit 90 |
| 46 | end |
| 47 | end |
| 48 | fn mode to uint |
| 49 | if eq argcnt 1 |
| 50 | ret 0 |
| 51 | end |
| 52 | if ne argcnt 2 |
| 53 | exit 90 |
| 54 | end |
| 55 | if ne argread 1 wire 0 1 1 |
| 56 | exit 90 |
| 57 | end |
| 58 | m = get wire 0 |
| 59 | if or lt m 48 gt m 56 |
| 60 | exit 90 |
| 61 | end |
| 62 | ret sub uint m 48 |
| 63 | end |
| 64 | fn flush to void |
| 65 | n = get pos 0 |
| 66 | if ne write 1 wire 0 n long n |
| 67 | exit 90 |
| 68 | end |
| 69 | put pos 0 0 |
| 70 | end |
| 71 | fn sendword x uint to void |
| 72 | for i ulong 4 |
| 73 | p = get pos 0 |
| 74 | put wire p uchar and shr x mul uint i 8 255 |
| 75 | put pos 0 add p 1 |
| 76 | if eq get pos 0 4096 |
| 77 | flush |
| 78 | end |
| 79 | end |
| 80 | end |
| 81 | fn recvword to uint |
| 82 | x = uint 0 |
| 83 | for i ulong 4 |
| 84 | if eq get pos 0 get avail 0 |
| 85 | n = read 0 wire 0 len wire |
| 86 | if le n 0 |
| 87 | exit 90 |
| 88 | end |
| 89 | put avail 0 ulong n |
| 90 | put pos 0 0 |
| 91 | end |
| 92 | p = get pos 0 |
| 93 | x = or x shl uint get wire p mul uint i 8 |
| 94 | put pos 0 add p 1 |
| 95 | end |
| 96 | ret x |
| 97 | end |
| 98 | fn endinput to void |
| 99 | if ne get pos 0 get avail 0 |
| 100 | exit 90 |
| 101 | end |
| 102 | if ne read 0 wire 0 len wire 0 |
| 103 | exit 90 |
| 104 | end |
| 105 | end |
| 106 | fn percentiles to void |
| 107 | for i ulong 101 |
| 108 | label 20 |
| 109 | number get samples i |
| 110 | end |
| 111 | for i ulong 101 |
| 112 | for j ulong 100 |
| 113 | if gt get samples j get samples add j 1 |
| 114 | t = get samples j |
| 115 | put samples j get samples add j 1 |
| 116 | put samples add j 1 t |
| 117 | end |
| 118 | end |
| 119 | end |
| 120 | label 21 |
| 121 | number get samples 50 |
| 122 | label 22 |
| 123 | number get samples 95 |
| 124 | label 23 |
| 125 | number get samples 99 |
| 126 | end |
| 127 | note Fixed two-child lifecycle measurement using gate669 fork/exec/wait pattern. |
| 128 | note Not a general runner. Existing compiled solver/checker required; no model code here. |
| 129 | text solver "build/security760-v3/solve0" |
| 130 | text checker "build/security760-v3/check0" |
| 131 | text spool "build/security760-v3/roundtrip.bin" |
| 132 | text nullpath "/dev/null" |
| 133 | global argv uchar 256 |
| 134 | global status uchar 4 |
| 135 | fn command c uint to ulong |
| 136 | put argv 0 1 |
| 137 | put argv 1 0 |
| 138 | n = len solver |
| 139 | if eq c 1 |
| 140 | n = len checker |
| 141 | end |
| 142 | put argv 2 uchar n |
| 143 | put argv 3 0 |
| 144 | for i ulong n |
| 145 | if eq c 0 |
| 146 | put argv add i 4 get solver i |
| 147 | else |
| 148 | put argv add i 4 get checker i |
| 149 | end |
| 150 | end |
| 151 | ret add n 4 |
| 152 | end |
| 153 | fn redir fd int dst int to void |
| 154 | if ne fd dst |
| 155 | if ne dupfd fd dst 0 long dst |
| 156 | exit 90 |
| 157 | end |
| 158 | end |
| 159 | end |
| 160 | fn reap pid long to void |
| 161 | start = monons |
| 162 | while true bound 60000 |
| 163 | r = waitpid int pid status 0 len status 1 |
| 164 | if eq r pid |
| 165 | if or ne get status 0 0 ne get status 1 0 |
| 166 | exit 90 |
| 167 | end |
| 168 | ret |
| 169 | end |
| 170 | if or lt r 0 gt sub monons start 30000000000 |
| 171 | r = killpid int pid 9 |
| 172 | r = waitpid int pid status 0 len status 0 |
| 173 | exit 90 |
| 174 | end |
| 175 | if ne sleepns 1000000 0 |
| 176 | exit 90 |
| 177 | end |
| 178 | end |
| 179 | exit 90 |
| 180 | end |
| 181 | fn child c uint fd int nullfd int to void |
| 182 | n = command c |
| 183 | pid = fork |
| 184 | if lt pid 0 |
| 185 | exit 90 |
| 186 | end |
| 187 | if eq pid 0 |
| 188 | redir nullfd 2 |
| 189 | if eq c 0 |
| 190 | redir nullfd 0 |
| 191 | redir fd 1 |
| 192 | else |
| 193 | redir fd 0 |
| 194 | redir nullfd 1 |
| 195 | end |
| 196 | r = execprog argv 0 n |
| 197 | exit 90 |
| 198 | end |
| 199 | reap pid |
| 200 | end |
| 201 | fn main to int |
| 202 | fd = fopen spool 0 len spool 194 384 |
| 203 | if lt fd 0 |
| 204 | ret 90 |
| 205 | end |
| 206 | nullfd = fopen nullpath 0 len nullpath 2 0 |
| 207 | if lt nullfd 0 |
| 208 | ret 90 |
| 209 | end |
| 210 | for i ulong 101 |
| 211 | start = monons |
| 212 | if ne fseek int fd 0 0 0 |
| 213 | ret 90 |
| 214 | end |
| 215 | child 0 int fd int nullfd |
| 216 | if ne fseek int fd 0 0 0 |
| 217 | ret 90 |
| 218 | end |
| 219 | child 1 int fd int nullfd |
| 220 | put samples i ulong sub monons start |
| 221 | end |
| 222 | percentiles |
| 223 | if ne fclose int fd 0 |
| 224 | ret 90 |
| 225 | end |
| 226 | if ne fclose int nullfd 0 |
| 227 | ret 90 |
| 228 | end |
| 229 | label 8 |
| 230 | ret 0 |
| 231 | end |