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/docs/CONTRACT.md # 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 / docs / CONTRACT.md` 292 lines · 24365 bytes Raw Blame History Rendered 1 # forged interface contract (v2) 2 3 Owner: ForgeServer. Applies to every unit composed into `forged`. Questions: `write agent://ForgeServer`. 4 5 `forged` is ONE seeded-Omega program (OM-2), built with the pinned omc 6 (omega-mv ``f4df8239``, `seed/out/omc` sha256 ``3ad9f10f`…3194`, at spark `~/work/flux/omega-mv`). 7 It serves sequentially: one request at a time, so all request/response state lives in **globals** 8 that every handler reads and writes **by name** (omc refuses a global as an argument, error 19). 9 Handlers never touch the http.om connection arrays `cs`/`io`. 10 11 ## 1. Build and unit order 12 13 `run.sh build` concatenates, in this order, and pipes into omc (`./run.sh units` prints the list): 14 15 ``` 16 om2 17 omega-mv seed/net/http.om (names h*, H*) 18 omega-mv seed/net/notls.om 19 omega-mv om/tls/sha2.om (sha256 for anyone: see its own header) 20 server/util.om (this contract: globals f*, helpers f*, texts tf*) 21 server/repos.om (allow-list helpers, repo metadata: both repository sources use them) 22 server/radsrc.om (Radicle source: RIDS.md allow-list, routing table; or .build/store.om + store/repos.om) 23 nodes/head.om (default branch from HEAD; or store/head.om) 24 browse/*.om or server/nobrowse.om ForgeBrowse prefix br* (fns), gb* / tb* (globals / texts) 25 dl/*.om or server/nodl.om ForgeDownloads prefix dl*, gd* / td* (dl/dlclone.om: the clone panel) 26 collab/*.om or server/nocollab.om ForgePatches prefix co*, gc* / tc* 27 social/*.om or server/nosocial.om ForgeSocial prefix so*, gs* / ts* 28 server/json.om server/counts.om (ForgeServer: JSON form fj* / tfj*, counts fz* / tfz*; docs/API.md) 29 store/moving.om (store-reading build only: the 503 "moving" answer mv*, fmvng; docs/API.md) 30 growth/*.om or server/nogrowth.om ForgeGrowth prefix gr* / gg* / tg*; docs/GROWTH.md; after counts so it can read them 31 (store-reading build: store/mvgrowth.om, /trending and /trending.json answer 503) 32 salvage/[0-9][0-9]*.om or server/nosalvage.om salvage (submissions) prefix sl* / gl* / tl*; docs/SALVAGE.md; 33 needs collab/ and social/ composed; salvage/collector.om is its own program 34 (store-reading build: store/mvsalvage.om, salvage/... answers 503) 35 community/[0-9][0-9]*.om or server/nocommunity.om Community Machines prefix cm_*; docs/COMMUNITY.md 36 (store-reading build: store/mvcommunity.om, community/... answers 503) 37 open/route.om or server/noopen.om open builds (Open Humanity shelf) prefix oh* / go* / to*; docs/OPEN-BUILDS.md; 38 needs salvage/ composed; open/intake.om is its own program 39 (store-reading build: store/mvopen.om, open/..., open.json, bring.sh, get.sh, 40 withdraw.sh answer 503) 41 research/route.om or server/noresearch.om research pages and questions prefix rx* / gx* / tx*; research/README.md 42 salvage, open and research each define nav (slnav, ohnav, rxnav): one 43 entry in the forge row of server/pages.om fhead; the seam defines it empty 44 door/*.om or server/nodoor.om the agent door: event stream, feed prefix ev* / gev* / tev*; docs/AGENT-DOOR.md; 45 needs collab/ and social/ composed; evnav is its forge row entry 46 .build/agents.om server/agents.om (ForgeServer: agents.json, fqa* / tfqa*; .build/agents.om is server/agents.tsv 47 compiled by run.sh at every build) 48 server/pages.om server/jsonp.om (jsonp: the JSON of every other page, fy* / tfy*; after pages.om for its globals) 49 server/route.om server/main.om 50 ``` 51 52 - A slice dir is composed only when it holds a `READY` file (ForgeServer sets it after a live test); 53 otherwise its seam is used. Check your unit composes BEFORE asking for integration: 54 `cd ~/work/forge/web && FORGE_TRY= FORGED_OUT=/tmp/x.try ./run.sh build` (rc 0 = composes). 55 - Every name you define (fn, global, text, const) MUST start with your prefix. Globals/texts are at 56 most 8 characters. Never define `f*`, `F*`, `tf*`, `h*`, `H*`. Texts are NOT forward-declared: 57 define a text above its first use. Known keyword clash: `faccess` (and likely other host-word 58 names) is refused with error 16. 59 - Files in your dir are composed in `ls` order. No `om2` line, no `fn main`, no `struct`, in your files. 60 - Functions may be called before their definition (forward calls work across units). 61 - The seam `server/no.om` defines your required functions with "not available" behaviour 62 (route returns 0; nodl also defines an empty `dlclone`). 63 64 ### Store-reading build (interplane-native DESIGN.md step 2) 65 66 `FORGE_STORE= FORGED_OUT= ./run.sh build` (optional 67 `FORGE_CLONE_BASE=https:////`) builds the same source with a second repository source. 68 `run.sh storegen` writes `.build/store.om` (texts `tfsroot`, `tfcbase`, const `FSCB`), composed after 69 `server/repos.om`, and these units are composed in place of the default ones: 70 71 | Default unit | Store-reading unit | What it gives | 72 |---|---|---| 73 | `server/radsrc.om` | `store/repos.om` | the allow-list, reload check, identifiers, identity words, JSON clone object, footer line, routing table | 74 | `nodes/head.om` | `store/head.om` | the default branch (the catalog's field instead of the HEAD file) | 75 | `dl/dlclone.om` | `store/clone.om` | the clone panel (no `rad clone` line; HTTPS only with a clone base) | 76 | `collab/`, `quiet/`, `growth/`, `salvage/`, `community/`, `open/` | their `server/no.om` seams | collab and quiet read Radicle patches and issues; growth, salvage, community and open need collab or salvage | 77 | `research/intake-route.om` | `research/noadd.om` | the intake runs `rad` through the open shelf | 78 79 Both sources define the same words, used by the units around them: `fload` (fills the allow-list, returns 80 the count or -1), `fsrcchg` (true when the source changed: RIDS.md mtime, or the catalog's inode, size and 81 mtime), `fputid i` (the identifier in machine forms: `rad:` or `git:<64-hex id>`), `fhasal i` (repo i 82 has an old Radicle id), `fradsrc` (Radicle node data may be read: server/counts.om `fzseeds` and its line), 83 `fradwalk` / `fradseeds i` (the routing table), `fpjterms` (the identity words of the "For developers" 84 section), `fjclone i` (the JSON clone object) and the text `tfsf4` (the footer line). `fkgit` / `fkgiti` 85 stay in server/util.om: `store/repos.om` sets `fsrcst` to 1 and `fsrt` to the store root when it loads, 86 and they then name `projects//repo.git`. `deploy` and `restart` refuse `FORGE_STORE`; a 87 store-reading build never writes `server/forged`. The store layout and its rules are interplane-native's 88 CONTRACT.md v0; `store/repos.om` says which of them forged checks. `store/tests/compare.sh` is the 89 acceptance test. 90 91 The store repository home resolves its default branch once and pins the README/file links, 92 Files tab and clone panel to that commit. `brpinhd` copies `gbsha` into `fpin` (uchar 40), calls 93 `frepohd 0`, then clears `fpin[0]`; tree pages use the same wrapper. `fputpin` writes its 40 bytes. 94 A full 40-hex ref segment is interpreted as a commit even if a branch has that exact name. 95 Without `FORGE_CLONE_BASE`, the Git command is omitted but the pinned archive links remain. 96 An empty repository has no clone panel. 97 98 The public Git edge, not `dlroute`, answers 99 `/drakestapleton//archive/commits/<40-lower-case-hex>.zip|.tar.gz` 100 (`infra/nginx/snippets/bazinga-git.conf`, `infra/bazinga/omega-read`). The object must be a commit 101 reachable from a root `refs/heads` or `refs/tags` in the public filtered Git mirror, including 102 older history and commits on another branch or only under a tag. The download's prefix is 103 `-/`, ETag is the quoted SHA, and Cache-Control is `no-cache`. HEAD sends no body. 104 Malformed paths fall through to forged; a well-formed but unknown, non-commit or unreachable SHA 105 gets an empty 404 from the edge. Existing branch archives retain their branch-based prefix. 106 Forged's legacy `/archive/<7..40-hex>` remains a 302 only for a commit at a canonical head or tag 107 tip, otherwise 404. It does not implement the edge's `/archive/commits/` path. 108 109 ## 2. Request (set by the server before dispatch; read only) 110 111 Scalars are `global X ulong 1`, read with `get X 0`. 112 113 | Global | Type | Meaning | 114 |---|---|---| 115 | `fmeth` | ulong 1 | 1 GET **or HEAD** (http.om drops the body of a HEAD response itself, so handlers treat HEAD as GET), 3 POST, 0 other. 2 is never delivered | 116 | `fpath`, `fpathl` | uchar 4096 | raw request path (before `?`), starts with `/`. The server already refused (400) any `..` or `.` segment (raw or `%2e`), `//`, NUL, control bytes, and paths over 4096 | 117 | `fqs`, `fqsl` | uchar 4096 | raw query string without `?` | 118 | `fbody`, `fbodyl` | uchar 65536 | POST body (at most 64 KiB; larger = 413 before dispatch) | 119 | `fck`, `fckl` | uchar 4096 | Cookie header value | 120 | `fip`, `fipl` | uchar 64 | client IP: `X-Real-IP` from nginx when present, else `127.0.0.1` | 121 | `fbase`, `fbasel` | uchar 64 | `/` or `/forge/` (from `X-Forge-Base`; any other value = `/`). Always ends in `/` | 122 | `fridx` | ulong 1 | allow-list index of the repo for `///...`, else 9999 | 123 | `frid`, `fridl` | uchar 64 | that repo's key: its RID **without** `rad:` (store-reading build: the old RID from record 1, or the 64-hex id of a project without one) | 124 | `fown`, `fownl` | uchar 64 | owner segment (`drakestapleton`) | 125 | `frepo`, `frepol` | uchar 128 | repo name exactly as in the allow-list | 126 | `frest`, `frestl` | uchar 4096 | the path after `//`; empty for the repo home, else starts with `/` (e.g. `/tree/main/src`) | 127 | `fuser`, `fuserl` | uchar 64 | signed-in user name; `fuserl` 0 = signed out (set by `sosess`) | 128 | `fcsrf`, `fcsrfl` | uchar 64 | the session's CSRF token (set by `sosess`), for hidden form fields | 129 | `finm`, `finml` | uchar 256 | `If-None-Match` header value | 130 | `forig`, `forigl` | uchar 256 | `Origin` header value (empty when absent) | 131 | `facc`, `faccl` | uchar 512 | `Accept` header value (cut at 512); `fjwant` is true when it names `application/json` and not `text/html` | 132 133 Allow-list (loaded at start, on the reload flag, and when the source changes): default build from spark 134 `~/handoffs/radicle/RIDS.md`, first table only; store-reading build from `/catalog.tsv`: every 135 public line (there is no served list since 2026-11-14; RIDS.md is not read), every project checked as 136 `store/repos.om` says (folders not links, record 1 hashes to the id and names the same project, deny 137 list by name or old id, no old id already served, head equal to `refs/heads/`; a malformed 138 catalog serves nothing; a private line is skipped; a project that fails a check is left out with one 139 stderr line). `fan` (count), and per index `i < fan`: 140 `fputrn i` appends the name, `fputrid i` the key (no 141 `rad:`), `fputid i` the identifier (the bare `` since `9a4420a` / `git:`), `frnlen i`/`fridlen i` lengths, 142 `frnbyte i k`/`fridbyte i k` one byte. `frepoix` returns the index of the repo whose name equals 143 `frepo[0,frepol)` or 9999. A repo not in the table does not exist for any handler: the server returns 404 144 before dispatch, and handlers MUST NOT read other storage dirs. The table holds `FAMAX` (256) 145 repositories (`fano` and the per-repo arrays, every loop over them `bound FAMAX`); a project past it is 146 left out alone ("the allow-list table is full"), and `store/tests/capacity.sh` alarms when the store's 147 public lines (or, in the default build, the RIDS.md first table) pass 192. In the store-reading build 148 the sandbox (`infra/spark/forged-sandbox.sh` with `FORGED_STORE`) holds only the projects 149 `forged-public.sh store_names` selects (public, valid name, not denied); a project created after the 150 start is bound at the next start. 151 152 Constants: `tfgit` = `/usr/bin/git`, `tfdata` = `/home/drakestapleton/forge-data/`. Default build: 153 `tfstore` = `/home/drakestapleton/.radicle/storage/` (server/util.om, used by fkgit / fkgiti while `fsrcst` is 0); store-reading build: `tfsroot` 154 (.build/store.om). Owner name text `tfowner` = `drakestapleton`, owner NID text `tfnid` = 155 ``z6MkfZDue1TbaNFi3ZzcD9uiTeduPLC52ucdFVuLKZwexxhK`` (the namespace of copied Radicle refs). 156 157 ## 3. Response (written by the handler) 158 159 | Global | Meaning | 160 |---|---| 161 | `fob`, `fobl` | body, uchar `8388608`. Append with the helpers below only (they cap at the size and set `fobtr` 1 when cut) | 162 | `fkind` | 0 = HTML **content fragment**: the server wraps it in the layout (header, footer) with title `fti`/`ftil` (uchar 256, plain text, escaped by the server). 1 = raw body with content type `fct`/`fctl`. 2 = redirect to `floc`/`flocl` (status 302 or 303). 3 = stream a file: path in `ffile`/`ffilel`, content type `fct`, size cap 512 MiB. 4 = stream a command's stdout: the argv left in `fpk` runs again at send time, its stdout goes out as a chunked body with content type `fct` (for output above `fxo`'s 16 MiB that the handler already ran once with `fexec`, e.g. browse `/commit/.diff`); a failure after the head cuts the connection without the last chunk | 163 | kind 5 (generated shelf stream) | `ohbody` fills the next complete-row batch in `fob` and returns true, or false at EOF; `ohbodyend` closes its input. `fsend5` sends chunked with `fct`, keeps HTML layout/translation and `format=text`, and calls again until EOF. No total response size limit. `fobtr` or a send failure closes without the final chunk, so a client detects an incomplete body. `server/noopen.om` provides the inactive seam. Used by `/open/` and `/open.json`; the developer page is unchanged. | 164 | `fct`, `fctl` | uchar 128 content type for kinds 1, 3, 4 and 5 | 165 | `fcd`, `fcdl` | uchar 512 optional `Content-Disposition` value (kinds 1 and 3) | 166 | `fsck`, `fsckl` | uchar 512 optional `Set-Cookie` value (`fsetsck t` / `fscc c`) | 167 | `floc`, `flocl` | uchar 4096 Location for kind 2. Build it with `flocb` (base) + `flocc`/`floct`; `flocrepo` appends `/` | 168 | `fetag`, `fetagl` | uchar 128 optional `ETag` value, quotes included (`fetc c`). With kind 1 or 3: when `finm` equals it, return 304 with kind 1 and empty `fob`; the server sends no body and no Content-Type | 169 | `fcc`, `fccl` | uchar 128 optional `Cache-Control` replacing `no-store` (`fsetcc t` / `fccc c`) | 170 | `fretry` | ulong; nonzero = also send `Retry-After: ` (seconds), e.g. with a 503 | 171 | `fcspsb` | ulong; nonzero = send the sandbox CSP `sandbox; default-src 'none'; img-src 'self'; style-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'` instead of the page CSP. Set it with `fsetsbx` (browse `/raw/`) | 172 173 The server resets all response globals before each dispatch (kind 0, lengths 0). 174 Every response gets `Content-Security-Policy: default-src 'none'; style-src 'self'; img-src 'self'; script-src 'none'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'`, 175 `X-Content-Type-Options: nosniff`, `Referrer-Policy: same-origin`, `Cache-Control: no-store` (kinds 0-2). 176 No JavaScript, ever: no `