AGENTS.md #
Instructions for agents working in this repository. CLAUDE.md is a symlink here.
Commands #
Use Node 24.22.1 or a newer patched 24.x release and npm. Run npm ci,
npm test, npm run check, and npm run build after relevant changes.
TypeScript 6 matches the SvelteKit peer requirements. Do not force peer overrides.
Security boundaries #
The frontend is a static SvelteKit 3 build, served by Caddy. There is no Svelte SSR server, public filesystem API, or runtime npm dependency tree. CSP hashes for Svelte's bootstrap are generated at build time. Caddy supplies frame denial and the other response headers. Do not reintroduce inline event handlers or styles without checking the CSP. Browser output must never contain secrets.
service/server.mjs is a small Node-builtins-only HTTP service bound to a Unix
socket. It has exactly two routes: GET /api/invite/config and POST /api/invite.
It has no PDS client or PDS admin credential. Startup explicitly refuses that
credential. It dispenses a finite SQLite pool; no request can mint new codes.
Do not add an admin endpoint, generic fetch proxy or test-mode security bypass.
service/refill.mjs is an offline command with no listener. Only this job gets
the PDS admin password. It can call only createInviteCode with useCount: 1.
Its mint ledger lives in a separate private volume, never mounted into the
issuer or public frontend. The pool database is shared, but deleting public
state must not reset the private mint budget. Ambiguous PDS writes remain
pending and consume capacity; do not automatically retry/refund them.
service/refresh.mjs fetches the public directory on a schedule, bounds pages,
accounts, response sizes, time and concurrency, and atomically replaces a JSON
snapshot. Failure leaves the previous file intact. It needs no admin key.
Page views read that snapshot and do not initiate PDS requests.
Admission and quotas #
The public farewell proxy overwrites X-Tea-Client-IP with its socket peer and X-Tea-Proxy-Key with a private shared key. The issuer verifies that key and the fixed Host before accepting the address. It ignores CF-Connecting-IP and XFF. Keep alternate ingresses fail-closed until the same authenticated contract is established. See deploy/farewell.caddy. Never trust a header solely by its name.
Sessions are signed, Secure, HttpOnly, SameSite=Strict cookies, with a separate CSRF value and session-bound Turnstile cdata. Check exact Origin for POST and reject cross-site Fetch Metadata. Turnstile hostname, action, cdata and token age are all validated server-side. The verification URL is fixed. Tokens are also replay-protected in SQLite. A session-bound request UUID makes retries return an existing code rather than allocate a second one. Cookies are not proof of one human: independent global budgets must remain enforced.
Quota checks and pool allocation happen in one BEGIN IMMEDIATE transaction. Do not hold database transactions over network I/O. IP, IPv6 /64, session, hourly-global and daily-global budgets persist across restarts and processes. Attempts and verification leases are also persistent and bounded. Raw IPs are not stored; identifiers use a private HMAC. Expired rows are cleaned up.
Deployment constraints #
Public, issuer and worker images are separate Docker targets. Public/issuer images must contain neither the admin key nor worker entry points; issuer has no node_modules. Runtime filesystems are read-only with explicit writable volumes. The public image has no Node runtime. Numeric UID 1000 is used in all images. Check shared-volume ownership and SELinux labels on deployment.
Secrets belong in separate mode-0600 env files/Podman secrets, never images, public JSON, error responses or logs. Do not log invite codes or raw upstream bodies. Keep proxy keys out of access/debug logs. Environment examples have no working keys; official Turnstile testing keys are rejected in production.
The current host's old emergency build override and Node health probe must be replaced together when deploying these targets. Do not push or activate a change without the user's authorization. Deployment examples target nadia's aletheia setup and farewell's existing Caddy/Tailscale transport.
The public Docker target rebuilds Caddy 2.11.7 with Go 1.27.3 and x/net 0.60.0 to fix vulnerabilities in the stock binary. Node runtime stages remove npm and Yarn. Scan the built runtime images as well as the application lockfile. Farewell's scoped pasta forwarder preserves real addresses while retaining its monitoring bridge; ordinary rootlessport forwarding collapses those addresses.