Draft architecture

T3 Code Cloud Control Plane and Managed Endpoint Flow

A concrete topology for one user with a MacBook Pro desktop environment, a headless Mac mini environment, the T3 Code mobile app, and the hosted web UI. The control plane owns identity, grants, provisioning, endpoint records, and connection tickets. The managed endpoint carries both normal environment HTTP/WebSocket traffic and short signed control-over-data-plane requests such as credential minting.

Client -> Cloud: HTTPS + IdP JWT Cloud -> Env: HTTPS + cloud-signed request Env -> Cloud: env-signed response Client -> Env: HTTPS/WSS + local T3 auth

Security Invariant

A cloud user session is not environment authority. Remote access requires an authorized IdP user, a linked environment authenticated by its registered cloud-link key, and a one-time local bootstrap credential minted by the target T3 server.

T3 Cloud must not proxy normal app traffic. It brokers identity, provisioning, grants, endpoint records, and connect tickets. To connect a client, T3 Cloud sends a short-lived signed mint request through the managed endpoint to the target local T3 server. After token exchange, clients talk directly to https://env_abc.tunnels.t3code.com and wss://env_abc.tunnels.t3code.com/ws.

Minimal Credential Set

1. User session
Hosted IdP session/JWT on clients.

2. Cloud signing key
Private key controlled by T3 Cloud; public issuer metadata installed into linked environments.

3. Environment cloud-link keypair
Private key stored in Keychain/state dir; public key registered with T3 Cloud.

4. Local server authority
Local tokens carrying relay:write mint single-use bootstrap credentials.

5. Managed endpoint runtime credential
Endpoint runtime credential used only to expose the environment's managed endpoint.

Implementation Auth and Transport Matrix

This table is the contract to implement and validate against. The managed endpoint transport forwards bytes; it does not authorize T3 sessions.

Path Transport Auth Material Verifier Purpose
Client -> T3 Cloud HTTPS Hosted IdP session/JWT T3 Cloud List environments, manage grants, request connect.
T3 Cloud -> local T3 server HTTPS through managed endpoint Cloud-signed mint or health request with nonce, audience, expiry, and scope. Local T3 server Ask the linked environment to mint a one-time bootstrap credential.
Local T3 server -> T3 Cloud HTTPS response through managed endpoint, or direct HTTPS cloud API for status. Environment cloud-link signature. T3 Cloud Prove the real linked environment responded or reported status.
Client -> local T3 token exchange HTTPS through managed endpoint Single-use bootstrap credential minted by the local T3 server. Local T3 server Mint a scoped proof-bound environment access token.
Client -> local T3 WebSocket ticket API HTTPS through managed endpoint Scoped environment access token plus DPoP proof. Local T3 server Mint a short-lived ticket for one WebSocket connection.
Client -> local T3 WebSocket WSS through managed endpoint wsTicket query parameter. Local T3 server Run the existing app RPC protocol.
Endpoint runtime -> endpoint provider Provider-specific outbound tunnel connection Cloudflare tunnel token today; T3 relay connector token later. Cloudflare Tunnel or T3 Relay Expose the loopback T3 server as a stable public HTTPS/WSS endpoint.
APNs -> mobile app APNs push transport Apple push token and APNs provider auth. Apple APNs and mobile app. Wake or update mobile UI with minimal status, not full agent traffic.
Do not add an app-session authorization dependency to Cloudflare Tunnel or T3 Relay. The endpoint provider may authenticate the connector, but local T3 auth remains the only verifier for bootstrap credentials, scoped access tokens, WebSocket tickets, and commands. The endpoint runtime credential authenticates the connector to the endpoint provider; it is not a client-facing access gate for the public hostname.

Overall Actor Diagram

Service-level auth/control/data lanes
User path The hosted IdP authenticates the human. Desktop, mobile, and hosted web present IdP sessions to T3 Cloud for account-scoped API calls.
Control plane T3 Cloud stores links, grants, endpoint records, audit events, and short-lived connect tickets. It reaches environments through signed requests over their managed endpoints, not through a persistent per-environment control channel.
Data plane Cloudflare Tunnel is the first managed endpoint transport. Later T3 Relay keeps the same httpBaseUrl/wsBaseUrl client contract.
Local authority The loopback T3 server remains the execution boundary and mints the one-time credential required before remote clients can open a normal session.

Credential Ownership

Credential Stored By Presented To What It Proves Implementation Rule
Hosted IdP session/JWT Desktop renderer, mobile app, hosted web browser. T3 Cloud control plane. The human user and account identity. Never treat this as local environment authority.
Cloud signing key T3 Cloud secret storage or signing service. Linked local T3 servers. The request came from T3 Cloud and was authorized by cloud policy. Use short expiries, nonce/jti replay protection, audience, and scoped claims.
Environment cloud-link private key Local T3 server on MacBook or Mac mini. T3 Cloud. The response/status came from the linked environment. Private key never leaves the environment; public key is registered in T3 Cloud.
Managed endpoint runtime credential Local environment sidecar/runtime. Cloudflare Tunnel today; T3 Relay later. The connector may expose this loopback origin through the endpoint provider. Do not use this as T3 app authorization; rotate on unlink or suspected compromise.
Single-use bootstrap credential Minted by local T3 server; returned to the requesting client via T3 Cloud. Local T3 server over managed endpoint. The client completed cloud authorization and environment minting. Single use, short TTL, bound to environment and cloud request nonce.
Environment access token Remote client after token exchange. Local T3 server over managed endpoint. The client has the granted environment scopes and proof key. Issued and revoked only by the local T3 server.
WebSocket ticket Remote client, briefly. Local T3 WebSocket endpoint. The WebSocket was opened by a client with a valid scoped access token. Short-lived, one connection, verified by existing T3 WebSocket auth.
APNs token Mobile app and T3 Cloud. Apple APNs. User/device notification and Live Activity delivery target. Account-scoped token. Environment links and preferences decide which environment updates fan out to that user's devices. Never include full agent traffic or secrets in push payloads.

How To Read The Sequence Diagrams

Each participant name includes where it runs. Arrows are concrete service boundaries: hosted IdP auth, local app-to-environment calls, T3 Cloud API calls, signed control-over-data-plane requests, managed endpoint traffic, or APNs delivery.

The hosted IdP never calls into a MacBook or Mac mini. An IdP arrow back to a client means the client-side auth SDK or hosted auth page finished sign-in and the client now has an IdP session/JWT.

Endpoint Contracts

Names are draft, but these contracts are the behavioral boundary. All timestamps are ISO strings. All nonces and token ids must be replay-protected until their expiry window has passed.

Cloud API: Request Remote Connect

POST /v1/environments/:environmentId/connect
Authorization: Bearer <idp-jwt>
DPoP: <client-proof-jwt>

Request body
{
  "clientKeyThumbprint": "jkt_..."
}

Response 200
{
  "environmentId": "env_mbp",
  "httpBaseUrl": "https://env_mbp.tunnels.t3code.com/",
  "wsBaseUrl": "wss://env_mbp.tunnels.t3code.com/ws",
  "credential": "one_time_bootstrap_...",
  "expiresAt": "2026-05-25T12:00:30.000Z"
}

Cloud -> Environment: Mint Credential

POST https://env_mbp.tunnels.t3code.com/api/t3-cloud/mint-credential
Authorization: T3Cloud <cloud-signed-jwt>
Content-Type: application/json

Cloud-signed claims
{
  "iss": "https://cloud.t3code.com",
  "aud": "t3-env:env_mbp",
  "sub": "user_123",
  "deviceId": "device_456",
  "cnf": { "jkt": "jkt_..." },
  "scope": ["environment:connect"],
  "nonce": "nonce_...",
  "jti": "mint_request_...",
  "exp": 1780000030
}

Environment-signed response 200
{
  "environmentId": "env_mbp",
  "nonce": "nonce_...",
  "credential": "one_time_bootstrap_...",
  "expiresAt": "2026-05-25T12:00:30.000Z",
  "signature": "env_signature_..."
}

Client -> Environment: Exchange Proof-Bound Bootstrap Grant

POST https://env_mbp.tunnels.t3code.com/oauth/token
DPoP: <client-proof-jwt-for-token-url>
Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:token-exchange
&subject_token=one_time_bootstrap_...
&subject_token_type=urn:t3:params:oauth:token-type:environment-bootstrap
&requested_token_type=urn:ietf:params:oauth:token-type:access_token
&scope=orchestration:read%20orchestration:operate%20terminal:operate%20review:write

Response 200
{
  "access_token": "env_access_...",
  "issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
  "token_type": "DPoP",
  "expires_in": 3600,
  "scope": "orchestration:read orchestration:operate terminal:operate review:write"
}
The client generates an ephemeral proof key before requesting connect. T3 Cloud includes the key thumbprint in the signed mint request, and the local T3 server binds the one-time bootstrap credential to that thumbprint. A cloud service that can see the minted credential still cannot redeem it without the client's private proof key.

Client -> Environment: Existing WebSocket Flow

POST https://env_mbp.tunnels.t3code.com/api/auth/websocket-ticket
Authorization: DPoP <env_access_token>
DPoP: <client-proof-jwt-for-ticket-url>

Response 200
{ "ticket": "ws_ticket_...", "expiresAt": "2026-05-25T12:01:00.000Z" }

GET wss://env_mbp.tunnels.t3code.com/ws?wsTicket=ws_ticket_...

Environment -> Cloud: Status For Notifications

POST /v1/environments/:environmentId/status
Authorization: T3Environment <env-signed-jwt-or-dpop-proof>

{
  "environmentId": "env_mbp",
  "status": "online",
  "summary": {
    "activeThreadId": "thread_123",
    "state": "agent_running"
  },
  "issuedAt": "2026-05-25T12:00:00.000Z",
  "nonce": "nonce_..."
}
These contracts preserve the current app protocol. Only the cloud connect flow and the local /api/t3-cloud/mint-credential endpoint are new. Bootstrap grants, scoped access tokens, and WebSocket tickets stay owned by the local T3 server.

Flow 1: Link MacBook Desktop Environment

sequenceDiagram
  actor User as User on MacBook
  participant Desktop as Desktop app on MacBook
  participant IdP as Hosted IdP
  participant Env as T3 server env_mbp on MacBook
  participant Cloud as T3 Cloud control plane
  participant Endpoint as Managed endpoint platform

  Note over Desktop,Env: Both run on the MacBook. The IdP never calls into the MacBook directly.
  User->>Desktop: Click Link cloud account
  Desktop->>IdP: Official hosted IdP sign-in flow
  IdP-->>Desktop: IdP session and JWT
  Desktop->>Env: Local owner-authorized link request with IdP JWT
  Env->>Env: Get or create cloud-link keypair
  Note right of Env: Private key stays local.
  Env->>Cloud: Link env_mbp with IdP JWT + descriptor + public key
  Cloud->>Cloud: Verify IdP user and store env grant/link record
  Cloud->>Endpoint: Create managed endpoint for env_mbp
  Endpoint-->>Cloud: Endpoint URLs and local runtime config
  Cloud-->>Env: Link accepted with endpoint config
  Env->>Env: Persist cloud link, cloud issuer metadata, and endpoint runtime config
  Env->>Endpoint: Maintain managed endpoint to loopback origin
  Cloud->>Endpoint: Optional signed health check through managed endpoint
  Endpoint->>Env: Forward health check to loopback origin
  Env-->>Endpoint: Signed environment health response
  Endpoint-->>Cloud: Environment health response
  Env-->>Desktop: Linked account and endpoint status
          
Flow 1 has three service boundaries: the hosted IdP proves the human user, the local T3 environment proves local machine authority, and T3 Cloud creates the cloud link plus managed endpoint. Health and credential-mint requests use the endpoint instead of a persistent environment control channel.

Flow 2: Link Headless Mac Mini

sequenceDiagram
  actor Admin as User in browser
  participant IdP as Hosted IdP
  participant CLI as t3 cloud login on Mac mini
  participant Env as T3 server env_mini on Mac mini
  participant Cloud as T3 Cloud control plane
  participant Endpoint as Managed endpoint platform

  CLI->>Env: Local owner-authorized headless link request
  Env->>Env: Get or create cloud-link keypair
  Env-->>CLI: Environment descriptor and public cloud-link key
  Note right of Env: Private key stays local.
  CLI->>Cloud: Start device-link request with descriptor and public key
  Cloud-->>CLI: Browser URL and short code
  CLI-->>Admin: Print URL and code
  Admin->>IdP: Open URL and sign in
  IdP-->>Admin: IdP session and JWT
  Admin->>Cloud: Approve device-link request with IdP JWT and code
  Cloud->>Cloud: Verify IdP user and store env grant/link record
  CLI->>Cloud: Poll until device-link request is approved
  Cloud->>Endpoint: Create managed endpoint for env_mini
  Endpoint-->>Cloud: Endpoint URLs and local runtime config
  Cloud-->>CLI: Link accepted with endpoint config
  CLI->>Env: Install endpoint config, cloud issuer metadata, and enable cloud link
  Env->>Env: Persist cloud link and endpoint runtime config
  Env->>Endpoint: Maintain managed endpoint to loopback origin
  Cloud->>Endpoint: Optional signed health check through managed endpoint
  Endpoint->>Env: Forward health check to loopback origin
  Env-->>Endpoint: Signed environment health response
  Endpoint-->>Cloud: Environment health response
          
This is the headless equivalent of desktop setup. The end state is identical: env_mini has a local cloud-link key, a managed endpoint connection, and a local endpoint that can verify signed cloud requests. The browser only approves the login; it never talks to the Mac mini directly.

Flow 3: Remote Connect Bootstrap

sequenceDiagram
  participant Client as Mobile or hosted web client
  participant Cloud as T3 Cloud control plane
  participant Endpoint as Managed endpoint data plane
  participant Env as Target T3 server on loopback

  Client->>Client: Generate ephemeral proof key
  Client->>Cloud: POST /v1/environments/:id/connect with IdP JWT + DPoP proof
  Cloud->>Cloud: Verify IdP user, grant, endpoint record, and connect policy
  Cloud->>Cloud: Create short-lived signed mint request bound to client key thumbprint
  Cloud->>Endpoint: POST /api/t3-cloud/mint-credential with signed request
  Endpoint->>Env: Forward signed mint request to loopback origin
  Env->>Env: Verify cloud signature, audience, expiry, nonce, link state, and key binding
  Env-->>Endpoint: Single-use proof-bound bootstrap credential and signed response
  Endpoint-->>Cloud: Single-use bootstrap credential and signed response
  Cloud->>Cloud: Verify environment signature and consume connect ticket
  Cloud-->>Client: httpBaseUrl, wsBaseUrl, one-time credential
  Client->>Endpoint: POST /oauth/token with credential, scopes, and DPoP proof
  Endpoint->>Env: Forward request to loopback origin
  Env->>Env: Verify proof matches credential key binding
  Env-->>Endpoint: Scoped DPoP access token response
  Endpoint-->>Client: Scoped DPoP access token response
  Client->>Endpoint: POST /api/auth/websocket-ticket using DPoP access token
  Endpoint-->>Client: Short-lived wsTicket
  Client->>Endpoint: Open WebSocket with wsTicket
          
T3 Cloud authorizes the account, but the environment still decides whether to mint the credential. The request reaches the local server through the managed endpoint, so the first implementation can infer reachability at connect time instead of maintaining a separate cloud-side presence service.

Flow 4: Mobile and Hosted Web Discover Environments

sequenceDiagram
  participant Client as Mobile app or hosted web UI
  participant IdP as Hosted IdP
  participant Cloud as T3 Cloud control plane
  participant Endpoint as Managed endpoint data plane
  participant Env as Target T3 server

  Client->>IdP: Official hosted IdP sign-in flow
  IdP-->>Client: IdP session and JWT
  Client->>Cloud: GET /v1/environments with IdP JWT
  Cloud->>Cloud: Verify user and lookup grants and endpoint records
  Cloud-->>Client: Environment list and endpoint records
  Client->>Cloud: POST /v1/environments/:id/connect with DPoP proof
  Cloud->>Endpoint: Signed proof-bound mint request over managed endpoint
  Endpoint->>Env: Forward signed mint request to loopback server
  Env-->>Endpoint: Single-use proof-bound bootstrap credential
  Endpoint-->>Cloud: Single-use bootstrap credential
  Cloud-->>Client: Endpoint URLs and one-time credential
  Client->>Endpoint: Exchange grant for scoped DPoP token and open WebSocket with ticket
  Endpoint->>Env: Forward app protocol to loopback server
          
Discovery stays cloud-mediated. Normal session traffic is direct to the managed endpoint after connect, not streamed through T3 Cloud.

Agent Traffic Over Managed Endpoint

App protocol stays HTTP + WebSocket
sequenceDiagram
  participant Client as Mobile or hosted web client
  participant Cloud as T3 Cloud control plane
  participant Endpoint as Cloudflare Tunnel or T3 Relay edge
  participant Env as T3 server loopback origin

  Client->>Cloud: Connect request with IdP JWT + DPoP proof
  Cloud->>Endpoint: Signed proof-bound mint request over managed endpoint
  Endpoint->>Env: Forward signed mint request to loopback origin
  Env-->>Endpoint: One-time proof-bound bootstrap credential
  Endpoint-->>Cloud: One-time bootstrap credential
  Cloud-->>Client: Endpoint URLs and one-time bootstrap credential
  Client->>Endpoint: HTTPS token exchange with requested scopes and DPoP proof
  Endpoint->>Env: Forward request over managed endpoint to loopback origin
  Env-->>Endpoint: Scoped DPoP access token response
  Endpoint-->>Client: Scoped DPoP access token established
  Client->>Endpoint: WebSocket RPC stream
  Endpoint->>Env: Forward WebSocket frames to existing T3 protocol
  Env-->>Endpoint: Agent chunks, status, command results
  Endpoint-->>Client: Agent chunks, status, command results
        
Cloud before traffic The control plane authorizes the user, checks grants, creates a short-lived signed mint request, and sends it through the managed endpoint to the target environment.
Data plane during traffic Normal agent chunks and command RPC use the existing environment HTTP/WebSocket protocol through the managed endpoint. T3 Cloud is not in this hot path.
Environment remains the boundary The local T3 server authenticates the bootstrap credential, mints WebSocket tickets, and can reject commands based on local policy or approval state.

Push Notifications and Live Activities

Minimal payloads, control-plane state
sequenceDiagram
  participant Mobile as T3 mobile app
  participant IdP as Hosted IdP
  participant Cloud as T3 Cloud control plane
  participant APNs as Apple APNs
  participant Env as Local T3 server

  Mobile->>IdP: Sign in with hosted IdP
  IdP-->>Mobile: IdP session and JWT
  Mobile->>Cloud: Register APNs and Live Activity tokens with IdP JWT
  Cloud->>Cloud: Store token per user/device with agent-awareness preferences
  Env->>Cloud: Publish minimal status via cloud API or webhook with cloud-link signature
  Cloud->>Cloud: Select linked users for the publishing environment
  Cloud->>Cloud: Store latest summary and notification state
  Cloud->>APNs: Send minimal notification or Live Activity payload
  APNs-->>Mobile: Deliver push or Live Activity update
  Mobile->>Cloud: App foregrounds and requests connect
  Cloud-->>Mobile: Endpoint URLs and bootstrap credential
        
Push payloads should be summaries: environment id, thread id, status, counters, and a short title if product policy allows. Full agent chunks are fetched from the environment over the managed endpoint after authentication.

Hosted Web UI Monitoring

sequenceDiagram
  participant Browser as Browser on other device
  participant IdP as Hosted IdP
  participant Cloud as T3 Cloud control plane
  participant Endpoint as Managed endpoint data plane
  participant Env as env_mbp or env_mini

  Browser->>IdP: Open app.t3.codes and sign in
  IdP-->>Browser: IdP session and JWT
  Browser->>Cloud: GET linked environments with IdP JWT
  Cloud-->>Browser: env_mbp and env_mini metadata
  Browser->>Cloud: Connect to selected environment
  Cloud->>Endpoint: Signed mint request over managed endpoint
  Endpoint->>Env: Forward signed mint request to loopback local server
  Env-->>Endpoint: One-time bootstrap credential
  Endpoint-->>Cloud: One-time bootstrap credential
  Cloud-->>Browser: Endpoint URLs and one-time credential
  Browser->>Endpoint: Exchange bootstrap grant for scoped DPoP access token
  Endpoint->>Env: Forward to loopback local server
  Browser->>Endpoint: Open WebSocket RPC stream
  Env-->>Endpoint: Live chunks and status
  Endpoint-->>Browser: Live chunks and status
  opt User starts an agent remotely
    Browser->>Endpoint: Command request over existing WebSocket
    Env->>Env: Local policy check
    Env-->>Endpoint: Accept or reject
    Endpoint-->>Browser: Accept or reject
  end
          

Account Mismatch Rule

Compare two identities The environment link state says env_mbp is linked to User A. The renderer IdP browser session may currently be User B.
Match If the renderer user and environment link match, show normal cloud management: refresh endpoint, unlink, rotate, and configure.
Mismatch If they differ, show linked-as User A and signed-in-as User B. Allow sign out, sign in as the linked user, or an explicit unlink/switch flow.
Never allowed Do not silently replace the linked account, treat the renderer cookie as environment authority, or issue connect credentials unless that cloud user is explicitly granted.
The displayed cloud account for an environment comes from the environment link state, not from whatever IdP session currently exists in the renderer.

End-to-End Setup Checklist For This Use Case

1. MacBook Pro desktop Start desktop app. User signs in with the hosted IdP. env_mbp registers its descriptor and cloud-link public key, receives a managed endpoint, enables the managed endpoint runtime, and accepts signed cloud mint requests through that endpoint.
2. Mac mini headless server Run t3 cloud login. Complete device/browser login as the same T3 user or org. env_mini registers its own cloud-link key, receives its own managed endpoint, enables the managed endpoint runtime, and accepts signed cloud mint requests through that endpoint.
3. MacBook remote environment entry Add Mac mini as a remote environment using existing direct auth such as SSH, pairing, or private network. This is for direct local/private management; the cloud link is a separate managed endpoint record.
4. Mobile app Sign into the T3 Code mobile app with the hosted IdP. Register APNs and Live Activity tokens. The app lists env_mbp and env_mini, asks T3 Cloud to connect, then opens HTTP/WebSocket traffic directly against the selected endpoint.
5. Hosted web Sign into app.t3.codes. It lists the same linked environments and exchanges for a direct managed-endpoint access token the same way mobile does.

Managed Endpoint Boundary

Cloudflare Tunnel is a transport choice, not the product architecture
Stable client contract T3 Cloud returns httpBaseUrl, wsBaseUrl, and a one-time credential. Clients do not know whether the endpoint is backed by Cloudflare Tunnel or a future T3 relay.
Cloudflare Tunnel today Provision one tunnel per environment, configure ingress to http://127.0.0.1:<serverPort>, create the public hostname, and give the linked environment only the endpoint credential it needs to expose that endpoint. T3 Cloud reaches the environment through signed HTTPS requests to that endpoint.
Request-time reachability V1 does not maintain authoritative online presence for each environment. The control plane infers reachability when it attempts a signed health or credential-mint request over the managed endpoint, then returns a concrete connect result or a timeout/failure.
T3 Relay later Replace the endpoint runtime with t3-relayd connect ... and keep the same managed endpoint, control-plane, and local credential semantics. The relay can add purpose-built stateful behavior later without changing client bootstrap semantics.

Implementation Validation Checklist

Cloud user auth is isolated A valid IdP JWT can list cloud environments and request connect, but cannot call local T3 app APIs directly without a local bootstrap credential.
Cloud-signed mint requests are strict The local T3 server rejects mint requests with the wrong issuer, audience, environment id, scope, expiry, nonce, replayed jti, or client key binding.
Environment responses are authenticated T3 Cloud rejects credential and health responses that are missing the environment cloud-link signature or are signed by a key other than the registered environment key.
Endpoint runtime auth is not app auth Stealing or rotating the Cloudflare tunnel token or future relay connector token does not create a valid T3 access token, WebSocket ticket, or environment-signed response.
Bootstrap credentials are one-shot The local T3 server rejects expired, replayed, wrong-environment, or wrong-nonce bootstrap credentials, and rejects proof-bound credentials unless the bootstrap request proves possession of the bound client key.
Existing WebSocket protocol stays unchanged After token exchange, remote clients use scoped access tokens and the wsTicket flow used for remote environments.
T3 Cloud is not in the hot path Agent chunks, command RPC, terminal traffic, and session WebSocket frames flow from client to managed endpoint to local T3 server, not through T3 Cloud.
Provider swap is observable only in endpoint metadata Replacing Cloudflare Tunnel with T3 Relay changes endpoint runtime provisioning and provider refs, but not client token exchange, scoped authorization, or WebSocket behavior.

V1 Infrastructure Primitives

Concrete stack for the first managed endpoint implementation
Concern V1 Primitive Source Of Truth? Implementation Notes
Control plane runtime Cloudflare Workers No, stateless runtime. Hosts T3 Cloud APIs, verifies IdP JWTs, provisions endpoint records, signs mint requests, receives status updates, and enqueues async work.
Hosted user identity Hosted IdP, v1 implementation: Clerk No, external identity authority. T3 Cloud verifies IdP JWTs and consumes IdP webhooks. Local T3 servers do not trust hosted IdP sessions directly.
Relational database PlanetScale Postgres via Cloudflare Hyperdrive Yes. Stores accounts, users, devices, environments, grants, cloud links, endpoint records, public environment keys, connect requests, notification targets, status snapshots, and audit events.
Database connection layer Cloudflare Hyperdrive No, connection/pooling layer. Workers connect to PlanetScale Postgres through Hyperdrive. Hyperdrive is never used as application state.
Cloud secrets Cloudflare Worker secret bindings No, secret source for Worker runtime. Use for IdP secrets, IdP webhook secret, Cloudflare API token, cloud mint signing private key, APNs provider credentials, and optional app encryption key. Do not use Secrets Store for v1 unless multiple independently deployed Workers need shared account-level secrets.
Environment private keys Local Keychain or local state directory Yes, for environment identity. Environment cloud-link private keys remain local only. T3 Cloud stores only the public key in PlanetScale.
Managed endpoint data plane Cloudflare Tunnel No, transport provider. First ManagedEndpointProvider. T3 Cloud provisions tunnels, DNS records, endpoint metadata, and one-time runtime config for the local environment.
Future data plane T3 Relay No, transport provider. Implements the same provider interface and client contract: httpBaseUrl, wsBaseUrl, and local T3 auth.
Async jobs Cloudflare Queues with dead-letter queues No, delivery mechanism. Use for endpoint provisioning, endpoint reconciliation, IdP webhook processing, unlink/rotate workflows, audit event fanout, and APNs delivery.
Push delivery Cloudflare Queues consumer -> Apple APNs No, delivery mechanism. Queue APNs jobs after status updates. Payloads are minimal and must not include full agent chunks, access tokens, bootstrap credentials, or WebSocket tickets.
Scheduled reconciliation Cloudflare Cron Triggers No, scheduler. Expire connect requests, reconcile pending tunnel provisioning, expire stale health observations, audit dangling tunnel/DNS records, and clean old link codes.
Blob/object storage Cloudflare R2, optional No for core auth/control state. Use only for diagnostics, exports, large redacted logs, or archived webhook payloads. PlanetScale remains the source of truth.
Coordination Database constraints, idempotency keys, queues PlanetScale is authoritative. Use explicit idempotency keys for link, provisioning, connect, notification, and rotation workflows. Keep the database as the durable coordination point for v1.
Observability Workers Observability, Analytics Engine, PlanetScale audit rows PlanetScale for durable audit events. Use Analytics Engine for high-cardinality operational/product metrics. Keep durable audit history in PlanetScale, with optional R2 exports.
Worker secret bindings are enough for the initial cloud secrets, and control-over-data-plane requests avoid persistent environment control sockets.

Design Anchors

These references are the standards this shape should align with. They are not product requirements by themselves, but they describe the secure patterns we should avoid reinventing badly.