interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / docs / CONTRACT.md

292 lines · 24365 bytes Raw Blame History Source

forged interface contract (v2)

Owner: ForgeServer. Applies to every unit composed into forged. Questions: write agent://ForgeServer.

forged is ONE seeded-Omega program (OM-2), built with the pinned omc (omega-mv f4df8239, seed/out/omc sha256 3ad9f10f…3194, at spark ~/work/flux/omega-mv). It serves sequentially: one request at a time, so all request/response state lives in globals that every handler reads and writes by name (omc refuses a global as an argument, error 19). Handlers never touch the http.om connection arrays cs/io.

1. Build and unit order

run.sh build concatenates, in this order, and pipes into omc (./run.sh units prints the list):

om2
omega-mv seed/net/http.om          (names h*, H*)
omega-mv seed/net/notls.om
omega-mv om/tls/sha2.om            (sha256 for anyone: see its own header)
server/util.om                     (this contract: globals f*, helpers f*, texts tf*)
server/repos.om                    (allow-list helpers, repo metadata: both repository sources use them)
server/radsrc.om                   (Radicle source: RIDS.md allow-list, routing table; or .build/store.om + store/repos.om)
nodes/head.om                      (default branch from HEAD; or store/head.om)
browse/*.om   or server/nobrowse.om   ForgeBrowse      prefix br* (fns), gb* / tb* (globals / texts)
dl/*.om       or server/nodl.om       ForgeDownloads   prefix dl*, gd* / td*  (dl/dlclone.om: the clone panel)
collab/*.om   or server/nocollab.om   ForgePatches     prefix co*, gc* / tc*
social/*.om   or server/nosocial.om   ForgeSocial      prefix so*, gs* / ts*
server/json.om server/counts.om    (ForgeServer: JSON form fj* / tfj*, counts fz* / tfz*; docs/API.md)
store/moving.om                    (store-reading build only: the 503 "moving" answer mv*, fmvng; docs/API.md)
growth/*.om or server/nogrowth.om   ForgeGrowth      prefix gr* / gg* / tg*; docs/GROWTH.md; after counts so it can read them
                                   (store-reading build: store/mvgrowth.om, /trending and /trending.json answer 503)
salvage/[0-9][0-9]*.om or server/nosalvage.om   salvage (submissions) prefix sl* / gl* / tl*; docs/SALVAGE.md;
                                   needs collab/ and social/ composed; salvage/collector.om is its own program
                                   (store-reading build: store/mvsalvage.om, salvage/... answers 503)
community/[0-9][0-9]*.om or server/nocommunity.om   Community Machines prefix cm_*; docs/COMMUNITY.md
                                   (store-reading build: store/mvcommunity.om, community/... answers 503)
open/route.om or server/noopen.om   open builds (Open Humanity shelf) prefix oh* / go* / to*; docs/OPEN-BUILDS.md;
                                   needs salvage/ composed; open/intake.om is its own program
                                   (store-reading build: store/mvopen.om, open/..., open.json, bring.sh, get.sh,
                                   withdraw.sh answer 503)
research/route.om or server/noresearch.om   research pages and questions   prefix rx* / gx* / tx*; research/README.md
                                   salvage, open and research each define <prefix>nav (slnav, ohnav, rxnav): one
                                   entry in the forge row of server/pages.om fhead; the seam defines it empty
door/*.om or server/nodoor.om       the agent door: event stream, feed  prefix ev* / gev* / tev*; docs/AGENT-DOOR.md;
                                   needs collab/ and social/ composed; evnav is its forge row entry
.build/agents.om server/agents.om  (ForgeServer: agents.json, fqa* / tfqa*; .build/agents.om is server/agents.tsv
                                   compiled by run.sh at every build)
server/pages.om server/jsonp.om    (jsonp: the JSON of every other page, fy* / tfy*; after pages.om for its globals)
server/route.om server/main.om

Store-reading build (interplane-native DESIGN.md step 2)

FORGE_STORE=<absolute store root> FORGED_OUT=<path> ./run.sh build (optional FORGE_CLONE_BASE=https://<host>/<path>/) builds the same source with a second repository source. run.sh storegen writes .build/store.om (texts tfsroot, tfcbase, const FSCB), composed after server/repos.om, and these units are composed in place of the default ones:

Default unitStore-reading unitWhat it gives
server/radsrc.omstore/repos.omthe allow-list, reload check, identifiers, identity words, JSON clone object, footer line, routing table
nodes/head.omstore/head.omthe default branch (the catalog's field instead of the HEAD file)
dl/dlclone.omstore/clone.omthe clone panel (no rad clone line; HTTPS only with a clone base)
collab/, quiet/, growth/, salvage/, community/, open/their server/no<slice>.om seamscollab and quiet read Radicle patches and issues; growth, salvage, community and open need collab or salvage
research/intake-route.omresearch/noadd.omthe intake runs rad through the open shelf

Both sources define the same words, used by the units around them: fload (fills the allow-list, returns the count or -1), fsrcchg (true when the source changed: RIDS.md mtime, or the catalog's inode, size and mtime), fputid i (the identifier in machine forms: rad:<RID> or git:<64-hex id>), fhasal i (repo i has an old Radicle id), fradsrc (Radicle node data may be read: server/counts.om fzseeds and its line), fradwalk / fradseeds i (the routing table), fpjterms (the identity words of the "For developers" section), fjclone i (the JSON clone object) and the text tfsf4 (the footer line). fkgit / fkgiti stay in server/util.om: store/repos.om sets fsrcst to 1 and fsrt to the store root when it loads, and they then name <root>projects/<name>/repo.git. deploy and restart refuse FORGE_STORE; a store-reading build never writes server/forged. The store layout and its rules are interplane-native's CONTRACT.md v0; store/repos.om says which of them forged checks. store/tests/compare.sh is the acceptance test.

The store repository home resolves its default branch once and pins the README/file links, Files tab and clone panel to that commit. brpinhd copies gbsha into fpin (uchar 40), calls frepohd 0, then clears fpin[0]; tree pages use the same wrapper. fputpin writes its 40 bytes. A full 40-hex ref segment is interpreted as a commit even if a branch has that exact name. Without FORGE_CLONE_BASE, the Git command is omitted but the pinned archive links remain. An empty repository has no clone panel.

The public Git edge, not dlroute, answers /drakestapleton/<repo>/archive/commits/<40-lower-case-hex>.zip|.tar.gz (infra/nginx/snippets/bazinga-git.conf, infra/bazinga/omega-read). The object must be a commit reachable from a root refs/heads or refs/tags in the public filtered Git mirror, including older history and commits on another branch or only under a tag. The download's prefix is <repo>-<sha>/, ETag is the quoted SHA, and Cache-Control is no-cache. HEAD sends no body. Malformed paths fall through to forged; a well-formed but unknown, non-commit or unreachable SHA gets an empty 404 from the edge. Existing branch archives retain their branch-based prefix. Forged's legacy /archive/<7..40-hex> remains a 302 only for a commit at a canonical head or tag tip, otherwise 404. It does not implement the edge's /archive/commits/ path.

2. Request (set by the server before dispatch; read only)

Scalars are global X ulong 1, read with get X 0.

GlobalTypeMeaning
fmethulong 11 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
fpath, fpathluchar 4096raw request path (before ?), starts with /. The server already refused (400) any .. or . segment (raw or %2e), //, NUL, control bytes, and paths over 4096
fqs, fqsluchar 4096raw query string without ?
fbody, fbodyluchar 65536POST body (at most 64 KiB; larger = 413 before dispatch)
fck, fckluchar 4096Cookie header value
fip, fipluchar 64client IP: X-Real-IP from nginx when present, else 127.0.0.1
fbase, fbaseluchar 64/ or /forge/ (from X-Forge-Base; any other value = /). Always ends in /
fridxulong 1allow-list index of the repo for /<owner>/<repo>/..., else 9999
frid, fridluchar 64that 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)
fown, fownluchar 64owner segment (drakestapleton)
frepo, frepoluchar 128repo name exactly as in the allow-list
frest, frestluchar 4096the path after /<owner>/<repo>; empty for the repo home, else starts with / (e.g. /tree/main/src)
fuser, fuserluchar 64signed-in user name; fuserl 0 = signed out (set by sosess)
fcsrf, fcsrfluchar 64the session's CSRF token (set by sosess), for hidden form fields
finm, finmluchar 256If-None-Match header value
forig, forigluchar 256Origin header value (empty when absent)
facc, faccluchar 512Accept header value (cut at 512); fjwant is true when it names application/json and not text/html

Allow-list (loaded at start, on the reload flag, and when the source changes): default build from spark ~/handoffs/radicle/RIDS.md, first table only; store-reading build from <store>/catalog.tsv: every public line (there is no served list since 2026-11-14; RIDS.md is not read), every project checked as store/repos.om says (folders not links, record 1 hashes to the id and names the same project, deny list by name or old id, no old id already served, head equal to refs/heads/<branch>; a malformed catalog serves nothing; a private line is skipped; a project that fails a check is left out with one stderr line). fan (count), and per index i < fan: fputrn i appends the name, fputrid i the key (no rad:), fputid i the identifier (the bare <RID> since 9a4420a / git:<id>), frnlen i/fridlen i lengths, frnbyte i k/fridbyte i k one byte. frepoix returns the index of the repo whose name equals frepo[0,frepol) or 9999. A repo not in the table does not exist for any handler: the server returns 404 before dispatch, and handlers MUST NOT read other storage dirs. The table holds FAMAX (256) repositories (fano and the per-repo arrays, every loop over them bound FAMAX); a project past it is left out alone ("the allow-list table is full"), and store/tests/capacity.sh alarms when the store's public lines (or, in the default build, the RIDS.md first table) pass 192. In the store-reading build the sandbox (infra/spark/forged-sandbox.sh with FORGED_STORE) holds only the projects forged-public.sh store_names selects (public, valid name, not denied); a project created after the start is bound at the next start.

Constants: tfgit = /usr/bin/git, tfdata = /home/drakestapleton/forge-data/. Default build: tfstore = /home/drakestapleton/.radicle/storage/ (server/util.om, used by fkgit / fkgiti while fsrcst is 0); store-reading build: tfsroot (.build/store.om). Owner name text tfowner = drakestapleton, owner NID text tfnid = z6MkfZDue1TbaNFi3ZzcD9uiTeduPLC52ucdFVuLKZwexxhK (the namespace of copied Radicle refs).

3. Response (written by the handler)

GlobalMeaning
fob, foblbody, uchar 8388608. Append with the helpers below only (they cap at the size and set fobtr 1 when cut)
fkind0 = 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/<sha>.diff); a failure after the head cuts the connection without the last chunk
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.
fct, fctluchar 128 content type for kinds 1, 3, 4 and 5
fcd, fcdluchar 512 optional Content-Disposition value (kinds 1 and 3)
fsck, fsckluchar 512 optional Set-Cookie value (fsetsck t / fscc c)
floc, flocluchar 4096 Location for kind 2. Build it with flocb (base) + flocc/floct; flocrepo appends <owner>/<repo>
fetag, fetagluchar 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
fcc, fccluchar 128 optional Cache-Control replacing no-store (fsetcc t / fccc c)
fretryulong; nonzero = also send Retry-After: <fretry> (seconds), e.g. with a 503
fcspsbulong; 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/)

The server resets all response globals before each dispatch (kind 0, lengths 0). 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', X-Content-Type-Options: nosniff, Referrer-Policy: same-origin, Cache-Control: no-store (kinds 0-2). No JavaScript, ever: no <script>, no on*= attributes, no javascript: URLs.

Handler naming and dispatch

fn brroute to long     ForgeBrowse   repo pages under /<owner>/<repo>[/...] (fridx set), and /<owner>/<repo>/search
fn dlroute to long     ForgeDownloads /<owner>/<repo>/archive/..., /<owner>/<repo>/releases[...]
fn coroute to long     ForgePatches  /<owner>/<repo>/patches[...], /<owner>/<repo>/issues[...]
fn soroute to long     ForgeSocial   /login /logout /stars /settings, POST star/fav/follow, /<owner>/followers etc.

Return 0 = not mine (the server tries the next handler, then its own pages). Otherwise return the HTTP status (200, 302, 303, 304, 400, 403, 404, 405, 413, 429, 500, 501) and fill the response globals. Order: soroute, dlroute, coroute, brroute, then server pages. A 4xx/5xx with fkind 0 and empty fob gets the server's error page. When no handler claims a known repo feature path (`/tree /blob /raw /blame /commits /commit /compare /branches /tags /releases /archive /patches /issues /stargazers /search /labels`) the server answers 501 "Coming soon", and the reserved pages /login /logout /settings /new /stars /notifications /api also answer 501 until claimed. An unclaimed POST to /<o>/<r>/star|unstar|fav|unfav or to <base>follow / <base>unfollow (form field user names the account) is 303 to <base>login. For /<owner>/<x> where x is not a public repo, only soroute is asked (with fridx 9999).

Machine form (ForgeServer, docs/API.md): before any slice, froute answers <base>explore.json, <base><o>/<r>.json and (with fjwant) /, /explore and the repo home as JSON (kind 1). For a repo home GET it first calls fzprep (reads what the logs added, server/counts.om); frepohd then shows the counts when frest is empty, and the layout adds <link rel="alternate"> to the JSON form on explore and the repo home. Slices need not do anything for either.

Every other page has a machine form too (card t_6b17c31a): the page answers JSON at its own URL when fjwant is true. A slice handler of a page with a JSON form does, after the same validation as its HTML path: if fjwant -> its JSON emitter (start with fyrhead / fyuhead, keys with fyk, values with fnum, fybool, fynull, fysx, fysv, fjstr, fjiso, close with fyend; all in server/json.om and server/jsonp.om); else fyalt (the layout then names the page's own URL as <link rel="alternate" type="application/json">) and the unchanged HTML handler. Errors stay "return the status with fob empty": for a JSON request ferrpage answers a forge/error/1 document. Raw byte routes (/raw/, .patch, .diff, archives, release assets) have no JSON form. Every schema is documented in docs/API.md in the format server/tests/jsonpages.py parses; that test walks every page under both bases.

Social functions the server calls (ForgeSocial provides)

fn sosess to long                 parse fck, set fuser/fuserl/fcsrf/fcsrfl; 1 signed in, 0 not
fn sostarn i ulong to ulong       star count of allow-list repo i
fn sofavn i ulong to ulong        favorite count of repo i
fn sofolln to ulong               followers of the user named fown[0,fownl)
fn sofollg to ulong               accounts that user follows
fn sobar to void                  append the star / favorite forms (or sign-in links) for repo fridx to fob
fn sofolbar to void               append the follow form for user fown to fob
fn socsrfok to bool               true when the body field csrf equals the session token (and signed in)
fn sostarsof to void              append the list of repos the user fown starred to fob (profile tab)
fn sojstars to void              the same list as a JSON array of {name, rid, path, stars} (forge/user/1 starred)
fn soload to long                 replay ~/forge-data log at start and on SIGHUP

Edge (ForgeInfra): nginx strips /forge/, so fpath is always rooted at / on both domains; X-Forge-Base only builds links and Locations. Redirect Locations MUST be base-prefixed (flocb). The edge CSP forbids inline style= and <style>: use class names from the server stylesheet <base>assets/forge.css, whose source is the text tchrcss of the generated unit .build/chrome.om (the site's :root line and, between the site-chrome marks, its header and footer rules, made at every build by server/chromegen.om from interplane.io public/style.css; checked by server/tests/sitechrome.sh) and the texts tfcssv and tfcss2..9 in server/pages.om (ask ForgeServer to add a class). frepohd tab and dlclone (the clone panel: rad, git over HTTPS, zip/tar.gz) are in pages.om / dl/dlclone.om (store-reading build: store/clone.om, git over HTTPS only with a clone base, zip/tar.gz).

The generated header marks the single https://interplane.io/explore link (Projects) current with aria-current="true"; tfcss2 styles it and the forge controls stay in their separate row. tchrfoot holds the site's three-column footer through its SI line; forge-specific fine print is followed by generated tchrfend, which closes the site's footer containers. The decorative rope band between the site's main and footer is deliberately excluded. Responsive chrome rules and the later Strand-system overrides retain source order and their enclosing at-blocks.

4. Helpers in server/util.om

HelperEffect
fput s view uchar * / fputc c ucharappend raw bytes / one byte to fob
fesc s view uchar * / fescc c ucharappend HTML-escaped (& < > " ')
fnum v ulongappend decimal
fputbappend the base (/ or /forge/)
flink p view uchar *append base + p (p has no leading /): flink tbx → /forge/x
fputrepoappend <owner>/<repo> of the current request, escaped
fputrlappend the repo URL <base><owner>/<repo>
fputown / fputrnmappend the owner / the repo name, escaped
frepohd tab ulong(pages.om) append the repo header: owner/repo title, description, sobar, clone line, tabs. tab: 0 Code 1 Commits 2 Branches 3 Tags 4 Releases 5 Patches 6 Issues
fdesc i ulong / fputbr i ulong / fputlc i ulongappend the escaped description / default branch / last commit line (YYYY-MM-DD <sha7> <subject>) of repo i
fpeq t / fpre tfpath equals / starts with text t
frsteq t / frstpre tthe same tests on frest
fqget n view uchar * to longfind query param n in fqs, percent-decode (+ = space) into fval (uchar 4096); returns length or -1
fbget n view uchar * to longsame for the urlencoded POST body fbody
flocb, flocc c uchar, floct t view uchar *build floc: base, then bytes
fsetct t view uchar *, fsetcd t view uchar *, fsetti t view uchar *, ftic c, fcdc cset content type, Content-Disposition, title (and byte variants)
fkgit / fkgiti i ulongstart an argv in fpk (uchar 8192): /usr/bin/git --git-dir=<storage>/<rid> (store-reading build, fsrcst 1: <store>/projects/<name>/repo.git) for the current repo / repo i
fkb, fka t view uchar *, fkopen, fkc c ucharargv builder (fkb empty; fka add an arg; fkopen start an arg and fkc append bytes to it)
fexec tmo long to longfork + execprog argv fpk (no shell, empty env, stdin/stderr /dev/null, stdout into fxo uchar 16777216, length fxol; fxotr 1 when cut). Returns exit status, -1 timeout (killed), -2 cannot start
fxput a ulong n ulong / fxesc a ulong n ulongappend fxo[a,a+n) raw / escaped to fob
flog t view uchar *one line to stderr (the access log is the server's)
fpb, fpc c, fpt t, frdall to longbuild a file path in fpth (fpb = data dir), read the whole file into fxo
fmtime to ulongst_mtime of fpth (0 when missing)
fratelim to boolper-IP write limit (30 writes per 60 s), keyed on the full IP (64-bit FNV-1a, 256 slots, a full table evicts the oldest window); false = answer 429
fsetsbxuse the sandbox CSP for this response (fcspsb 1)

Inputs: every user-supplied value is length-checked by the caller of fqget/fbget (they cap at

  1. and escaped on output with fesc/fescc/fxesc. git args from users (refs, paths) MUST be checked by the slice: refuse a leading -, NUL, control bytes and .. segments, and pass them after -- where git allows.

5. Writes

Before any handler runs, froute answers 403 to a POST whose Origin header is present and is not exactly https://interplane.io or https://www.aienos.com (an absent Origin leaves the CSRF token to decide). Every POST handler MUST: require fmeth 3, sosess signed in (else 303 to /login), socsrfok (else 403), and the per-IP write limit fratelim to bool (false = 429). Then 303 back to the page.

Every link and form action is built from the base: flink, fputb, flocb. Never write a bare href="/ . The same page MUST be correct under X-Forge-Base: / and X-Forge-Base: /forge/.