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/server/state.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 / server / state.om`
629 lines ยท 14412 bytes Raw Blame History
1 note forged server/state.om: the plain state line of a project (the repo home header and the explore,
2 note profile and search rows), read from the Interplane receipts list: content/receipts/ledger.tsv on
3 note the default branch (HEAD) of the site's own repository rad:`z399yKvnXcBQNkKoq86iBDgTvQ5QV`, which
4 note is on the allow-list. https://interplane.io/receipts/ publishes that list and its verify.sh walks it.
5 note A project is "Checked: ran again on Checked: ran again on "
55 text tfpjno1 " Unfinished: not checked yet
That is the version shown here. That was an earlier version: later changes are not checked yet. Read the receipt
\n" 61 text tfpjn1 "There is no published receipt of a rebuild from its source yet. What a receipt is
\n" 63 text tfpjm1 "Receipt " 64 text tfpjm2 " of that list says: “" 65 text tfpjm3 "” (its evidence file)." 67 text tfpjm7 "This project has no receipt in that list yet." 68 note ---- reading and verifying the list 69 note fpjsite: the allow-list index of the site repository, or fan when it is not listed 70 fn fpjsite to ulong 71 for i ulong get fan 0 bound FAMAX 72 if eq get fail i len tfpjsite 73 m = true 74 for k ulong len tfpjsite 75 if ne fridbyte i k get tfpjsite k 76 m = false 77 break 78 end 79 end 80 if m 81 ret i 82 end 83 end 84 end 85 ret get fan 0 86 end 87 fn fpjhex c uchar to bool 88 if and ge c 48 le c 57 89 ret true 90 end 91 ret and ge c 97 le c 102 92 end 93 fn fpjhx v ulong to uchar 94 if lt v 10 95 ret uchar add v 48 96 end 97 ret uchar add v 87 98 end 99 note fpjfs: start of field k (0-based) of record r; fpjfe: its end (the tab or the line feed) 100 fn fpjfs r ulong k ulong to ulong 101 p = get fpjrs r 102 e = get fpjre r 103 if eq k 0 104 ret p 105 end 106 c = ulong 0 107 while lt p e bound FPJLEN 108 if eq get fpjl p 9 109 c = add c 1 110 if eq c k 111 ret add p 1 112 end 113 end 114 p = add p 1 115 end 116 ret e 117 end 118 fn fpjfe r ulong k ulong to ulong 119 p = fpjfs r k 120 e = get fpjre r 121 while lt p e bound FPJLEN 122 if eq get fpjl p 9 123 ret p 124 end 125 p = add p 1 126 end 127 ret e 128 end 129 note fpjfeq: field k of record r is the text t 130 fn fpjfeq r ulong k ulong t view uchar * to bool 131 a = fpjfs r k 132 if ne sub fpjfe r k a len t 133 ret false 134 end 135 for i ulong len t bound 64 136 if ne get fpjl add a i get t i 137 ret false 138 end 139 end 140 ret true 141 end 142 note fpjsame: field k of records r and q hold the same bytes 143 fn fpjsame r ulong q ulong k ulong to bool 144 a = fpjfs r k 145 n = sub fpjfe r k a 146 b = fpjfs q k 147 if ne n sub fpjfe q k b 148 ret false 149 end 150 for i ulong n bound FPJLEN 151 if ne get fpjl add a i get fpjl add b i 152 ret false 153 end 154 end 155 ret true 156 end 157 note fpjrec: record r (line r+1) is well formed and links to the line before it 158 fn fpjrec r ulong to bool 159 s = get fpjrs r 160 e = get fpjre r 161 t = ulong 0 162 for i ulong sub e s bound FPJLEN 163 if eq get fpjl add s i 9 164 t = add t 1 165 end 166 end 167 if ne t 6 168 ret false 169 end 170 note field 1: the decimal record number r+1 171 a = fpjfs r 0 172 b = fpjfe r 0 173 if or eq a b gt sub b a 7 174 ret false 175 end 176 v = ulong 0 177 for i ulong sub b a bound 8 178 c = get fpjl add a i 179 if or lt c 48 gt c 57 180 ret false 181 end 182 note verify.sh compares the number as text: "01" is not record 1 183 if and eq i 0 eq c 48 184 ret false 185 end 186 v = add mul v 10 ulong sub c 48 187 end 188 if ne v add r 1 189 ret false 190 end 191 note field 2: YYYY-MM-DDTHH:MM:SSZ 192 a = fpjfs r 1 193 if ne sub fpjfe r 1 a 20 194 ret false 195 end 196 for i ulong 20 197 c = get fpjl add a i 198 if or eq i 4 eq i 7 199 if ne c 45 200 ret false 201 end 202 continue 203 end 204 if eq i 10 205 if ne c 84 206 ret false 207 end 208 continue 209 end 210 if or eq i 13 eq i 16 211 if ne c 58 212 ret false 213 end 214 continue 215 end 216 if eq i 19 217 if ne c 90 218 ret false 219 end 220 continue 221 end 222 if or lt c 48 gt c 57 223 ret false 224 end 225 end 226 note field 6: the evidence file name, 64 lowercase hex 227 a = fpjfs r 5 228 if ne sub fpjfe r 5 a 64 229 ret false 230 end 231 for i ulong 64 232 if not fpjhex get fpjl add a i 233 ret false 234 end 235 end 236 note field 7: GENESIS first, else the SHA-256 of the line before 237 a = fpjfs r 6 238 if eq r 0 239 ret fpjfeq r 6 tfpjgen 240 end 241 if ne sub fpjfe r 6 a 64 242 ret false 243 end 244 ps = get fpjrs sub r 1 245 fpjshl ps sub get fpjre sub r 1 ps 246 ret fpjhexeq a 247 end 248 note ---- SHA-256 of a part of a global (a global cannot be an argument: omc error 19), copied 249 note through a local buffer 64 KiB at a time; the digest goes to fpjh 250 global fpjh uchar 32 251 fn fpjshl s ulong n ulong to void 252 c = new ulong 40 0 253 b = new uchar 65536 0 254 o = new uchar 32 0 255 sha256_init c 256 d = ulong 0 257 while lt d n bound FPJLEN 258 k = hmin sub n d 65536 259 for j ulong k bound 65536 260 put b j get fpjl add add s d j 261 end 262 sha256_update c view part b 0 k 263 d = add d k 264 end 265 sha256_final c o 266 for j ulong 32 267 put fpjh j get o j 268 end 269 end 270 fn fpjshx n ulong to void 271 c = new ulong 40 0 272 b = new uchar 65536 0 273 o = new uchar 32 0 274 sha256_init c 275 d = ulong 0 276 while lt d n bound FPJXO 277 k = hmin sub n d 65536 278 for j ulong k bound 65536 279 put b j get fxo add d j 280 end 281 sha256_update c view part b 0 k 282 d = add d k 283 end 284 sha256_final c o 285 for j ulong 32 286 put fpjh j get o j 287 end 288 end 289 note fpjhexeq: fpjl[a, a+64) is fpjh in lowercase hex 290 fn fpjhexeq a ulong to bool 291 for i ulong 32 292 v = ulong get fpjh i 293 if ne get fpjl add a mul i 2 fpjhx shr v 4 294 ret false 295 end 296 if ne get fpjl add a add mul i 2 1 fpjhx and v 15 297 ret false 298 end 299 end 300 ret true 301 end 302 note fpjload: read and verify the list. When it cannot (the site repository is not on the allow-list, 303 note git fails, the list is longer than fxo, the exec buffer every forged read goes through, or it does 304 note not verify), every project shows "Unfinished" and one line goes to the service log, so the cause 305 note is seen; server/tests/readmefirst.sh alarms before the real list nears that size. 306 text tfpjlg1 "forged: state: the receipts list was not read (site repository not listed, git failed, or the list is 16 MiB or longer); every project shows Unfinished\n" 307 text tfpjlg2 "forged: state: the receipts list does not verify (record number, date, fingerprint or chain); every project shows Unfinished\n" 308 fn fpjload to void 309 put fpjb 0 FPJNONE 310 put fpjst 0 0 311 put fpjrn 0 0 312 put fpjn 0 0 313 if fpjread 314 if fpjsplit 315 put fpjst 0 1 316 else 317 flog tfpjlg2 318 end 319 else 320 flog tfpjlg1 321 end 322 end 323 fn fpjread to bool 324 i = fpjsite 325 if ge i get fan 0 326 ret false 327 end 328 fkgiti i 329 fka tfpjcat 330 fka tfpjblob 331 fka tfpjled 332 st = fexec `5000000000` 333 if or ne st 0 ne get fxotr 0 0 334 ret false 335 end 336 n = get fxol 0 337 if or eq n 0 gt n len fpjl 338 ret false 339 end 340 for k ulong n bound FPJLEN 341 put fpjl k get fxo k 342 end 343 put fpjn 0 n 344 ret true 345 end 346 note fpjsplit: the records of fpjl, each checked; false at the first that does not verify. FPJMAX 347 note holds more records than 16 MiB of them can be (a record is at least 157 bytes), so it is never 348 note the limit. 349 fn fpjsplit to bool 350 n = get fpjn 0 351 if ne get fpjl sub n 1 10 352 ret false 353 end 354 s = ulong 0 355 r = ulong 0 356 p = ulong 0 357 while lt p n bound FPJLEN 358 if eq get fpjl p 10 359 if ge r FPJMAX 360 ret false 361 end 362 put fpjrs r s 363 put fpjre r p 364 put fpjev r 0 365 if not fpjrec r 366 ret false 367 end 368 r = add r 1 369 s = add p 1 370 end 371 p = add p 1 372 end 373 put fpjrn 0 r 374 ret true 375 end 376 note fpjev1: the evidence file of record r hashes to its name (cached per request in fpjev) 377 fn fpjev1 r ulong to bool 378 v = get fpjev r 379 if ne v 0 380 ret eq v 1 381 end 382 put fpjev r 2 383 i = fpjsite 384 if ge i get fan 0 385 ret false 386 end 387 a = fpjfs r 5 388 fkgiti i 389 fka tfpjcat 390 fka tfpjblob 391 fka tfpjpay 392 for k ulong 64 393 fkc get fpjl add a k 394 end 395 fkt tfpjtxt 396 st = fexec `5000000000` 397 if or ne st 0 ne get fxotr 0 0 398 ret false 399 end 400 fpjshx get fxol 0 401 if not fpjhexeq a 402 ret false 403 end 404 put fpjev r 1 405 ret true 406 end 407 note ---- one project 408 note fpjnames: the text (field 5) of record q names rad:Unfinished: not checked yet
" 566 text tfpjrx "" 567 fn fpjrow i ulong to void 568 if not fpjfind i 569 fput tfpjno2 570 ret 571 end 572 b = get fpjb 0 573 fput tfpjok1 574 fpjdate b 575 if eq get fpjnew 0 0 576 fput tfpjold 577 end 578 fput tfpjrx 579 end 580 note fpjfull: the state lines of the project page header, with a link to the receipt 581 fn fpjfull i ulong to void 582 if not fpjfind i 583 fput tfpjno1 584 fput tfpjn1 585 fput tfpjrurl 586 fput tfpjn2 587 ret 588 end 589 b = get fpjb 0 590 fput tfpjok1 591 fpjdate b 592 fput tfpjpx 593 if eq get fpjnew 0 1 594 fput tfpjnew1 595 else 596 fput tfpjnew0 597 end 598 fpjpay b 599 fput tfpjm5 600 end 601 fn fpjpay b ulong to void 602 fput tfpjpurl 603 a = fpjfs b 5 604 for k ulong 64 605 fputc get fpjl add a k 606 end 607 end 608 note fpjrcpt: for the "For developers" section: the receipt the state comes from, quoted, after 609 note fpjfull ran for this project (fpjb) 610 fn fpjrcpt to void 611 b = get fpjb 0 612 if ge b get fpjrn 0 613 fput tfpjm7 614 ret 615 end 616 fput tfpjm1 617 a = fpjfs b 0 618 for k ulong sub fpjfe b 0 a bound 8 619 fputc get fpjl add a k 620 end 621 fput tfpjm2 622 a = fpjfs b 4 623 for k ulong sub fpjfe b 4 a bound FPJLEN 624 fescc get fpjl add a k 625 end 626 fput tfpjm3 627 fpjpay b 628 fput tfpjm6 629 end