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
omega-mv / apps / interplane-forge / server / radsrc.om
| 1 | note forged server/radsrc.om: the Radicle source of the default build (the live binary), composed after |
| 2 | note server/repos.om (the shared allow-list helpers and per-repo metadata). It defines what a |
| 3 | note repository source gives the rest of forged: fload (the public allow-list), fsrcchg (the source |
| 4 | note changed: reload), fputid (a repository's identifier in machine forms), fhasal (it has an old |
| 5 | note Radicle id), fradsrc (Radicle node data may be read) with fradwalk / fradseeds (the routing |
| 6 | note table), fpjterms (the identity words of the "For developers" section), fjclone (the JSON clone |
| 7 | note object) and tfsf4 (the footer line). Git paths are server/util.om fkgit / fkgiti (tfstore + RID). |
| 8 | note The store-reading build composes store/repos.om in place of this unit (run.sh units, FORGE_STORE). |
| 9 | note Allow-list: the FIRST table of ~/handoffs/radicle/RIDS.md (header "| repo | RID | default |
| 10 | note branch"). A row is kept only when the name, RID and branch are well formed and |
| 11 | note ~/.radicle/storage/<rid> exists. Fail closed: when the file cannot be read or has no table, fan |
| 12 | note is 0 and every repo URL is 404. |
| 13 | text tfrids "/home/drakestapleton/handoffs/radicle/RIDS.md" |
| 14 | text tfthd "| repo | RID | default branch" |
| 15 | fn flmat s ulong ln ulong to bool |
| 16 | if gt add s len tfthd ln |
| 17 | ret false |
| 18 | end |
| 19 | for k ulong len tfthd bound 64 |
| 20 | if ne get fxo add s k get tfthd k |
| 21 | ret false |
| 22 | end |
| 23 | end |
| 24 | ret true |
| 25 | end |
| 26 | fn flfind ln ulong to ulong |
| 27 | p = ulong 0 |
| 28 | for it ulong 100000 |
| 29 | if ge p ln |
| 30 | ret ln |
| 31 | end |
| 32 | if flmat p ln |
| 33 | ret p |
| 34 | end |
| 35 | p = flnext p ln |
| 36 | end |
| 37 | ret ln |
| 38 | end |
| 39 | fn flbar p ulong e ulong to ulong |
| 40 | j = p |
| 41 | while lt j e bound 16777216 |
| 42 | if eq get fxo j 124 |
| 43 | ret j |
| 44 | end |
| 45 | j = add j 1 |
| 46 | end |
| 47 | ret e |
| 48 | end |
| 49 | fn fidput k ulong a ulong b ulong to bool |
| 50 | s = ftrs a b |
| 51 | t = ftre s b |
| 52 | if lt sub t s 6 |
| 53 | ret false |
| 54 | end |
| 55 | if or ne get fxo s 114 ne get fxo add s 1 97 |
| 56 | ret false |
| 57 | end |
| 58 | if or ne get fxo add s 2 100 ne get fxo add s 3 58 |
| 59 | ret false |
| 60 | end |
| 61 | s = add s 4 |
| 62 | n = sub t s |
| 63 | if gt n 60 |
| 64 | ret false |
| 65 | end |
| 66 | cur = fidcur k |
| 67 | if gt add cur n len faid |
| 68 | ret false |
| 69 | end |
| 70 | put faio k cur |
| 71 | put fail k n |
| 72 | for i ulong n bound 64 |
| 73 | c = get fxo add s i |
| 74 | if not fisaln c |
| 75 | ret false |
| 76 | end |
| 77 | put faid add cur i c |
| 78 | end |
| 79 | ret true |
| 80 | end |
| 81 | note fstok: ~/.radicle/storage/<rid of k> exists |
| 82 | fn fstok k ulong to bool |
| 83 | fpb |
| 84 | fpt tfstore |
| 85 | for i ulong get fail k bound 64 |
| 86 | fpc fridbyte k i |
| 87 | end |
| 88 | r = stat fpth 0 get fpthl 0 fstb 0 128 |
| 89 | ret ge r 0 |
| 90 | end |
| 91 | fn frow p ulong e ulong to void |
| 92 | b1 = flbar add p 1 e |
| 93 | b2 = flbar add b1 1 e |
| 94 | b3 = flbar add b2 1 e |
| 95 | if ge b3 e |
| 96 | ret |
| 97 | end |
| 98 | k = get fan 0 |
| 99 | if ge k FAMAX |
| 100 | ret |
| 101 | end |
| 102 | if not fnmput k add p 1 b1 |
| 103 | ret |
| 104 | end |
| 105 | if not fidput k add b1 1 b2 |
| 106 | ret |
| 107 | end |
| 108 | if not fbrput k add b2 1 b3 |
| 109 | ret |
| 110 | end |
| 111 | put fan 0 add k 1 |
| 112 | end |
| 113 | fn fload to long |
| 114 | put fan 0 0 |
| 115 | fpb |
| 116 | fpt tfrids |
| 117 | put famt 0 fmtime |
| 118 | n = frdall |
| 119 | if le n 0 |
| 120 | ret -1 |
| 121 | end |
| 122 | ln = ulong n |
| 123 | p = flfind ln |
| 124 | if ge p ln |
| 125 | ret -2 |
| 126 | end |
| 127 | p = flnext p ln |
| 128 | p = flnext p ln |
| 129 | for it ulong FAMAX |
| 130 | if ge p ln |
| 131 | break |
| 132 | end |
| 133 | if ne get fxo p 124 |
| 134 | break |
| 135 | end |
| 136 | e = fleol p ln |
| 137 | frow p e |
| 138 | p = flnext p ln |
| 139 | end |
| 140 | fdrop |
| 141 | for i ulong get fan 0 bound FAMAX |
| 142 | fmeta i |
| 143 | end |
| 144 | ret long get fan 0 |
| 145 | end |
| 146 | note fdrop: remove denied rows and rows whose storage dir is missing (keeps order; areas stay valid) |
| 147 | fn fdrop to void |
| 148 | w = ulong 0 |
| 149 | for i ulong get fan 0 bound FAMAX |
| 150 | if and not fdeny i fstok i |
| 151 | fmove w i |
| 152 | w = add w 1 |
| 153 | end |
| 154 | end |
| 155 | put fan 0 w |
| 156 | end |
| 157 | note fsrcchg: true when RIDS.md changed since fload read it (main.om fchkrl reloads then) |
| 158 | fn fsrcchg to bool |
| 159 | fpb |
| 160 | fpt tfrids |
| 161 | m = fmtime |
| 162 | ret ne m get famt 0 |
| 163 | end |
| 164 | note fputid: the identifier of allow-list repo i in the machine forms ("rid" fields): the bare RID |
| 165 | note (z then base58; the rad: prefix is no longer shown since Radicle was removed on 2026-11-14) |
| 166 | fn fputid i ulong to void |
| 167 | fputrid i |
| 168 | end |
| 169 | note fhasal: every repository of this source has a Radicle id |
| 170 | fn fhasal i ulong to bool |
| 171 | ret true |
| 172 | end |
| 173 | note fradsrc: Radicle node data (the routing table, server/counts.om fzseeds) belongs to this source |
| 174 | fn fradsrc to bool |
| 175 | ret true |
| 176 | end |
| 177 | note ---- seeds: rad node routing --rid rad:<RID> --json, read again when the node database changed |
| 178 | text tfzenv "/usr/bin/env" |
| 179 | text tfzhenv "HOME=/home/drakestapleton" |
| 180 | text tfzrad "/home/drakestapleton/.radicle/bin/rad" |
| 181 | text tfznode "node" |
| 182 | text tfzrout "routing" |
| 183 | text tfzrid "--rid" |
| 184 | text tfzjson "--json" |
| 185 | text tfzradp "rad:" |
| 186 | text tfzwal "/home/drakestapleton/.radicle/node/node.db-wal" |
| 187 | text tfzrow "{\"rid\":\"rad:" |
| 188 | text tfznid "\"nid\":\"" |
| 189 | note fradwalk: the change key of the node database (node.db-wal mtime in ns), 0 when it is missing |
| 190 | fn fradwalk to ulong |
| 191 | fpb |
| 192 | fpt tfzwal |
| 193 | r = stat fpth 0 get fpthl 0 fstb 0 128 |
| 194 | if lt r 0 |
| 195 | ret 0 |
| 196 | end |
| 197 | ret add mul fradle8 88 1000000000 fradle8 96 |
| 198 | end |
| 199 | fn fradle8 o ulong to ulong |
| 200 | v = ulong 0 |
| 201 | for i ulong 8 |
| 202 | v = or v shl ulong get fstb add o i mul i 8 |
| 203 | end |
| 204 | ret v |
| 205 | end |
| 206 | note fradseeds: the nodes this node's routing table says seed repo i (this node included), or -1 when |
| 207 | note rad did not answer |
| 208 | fn fradseeds i ulong to long |
| 209 | fkb |
| 210 | fka tfzenv |
| 211 | fka tfzhenv |
| 212 | fka tfzrad |
| 213 | fka tfznode |
| 214 | fka tfzrout |
| 215 | fka tfzrid |
| 216 | fkopen |
| 217 | fkt tfzradp |
| 218 | for k ulong get fail i bound 64 |
| 219 | fkc fridbyte i k |
| 220 | end |
| 221 | fka tfzjson |
| 222 | st = fexec 5000000000 |
| 223 | if ne st 0 |
| 224 | ret -1 |
| 225 | end |
| 226 | ret long fzrows i |
| 227 | end |
| 228 | note fzrows: lines of fxo that are {"rid":"rad:<RID of i>",...,"nid":"... |
| 229 | fn fzrows i ulong to ulong |
| 230 | ln = get fxol 0 |
| 231 | p = ulong 0 |
| 232 | n = ulong 0 |
| 233 | for it ulong 1000000 |
| 234 | if ge p ln |
| 235 | break |
| 236 | end |
| 237 | e = fleol p ln |
| 238 | if fzrowok i p e |
| 239 | n = add n 1 |
| 240 | end |
| 241 | p = add e 1 |
| 242 | end |
| 243 | ret n |
| 244 | end |
| 245 | fn fzxpre a ulong e ulong t view uchar * to bool |
| 246 | if gt add a len t e |
| 247 | ret false |
| 248 | end |
| 249 | for k ulong len t bound 64 |
| 250 | if ne get fxo add a k get t k |
| 251 | ret false |
| 252 | end |
| 253 | end |
| 254 | ret true |
| 255 | end |
| 256 | fn fzrowok i ulong p ulong e ulong to bool |
| 257 | if not fzxpre p e tfzrow |
| 258 | ret false |
| 259 | end |
| 260 | a = add p len tfzrow |
| 261 | l = get fail i |
| 262 | if gt add a add l 2 e |
| 263 | ret false |
| 264 | end |
| 265 | for k ulong l bound 64 |
| 266 | if ne get fxo add a k fridbyte i k |
| 267 | ret false |
| 268 | end |
| 269 | end |
| 270 | if ne get fxo add a l 34 |
| 271 | ret false |
| 272 | end |
| 273 | q = add add a l 1 |
| 274 | for it ulong sub e q bound 16777216 |
| 275 | if fzxpre q e tfznid |
| 276 | ret true |
| 277 | end |
| 278 | q = add q 1 |
| 279 | end |
| 280 | ret false |
| 281 | end |
| 282 | note ---- the footer line that says what forged serves (server/pages.om ffoot) |
| 283 | text tfsf4 "<p class=\"foot-fine\">INTERPLANE Forge: agents express intent; the forge retains authority. Repositories are served by forged, a seeded-Omega web server, with no JavaScript.</p>\n<p class=\"foot-fine\"><a href=\"" |
| 284 | note ---- the identity words of the "For developers" section (server/pages.om fpjdev1): Delegate, |
| 285 | note Refs and HEAD, and Patch up to its link |
| 286 | text tfdv3 "<dt>Delegate</dt><dd>A key that may sign the project's official versions. This forge lists the project under " |
| 287 | text tfdv4 ".</dd>\n<dt>Refs and HEAD</dt><dd>Refs are the names that point at versions: branches and tags. HEAD is the version a fresh copy starts from, the newest commit of the default branch.</dd>\n<dt>Patch</dt><dd>A proposed change, stored in the repository and reviewed before it is merged. The list is under <a href=\"" |
| 288 | fn fpjterms to void |
| 289 | fput tfdv3 |
| 290 | fputown |
| 291 | fput tfdv4 |
| 292 | end |
| 293 | note ---- the clone object of the JSON repo form (server/json.om fjrepo) |
| 294 | text tfjcl1 ",\n\"clone\":{\"rad\":\"" |
| 295 | text tfjcl2 "\",\"rad_clone\":null,\"git_https\":null}" |
| 296 | fn fjclone i ulong to void |
| 297 | fput tfjcl1 |
| 298 | fputrid i |
| 299 | fput tfjcl2 |
| 300 | end |