System teardown · TrustedRouter Field Manual
Orientation

System teardown

A clickable map of the whole system, plus the codebase in numbers.

Video 01 The big picture · Clients, the attested gateway, the control plane, providers, and the trust boundary.

The system on one page

Click any box to open the chapter that covers it. The dashed outline is the hardware trust boundary: prompts exist only inside it and at the provider. Everything below the boundary sees metadata.

TrustedRouter system mapClients send prompts to the attested gateway, which calls providers and exchanges only metadata with the quill-router control plane. The control plane keeps money state in Spanner, drains analytics to ClickHouse, and is deployed by GitHub Actions to Cloud Run, AWS and Azure.SDKs, integrations and apps: open the SDK chapterClientsSDKs: py js go rustjava swift (+ C ABI)Plugins: llm, n8n,LlamaIndex, OpenClawApps: QuillCode, trpiTRUST BOUNDARY · ATTESTED TEEThe only place prompts exist: open the platform repos chapterAttested gatewayapi.trustedrouter.comrepo: quill-cloud-proxy (Go)GCP Confidential Space (TDX)AWS Nitro · Azure SEV-SNPTLS ends here · /attestationProvider catalog: open the product surface chapterProviders108 in catalogOpenAI · AnthropicGemini/VertexTinfoil · NEAR AIPrivatemode · ChutesPayment rails: open the money chapterPayments inStripe card/ACHPayPalLightningx402 (flagged)Adyen (dark)Control plane: open the architecture chapterControl plane · trustedrouter.comrepo: quill-router · Python/FastAPI · Cloud Run ×4 regions · no prompts in prodGateway callbacksGateway callbacksauthorize · heartbeatsettle · refundRouting & catalogRouting & catalogmin_privacy floorsaliases, pricingAuth & keysAuth & keyssk-tr hashes, OAuthBYOK via Cloud KMSCredit ledgerCredit ledgerreserve→settle→refundsettle outboxConsole & siteConsole & siteJinja pages, /chatSEO, Token ExchangeAsync settle (off)Async settle (off)shadow v2 gates~110 filesSpanner (AWS: DSQL, Azure: Postgres): open the data chapterSpannercredits, keys, holdsoutboxes · tr_entitiesClickHouseClickHouseanalytics, 3 replicasstatus, leaderboardfastpathfastpathGo pilotcredit leasesCI/CD and deploys: open the infra chapterShip itGitHub Actions28 workflowsCI: 3 gates,12+8 shardsrollout.shENV_VARSTerraform infra/Other cloudsOther cloudsAWS EU (ECS)Azure uaenorthpromptpromptmetadata only:key hash, model,token countswebhooks → creditsdraindeploy
prompt bytesmetadata only (internal token)control and data flowattested trust boundary

Teardown: what each layer is made of

LayerBuilt withLives inOwned stateBlast radius if wrong
Attested gatewayGo, Confidential Space / Nitro / SEV-SNPquill-cloud-proxyNone persistent; BYOK key cache in memoryPrivacy claim. A digest mismatch is caught by trust-drift.
Gateway callbacksFastAPI, routes/internal/gateway.py (6k lines)quill-routerAuthorizations, reservationsMoney: double charge or free usage
Credit ledgerSpanner typed tables, settle outbox, reaperquill-routertr_credit_balance, tr_key_limit, tr_reservationMoney; covered by the proof oracle and TLA+
Routing & catalogImport-time catalog, 92 provider JSON filesquill-routerPrices, privacy flagsMispricing, or a privacy floor routed to a non-qualifying provider
Storage layerStore protocol (210 methods), 3 production backendsquill-routerEverything durableSpanner CPU incidents; cross-cloud drift
AnalyticsSpanner outbox → ClickHouse (3 replicas)quill-router/clickhouseUsage events, rollupsStatus page, leaderboard, reports (not money)
DeliveryGitHub Actions, rollout.sh, Terraform.github/, scripts/deploy/, infra/Config-as-code ENV_VARSEvery merge to main can ship

The codebase in numbers

3,213commits since 2026-05-03
1,711merged PRs
194klines of Python source
343klines of Python tests
28GitHub workflows
25incident write-ups

Commits per month, by author

Oct* covers Oct 1–19. Bots are the hourly pricing bot and Dependabot.

Joseph PerlaJasmine LeeBots
0300600900May · Joseph Perla: 206 commitsMay · Bots: 195 commits401MayJun · Joseph Perla: 378 commitsJun · Bots: 46 commits424JunJul · Joseph Perla: 348 commitsJul · Bots: 47 commits395JulAug · Joseph Perla: 651 commitsAug · Bots: 182 commits833AugSep · Joseph Perla: 449 commitsSep · Jasmine Lee: 42 commitsSep · Bots: 64 commits555SepOct* · Joseph Perla: 417 commitsOct* · Jasmine Lee: 166 commitsOct* · Bots: 22 commits605Oct*
Table view
MonthJoseph PerlaJasmine LeeBots
May2060195
Jun378046
Jul348047
Aug6510182
Sep4494264
Oct*41716622

Python lines by top-level directory

Tests outweigh source by 1.77 to 1.

0100k200k300kteststests: 343,036 lines343,036srcsrc: 193,623 lines193,623scriptsscripts: 60,083 lines60,083clickhouseclickhouse: 9,394 lines9,394experimentsexperiments: 7,029 lines7,029proofsproofs: 3,015 lines3,015sitessites: 2,255 lines2,255

Largest source modules

Lines of code in src/trusted_router. The four largest are also the most-changed files.

02k4k6k8kstorage_postgres.pystorage_postgres.py: 7,869 lines7,869storage_gcp.pystorage_gcp.py: 7,406 lines7,406dashboard.pydashboard.py: 6,590 lines6,590routes/internal/gateway.pyroutes/internal/gateway.py: 6,062 lines6,062catalog_data.pycatalog_data.py: 4,456 lines4,456storage.pystorage.py: 4,103 lines4,103routes/public.pyroutes/public.py: 3,727 lines3,727synthetic/probes.pysynthetic/probes.py: 3,341 lines3,341config.pyconfig.py: 2,388 lines2,388competitor_comparisons.pycompetitor_comparisons.py: 2,349 lines2,349

Human-edited hotspots, last 90 days

Expect merge conflicts in these files.

FileChanges
src/trusted_router/routes/internal/gateway.py141
src/trusted_router/dashboard.py141
src/trusted_router/storage_gcp.py140
src/trusted_router/config.py134
scripts/deploy/rollout.sh119
src/trusted_router/static/og/providers/manifest.json112
src/trusted_router/storage_postgres.py105
src/trusted_router/routes/public.py102
src/trusted_router/catalog_data.py100
src/trusted_router/storage.py96