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/research/route.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 / research / route.om` 508 lines ยท 10790 bytes Raw Blame History 1 note research/route.om: the research pages inside forged. Prefix rx* (functions), gx* (globals), tx* (texts). 2 note forged builds nothing here. research-build (research/build.om, its own program, run by 3 note research/publish.sh) writes the pages into research/; forged streams those files: 4 note /research, /research/ research/index.html 5 note /research.json .bib .txt research/index.json, works.bib, agents.txt 6 note /assets/research.css research/research.css 7 note /research/[.json|.bib] research/w/.html, .json, .bib 8 note Questions: GET /research/ask?q=... writes the question to research/ask/.q, appends one 9 note line " " to research/ask/queue and answers 303 to /research/ask/. 10 note forged has no network and never calls a model. The research agent (research/agent.om, its own 11 note service outside the sandbox) reads the queue and writes research/ask/.html and .json. 12 note /research/ask/[.json] streams the answer when it exists, else a page that reloads itself. 13 note is the first 32 hex characters of SHA-256 over the lowercased, space-collapsed question, so 14 note the same question is asked once. Served on the interplane.io base "/" only, as the galaxy is. 15 text txp "/research" 16 text txps "/research/" 17 text txpj "/research.json" 18 text txpb "/research.bib" 19 text txpt "/research.txt" 20 text txpc "/assets/research.css" 21 text txpa "/research/ask" 22 text txpas "/research/ask/" 23 text txdir "research/" 24 text txask "research/ask/" 25 text txw "research/w/" 26 text txfi "index.html" 27 text txfj "index.json" 28 text txfb "works.bib" 29 text txft "agents.txt" 30 text txfc "research.css" 31 text txfq "queue" 32 text txeh ".html" 33 text txej ".json" 34 text txeb ".bib" 35 text txeq ".q" 36 text txno "" 37 text txcth "text/html; charset=utf-8" 38 text txctj "application/json; charset=utf-8" 39 text txctt "text/plain; charset=utf-8" 40 text txctc "text/css; charset=utf-8" 41 text txcc "public, max-age=60" 42 text txq "q" 43 text txhex "`0123456789abcdef`" 44 text txloc "research/ask/" 45 text txhome "research" 46 text txw1 "Reading the papers\n
INTERPLANE
\n

Question

" 47 text txw2 "

The agent on the Spark is reading the papers. Its model answers one question at a time, so this can take a minute. This page reloads by itself. You can also keep the link and come back.

Back to the research

\n" 48 text txj1 "{\"schema\":\"interplane/research-answer/1\",\"status\":\"pending\",\"id\":\"" 49 text txj2 "\"}\n" 50 global gxq uchar 304 51 global gxql ulong 1 52 global gxid uchar 32 53 text txcur "current" 54 text txgen "gen/public." 55 note rxfile: pin current once; fsend3 may open later, so ffile must not contain current. 56 note Every published generation is retained; mutable ask/add paths do not use this function. 57 fn rxroot to void 58 v = new uchar 4096 0 59 put ffilel 0 0 60 for i ulong len tfdata bound 128 61 ffilc get tfdata i 62 end 63 for i ulong len txdir bound 64 64 ffilc get txdir i 65 end 66 base = get ffilel 0 67 for i ulong len txcur bound 16 68 ffilc get txcur i 69 end 70 k = readlnk ffile 0 get ffilel 0 v 0 4096 71 put ffilel 0 0 72 if or le k long len txgen ge k 4096 73 ret 74 end 75 for i ulong len txgen bound 16 76 if ne get v i get txgen i 77 ret 78 end 79 end 80 for i ulong sub ulong k len txgen bound 4096 81 c = get v add i len txgen 82 ok = or and ge c 48 le c 57 and ge c 65 le c 90 83 ok = or ok and ge c 97 le c 122 84 if not ok 85 ret 86 end 87 end 88 put ffilel 0 base 89 for i ulong ulong k bound 4096 90 ffilc get v i 91 end 92 ffilc 47 93 end 94 fn rxfile dir view uchar * a ulong n ulong ext view uchar * to void 95 rxroot 96 if eq get ffilel 0 0 97 ret 98 end 99 for i ulong sub len dir len txdir bound 64 100 ffilc get dir add len txdir i 101 end 102 for i ulong n bound 64 103 ffilc fpathat add a i 104 end 105 for i ulong len ext bound 16 106 ffilc get ext i 107 end 108 end 109 note rxidfile: ffile = research/ask/ 110 fn rxidfile ext view uchar * to void 111 put ffilel 0 0 112 for i ulong len tfdata bound 128 113 ffilc get tfdata i 114 end 115 for i ulong len txask bound 64 116 ffilc get txask i 117 end 118 for i ulong 32 119 ffilc get gxid i 120 end 121 for i ulong len ext bound 16 122 ffilc get ext i 123 end 124 end 125 fn rxhas to bool 126 if eq get ffilel 0 0 127 ret false 128 end 129 ret eq faccess ffile 0 get ffilel 0 4 0 130 end 131 note rxsend: stream ffile (kind 3). GET only; a file that is not there is 404. 132 fn rxsend ct view uchar * to long 133 if not fget 134 ret 405 135 end 136 if not rxhas 137 ret 404 138 end 139 put fobl 0 0 140 put fkind 0 3 141 fsetct ct 142 fsetcc txcc 143 ret 200 144 end 145 note rxends: fpath ends with t 146 fn rxends t view uchar * to bool 147 n = get fpathl 0 148 if lt n len t 149 ret false 150 end 151 b = sub n len t 152 for i ulong len t bound 16 153 if ne fpathat add b i get t i 154 ret false 155 end 156 end 157 ret true 158 end 159 note rxslug: fpath[a, a+n) is 1 to 64 bytes of a-z, 0-9 and - 160 fn rxslug a ulong n ulong to bool 161 if or eq n 0 gt n 64 162 ret false 163 end 164 for i ulong n bound 64 165 c = fpathat add a i 166 ok = false 167 if and ge c 97 le c 122 168 ok = true 169 end 170 if and ge c 48 le c 57 171 ok = true 172 end 173 if eq c 45 174 ok = true 175 end 176 if not ok 177 ret false 178 end 179 end 180 ret true 181 end 182 note rxhexs: fpath[a, a+32) is 32 lowercase hex characters; they are copied into gxid 183 fn rxhexs a ulong n ulong to bool 184 if ne n 32 185 ret false 186 end 187 for i ulong 32 188 c = fpathat add a i 189 ok = false 190 if and ge c 48 le c 57 191 ok = true 192 end 193 if and ge c 97 le c 102 194 ok = true 195 end 196 if not ok 197 ret false 198 end 199 put gxid i c 200 end 201 ret true 202 end 203 note rxwork: /research/[.json|.bib] 204 fn rxwork to long 205 a = len txps 206 n = sub get fpathl 0 a 207 if rxends txej 208 n = sub n len txej 209 if not rxslug a n 210 ret 404 211 end 212 rxfile txw a n txej 213 ret rxsend txctj 214 end 215 if rxends txeb 216 n = sub n len txeb 217 if not rxslug a n 218 ret 404 219 end 220 rxfile txw a n txeb 221 ret rxsend txctt 222 end 223 if not rxslug a n 224 ret 404 225 end 226 rxfile txw a n txeh 227 ret rxsend txcth 228 end 229 note rxnorm: the decoded question fval[0, n) into gxq: control bytes become a space, runs of spaces 230 note become one, no space at either end. False when nothing is left or it is over 300 bytes. 231 fn rxnorm n ulong to bool 232 o = ulong 0 233 sp = true 234 for i ulong n bound 4096 235 c = get fval i 236 if or lt c 32 eq c 127 237 c = uchar 32 238 end 239 if eq c 32 240 if not sp 241 if ge o 300 242 ret false 243 end 244 put gxq o c 245 o = add o 1 246 end 247 sp = true 248 else 249 if ge o 300 250 ret false 251 end 252 put gxq o c 253 o = add o 1 254 sp = false 255 end 256 end 257 if gt o 0 258 if eq get gxq sub o 1 32 259 o = sub o 1 260 end 261 end 262 put gxql 0 o 263 ret gt o 0 264 end 265 note rxmkid: gxid from gxq (ASCII letters lowercased before hashing) 266 fn rxmkid to void 267 b = new uchar 304 0 268 d = new uchar 32 0 269 n = get gxql 0 270 for i ulong n bound 304 271 c = get gxq i 272 if and ge c 65 le c 90 273 c = uchar add c 32 274 end 275 put b i c 276 end 277 r = sha2_digest 256 view part b 0 n d 278 for i ulong 16 279 v = get d i 280 put gxid mul i 2 get txhex ulong shr v 4 281 put gxid add mul i 2 1 get txhex ulong and v 15 282 end 283 end 284 note rxgo: 303 to research/ask/ 285 fn rxgo to long 286 flocb 287 floct txloc 288 for i ulong 32 289 flocc get gxid i 290 end 291 put fkind 0 2 292 ret 303 293 end 294 note rxqueue: write the question file and append the queue line. 0 done, else the status to answer. 295 fn rxqueue to long 296 b = new uchar 352 0 297 st = new uchar 128 0 298 n = get gxql 0 299 put ffilel 0 0 300 for i ulong len tfdata bound 128 301 ffilc get tfdata i 302 end 303 for i ulong len txdir bound 64 304 ffilc get txdir i 305 end 306 r = makedir ffile 0 get ffilel 0 448 307 for i ulong sub len txask len txdir bound 64 308 ffilc get txask add len txdir i 309 end 310 r = makedir ffile 0 get ffilel 0 448 311 for i ulong len txfq bound 16 312 ffilc get txfq i 313 end 314 fd = fopen ffile 0 get ffilel 0 558145 384 315 if lt fd 0 316 ret 503 317 end 318 r = fstat int fd st 0 128 319 sz = or or ulong get st 48 shl ulong get st 49 8 or shl ulong get st 50 16 shl ulong get st 51 24 320 if or ne r 0 gt sz `4194304` 321 x = fclose int fd 322 put fretry 0 60 323 ret 503 324 end 325 for i ulong 32 326 put b i get gxid i 327 end 328 put b 32 9 329 for i ulong n bound 304 330 put b add 33 i get gxq i 331 end 332 put b add 33 n 10 333 w = write int fd b 0 add 34 n 334 x = fclose int fd 335 if ne w long add 34 n 336 ret 503 337 end 338 rxidfile txeq 339 fd = fopen ffile 0 get ffilel 0 557249 384 340 if ge fd 0 341 w = write int fd b 33 n 342 x = fclose int fd 343 end 344 ret 0 345 end 346 note rxask: /research/ask?q=... 347 fn rxask to long 348 if not fget 349 ret 405 350 end 351 n = fqget txq 352 if le n 0 353 flocb 354 floct txhome 355 put fkind 0 2 356 ret 303 357 end 358 if not rxnorm ulong n 359 ret 400 360 end 361 rxmkid 362 rxidfile txeh 363 if rxhas 364 ret rxgo 365 end 366 rxidfile txeq 367 if rxhas 368 ret rxgo 369 end 370 if not fratelim 371 ret 429 372 end 373 r = rxqueue 374 if ne r 0 375 ret r 376 end 377 ret rxgo 378 end 379 note rxpend: the answer is not written yet. The question file must exist (else 404). 380 fn rxpend json bool to long 381 b = new uchar 304 0 382 if not fget 383 ret 405 384 end 385 rxidfile txeq 386 fd = fopen ffile 0 get ffilel 0 557056 0 387 if lt fd 0 388 ret 404 389 end 390 n = read int fd b 0 300 391 x = fclose int fd 392 put fobl 0 0 393 put fkind 0 1 394 if json 395 fput txj1 396 for i ulong 32 397 fputc get gxid i 398 end 399 fput txj2 400 fsetct txctj 401 ret 200 402 end 403 fput txw1 404 if gt n 0 405 for i ulong ulong n bound 300 406 fescc get b i 407 end 408 end 409 fput txw2 410 fsetct txcth 411 ret 200 412 end 413 note rxans: /research/ask/[.json] 414 fn rxans to long 415 a = len txpas 416 n = sub get fpathl 0 a 417 json = rxends txej 418 if json 419 n = sub n len txej 420 end 421 if not rxhexs a n 422 ret 404 423 end 424 if json 425 rxidfile txej 426 else 427 rxidfile txeh 428 end 429 if rxhas 430 if json 431 ret rxsend txctj 432 end 433 ret rxsend txcth 434 end 435 ret rxpend json 436 end 437 note rxone: ffile = research/, then stream it 438 fn rxone name view uchar * ct view uchar * to long 439 rxfile txdir 0 0 name 440 ret rxsend ct 441 end 442 text txnav "Research" 443 note rxnav: the forge row entry (server/pages.om fhead); the research pages exist on base "/" only 444 fn rxnav to void 445 if eq get fbasel 0 1 446 fput txnav 447 end 448 end 449 text txauth "/research/authors/" 450 text txadir "research/a/" 451 text txadd "/research/add" 452 text txdoi "/research/doi" 453 text txaf "add.html" 454 text txdf "doi.html" 455 note rxauthor: one validated author id, no path separators, into research/a/.html 456 fn rxauthor to long 457 a = len txauth 458 n = sub get fpathl 0 a 459 if not rxslug a n 460 ret 404 461 end 462 rxfile txadir a n txeh 463 ret rxsend txcth 464 end 465 note rxroute: 0 = not a research path 466 fn rxroute to long 467 if ne get fbasel 0 1 468 ret 0 469 end 470 r = rxint 471 if ne r 0 472 ret r 473 end 474 if fpre txauth 475 ret rxauthor 476 end 477 if fpeq txadd 478 ret rxone txaf txcth 479 end 480 if fpeq txdoi 481 ret rxone txdf txcth 482 end 483 if fpeq txpc 484 ret rxone txfc txctc 485 end 486 if fpeq txpj 487 ret rxone txfj txctj 488 end 489 if fpeq txpb 490 ret rxone txfb txctt 491 end 492 if fpeq txpt 493 ret rxone txft txctt 494 end 495 if or fpeq txp fpeq txps 496 ret rxone txfi txcth 497 end 498 if not fpre txps 499 ret 0 500 end 501 if fpeq txpa 502 ret rxask 503 end 504 if fpre txpas 505 ret rxans 506 end 507 ret rxwork 508 end