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/aienux/allen/tests/look-chat.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 / aienux / allen / tests / look-chat.om` 313 lines ยท 7537 bytes Raw Blame History 1 note Courier over UDP 47033 on net.om: concatenate after platform.om, the gate.sh 2 note core list, net.om, look-chat.om and tests/check.om. Host-only fixtures: HI, 3 note ACK and LINE datagrams are built by courier.om's own serializer in the live 4 note relay's form (allen-courier main.rs datagram(): HI/ACK part=0/0 bytes=0, 5 note LINE part=i/0 bytes=), wrapped in Ethernet/IPv4/UDP frames with 6 note an independent checksum, and fed through netinput; outgoing frames are 7 note checked against the same rules. The first HELLO frame is written raw to 8 note fd 2 for an outside checksum check. check prints through Outb, so every 9 note fixture is delivered before its packet result is checked. 10 text Cvline " 1/1 Model answer." 11 text Cvsay "SAY " 12 text Cvask "hello" 13 global Cvdst ulong 1 14 fn cvw16 p ulong v ulong to void 15 put Nrx p uchar and shr v 8 255 16 put Nrx add p 1 uchar and v 255 17 end 18 fn cvw32 p ulong v ulong to void 19 cvw16 p shr v 16 20 cvw16 add p 2 and v 65535 21 end 22 fn cvt16 p ulong to ulong 23 ret add shl ulong get Ntx p 8 ulong get Ntx add p 1 24 end 25 fn cvt32 p ulong to ulong 26 ret add shl cvt16 p 16 cvt16 add p 2 27 end 28 note Independent one's-complement sum over Nrx (tx false) or Ntx (tx true). 29 fn cvsum tx bool p ulong n ulong to ulong 30 s = ulong 0 31 for i ulong n 32 v = ulong 0 33 if tx 34 v = ulong get Ntx add p i 35 else 36 v = ulong get Nrx add p i 37 end 38 if eq rem i 2 0 39 s = add s shl v 8 40 else 41 s = add s v 42 end 43 end 44 ret s 45 end 46 fn cvcpl s ulong to ulong 47 while gt s 65535 bound 8 48 s = add shr s 16 and s 65535 49 end 50 ret xor s 65535 51 end 52 fn cvpseudo a ulong b ulong n ulong to ulong 53 s = add add shr a 16 and a 65535 add shr b 16 and b 65535 54 ret add s add 17 n 55 end 56 fn cvip4 a ulong b ulong c ulong d ulong to ulong 57 ret add add shl a 24 shl b 16 add shl c 8 d 58 end 59 note Wrap Outb[0..Outlen) in a frame from 192.168.1.10:sp to Cvdst:dp and feed it in. 60 fn cvdeliver sp ulong dp ulong now ulong to void 61 n = get Outlen 0 62 for i ulong 2048 63 put Nrx i uchar 0 64 end 65 for i ulong 6 66 put Nrx i uchar 255 67 put Nrx add i 6 uchar 0 68 end 69 put Nrx 6 uchar 2 70 put Nrx 11 uchar 170 71 cvw16 12 2048 72 put Nrx 14 uchar 69 73 cvw16 16 add n 28 74 cvw16 20 16384 75 put Nrx 22 uchar 64 76 put Nrx 23 uchar 17 77 src = cvip4 192 168 1 10 78 cvw32 26 src 79 cvw32 30 get Cvdst 0 80 cvw16 24 cvcpl cvsum false 14 20 81 cvw16 34 sp 82 cvw16 36 dp 83 cvw16 38 add n 8 84 for i ulong n 85 put Nrx add 42 i get Outb i 86 end 87 c = cvcpl add cvpseudo src get Cvdst 0 add n 8 cvsum false 34 add n 8 88 if eq c 0 89 c = 65535 90 end 91 cvw16 40 c 92 if lt n 18 93 n = 18 94 end 95 netinput add 42 n now 96 end 97 note A 20-byte TCP segment from 192.168.1.10:443 to Cvdst:Ncfg21 (session port). 98 fn cvtcp now ulong to void 99 for i ulong 2048 100 put Nrx i uchar 0 101 end 102 for i ulong 6 103 put Nrx i uchar 255 104 put Nrx add i 6 uchar 0 105 end 106 put Nrx 6 uchar 2 107 put Nrx 11 uchar 170 108 cvw16 12 2048 109 put Nrx 14 uchar 69 110 cvw16 16 40 111 cvw16 20 16384 112 put Nrx 22 uchar 64 113 put Nrx 23 uchar 6 114 cvw32 26 cvip4 192 168 1 10 115 cvw32 30 get Cvdst 0 116 cvw16 24 cvcpl cvsum false 14 20 117 cvw16 34 443 118 cvw16 36 get Ncfg 21 119 put Nrx 46 uchar 80 120 netinput 54 now 121 end 122 note Outgoing courier frame: broadcast, IPv4/UDP 47033 both ways, valid checksums. 123 fn cvtxok to bool 124 if eq get Ntxlen 0 0 125 ret false 126 end 127 for i ulong 6 128 if ne get Ntx i 255 129 ret false 130 end 131 end 132 if or ne cvt16 12 2048 ne get Ntx 23 17 133 ret false 134 end 135 if ne cvcpl cvsum true 14 20 0 136 ret false 137 end 138 if or ne cvt16 34 47033 ne cvt16 36 47033 139 ret false 140 end 141 n = sub cvt16 16 20 142 if or ne n cvt16 38 gt add n 34 get Ntxlen 0 143 ret false 144 end 145 if ne cvt32 30 `4294967295` 146 ret false 147 end 148 s = cvpseudo cvt32 26 cvt32 30 n 149 ret eq cvcpl add s cvsum true 34 n 0 150 end 151 fn cvkind c uchar to bool 152 note The kind field starts at offset 22+16+6 of the head (ALLEN-COURIER v=1 run=<16> kind=). 153 ret eq ulong get Ntx 86 ulong c 154 end 155 fn cvbody seq ulong to void 156 outreset 157 for i ulong len Cvsay 158 emitb get Cvsay i 159 end 160 emitn seq 161 for i ulong len Cvline 162 emitb get Cvline i 163 end 164 put Inlen 0 get Outlen 0 165 for i ulong get Outlen 0 166 put In i get Outb i 167 end 168 end 169 fn main to int 170 put Cvdst 0 `4294967295` 171 put Nmac 0 uchar 2 172 for i ulong 4 173 put Nmac add i 1 uchar 0 174 end 175 put Nmac 5 uchar 1 176 netinit 5000 177 netsent true 5000 178 check eq get Ntxlen 0 0 7 179 check not chbusy 1 180 check chinit 5000 0 2 181 check ne get Q 0 0 3 182 check eq get Q 0 chrun 5000 4 183 check not chinit 5000 0 5 184 check eq get Ncfg 2 0 6 185 chstep 5000 true 186 check cvtxok 10 187 check eq cvt32 26 0 11 188 check cvkind 72 12 189 check eq get Ch 2 1 13 190 check not netudpsend 10 14 191 w = write 2 Ntx 0 get Ntxlen 0 192 netsent true 5000 193 check eq get Ntxlen 0 0 15 194 put Inlen 0 0 195 ok = packet 6 0 0 0 0 196 n = get Outlen 0 197 cvdeliver 47033 47033 5001 198 check ok 16 199 check eq get Chrxn 0 n 17 200 chstep 5001 true 201 check eq get Chrxn 0 0 18 202 check eq get T 1 1 19 203 check eq get Ch 3 1 20 204 check eq get Ntxlen 0 0 21 205 put Dprmn 0 len Cvask 206 for i ulong len Cvask 207 put Dprm i get Cvask i 208 end 209 check chask 5002 30 210 check chbusy 31 211 check not chask 5003 32 212 chstep 5003 true 213 check cvtxok 33 214 check cvkind 74 34 215 netsent true 5003 216 put Inlen 0 0 217 ok = packet 4 get Q 1 0 0 0 218 cvdeliver 47033 47033 5004 219 check ok 35 220 chstep 5004 true 221 check eq get T 6 1 36 222 check eq get Ntxlen 0 0 37 223 note Negative control: a LINE whose bytes= is neither 0 nor the body length is refused. 224 cvbody get Q 1 225 ok = packet 2 get Q 1 1 0 add get Inlen 0 1 226 cvdeliver 47033 47033 5005 227 chstep 5005 true 228 check and ok and eq get Chevent 0 0 eq get Ntxlen 0 0 39 229 cvbody get Q 1 230 ok = packet 2 get Q 1 1 0 get Inlen 0 231 cvdeliver 47033 47033 5005 232 n = get Chdrop 0 233 cvdeliver 47033 47033 5005 234 check ok 40 235 check eq n 0 41 236 check eq get Chdrop 0 1 42 237 chstep 5005 true 238 check eq get Chevent 0 1 43 239 check eq get Chsayn 0 13 44 240 check eq get Chsay 0 77 45 241 check eq get Ch 5 1 46 242 check cvtxok 47 243 check cvkind 71 48 244 check not chbusy 49 245 netsent true 5005 246 note Like the C kernel, ours by Ethernet destination and port alone: other ports 247 note never reach the courier slot; any IPv4 destination does, so the relay's 248 note --udp-answer 192.168.1.255 is heard without a lease. 249 cvdeliver 47033 47034 5006 250 check eq get Chrxn 0 0 50 251 cvdeliver 1234 47033 5006 252 check ne get Chrxn 0 0 51 253 put Chrxn 0 0 254 put Cvdst 0 cvip4 192 168 1 255 255 cvdeliver 47033 47033 5007 256 check ne get Chrxn 0 0 52 257 put Chrxn 0 0 258 put Ncfg 2 cvip4 192 168 1 20 259 put Ncfg 3 cvip4 255 255 255 0 260 put Cvdst 0 cvip4 192 168 1 20 261 cvdeliver 47033 47033 5007 262 check ne get Chrxn 0 0 53 263 put Chrxn 0 0 264 put Cvdst 0 cvip4 192 168 1 21 265 cvdeliver 47033 47033 5007 266 check ne get Chrxn 0 0 54 267 put Chrxn 0 0 268 put Chevent 0 1 269 chcancel 270 check eq get Chevent 0 0 55 271 check not chbusy 56 272 note With a lease the frame leaves from our address and the relay's subnet 273 note broadcast answer (--udp-answer 192.168.1.255) is still heard. 274 put Dprmn 0 len Cvask 275 check chask 5008 60 276 chstep 5008 true 277 check cvtxok 61 278 check eq cvt32 26 cvip4 192 168 1 20 62 279 netsent true 5008 280 put Cvdst 0 cvip4 192 168 1 255 281 put Inlen 0 0 282 ok = packet 4 get Q 1 0 0 0 283 cvdeliver 47033 47033 5009 284 chstep 5009 true 285 check and ok eq get T 6 1 63 286 note Error state 6 after a failed repository session: the courier still hears a 287 note LINE and sends its GOT, while a TCP segment for the dead session is frozen 288 note (Ndrop 12 is ntcpin's first verdict for a segment from the wrong peer). 289 put Tcpstate 0 6 290 cvbody get Q 1 291 ok = packet 2 get Q 1 1 0 get Inlen 0 292 cvdeliver 47033 47033 5010 293 check and ok ne get Chrxn 0 0 64 294 r = get Ch 4 295 chstep 5010 true 296 check eq get Chevent 0 1 65 297 check and cvtxok cvkind 71 66 298 check eq get Ch 4 r 67 299 netsent true 5010 300 put Cvdst 0 cvip4 192 168 1 20 301 put Ncfg 1 4 302 put Ncfg 21 40000 303 put Tcpstate 2 cvip4 10 0 0 1 304 put Tcpstate 0 5 305 put Ndrop 0 0 306 cvtcp 5011 307 check eq get Ndrop 0 12 68 308 put Ndrop 0 0 309 put Tcpstate 0 6 310 cvtcp 5011 311 check eq get Ndrop 0 0 69 312 ret int get Fails 0 313 end