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/interplane-forge/blob/main/galaxy/live.om # interplane-forge INTERPLANE Forge 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 `interplane-forge / galaxy / live.om` 636 lines ยท 10458 bytes Raw Blame History 1 note live.om: the page that keeps itself current. Composed after page.om. 2 note It connects to the factory's public Now stream (127.0.0.1:4748, server-sent events), keeps the 3 note figures the page shows, and rewrites index.html in the working directory after an event, at 4 note most once per 30 s of stream time (the event's own "generated" second; no clock is read, so 5 note the pacing is the same on a recorded stream). No timer: without stream events nothing is 6 note written. On a lost connection it waits 5 s and connects again. With any argument it reads the 7 note stream bytes from stdin instead and exits at end of input (the gate uses this). 8 note Files in the working directory: stars.tsv (optional R and M lines, at most 32,768 bytes), 9 note index.html and galaxy.css (each written to a .tmp name, synced, then renamed over the old one). 10 note vnum: 0 generated, 1 delivered, 2 gpu watts, 3 review queue, 4 approved, 5 dirty, 6 generated at the 11 note last publish, 7 published once, 8 line too long, 10+j jobs in work of station j, 20+j delivered in 24 h 12 global vrx uchar 65536 13 global vln uchar `1048576` 14 global vlnl ulong 1 15 global vnum ulong 32 16 global vnm uchar 640 17 global vnl ulong 10 18 global vsx uchar 32768 19 global vad uchar 16 20 global vrq uchar 64 21 global vpl uchar 64 22 text vkgen "generated" 23 text vktot "totals" 24 text vkdon "done" 25 text vkmac "machine" 26 text vkgpu "gpu_w" 27 text vksta "stations" 28 text vkid "id" 29 text vknam "name" 30 text vkmov "moving" 31 text vkd24 "done24" 32 text vkque "queue" 33 text vkapp "approved" 34 text vi0 "intake" 35 text vi1 "command" 36 text vi2 "aegis" 37 text vi3 "omega" 38 text vi4 "cuda" 39 text vi5 "kernel" 40 text vi6 "mill" 41 text vi7 "core" 42 text vi8 "si" 43 text vi9 "dock" 44 text vget "GET /now/stream HTTP/1.0" 45 text vfidx "index.html" 46 text vftmp "index.html.tmp" 47 text vfcss "galaxy.css" 48 text vfctm "galaxy.css.tmp" 49 text vfsta "stars.tsv" 50 text vla "K\tasof\t" 51 text vlb " UTC\nK\tdelivered\t" 52 text vlc "\nK\tverdicts\t" 53 text vld "\nK\tapproved\t" 54 text vle "\nK\twaiting\t" 55 text vlf "\nK\tgpuw\t" 56 note ---- JSON scanning over the current line vln; every index stays inside 0..vlnl 57 fn vws p ulong to ulong 58 lim = get vlnl 0 59 i = p 60 while lt i lim bound `1048576` 61 if gt get vln i 32 62 ret i 63 end 64 i = add i 1 65 end 66 ret lim 67 end 68 note vstr: p is at an opening quote; the index after the closing quote 69 fn vstr p ulong to ulong 70 lim = get vlnl 0 71 i = add p 1 72 while lt i lim bound `1048576` 73 c = get vln i 74 if eq c 92 75 i = add i 2 76 else 77 if eq c 34 78 ret add i 1 79 end 80 i = add i 1 81 end 82 end 83 ret lim 84 end 85 note vskip: the index after the JSON value that starts at p 86 fn vskip p ulong to ulong 87 lim = get vlnl 0 88 if ge p lim 89 ret lim 90 end 91 c = get vln p 92 if eq c 34 93 ret vstr p 94 end 95 if or eq c 123 eq c 91 96 d = ulong 0 97 i = p 98 while lt i lim bound `1048576` 99 b = get vln i 100 if eq b 34 101 i = vstr i 102 else 103 if or eq b 123 eq b 91 104 d = add d 1 105 end 106 if or eq b 125 eq b 93 107 d = sub d 1 108 if eq d 0 109 ret add i 1 110 end 111 end 112 i = add i 1 113 end 114 end 115 ret lim 116 end 117 j = p 118 while lt j lim bound `1048576` 119 s = get vln j 120 if or or eq s 44 eq s 125 or eq s 93 le s 32 121 ret j 122 end 123 j = add j 1 124 end 125 ret lim 126 end 127 fn vkeq a ulong b ulong t view uchar * to bool 128 n = len t 129 if lt b a 130 ret false 131 end 132 if ne sub b a n 133 ret false 134 end 135 i = ulong 0 136 while lt i n bound 64 137 if ne get vln add a i get t i 138 ret false 139 end 140 i = add i 1 141 end 142 ret true 143 end 144 note vkey: p is at the brace of an object; the start of the value of key t, or vlnl 145 fn vkey p ulong t view uchar * to ulong 146 lim = get vlnl 0 147 if ge p lim 148 ret lim 149 end 150 if ne get vln p 123 151 ret lim 152 end 153 i = vws add p 1 154 while lt i lim bound `1048576` 155 if ne get vln i 34 156 ret lim 157 end 158 ke = vstr i 159 v = vws ke 160 if ge v lim 161 ret lim 162 end 163 v = vws add v 1 164 if vkeq add i 1 sub ke 1 t 165 ret v 166 end 167 i = vws vskip v 168 if ge i lim 169 ret lim 170 end 171 if ne get vln i 44 172 ret lim 173 end 174 i = vws add i 1 175 end 176 ret lim 177 end 178 note vstat: p is at the bracket of the stations array; the start of the object whose id is t, or vlnl 179 fn vstat p ulong t view uchar * to ulong 180 lim = get vlnl 0 181 if ge p lim 182 ret lim 183 end 184 if ne get vln p 91 185 ret lim 186 end 187 i = vws add p 1 188 while lt i lim bound `1048576` 189 if ne get vln i 123 190 ret lim 191 end 192 v = vkey i vkid 193 if lt v lim 194 if eq get vln v 34 195 e = vstr v 196 if vkeq add v 1 sub e 1 t 197 ret i 198 end 199 end 200 end 201 i = vws vskip i 202 if ge i lim 203 ret lim 204 end 205 if ne get vln i 44 206 ret lim 207 end 208 i = vws add i 1 209 end 210 ret lim 211 end 212 fn vdig p ulong to ulong 213 lim = get vlnl 0 214 i = p 215 while lt i lim bound `1048576` 216 c = get vln i 217 if or lt c 48 gt c 57 218 ret i 219 end 220 i = add i 1 221 end 222 ret lim 223 end 224 fn vint p ulong to ulong 225 e = vdig p 226 v = ulong 0 227 i = p 228 while lt i e bound `1048576` 229 v = add mul v 10 ulong sub get vln i 48 230 i = add i 1 231 end 232 ret v 233 end 234 note vround: a JSON number to the nearest whole number, halves up 235 fn vround p ulong to ulong 236 lim = get vlnl 0 237 v = vint p 238 e = vdig p 239 if lt add e 1 lim 240 if eq get vln e 46 241 d = get vln add e 1 242 if ge d 53 243 if le d 57 244 v = add v 1 245 end 246 end 247 end 248 end 249 ret v 250 end 251 note vname: p is the value of "name"; slot j keeps at most 63 printable bytes, an escape becomes "?" 252 fn vname p ulong j ulong to void 253 lim = get vlnl 0 254 if ge p lim 255 ret 256 end 257 if ne get vln p 34 258 ret 259 end 260 e = vstr p 261 i = add p 1 262 n = ulong 0 263 while lt add i 1 e bound `1048576` 264 c = get vln i 265 if eq c 92 266 c = uchar 63 267 i = add i 1 268 end 269 if lt n 63 270 if ge c 32 271 put vnm add mul j 64 n c 272 n = add n 1 273 end 274 end 275 i = add i 1 276 end 277 put vnl j n 278 end 279 fn vone a ulong j ulong t view uchar * to void 280 lim = get vlnl 0 281 s = vstat a t 282 if ge s lim 283 ret 284 end 285 vname vkey s vknam j 286 m = vkey s vkmov 287 if lt m lim 288 put vnum add 10 j vint m 289 end 290 d = vkey s vkd24 291 if lt d lim 292 put vnum add 20 j vint d 293 end 294 if eq j 2 295 q = vkey s vkque 296 if lt q lim 297 put vnum 3 vint q 298 end 299 put vnum 4 0 300 p = vkey s vkapp 301 if lt p lim 302 put vnum 4 vint p 303 end 304 end 305 end 306 note vevent: the line is "data: {...}"; each top-level key it carries replaces what was kept 307 fn vevent to void 308 lim = get vlnl 0 309 o = vws 5 310 g = vkey o vkgen 311 if lt g lim 312 put vnum 0 vint g 313 end 314 t = vkey o vktot 315 if lt t lim 316 d = vkey t vkdon 317 if lt d lim 318 put vnum 1 vint d 319 end 320 end 321 m = vkey o vkmac 322 if lt m lim 323 w = vkey m vkgpu 324 if lt w lim 325 put vnum 2 vround w 326 end 327 end 328 s = vkey o vksta 329 if lt s lim 330 vone s 0 vi0 331 vone s 1 vi1 332 vone s 2 vi2 333 vone s 3 vi3 334 vone s 4 vi4 335 vone s 5 vi5 336 vone s 6 vi6 337 vone s 7 vi7 338 vone s 8 vi8 339 vone s 9 vi9 340 end 341 put vnum 5 1 342 end 343 note ---- the feed, written into the page generator's input buffer ib 344 fn via t view uchar * to void 345 n = len t 346 o = get ibl 0 347 i = ulong 0 348 while lt i n bound 65536 349 put ib add o i get t i 350 i = add i 1 351 end 352 put ibl 0 add o n 353 end 354 fn viab c uchar to void 355 o = get ibl 0 356 put ib o c 357 put ibl 0 add o 1 358 end 359 fn vian v ulong to void 360 d = new uchar 20 0 361 n = ulong 0 362 x = v 363 if eq x 0 364 viab 48 365 end 366 while gt x 0 bound 20 367 put d n uchar add 48 rem x 10 368 x = div x 10 369 n = add n 1 370 end 371 while gt n 0 bound 20 372 n = sub n 1 373 viab get d n 374 end 375 end 376 fn via2 v ulong to void 377 viab uchar add 48 rem div v 10 10 378 viab uchar add 48 rem v 10 379 end 380 note vymd: days since 1970-01-01 as YYYY-MM-DD (proleptic Gregorian; the gate checks it against date -u) 381 fn vymd days ulong to void 382 z = add days 719468 383 era = div z 146097 384 doe = sub z mul era 146097 385 t = sub doe div doe 1460 386 t = add t div doe 36524 387 t = sub t div doe 146096 388 yoe = div t 365 389 y = add yoe mul era 400 390 doy = sub doe sub add mul 365 yoe div yoe 4 div yoe 100 391 mp = div add mul 5 doy 2 153 392 d = add sub doy div add mul 153 mp 2 5 1 393 m = add mp 3 394 if ge mp 10 395 m = sub mp 9 396 end 397 if le m 2 398 y = add y 1 399 end 400 vian y 401 viab 45 402 via2 m 403 viab 45 404 via2 d 405 end 406 fn vdate s ulong to void 407 r = rem s 86400 408 vymd div s 86400 409 viab 32 410 via2 div r 3600 411 viab 58 412 via2 div rem r 3600 60 413 end 414 fn vcell j ulong to void 415 n = get vnl j 416 if gt n 0 417 viab 83 418 viab 9 419 i = ulong 0 420 while lt i n bound 64 421 viab get vnm add mul j 64 i 422 i = add i 1 423 end 424 viab 9 425 vian get vnum add 10 j 426 viab 9 427 vian get vnum add 20 j 428 viab 10 429 end 430 end 431 fn vstars to void 432 fd = int fopen vfsta 0 len vfsta 0 0 433 if lt fd 0 434 ret 435 end 436 n = ulong 0 437 k = long 1 438 while gt k 0 bound 32769 439 k = read fd vsx n sub 32768 n 440 if gt k 0 441 n = add n ulong k 442 end 443 end 444 r = fclose fd 445 o = get ibl 0 446 i = ulong 0 447 while lt i n bound 32768 448 put ib add o i get vsx i 449 i = add i 1 450 end 451 put ibl 0 add o n 452 end 453 fn vfeed to void 454 put ibl 0 0 455 via vla 456 vdate get vnum 0 457 via vlb 458 vian get vnum 1 459 via vlc 460 vian get vnum 22 461 via vld 462 vian get vnum 4 463 via vle 464 vian get vnum 3 465 via vlf 466 vian get vnum 2 467 viab 10 468 j = ulong 0 469 while lt j 10 bound 10 470 vcell j 471 j = add j 1 472 end 473 vstars 474 end 475 note ---- files: write the output buffer ob to tmp, sync, rename over fin 476 fn vren a view uchar * b view uchar * to bool 477 la = len a 478 lb = len b 479 put vpl 0 2 480 put vpl 1 0 481 put vpl 2 uchar la 482 put vpl 3 0 483 i = ulong 0 484 while lt i la bound 28 485 put vpl add 4 i get a i 486 i = add i 1 487 end 488 o = add 4 la 489 put vpl o uchar lb 490 put vpl add o 1 0 491 k = ulong 0 492 while lt k lb bound 28 493 put vpl add add o 2 k get b k 494 k = add k 1 495 end 496 ret eq renames vpl 0 add add o 2 lb 0 0 497 end 498 fn vwrite tmp view uchar * fin view uchar * to bool 499 fd = int fopen tmp 0 len tmp 577 420 500 if lt fd 0 501 ret false 502 end 503 n = get obl 0 504 o = ulong 0 505 ok = true 506 while lt o n bound `1048576` 507 k = write fd ob o sub n o 508 if le k 0 509 ok = false 510 o = n 511 else 512 o = add o ulong k 513 end 514 end 515 r = fsync fd 516 r = fclose fd 517 if not ok 518 ret false 519 end 520 ret vren tmp fin 521 end 522 fn vpub to void 523 vfeed 524 put obl 0 0 525 page 526 if vwrite vftmp vfidx 527 put vnum 5 0 528 put vnum 7 1 529 end 530 put vnum 6 get vnum 0 531 end 532 note vmaybe: publish when an event came, the stations are known, and it is the first time, or the 533 note stream's generated second is 30 or more past the last publish, or went backwards (a restarted source) 534 fn vmaybe to void 535 if eq get vnum 5 0 536 ret 537 end 538 if eq get vnl 0 0 539 ret 540 end 541 if eq get vnum 7 0 542 vpub 543 ret 544 end 545 g = get vnum 0 546 l = get vnum 6 547 if lt g l 548 vpub 549 ret 550 end 551 if ge sub g l 30 552 vpub 553 end 554 end 555 fn vline to void 556 n = get vlnl 0 557 if eq get vnum 8 0 558 if ge n 6 559 if eq get vln 0 100 560 if eq get vln 1 97 561 if eq get vln 4 58 562 vevent 563 vmaybe 564 end 565 end 566 end 567 end 568 end 569 put vlnl 0 0 570 put vnum 8 0 571 end 572 fn vbytes n ulong to void 573 i = ulong 0 574 while lt i n bound 65536 575 c = get vrx i 576 if eq c 10 577 vline 578 else 579 m = get vlnl 0 580 if lt m `1048575` 581 put vln m c 582 put vlnl 0 add m 1 583 else 584 put vnum 8 1 585 end 586 end 587 i = add i 1 588 end 589 end 590 fn vpump fd int to void 591 k = long 1 592 while gt k 0 bound `9223372036854775807` 593 k = read fd vrx 0 65536 594 if gt k 0 595 vbytes ulong k 596 end 597 end 598 end 599 fn main to int 600 put vad 0 2 601 put vad 2 18 602 put vad 3 140 603 put vad 4 127 604 put vad 7 1 605 put obl 0 0 606 css 607 ok = vwrite vfctm vfcss 608 if gt argcnt 1 609 vpump 0 610 ret 0 611 end 612 n = len vget 613 i = ulong 0 614 while lt i n bound 60 615 put vrq i get vget i 616 i = add i 1 617 end 618 put vrq n 13 619 put vrq add n 1 10 620 put vrq add n 2 13 621 put vrq add n 3 10 622 while true bound `9223372036854775807` 623 s = int socknew 2 1 0 624 if ge s 0 625 if eq connect s vad 0 16 0 626 if gt send s vrq 0 add n 4 0 0 627 put vlnl 0 0 628 vpump s 629 end 630 end 631 r = fclose s 632 end 633 z = sleepns `5000000000` 634 end 635 ret 0 636 end