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/apps/interplane-forge/server/route.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 / apps / interplane-forge / server / route.om` 725 lines ยท 12413 bytes Raw Blame History 1 note forged server/route.om: path safety, the allow-list gate, the /rad: redirect, slice dispatch. 2 text tforg1 "https://interplane.io" 3 text tforg2 "https://www.aienos.com" 4 text tfpexp "/explore" 5 text tfpcss "/assets/forge.css" 6 text tfpico "/assets/favicon.svg" 7 text tfprad "/rad:" 8 text tfrsv1 "quick-start" 9 text tfrsv2 "concepts" 10 text tfrsv3 "adapter" 11 text tfrsv4 "conformance" 12 text tfrsv5 "status" 13 text tfrsv6 "forge" 14 text tfrsv7 "protocol" 15 text tfrsv8 "api" 16 text tfrsv9 "login" 17 text tfrsv10 "logout" 18 text tfrsv11 "explore" 19 text tfrsv12 "settings" 20 text tfrsv13 "new" 21 text tfrsv14 "search" 22 text tfrsv15 "stars" 23 text tfrsv16 "notifications" 24 text tfrsv17 "llms.txt" 25 text tfrsv18 "sitemap.xml" 26 text tfrsv19 "robots.txt" 27 text tfrsv20 "assets" 28 note ---- galaxy: the INTERPLANE front page. galaxy-live (galaxy/live.om) writes it into galaxy/; 29 note forged only streams those files. Served on the interplane.io base "/" alone: the page links 30 note /assets/..., which under the /forge/ base would leave the forge. 31 text tfgxi "galaxy/index.html" 32 text tfgxc "galaxy/galaxy.css" 33 text tfgxt "galaxy/tokens.css" 34 text tfpgx "/galaxy" 35 text tfpgxs "/galaxy/" 36 text tfpgxc "/assets/galaxy.css" 37 text tfpgxt "/assets/tokens.css" 38 text tfgxhtm "text/html; charset=utf-8" 39 text tfgxcc "public, max-age=30" 40 note fgxpath: ffile = 41 fn fgxpath t view uchar * to void 42 put ffilel 0 0 43 for i ulong len tfdata bound 128 44 ffilc get tfdata i 45 end 46 for k ulong len t bound 128 47 ffilc get t k 48 end 49 end 50 note fgxhas: the request came through base "/" and the page file is readable 51 fn fgxhas to bool 52 if ne get fbasel 0 1 53 ret false 54 end 55 fgxpath tfgxi 56 ret eq faccess ffile 0 get ffilel 0 4 0 57 end 58 note fgxsend: stream one galaxy file (kind 3; a missing file is 404). GET only. 59 fn fgxsend t view uchar * ct view uchar * to long 60 if not fget 61 ret 405 62 end 63 fgxpath t 64 put fobl 0 0 65 put fkind 0 3 66 fsetct ct 67 fsetcc tfgxcc 68 ret 200 69 end 70 note ---- path safety: 1 = safe. Refuses NUL / control / backslash, "//", "." and ".." segments 71 note (raw or %2e-encoded), and any %2f / %5c / %00 (encoded separators and NUL). 72 fn fsegdot a ulong e ulong to bool 73 n = sub e a 74 if eq n 1 75 ret eq fpathat a 46 76 end 77 if eq n 2 78 ret and eq fpathat a 46 eq fpathat add a 1 46 79 end 80 ret false 81 end 82 fn fpctbad i ulong to bool 83 if ne fpathat i 37 84 ret false 85 end 86 h = flow fpathat add i 1 87 l = flow fpathat add i 2 88 if and eq h 50 eq l 101 89 ret true 90 end 91 if and eq h 50 eq l 102 92 ret true 93 end 94 if and eq h 53 eq l 99 95 ret true 96 end 97 ret and eq h 48 eq l 48 98 end 99 fn fpathok to bool 100 n = get fpathl 0 101 if or eq n 0 ge n 4096 102 ret false 103 end 104 if ne fpathat 0 47 105 ret false 106 end 107 s = ulong 1 108 for i ulong n bound 4096 109 c = fpathat i 110 if or lt c 32 eq c 127 111 ret false 112 end 113 if eq c 92 114 ret false 115 end 116 if fpctbad i 117 ret false 118 end 119 if and gt i 0 eq c 47 120 if eq s i 121 ret false 122 end 123 if fsegdot s i 124 ret false 125 end 126 s = add i 1 127 end 128 end 129 if fsegdot s n 130 ret false 131 end 132 ret true 133 end 134 note ---- path segments: fseg0 / fseg1 fill fown and frepo; frest gets the remainder 135 fn fsegend a ulong to ulong 136 n = get fpathl 0 137 j = a 138 while lt j n bound 4096 139 if eq fpathat j 47 140 ret j 141 end 142 j = add j 1 143 end 144 ret n 145 end 146 note fsplit: 0 = "/", 1 = "/", 2 = "//[...]"; returns 9 when a segment is too long 147 fn fsplit to ulong 148 put fownl 0 0 149 put frepol 0 0 150 put frestl 0 0 151 n = get fpathl 0 152 if le n 1 153 ret 0 154 end 155 e1 = fsegend 1 156 if gt sub e1 1 63 157 ret 9 158 end 159 for i ulong sub e1 1 bound 64 160 put fown i fpathat add 1 i 161 end 162 put fownl 0 sub e1 1 163 if ge add e1 1 n 164 ret 1 165 end 166 e2 = fsegend add e1 1 167 if gt sub sub e2 e1 1 127 168 ret 9 169 end 170 for i ulong sub sub e2 e1 1 bound 128 171 put frepo i fpathat add add e1 1 i 172 end 173 put frepol 0 sub sub e2 e1 1 174 if gt sub n e2 4095 175 ret 9 176 end 177 for i ulong sub n e2 bound 4096 178 put frest i fpathat add e2 i 179 end 180 put frestl 0 sub n e2 181 ret 2 182 end 183 fn fowneq t view uchar * to bool 184 if ne len t get fownl 0 185 ret false 186 end 187 for i ulong len t bound 64 188 if ne get t i get fown i 189 ret false 190 end 191 end 192 ret true 193 end 194 fn frepoeq t view uchar * to bool 195 if ne len t get frepol 0 196 ret false 197 end 198 for i ulong len t bound 128 199 if ne get t i get frepo i 200 ret false 201 end 202 end 203 ret true 204 end 205 note fseg1: frest's first segment is exactly t (t starts with /) 206 fn fseg1 t view uchar * to bool 207 if not frstpre t 208 ret false 209 end 210 n = len t 211 if eq n get frestl 0 212 ret true 213 end 214 ret eq get frest n 47 215 end 216 note fgologin: 303 to login (a write without a session; the social slice claims it when signed in) 217 fn fgologin to long 218 flocb 219 floct tfrsv9 220 put fkind 0 2 221 ret 303 222 end 223 text tfwfol "follow" 224 text tfwufol "unfollow" 225 text tfwstar "/star" 226 text tfwfav "/fav" 227 text tfwust "/unstar" 228 text tfwufav "/unfav" 229 note fwrsess: an unclaimed social write path: POST goes to sign-in, other methods are 405 230 fn fwrsess to long 231 if eq get fmeth 0 3 232 ret fgologin 233 end 234 ret 405 235 end 236 fn fiswr2 to bool 237 if or fseg1 tfwstar fseg1 tfwfav 238 ret true 239 end 240 ret or fseg1 tfwust fseg1 tfwufav 241 end 242 note fcomone: reserved one-segment forge pages that are not served yet answer 501 243 fn fcomone to bool 244 if or or fowneq tfrsv9 fowneq tfrsv10 fowneq tfrsv12 245 ret true 246 end 247 ret or or fowneq tfrsv13 fowneq tfrsv15 or fowneq tfrsv16 fowneq tfrsv8 248 end 249 fn fisown to bool 250 ret fowneq tfowner 251 end 252 fn frsv1 to bool 253 if or or fowneq tfrsv1 fowneq tfrsv2 fowneq tfrsv3 254 ret true 255 end 256 if or or fowneq tfrsv4 fowneq tfrsv5 fowneq tfrsv6 257 ret true 258 end 259 if or or fowneq tfrsv7 fowneq tfrsv8 fowneq tfrsv9 260 ret true 261 end 262 ret or fowneq tfrsv10 fowneq tfrsv11 263 end 264 fn frsv2 to bool 265 if or or fowneq tfrsv12 fowneq tfrsv13 fowneq tfrsv14 266 ret true 267 end 268 if or or fowneq tfrsv15 fowneq tfrsv16 fowneq tfrsv17 269 ret true 270 end 271 ret or or fowneq tfrsv18 fowneq tfrsv19 fowneq tfrsv20 272 end 273 fn freserved to bool 274 if frsv1 275 ret true 276 end 277 ret frsv2 278 end 279 note fsetrepo: owner must be the delegate and repo in the allow-list; fills fridx / frid 280 fn fsetrepo to bool 281 put fridx 0 9999 282 put fridl 0 0 283 if not fisown 284 ret false 285 end 286 i = frepoix 287 if ge i get fan 0 288 ret false 289 end 290 put fridx 0 i 291 l = get fail i 292 for k ulong l bound 64 293 put frid k fridbyte i k 294 end 295 put fridl 0 l 296 ret true 297 end 298 note ---- /rad:[/rest] -> 302 to //[/rest] when public, else 404. Only a project 299 note that has an old Radicle id (fhasal) answers to one: in the store-reading build the key of a 300 note project without one is its git id, which is never a /rad: link. 301 fn fridat i ulong to bool 302 l = get fail i 303 if ne get fownl 0 add l 4 304 ret false 305 end 306 for k ulong l bound 64 307 if ne fridbyte i k get fown add k 4 308 ret false 309 end 310 end 311 ret true 312 end 313 fn fradredir to long 314 if not fpre tfprad 315 ret 0 316 end 317 for i ulong get fan 0 bound FAMAX 318 if and fhasal i fridat i 319 fradloc i 320 ret 302 321 end 322 end 323 ret 404 324 end 325 fn fradloc i ulong to void 326 flocb 327 floct tfowner 328 flocc 47 329 for k ulong get fanl i bound 128 330 flocc frnbyte i k 331 end 332 a = add 1 get fownl 0 333 n = sub get fpathl 0 a 334 for k ulong n bound 4096 335 flocc fpathat add a k 336 end 337 fqsloc 338 put fkind 0 2 339 end 340 fn fqsloc to void 341 if eq get fqsl 0 0 342 ret 343 end 344 flocc 63 345 for k ulong get fqsl 0 bound 4096 346 flocc get fqs k 347 end 348 end 349 note fslashrd: /// (lone trailing slash) -> 301 to //, query kept 350 fn fslashrd to long 351 flocb 352 floct tfowner 353 flocc 47 354 i = get fridx 0 355 for k ulong get fanl i bound 128 356 flocc frnbyte i k 357 end 358 fqsloc 359 put fkind 0 2 360 ret 301 361 end 362 note ---- the dispatcher. Returns the HTTP status; fob / fkind are filled. 363 fn fslices to long 364 r = qnroute 365 if ne r 0 366 ret r 367 end 368 r = grroute 369 if ne r 0 370 ret r 371 end 372 r = soroute 373 if ne r 0 374 ret r 375 end 376 r = dlroute 377 if ne r 0 378 ret r 379 end 380 note the git patch store (patch/, docs/API.md) holds /patches, /pulls and /pull; collab keeps /issues 381 r = paroute 382 if ne r 0 383 ret r 384 end 385 r = coroute 386 if ne r 0 387 ret r 388 end 389 ret brroute 390 end 391 fn fget to bool 392 ret eq get fmeth 0 1 393 end 394 note forigeq: the Origin header equals t exactly 395 fn forigeq t view uchar * to bool 396 if ne get forigl 0 len t 397 ret false 398 end 399 for i ulong len t bound 256 400 if ne get forig i get t i 401 ret false 402 end 403 end 404 ret true 405 end 406 note forigok: a POST carries no Origin (the CSRF token still decides) or one of the two public origins 407 fn forigok to bool 408 if eq get forigl 0 0 409 ret true 410 end 411 if forigeq tforg1 412 ret true 413 end 414 ret forigeq tforg2 415 end 416 fn froute to long 417 if not fpathok 418 ret 400 419 end 420 if and eq get fmeth 0 3 not forigok 421 ret 403 422 end 423 r = slroute 424 if ne r 0 425 ret r 426 end 427 r = cm_route 428 if ne r 0 429 ret r 430 end 431 r = ohroute 432 if ne r 0 433 ret r 434 end 435 note the research pages and questions (research/route.om); before the split, which reads 436 note /research/ as an owner and a repository 437 r = rxroute 438 if ne r 0 439 ret r 440 end 441 sg = fsplit 442 if eq sg 9 443 ret 404 444 end 445 put fridx 0 9999 446 note /galaxy/ (with the slash) is the same page as /galaxy; asked for before the segment count 447 note decides, because the split reads it as an owner with an empty repository 448 if fpeq tfpgxs 449 if fgxhas 450 ret fgxsend tfgxi tfgxhtm 451 end 452 end 453 if eq sg 0 454 ret fpgroot 455 end 456 if eq sg 1 457 ret fpgone 458 end 459 r = fradredir 460 if ne r 0 461 ret r 462 end 463 if freserved 464 ret fslices0 465 end 466 if not fsetrepo 467 r = fjsfx 468 if ne r 0 469 ret r 470 end 471 note a patch upload to a repository outside the public list is refused by the write gate first 472 note (session, CSRF), then answered 404 in the plain text the uploader reads (patch/p3gate.om) 473 r = paunl 474 if ne r 0 475 ret r 476 end 477 ret fnorepo 478 end 479 if eq get frestl 0 1 480 ret fslashrd 481 end 482 if and fget eq get frestl 0 0 483 fzprep 484 if fjwant 485 fjrepo 486 ret 200 487 end 488 end 489 r = fslices 490 if ne r 0 491 ret r 492 end 493 if and fget eq get frestl 0 0 494 frepohome 495 ret 200 496 end 497 if fiswr2 498 ret fwrsess 499 end 500 if fcoming 501 ret 501 502 end 503 ret 404 504 end 505 note fnorepo: // where x is not a public repo: the social slice may claim it (follow); else 404 506 fn fnorepo to long 507 put fridx 0 9999 508 r = soroute 509 if ne r 0 510 ret r 511 end 512 if not fisown 513 ret 404 514 end 515 if ne get frestl 0 0 516 ret 404 517 end 518 if or frepoeq tfwfol frepoeq tfwufol 519 ret fwrsess 520 end 521 ret 404 522 end 523 text tfcm1 "/tree" 524 text tfcm2 "/blob" 525 text tfcm3 "/raw" 526 text tfcm4 "/blame" 527 text tfcm5 "/commits" 528 text tfcm6 "/commit" 529 text tfcm7 "/compare" 530 text tfcm8 "/branches" 531 text tfcm9 "/tags" 532 text tfcm10 "/releases" 533 text tfcm11 "/archive" 534 text tfcm12 "/patches" 535 text tfcm13 "/issues" 536 text tfcm14 "/stargazers" 537 text tfcm15 "/search" 538 text tfcm16 "/labels" 539 text tfcm17 "/star" 540 text tfcm18 "/fav" 541 note fcoming: a known repo feature path that no composed slice served yet: 501 "coming", not 404 542 fn fcoming to bool 543 if fcoma 544 ret true 545 end 546 ret fcomb 547 end 548 fn fcoma to bool 549 if or or fseg1 tfcm1 fseg1 tfcm2 or fseg1 tfcm3 fseg1 tfcm4 550 ret true 551 end 552 if or or fseg1 tfcm5 fseg1 tfcm6 or fseg1 tfcm7 fseg1 tfcm8 553 ret true 554 end 555 ret fseg1 tfcm9 556 end 557 fn fcomb to bool 558 if or or fseg1 tfcm10 fseg1 tfcm11 or fseg1 tfcm12 fseg1 tfcm13 559 ret true 560 end 561 if or or fseg1 tfcm14 fseg1 tfcm15 or fseg1 tfcm16 fseg1 tfcm17 562 ret true 563 end 564 ret fseg1 tfcm18 565 end 566 note fslices0: reserved two-segment paths (e.g. /assets/forge.css, /login/x): the slices may claim them 567 fn fslices0 to long 568 if fpeq tfpcss 569 if not fget 570 ret 405 571 end 572 fcssout 573 ret 200 574 end 575 if fpeq tfpico 576 if not fget 577 ret 405 578 end 579 ficoout 580 ret 200 581 end 582 if eq get fbasel 0 1 583 if fpeq tfpgxc 584 ret fgxsend tfgxc tfctcss 585 end 586 if fpeq tfpgxt 587 ret fgxsend tfgxt tfctcss 588 end 589 end 590 r = fslices 591 if ne r 0 592 ret r 593 end 594 ret 404 595 end 596 fn fpgroot to long 597 if not fget 598 ret 405 599 end 600 r = grorder 601 if ne r 0 602 ret r 603 end 604 if fjwant 605 fjexplore 606 ret 200 607 end 608 note the root stays the explore page; the galaxy is its own page at /galaxy (fpgone), the map 609 fexplore true 610 ret 200 611 end 612 text tfpexj "/explore.json" 613 text tfjsfx ".json" 614 note fjsfx: //.json (no more path) for a public repo: its forge/repo/1 JSON; 0 = not this 615 fn fjsfx to long 616 if ne get frestl 0 0 617 ret 0 618 end 619 n = get frepol 0 620 if le n len tfjsfx 621 ret 0 622 end 623 b = sub n len tfjsfx 624 for k ulong len tfjsfx 625 if ne get frepo add b k get tfjsfx k 626 ret 0 627 end 628 end 629 put frepol 0 b 630 if not fsetrepo 631 put frepol 0 n 632 put fridx 0 9999 633 ret 0 634 end 635 if not fget 636 ret 405 637 end 638 fzprep 639 fjrepo 640 ret 200 641 end 642 note fpgone: one segment: forge pages, the social slice, then the owner profile 643 fn fpgone to long 644 r = grorder 645 if ne r 0 646 ret r 647 end 648 note agents.json (server/agents.om) and the event stream and feed (door/, or the seam server/nodoor.om) 649 r = fqaroute 650 if ne r 0 651 ret r 652 end 653 r = evroute 654 if ne r 0 655 ret r 656 end 657 if fpeq tfpexj 658 if not fget 659 ret 405 660 end 661 fjexplore 662 ret 200 663 end 664 if fpeq tfpgx 665 if fgxhas 666 ret fgxsend tfgxi tfgxhtm 667 end 668 end 669 r = fslices 670 if ne r 0 671 ret r 672 end 673 if fpeq tfpexp 674 if not fget 675 ret 405 676 end 677 if fjwant 678 fjexplore 679 ret 200 680 end 681 fexplore false 682 ret 200 683 end 684 if fpeq tfpsrch 685 if not fget 686 ret 405 687 end 688 fqcap 689 if fjwant 690 fyjsrch 691 ret 200 692 end 693 fyalt 694 fsearch 695 ret 200 696 end 697 if fpre tfprad 698 ret fradredir 699 end 700 if or fpeq tfst fpeq tfstj 701 if not fget 702 ret 405 703 end 704 ret nsstat 705 end 706 if freserved 707 if fcomone 708 ret 501 709 end 710 ret 404 711 end 712 if not fisown 713 ret 404 714 end 715 if not fget 716 ret 405 717 end 718 if fjwant 719 fyjprof 720 ret 200 721 end 722 fyalt 723 fprofile 724 ret 200 725 end