Skip to Content
turbo-12f
Architecture

UI and access

How t12-ui serves an embedded React SPA and live SSE flow graphs, enforces CSP/CSRF, manages mode/approvals/Observer, and delegates git and pipeline writes to t12.

Explanation

The web workbench (cmd/t12-ui) authenticates sessions from private JSON state, checks origin and CSRF tokens on every mutation, delegates git and pipeline writes to child t12 processes, and manages host control files (access/, approvals/, observer/) plus read-only Observer sessions directly.

Frontend

Embedded React SPA

React 19 + Optics UI bundled via Vite and embedded with zero-inline CSP.

Security

Auth, CSRF & RBAC

PBKDF2 passwords, 15m tokens, Tailscale Serve auth, and two-operator safety checks.

Engine

Subprocesses & SSE

Forks sibling t12 under lock sync, streams 500ms SSE graphs, and runs Observer.

Subprocess delegation and factory-wide controls

internal/ui (requests.go, control.go, mode.go, approvals.go, observer.go) reads projections directly from record.Home, internal/rollup, internal/roles/context, and internal/roles/release.

Control surfaceMechanism
Sibling t12 forksMutations spawn sibling("t12") (Setpgid: true), inject T12_AUTONOMY from mode.json, and stream T12_UI_PROGRESS=1 output to liveBuffer (80 lines) and commands/<job>.log (0600).
External lock syncactionSlot probes LockContext/LockAsk/LockConfirm/LockRelease via Home.RequestLocked; buildSlot probes LockRun; controlOf clears stale Paused/Stopped markers when external CLI locks run.
Graceful haltPause, stop, and shutdown terminate process groups (SIGTERM, 5s haltGrace, SIGKILL); Server.Close() closes s.closed and BaseContext so open SSE streams exit cleanly.
Permission & approvalsModeMenu inside PromptBar writes <home>/access/mode.json (review, default, auto, turbo). In Request Review, CommandApprovals posts decisions to <home>/approvals/<YYYY-MM-DDTHH>/<id>.decision.json.
Observer loop<ObserverBubble> drawer and /observer write scoped projects/conversations to <home>/access/observer.json. Every 10s, SessionDecider resolves 9 kinds via Server handlers and logs to observer/log.jsonl.
Setup & docs chatsetup.Manager (setup.go) drives OAuth, API key, and test flows for GitHub, agy, omp, and claude; docschat.Wrap serves /api/docs-chat SSE answers on t12-ui and --serve-dir.

Embedded SPA and CSP hardening

server.go embeds the built frontend via //go:embed all:web/dist and enforces strict browser headers:

Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self'; font-src 'self'; img-src 'self' blob:; connect-src 'self'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'
  • Headers & images: Pairs zero-inline CSP with X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: same-origin, and Cache-Control: no-store. GET /api/c/{id}/images/{name} checks conversation access and image MIME types.
  • Origin, CSRF & cookies: sameOrigin matches Origin to Server.BaseURL or r.Host; signed-in POSTs verify X-CSRF-Token with subtle.ConstantTimeCompare against store.SHA256("csrf:" + session)[:32]. Cookies set HttpOnly, SameSiteLaxMode, and Secure on https.
  • Build-time CSP patches: cspSafeLibraries in vite.config.ts rewrites runtime <style> injectors in sonner, vaul-base, and number-flow.

The app only presses buttons

Flow
100%
cookiePOSTroleallowedrunsappendsderivesreadsproposesAuth & sign-inpw · Tailscale · linkBrowser sessionmember or testerAccess store0600 · mode · observerRequest guardsOrigin · CSRF · RBACt12-ui server1 slot · SSE · ObserverRollup viewsread-only snapshotRecord logwrites evidence chaint12 CLI coret12 <verb> --by <mail>proposals/ queuenon-OS safety keys

Every UI POST passes Origin, CSRF, and role guards before executing sibling t12 verbs or updating access, approval, and Observer stores.

Click any node or press Play

Access model and two-operator safety approval

internal/access (access.go, password.go) persists users, teams, PBKDF2 hashes, Tailscale aliases, tokens, sessions, testers, and pending requests in <home>/access/access.json (0600 under access/lock, audited to access/log.jsonl).

MechanismDetails
Secret & password storagestore.SHA256 hashes for tokens/sessions; salted PBKDF2-SHA256 (600,000 iterations) with rate limits (10/account, 30/IP per 15m)
Sign-in linksLinkTTL (15m), SignInEvery (1m) throttle, constant-shape responses; /link requires click POST (redeem)
Tailscale auto-login--trust-tailscale (T12_TRUST_TAILSCALE, auto on https://*.ts.net) reads Tailscale-User-Login over loopback unless t12_ts_out=1
Sessions & access askst12_session cookie (30 days); up to 50 pending access requests (24h TTL) verified via 6-char code
RolesOperators (ui.Local first sign-up, --bootstrap, set-password --operator), Editors, Viewers, Acceptors, Bug-bash testers
Project access & lifecycleOperators or project Editors share project access (/api/p/{project}/access/*); Operators archive, restore, or delete projects (/api/p/{project}/archive and /api/p/{project}/delete)
Profiles & notificationsPer-user Observer profiles (access/profiles/<hash>.json) and notification state (access/notifications/<hash>.json) power /onboarding, /profile, /settings, and the header bell

Changing a safety-group preference writes proposals/config-<key>-<ts>.json and requires Operator approval (POST /api/p/{project}/preferences/decide). With multiple Operators, authors cannot approve their own proposals; a sole Operator must pass confirm=1.

React 19 SPA architecture

The frontend under internal/ui/web uses React 19, React Router, Tailwind CSS v4, Optics UI primitives under src/components/optics/ (including popover.tsx, select.tsx, sheet.tsx, and switch.tsx), and OKLCH tokens in index.css. That directory is the factory UI's own component set and evolves independently of the minimal starter subset under catalogue/templates/web-react/src/client/components/optics/.

Data fetching, live controls, and views

LayerImplementation and cadence
Page polling (usePage)Fetches JSON and polls every 5000ms while data.busy or data.working is true
Home cache & ProjectSyncCoalesced fetchHome/ensureFreshHome plus GET /api/projects on confirms, unseen projects, /access transfers, focus, and 60s timer (homeCache + project.NameAt on server)
Global controls (useLive<T>)Shared timer per key (mode 15s, approvals 3s, observer 3s), pausing when tab is hidden
Navigation & workspaceSidebar search, click-to-expand project conversation trees, centered PromptBar composer on / with ModeMenu permission, and unified /c/:id workspace (JourneyBar, inline Confirm, LiveActivityCard, DeliveryWorkspace)
Intake, setup & guidanceRepoPicker, multi-issue IssuePicker (POST /api/c/{id}/issues), 5 images, AgentPicker (availability), ErrorBoundary, classifyError guidance, Decide for me, and ViewSwitch (?view=detailed)
Live flow canvas & SSE (useFlowStream)#flow-preview and #flow (layoutFlowGraph, useDiagramCamera) subscribe to GET /api/c/{id}/stream (500ms ticks, 15s keepalives, 300ms throttle) with 5000ms /graph fallback

Key takeaway

t12-ui never implements separate git or build logic: it acts as an authenticated, CSP-hardened control plane over t12 subprocesses, lock files, and SSE projections.

Next steps

On this page