stan.computer #
A forge for specs — like a code forge, but for specifications. Specs are
written and versioned here, stored as group.standards.* records in their
authors' own AT Protocol repos, rendered in the DASL
style, and readable by anyone. See SPEC.md for the product spec.
Layout #
| Path | What |
|---|---|
lexicons/group/standards/ |
The data model: spec, section, block, version records; richtext facets; the getSpec, listSpecs, requestTracking XRPC methods. |
shared/ |
Isomorphic core (TypeScript, run as-is by Node and bundled by Vite): rich-text layout, folding records into a document, HTML and Markdown renderers, the editor draft → save-plan logic, DID resolution. |
server/ |
The Node server: SQLite index fed by Tap (or by polling PDSes in dev), /xrpc/group.standards.*, /<handle>/<shortname>/html and /md, /blob/:did/:cid redirects, and the built app. |
web/ |
The app: Lit 3 + refrakt, atproto OAuth, path-routed, styled with supram (@supramundane/supram). The account page, the rendered spec view, and the spec editor, which is draft (@portent/draft) with stan's metadata around it, stan's catalogue as its reference source, and its records converted to and from draft's document in editor/convert.ts. Suggestions and comments made in the editor are reviewed before a save (the records carry the settled text). |
tap/ |
The dedicated Tap instance, as its own sm service. |
test/ |
node --test over the shared core. |
Dockerfile, compose.yaml, service.json |
The deployable unit for sm. |
Development #
npm install
npm run dev # server on 127.0.0.1:3000 (polling PDSes, no Tap needed) + Vite on 127.0.0.1:5173
npm test # shared core
npm run typecheck # web + server
npm run build # web/dist
Open http://127.0.0.1:5173/. Sign in with your handle: in dev the atproto
loopback OAuth client is used, so nothing needs registering. Your specs live
at /<your.handle>; create one there and the editor opens.
Without STANDARDS_TAP_URL, the server lists the group.standards.*
collections of every tracked repo straight from its PDS (every 30s, and
immediately after a save), which is enough for local work. To consume the
real Tap instead: STANDARDS_TAP_URL=… STANDARDS_TAP_PASSWORD=… npm run dev.
Data model #
- A spec record (
group.standards.spec, TID rkey) holds the metadata (shortname, title, abstract, editors, status) and its top-level sections by AT URI. A section holds a title, an id, its content blocks and subsections by AT URI. A block is a paragraph, image, code, math, list, or definition list. - A spec also carries its card banner: a
colourfrom the DASL palette and anemoji. The server rasterises it at/<handle>/<shortname>/banner.png(resvg-wasm + Twemoji, cached under the data dir) and puts it in the Open Graph tags of both the/htmlrendering and the app page. - A list item is its text plus an optional nested list (
#listItem); early records with text-only items and bare nested lists are read and rewritten in that shape. - Titles and terms are simple rich text (bold, italic, code, sub, sup);
prose is full rich text, adding links, inline math, definitions,
definition references, and bibliographic references. Facets use UTF-8 byte
offsets, as
app.bsky.richtext.facetdoes. - Live records keep their URIs. On save, each changed record's previous
state is written as a
group.standards.versionrecord and linked from the new state throughprev; the spec record's ownprevchain (with optional labels) is the save history. Removed records are archived the same way, then deleted. - The editor reads the owner's records straight from their PDS (so it never
lags the index) and writes a save as one
applyWritescommit. Save (⌘S) writes what changed; Snapshot (⌘⇧S) also gives the version a name and records one even when nothing changed. Readers getgroup.standards.getSpec, which folds the index's records into one document./htmland/mdrender that same document server-side with the same renderers the app uses.
The reference catalogue #
Specs cite other specs and reuse their terms, so the site keeps a catalogue
of what can be cited, as records in an ordinary atproto account (the refs
account, STANDARDS_REFS_HANDLE):
group.standards.ref, one per citable spec, rkey = citation key: the webref shortname (html,css-color-4,EXT_sRGB) orrfcNNNN. It holds the title, the URL to cite (the latest published version, with the editor's draft asnightly), organisation, status, date, series, obsoletion, and for RFCs the abstract.group.standards.terms, the terms a spec exports, in parts of ~60 KB (rkey<key>.<part>): linking text, type (interface,method…), what it isfor, and the definition's URL.
Two sources feed it (server/refs/):
- webref —
https://w3c.github.io/webref/ed/index.jsonlists the web platform's specs (W3C, WHATWG, the IETF HTTP specs, Ecma, Khronos…) anddfns/<shortname>.jsontheir definitions; only the exported (public) ones become terms. - the RFC Editor —
rfc-index.xmllists every RFC; those published in RFCXML (v3) also get their terms from the definition lists in sections named Terminology, Definitions, Glossary or the like, linked to the HTML rendering's anchors. RFCs never change, so this is done once per RFC.
When the same key comes from both (rfc9110), the RFC Editor's metadata wins and webref's nightly URL and terms are kept.
The server syncs the catalogue itself, daily (STANDARDS_REFS_INTERVAL), on
boot when the last run is older than that, and hourly while it has work
left: a run reads the account's records and the sources, rewrites only what
changed (terms only for specs whose source revision moved, at most
STANDARDS_REFS_TERM_BUDGET per run), and stops at the PDS's write rate
limit (5000 points an hour on the reference PDS: a create is 3) to carry on
next time. The first fill of ~10,000 records therefore takes a few hours.
npm run refs runs one sync by hand with the same environment.
In a spec, the metadata's imports row adds catalogue references
(searched by key or title). Their terms then show up when typing @, next
to the spec's own definitions, and are inserted as definition references
pointing at the term's URL (dfnRef with ref and uri); the rendering
links out and cites the reference in References. Typing [ searches the
catalogue too, and a picked entry brings its title and URL along. The XRPC
side is group.standards.searchRefs, searchTerms and getRef, all
answered from the index, which tracks the refs account like any other repo.
Setting it up: create the account on any PDS (say refs.stan.computer,
a handle verified by the _atproto.refs TXT record), make an app password,
put both in .env.prod as STANDARDS_REFS_HANDLE / STANDARDS_REFS_PASSWORD,
and deploy. The container logs each run (refs: …).
Deployment #
Two sm services on the supramundane network. sm deploy excludes .env
from its sync on purpose (secrets stay server-side), so each service's .env
has to exist on the server, next to its deployed compose.yaml; it survives
later deploys.
# 1. the Tap: create its server-side .env once, then deploy
cd tap
ssh root@$SUPRAMUNDANE 'mkdir -p /srv/supramundane/services/standards-tap && umask 077 && printf "TAP_ADMIN_PASSWORD=%s\n" "<password>" > /srv/supramundane/services/standards-tap/.env'
sm deploy
# 2. the site: .env.prod is pushed to the server by `standards deploy` itself
cd ..
cp .env.example .env.prod # set STANDARDS_TAP_PASSWORD to the same password
npm run deploy # scp .env.prod → server's .env, then sm deploy
Locally (sm deploy --local / npm run deploy:local) compose reads the
.env in the directory, so tap/.env and .env.local are enough.
Production OAuth uses web/public/oauth/client-metadata.json at
https://stan.computer/oauth/client-metadata.json; the loopback client is
only for 127.0.0.1:5173.