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/aienos.com/blob/main/om/site/runtime.om # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / om / site / runtime.om` 510 lines ยท 9938 bytes Raw Blame History 1 note Shared native site runtime; concatenate after the unit's leading om2. 2 note API sr_raw/sr_bytes write exact bytes; sr_esc escapes HTML text and quoted attributes. 3 note sr_open creates checked parents and truncates a file; sr_close flushes and restores stdout. 4 note sofd is the current output descriptor after sr_init or sr_open. Never mutate it without sr_flush. 5 note sr_copy preserves bytes, not mode; refuses same inode before truncation. All I/O errors exit 70. 6 note Paths use the host's 4095-byte limit; zero bytes and empty paths are refused by name. 7 note Streaming operations allow 999998 read attempts, then refuse IO_LIMIT rather than trap/truncate. 8 note Integration cases (NOT_RUN): nested parents; existing regular-file parent refusal; missing source; 9 note same-inode copy refusal including hardlink; empty and multi-block copy; /dev/full write refusal; 10 note partial pipe reads/writes; empty strings; equality length mismatch; escaping ampersand/angles/quotes. 11 text srepre "site runtime: " 12 text srenl "\n" 13 text srewr "WRITE" 14 text srerd "READ" 15 text srecl "CLOSE" 16 text sreop "OPEN" 17 text sremk "MKDIR" 18 text srepa "PATH" 19 text srebo "BOUNDS" 20 text ghforge "https://interplane.io/drakestapleton/" 21 text sreli "IO_LIMIT" 22 text sresa "COPY_SAME_FILE" 23 text srest "STAT" 24 text sretr "TRUNCATE" 25 text sreamp "&" 26 text srelt "<" 27 text sregt ">" 28 text srequ """ 29 text sreapo "'" 30 text srehash "#" 31 global sofd int 1 32 global srb uchar 16384 33 global srn ulong 1 34 global sri uchar 1 35 note srnoh[0] = 1 while a Markdown link URL is written: its # stays a byte, as in r4. 36 global srnoh uchar 1 37 fn sr_diag s view uchar * to void 38 p = ulong 0 39 while lt p len s bound 4096 40 k = write 2 s p sub len s p 41 if le k 0 42 exit 70 43 end 44 p = add p ulong k 45 end 46 end 47 fn sr_fail why view uchar * to void 48 sr_diag srepre 49 sr_diag why 50 sr_diag srenl 51 exit 70 52 end 53 fn sr_init to void 54 if eq get sri 0 0 55 put sofd 0 1 56 put sri 0 1 57 end 58 end 59 fn sr_flush to void 60 sr_init 61 p = ulong 0 62 while lt p get srn 0 bound 16384 63 k = write get sofd 0 srb p sub get srn 0 p 64 if le k 0 65 sr_fail srewr 66 end 67 p = add p ulong k 68 end 69 put srn 0 0 70 end 71 fn sr_byte c uchar to void 72 if eq get srn 0 len srb 73 sr_flush 74 end 75 put srb get srn 0 c 76 put srn 0 add get srn 0 1 77 end 78 fn sr_write fd int s view uchar * off ulong cnt ulong to void 79 note A chunk is at most 65536 bytes, so even one-byte progress respects the loop bound. 80 p = ulong 0 81 while lt p cnt bound 65536 82 k = write fd s add off p sub cnt p 83 if le k 0 84 sr_fail srewr 85 end 86 p = add p ulong k 87 end 88 end 89 fn sr_bytes s view uchar * off ulong cnt ulong to void 90 if gt off len s 91 sr_fail srebo 92 end 93 if gt cnt sub len s off 94 sr_fail srebo 95 end 96 note Compiler array limit is `16777216` bytes. Chunking avoids the million-iteration guard. 97 if gt cnt `16777216` 98 sr_fail srebo 99 end 100 p = ulong 0 101 while lt p cnt bound 16384 102 n = sub cnt p 103 if ge n len srb 104 sr_flush 105 if gt n 65536 106 n = 65536 107 end 108 sr_write get sofd 0 s add off p n 109 p = add p n 110 else 111 for j ulong n 112 sr_byte get s add add off p j 113 end 114 p = add p n 115 end 116 end 117 end 118 fn sr_raw s view uchar * to void 119 sr_bytes s 0 len s 120 end 121 fn sr_escape c uchar to void 122 if eq c 38 123 sr_raw sreamp 124 ret 125 end 126 if eq c 60 127 sr_raw srelt 128 ret 129 end 130 if eq c 62 131 sr_raw sregt 132 ret 133 end 134 if eq c 34 135 sr_raw srequ 136 ret 137 end 138 if eq c 39 139 sr_raw sreapo 140 ret 141 end 142 sr_byte c 143 end 144 note sr_escref: c escaped as sr_escape does, except the # of a reference (# then the digit d, 145 note as in #775) is #, so page text has no # followed by digits; it renders the same. 146 fn sr_escref c uchar d uchar to void 147 if eq c 35 148 if and ge d 48 eq get srnoh 0 0 149 if lt d 58 150 sr_raw srehash 151 ret 152 end 153 end 154 end 155 sr_escape c 156 end 157 fn sr_esc s view uchar * to void 158 p = ulong 0 159 while lt p len s bound 16384 160 n = sub len s p 161 if gt n 65536 162 n = 65536 163 end 164 for j ulong n 165 ec8 = get s add p j 166 ed8 = ec8 167 ek8 = add add p j 1 168 if lt ek8 len s 169 ed8 = get s ek8 170 end 171 sr_escref ec8 ed8 172 end 173 p = add p n 174 end 175 end 176 fn sr_equal a view uchar * b view uchar * to bool 177 if ne len a len b 178 ret false 179 end 180 p = ulong 0 181 while lt p len a bound 16384 182 n = sub len a p 183 if gt n 65536 184 n = 65536 185 end 186 for j ulong n 187 if ne get a add p j get b add p j 188 ret false 189 end 190 end 191 p = add p n 192 end 193 ret true 194 end 195 fn sr_num n ulong to void 196 buf = new uchar 20 0 197 p = ulong 20 198 while true bound 20 199 p = sub p 1 200 put buf p uchar add rem n 10 48 201 n = div n 10 202 if eq n 0 203 break 204 end 205 end 206 sr_bytes buf p sub ulong 20 p 207 end 208 fn sr_path path view uchar * to void 209 if or eq len path 0 gt len path 4095 210 sr_fail srepa 211 end 212 for j ulong len path 213 if eq get path j 0 214 sr_fail srepa 215 end 216 end 217 end 218 fn sr_fclose fd int to void 219 k = fclose fd 220 if ne k 0 221 sr_fail srecl 222 end 223 end 224 fn sr_dir path view uchar * n ulong to void 225 k = makedir path 0 n 493 226 if and lt k 0 ne k -17 227 sr_fail sremk 228 end 229 note EEXIST alone is not success: Linux AArch64 O_DIRECTORY (16384) proves a directory. 230 k = fopen path 0 n 16384 0 231 if lt k 0 232 sr_fail sremk 233 end 234 sr_fclose int k 235 end 236 fn sr_parents path view uchar * to void 237 sr_path path 238 for j ulong len path 239 if gt j 0 240 if eq get path j 47 241 sr_dir path j 242 end 243 end 244 end 245 end 246 fn sr_open path view uchar * to void 247 sr_close 248 sr_parents path 249 k = fopen path 0 len path 577 420 250 if lt k 0 251 sr_fail sreop 252 end 253 put sofd 0 int k 254 put sri 0 2 255 end 256 fn sr_close to void 257 sr_flush 258 if eq get sri 0 2 259 sr_fclose get sofd 0 260 end 261 put sofd 0 1 262 put sri 0 1 263 end 264 fn sr_stream fd int dest int to void 265 buf = new uchar 65536 0 266 for tries ulong 999998 267 k = read fd buf 0 len buf 268 if lt k 0 269 sr_fail srerd 270 end 271 if eq k 0 272 ret 273 end 274 sr_write dest buf 0 ulong k 275 end 276 sr_fail sreli 277 end 278 fn sr_file path view uchar * to void 279 sr_path path 280 k = fopen path 0 len path 0 0 281 if lt k 0 282 sr_fail sreop 283 end 284 sr_flush 285 sr_stream int k get sofd 0 286 sr_fclose int k 287 end 288 fn sr_distinct src int dst int to void 289 a = new uchar 128 0 290 b = new uchar 128 0 291 k = fstat src a 0 len a 292 if ne k 0 293 sr_fail srest 294 end 295 k = fstat dst b 0 len b 296 if ne k 0 297 sr_fail srest 298 end 299 note Linux AArch64 stat begins with st_dev and st_ino, each eight bytes. 300 same = true 301 for j ulong 16 302 if ne get a j get b j 303 same = false 304 end 305 end 306 if same 307 sr_fail sresa 308 end 309 end 310 fn sr_copy src view uchar * dst view uchar * to void 311 sr_path src 312 sr_parents dst 313 fd = fopen src 0 len src 0 0 314 if lt fd 0 315 sr_fail sreop 316 end 317 od = fopen dst 0 len dst 65 420 318 if lt od 0 319 sr_fail sreop 320 end 321 sr_distinct int fd int od 322 k = ftrunc int od 0 323 if ne k 0 324 sr_fail sretr 325 end 326 sr_stream int fd int od 327 sr_fclose int fd 328 sr_fclose int od 329 end 330 331 note Public project navigation uses INTERPLANE; GitHub source provenance in code examples is retained as text. 332 text ghhost "https://github.com/" 333 text ghhttp "http://github.com/" 334 text ghexpl "https://interplane.io/explore" 335 text ghslash "/" 336 text ghpull "/pull" 337 text ghissue "/issues" 338 text ghrel "/releases" 339 text ghpatch "/patches" 340 text ghblob "/blob/" 341 text ghtree "/tree/" 342 text ghcommit "/commit/" 343 text ghcs "/commits/" 344 text ghdev "aien-dev" 345 text ghspark "aien-spark" 346 text ghdrake "drakestapleton" 347 text ghmap "omega|omega-mv\naien-architecture|aien-architecture-mv\naien-sovereign-core|aien-sovereign-core-mv\naien-protocols|aien-protocols-mv\nbenchmarks|benchmarks-mv\ninterplane|interplane-mv\nphysics|physics-mv\naegis-runtime|aegis-runtime-mv\nspark-rsi|spark-rsi-mv\n" 348 fn gh_prefix value view uchar * to ulong 349 if ge len value len ghhost 350 if sr_equal part value 0 len ghhost ghhost 351 ret len ghhost 352 end 353 end 354 if ge len value len ghhttp 355 if sr_equal part value 0 len ghhttp ghhttp 356 ret len ghhttp 357 end 358 end 359 ret 0 360 end 361 fn gh_repo value view uchar * to void 362 p = ulong 0 363 while lt p len ghmap bound 4096 364 q = p 365 while lt q len ghmap bound 4096 366 if eq get ghmap q 124 367 break 368 end 369 q = add q 1 370 end 371 z = add q 1 372 while lt z len ghmap bound 4096 373 if eq get ghmap z 10 374 break 375 end 376 z = add z 1 377 end 378 if sr_equal value part ghmap p sub q p 379 sr_esc part ghmap add q 1 sub z add q 1 380 ret 381 end 382 p = add z 1 383 end 384 sr_esc value 385 end 386 fn gh_tail value view uchar * term view uchar * to bool 387 if lt len value len term 388 ret false 389 end 390 ret sr_equal part value 0 len term term 391 end 392 fn gxextern value view uchar * to bool 393 p = gh_prefix value 394 if eq p 0 395 ret false 396 end 397 q = p 398 while lt q len value bound 4096 399 if eq get value q 47 400 break 401 end 402 q = add q 1 403 end 404 ret not or sr_equal part value p sub q p ghdev or sr_equal part value p sub q p ghspark sr_equal part value p sub q p ghdrake 405 end 406 fn gh_numeric value view uchar * pos ulong to bool 407 if ge pos len value 408 ret false 409 end 410 seen = false 411 p = pos 412 while lt p len value bound 4096 413 c = get value p 414 if or eq c 35 eq c 63 415 break 416 end 417 if or lt c 48 gt c 57 418 ret false 419 end 420 seen = true 421 p = add p 1 422 end 423 ret seen 424 end 425 text ghisnum "/issues/" 426 text ghplnum "/pull/" 427 fn gh_forge_url value view uchar * to void 428 p = len ghforge 429 while lt p len value bound 4096 430 if eq get value p 47 431 break 432 end 433 p = add p 1 434 end 435 if lt p len value 436 if and gh_tail part value p sub len value p ghisnum gh_numeric value add p len ghisnum 437 sr_esc part value 0 p 438 sr_raw ghissue 439 ret 440 end 441 if and gh_tail part value p sub len value p ghplnum gh_numeric value add p len ghplnum 442 sr_esc part value 0 p 443 sr_raw ghpatch 444 ret 445 end 446 end 447 sr_esc value 448 end 449 fn gh_url value view uchar * to void 450 p = gh_prefix value 451 if eq p 0 452 if gh_tail value ghforge 453 gh_forge_url value 454 else 455 sr_esc value 456 end 457 ret 458 end 459 q = p 460 while lt q len value bound 4096 461 if eq get value q 47 462 break 463 end 464 q = add q 1 465 end 466 if eq q len value 467 sr_raw ghexpl 468 ret 469 end 470 if not or sr_equal part value p sub q p ghdev or sr_equal part value p sub q p ghspark sr_equal part value p sub q p ghdrake 471 sr_esc value 472 ret 473 end 474 p = add q 1 475 q = p 476 while lt q len value bound 4096 477 if or eq get value q 47 or eq get value q 35 eq get value q 63 478 break 479 end 480 q = add q 1 481 end 482 if eq p q 483 sr_raw ghexpl 484 ret 485 end 486 sr_raw ghforge 487 gh_repo part value p sub q p 488 if ge q len value 489 ret 490 end 491 if or gh_tail part value q sub len value q ghblob gh_tail part value q sub len value q ghtree 492 sr_esc part value q sub len value q 493 ret 494 end 495 if or gh_tail part value q sub len value q ghcommit gh_tail part value q sub len value q ghcs 496 sr_esc part value q sub len value q 497 ret 498 end 499 if gh_tail part value q sub len value q ghpull 500 sr_raw ghpatch 501 ret 502 end 503 if gh_tail part value q sub len value q ghissue 504 sr_raw ghissue 505 ret 506 end 507 if gh_tail part value q sub len value q ghrel 508 sr_raw ghrel 509 end 510 end