Cloud client and protocol
Temps Cloud is an optional remote control plane for a local Temps instance or a managed runtime. The local Cloud service links the runtime to that plane for enrollment, liveness, status, telemetry, backups, notifications, managed AI, and remote console access while keeping application traffic and core local work independent from the remote service. Worker agents and gateway services extend this link to managed Docker nodes and workload ingress.
System boundary
The cloud connection is a control path, not an application proxy. The local runtime keeps its own cached state and can keep deploying, serving applications, and storing local telemetry when the managed backend is slow or unavailable. See the Cloud control plane page for the remote service and Identity and team access for account and user access.
This diagram shows how local work reaches the remote control plane through separate service paths.
flowchart LR
R[Local or managed runtime]
S[Local Cloud service]
L[Cloud link and client]
C[Temps Cloud control plane]
A[Runtime agents]
G[AI gateway]
X[Console proxy]
W[Worker agent and workload gateways]
R --> S
S --> L
L -->|HTTPS and WebSocket| C
C -->|status, capability, and acknowledgements| L
L -->|authenticated node control| W
W -->|containers, services, and ingress| R
A -->|node and sandbox control| S
G -->|managed AI requests| L
X -->|streamed console requests| L
Cloud service
The Cloud service is the local owner of the link lifecycle. It loads the link, applies saved export choices, exposes local Cloud status and enrollment routes, and starts background work for telemetry, backups, notifications, and liveness.
Backup reporting has two related paths. A lifecycle notifier gives Cloud an early view of backup changes, while the backup mirror remains the source of truth and can be woken when a local backup completes. A Cloud-managed backup destination is tracked separately from the backup export switch because completed data can already be in a Cloud-owned bucket and still needs a Cloud catalog record.
The service treats Cloud as optional. A failed startup leaves the main console running and reports the Cloud problem as a local status issue instead of making the whole runtime fail.
References: crates/…/service.rs• L146-193 crates/…/service.rs• L238-332 crates/…/service.rs• L354-376
Local Cloud API
The local runtime exposes an authenticated Cloud API for status and capability display, enrollment, consent changes, backup setup, and disconnect. These routes keep operator actions local while the Cloud service performs the remote work. Link and feature changes are audited, and internal or upstream failures become safe problem responses rather than responses that expose configuration or provider secrets.
Fresh enrollment can also start a purchase-triggered telemetry activation for an instance administrator. The activation runs after the enrollment response and does not make a successful link fail if job creation or audit work fails. Re-enrollment to the same tenant does not repeat that spend-triggered action.
References: crates/…/handler.rs• L144-195 crates/…/handler.rs• L229-341 crates/…/handler.rs• L343-521 crates/…/handler.rs• L524-681
Cloud link
The Cloud link is the shared local connection object used by all Cloud-facing features. It holds the backend origin, stable instance identity, tenant link, encrypted credential state, export gates, pending telemetry, and current health.
The link turns local operations into bounded Cloud calls. Enrollment exchanges a short-lived operator code for an instance token. Later calls use that token to identify the instance and tenant. The link also owns disconnect and re-enrollment behavior so a stale or changed credential does not create a second hidden connection. It accepts only a trusted HTTPS origin in production and keeps credentials and buffered submissions tied to that origin.
The client uses short request limits and does not follow redirects for Cloud calls. This keeps a slow or changed backend from becoming an unbounded local wait or moving a bearer-token request to another origin.
Link state can live in the local encrypted state file or in encrypted control-plane state stored in PostgreSQL. A damaged state record blocks link mutations instead of being replaced, while an uncertain database write blocks later mutations until the control plane can be restarted safely.
References: crates/…/lib.rs• L87-189 crates/…/lib.rs• L262-338 crates/…/link.rs• L328-380 crates/…/link.rs• L401-519 crates/…/state.rs• L71-158
Console proxy
The console proxy gives Cloud an optional, operator-controlled path to the local console without making the local console an open public endpoint. It uses a dedicated WebSocket, separate from the liveness channel, and dispatches each Cloud stream into the in-process console router.
The proxy stays disabled until the Cloud link and local consent allow it. Cloud first provides the managed console identity configuration. The local owner must accept that configuration before the worker pins the console host and serves browser requests. A revoke or failed identity setup closes active streams and leaves routing disabled.
The proxy carries request and response bodies as bounded frames. It also supports WebSocket upgrades and flow control, so large responses and long-lived streams do not require whole-body buffering. The worker checks the pinned host, browser origin, client address, header limits, stream count, and idle time before dispatch.
The worker reconnects with bounded backoff. A short-lived connection does not reset an outage backoff until the relay stays up long enough to show recovery. A lost link or disabled consent affects console access only and does not stop local console operation.
References: crates/…/console_proxy.rs• L1-38 crates/…/console_proxy.rs• L164-255 crates/…/console_proxy.rs• L261-429 crates/…/console_proxy.rs• L821-1167 crates/…/console_proxy.rs• L1254-1660
Local-primary operation
The default mode is local primary with Cloud as a mirror. Cloud work runs in background tasks with short request limits and backoff, so a remote outage adds queue depth and status detail rather than application latency.
Telemetry can use an explicit Cloud-primary mode for selected projects. In that mode the durable local outbox is the handoff point until Cloud accepts the data. If Cloud access is withdrawn or its telemetry export gate is disabled, those projects return to local storage so new spans have a local owner.
References: crates/…/lib.rs• L4-22 crates/…/link.rs• L73-110 crates/…/outbox_worker.rs• L4-35
Link lifecycle and consent
Linking an instance proves who owns the Cloud account. It does not by itself grant permission to export each data class. The local service keeps identity, feature consent, managed backup destination state, and transport health as separate states.
Enrollment flow
Enrollment starts with a code copied from the Cloud console. The client sends the code with the stable instance ID and build version. Cloud returns the tenant ID, a long-lived instance token, and the tenant's current capabilities. The local service stores the link and then tries to provision a Cloud-managed backup source when the tenant supports it.
Managed backup provisioning does not make enrollment fail. If Cloud has not prepared a destination or the local persistence step fails, the instance remains linked and reports a setup state that can be retried. Re-enrollment to the same tenant is still not treated as a new purchase or link event.
For a fresh link made by an instance administrator, enrollment can also queue activation of Cloud telemetry for projects that still store spans locally. That work is asynchronous so the link response stays fast. Credential recovery may replace a rejected token without repeating this purchase-triggered action.
Unattended first-boot enrollment does not replace a link that appears while the code is in flight. It reports that race so the operator can reconcile the consumed code and the local credential.
sequenceDiagram
participant O as Operator
participant S as Local Cloud service
participant C as Cloud client
participant P as Cloud control plane
O->>S: Submit enrollment code
S->>C: Send code with instance identity
C->>P: Enrollment request over HTTPS
P-->>C: Tenant identity, token, and capabilities
C-->>S: Enrollment result
S->>P: Request managed backup capability
P-->>S: Destination or setup reason
S->>S: Store link and apply feature gates
S-->>O: Linked status and backup setup state
References: crates/…/messages.rs• L51-108 crates/…/lib.rs• L283-337 crates/…/link.rs• L1169-1314 crates/…/service.rs• L581-687
Export gates
Telemetry, backups, and notifications each have an operator-controlled gate. The gates are persisted separately from enrollment, so linking an account does not silently export local data.
Cloud may also provision a managed backup destination. Once local backups write into that Cloud-owned destination, the runtime must register those objects so the Cloud console can find and restore them. This physical fact is separate from the operator's choice to mirror other backup data.
References: crates/…/lib.rs• L55-62 crates/…/link.rs• L596-707 crates/…/service.rs• L339-376
Wire protocol
The Cloud wire contract uses HTTPS JSON for request and response operations and WebSocket management channels for liveness, optional instance status, and console access. The public protocol crate defines the shared message shapes so a local runtime and a remote backend agree on what crosses the boundary.
Protocol negotiation
A capability is a named feature that both peers must support before the connection can use it. Each management connection begins with a Hello message that carries a protocol version, build version, and capabilities. The usable set is the intersection of both peers' capabilities.
The protocol favors safe forward change. New fields have defaults, unknown message kinds can be ignored, and a breaking change requires a new protocol version. A missing capability means that feature is not supported; it does not make the whole connection fail.
References: crates/…/lib.rs• L4-128 crates/…/messages.rs• L4-44 crates/…/console_proxy.rs• L495-519
Management channel
The management channel is a WebSocket at /v1/management. The server sends the first Hello message, the runtime replies with its Hello, and the runtime then sends a heartbeat at a fixed cadence. The heartbeat proves that a quiet linked instance is still reachable and carries the local telemetry queue size for Cloud-side health display.
The channel is independent from telemetry shipment, backup work, and console proxy traffic. It reconnects with bounded backoff and treats heartbeat acknowledgements as clock and liveness data only. When the peers negotiate instance status reporting, the same channel also carries slower status updates.
References: crates/…/heartbeat.rs• L24-46 crates/…/heartbeat.rs• L154-205 crates/…/heartbeat.rs• L433-560 crates/…/messages.rs• L934-963
Instance status reporting
Instance status reporting gives the Cloud console a view of the runtime beyond its last heartbeat. It is an advisory report from the instance that can include version, uptime, deployment, service, and project counts, resource readings, and local self-update state. Cloud can request a fresh report, but it cannot use this channel to tell the instance to update or restart.
The report is sent only when both peers negotiate InstanceStatusReporting and the host registers a StatusProvider. A missing provider or an older backend produces no error and no report. Status collection stays separate from the heartbeat path and uses a bound so a slow snapshot cannot delay liveness or shutdown.
References: crates/…/status_provider.rs• L29-65 crates/…/heartbeat.rs• L72-119 crates/…/heartbeat.rs• L359-560 crates/…/messages.rs• L976-999
Message families
The protocol groups Cloud work by the result that the remote plane provides to the local runtime.
| Message family | System purpose |
|---|---|
| Enrollment and status | Bind one runtime to one tenant and report capability, quota, and health state. |
| Telemetry | Send span batches with a stable submission ID and receive acknowledgement. |
| Backup control | Declare snapshots, receive upload targets, resume verified objects, and catalog objects already in a managed bucket. |
| Managed AI | Ask Cloud for capability, submit an approved analysis manifest, or proxy an OpenAI-shaped chat request. |
| Notifications | Send one bounded local alert for Cloud to fan out to configured sinks. |
| Liveness and instance status | Keep the management view current and add advisory runtime facts when available. |
| Console proxy | Carry approved browser requests and responses between Cloud and the local console as bounded streams. |
Sensitive values stay out of normal diagnostics. Enrollment codes, instance tokens, backup secrets, and console credentials are redacted before logging.
References: crates/…/messages.rs• L49-108 crates/…/messages.rs• L127-234 crates/…/messages.rs• L327-515 crates/…/messages.rs• L678-746 crates/…/messages.rs• L846-927
Telemetry transport
Telemetry uses a write path for shipping and a separate read path for querying. The local runtime controls the fidelity and destination of each project, while Cloud controls acceptance, retention, quota, and any server-side sampling.
Telemetry shipping
The client sends batches to /v1/telemetry. Every batch has a submission ID that stays the same across retries. A retry is idempotent, which means repeating the same submission does not create a second accepted result. The client removes a batch only when Cloud confirms that the full batch was processed.
The default mirror uses a bounded spool and a background flusher. Cloud-primary projects use a durable local outbox and drain it until idle. The outbox accepts data up to an operator-set byte limit and records a visible gap when the limit refuses new data. Accepted rows remain available across process restarts until Cloud acknowledges them.
References: crates/…/lib.rs• L705-769 crates/…/outbox.rs• L4-132 crates/…/outbox.rs• L283-409 crates/…/outbox_worker.rs• L4-35 crates/…/messages.rs• L127-234
Telemetry fidelity
Each project chooses how much span data may leave the instance. Metered fidelity keeps only enough information to count and prove activity. Queryable fidelity adds the fields needed to render and filter traces in a Cloud view.
Queryable data uses stable link-scoped references rather than exposing local project names. Optional wire fields let older runtimes and newer gateways continue to exchange metered records.
References: crates/…/messages.rs• L127-206 crates/…/link.rs• L932-979
Telemetry readback
Cloud exposes a read-only ClickHouse HTTP proxy at /v1/telemetry/query. The local client can point a standard ClickHouse client at that surface, while the proxy selects the tenant and rejects non-read statements. Read support is negotiated separately from telemetry shipping.
Read queries have their own wall-clock budget. A slow read is reported as an unavailable backend rather than being allowed to hold a local request forever.
References: crates/…/query.rs• L4-71 crates/…/lib.rs• L66-82
Backup and notification transport
Backup and notification flows send control records to Cloud while keeping the large local payload on its intended storage path. Cloud receives enough identity and state to show, bill, restore, or fan out the result.
Managed backup flow
For a tenant with managed backups, Cloud returns an object-storage destination and a scoped credential. The local service stores and refreshes that credential before expiry.
The backup mirror declares snapshots and object checksums when a copy is needed. Cloud can return objects already verified for that snapshot, which lets the next pass resume. When the source bucket is already Cloud-owned, the mirror can ask Cloud to catalog objects in place instead of reading and uploading a second copy.
References: crates/…/lib.rs• L392-415 crates/…/lib.rs• L477-558 crates/…/messages.rs• L327-395 crates/…/messages.rs• L439-676
Backup lifecycle
The local job stream can report backup started, completed, failed, or deleted events as they happen. A completed event also wakes the mirror so a new local backup does not wait behind an outage backoff. These pushes improve freshness, but the periodic backup mirror remains the source of truth.
References: crates/…/messages.rs• L882-927 crates/…/lib.rs• L640-650 crates/…/lifecycle_notify.rs• L21-73 crates/…/lifecycle_notify.rs• L99-197
Notification fan-out
The local runtime sends a bounded notification with a stable source ID, title, message, severity, and small metadata map. Cloud queues delivery to the tenant's configured sinks and treats a repeated source ID as the same event.
References: crates/…/messages.rs• L846-880 crates/…/lib.rs• L693-702 crates/…/lifecycle_notify.rs• L119-170
Runtime agents
Runtime agents let a local or managed runtime perform work under control of the platform. They include the worker node API, isolated run sandboxes, scheduled agent runs, preview routing, and host-to-plugin channels. These local contracts are separate from the Cloud management channel.
Agent orchestration
The agent service turns project configuration and platform events into bounded runs. It stores agent settings, syncs YAML as the source of truth when used, emits scheduled triggers, checks trigger gates, and hands accepted work to the executor.
Scheduled triggers select only agents that are due. The scheduler records the next occurrence before it sends a job, and the executor prepares an isolated run, provides approved credentials and tools, runs the selected AI command, and cleans up run-scoped resources.
References: crates/…/config_service.rs• L303-369 crates/…/cron_scheduler.rs• L55-167 crates/…/executor.rs• L296-370
Worker node agent
The worker node agent is the control plane's remote execution boundary. It exposes authenticated container, image, external-service, sandbox, health, log, and terminal operations against the Docker daemon on a worker. It reports capacity, identity, platform, inventory, and network health back to the control plane.
The worker uses a node bearer token and can require mutual TLS. In mutual-TLS mode, the worker verifies the control plane's client certificate against the cluster CA. An incomplete identity or a non-HTTPS control-plane URL fails closed. A separate trust mode protects worker calls to the control plane without treating every enrolled worker certificate as a control-plane certificate.
Heartbeats carry labels, capacity, platform, network and ingress health, and a first-connection container inventory. The reported platform comes from the Docker daemon, so the control plane can place images on a compatible node. The worker keeps the last confirmed platform when a later check cannot reach Docker.
The worker keeps workload ports on its private or overlay address instead of a public wildcard address. It exposes managed service containers for databases, caches, and object stores. Container commands and service work have per-operation and per-container limits, so a slow remote request does not consume all worker capacity.
The worker also exposes a restricted runtime-health protocol. It is mounted only when the complete mutual-TLS identity is present. Its control plane can read the host identity, authorize or revoke a deployment lease, and request a bounded health report. Node authentication and deployment permissions protect these operations, while stale sessions and unavailable health state return explicit failures.
References: crates/…/lib.rs• L73-228 crates/…/server.rs• L54-227 crates/…/server.rs• L357-637 crates/…/server.rs• L708-918 crates/…/runtime_health.rs• L53-171 crates/…/handlers.rs• L95-180 crates/…/service_handlers.rs• L263-617
Worker execution lifecycle
The worker treats a Docker command as owned work until it has clear completion or Docker confirms cleanup. It pins the immutable container identity before the command starts. This prevents a reused name or a changed container from receiving cleanup meant for another workload.
One-shot commands and service commands use bounded output and operation capacity. A detached command keeps lifecycle ownership until inspection proves that it stopped. If a request is cancelled or its result is ambiguous, the worker cleans up the containing container and retains operation capacity until cleanup succeeds.
Normal operator and service commands restart the containing container after an ambiguous timeout because Docker cannot reliably cancel all child processes in an exec. Deployment health probes use stop-only cleanup so a failed candidate cannot be resurrected by late cleanup. A command that Docker definitively rejects before start does not restart the healthy container.
References: crates/…/exec_timeout.rs• L4-16 crates/…/exec_timeout.rs• L112-225 crates/…/exec_timeout.rs• L266-352 crates/…/exec_timeout.rs• L481-549 crates/…/handlers.rs• L886-1217 crates/…/service_handlers.rs• L913-1252
Worker image lifecycle
The worker can build an image from an uploaded source context when the control-plane node does not have a Docker daemon. It streams bounded newline-delimited build events, then lets the control plane inspect, export, or extract a path from the result so another node or deployment step can use it. The same boundary accepts image imports, registry fetches, pulls, and vulnerability scans for images already on the node.
Build admission is shared with image transfers and can use a live per-node concurrency limit. Versioned settings prevent an older request from raising a newer lower limit. Lowering a limit drains active work without cancelling it. Queue and build deadlines are separate, so work that waits for capacity still receives its configured build time after admission.
The build path accepts only a safe regular-file context with a valid build specification. Validated build arguments and cache namespaces reach the local daemon without appearing in streamed log lines. The worker checks the requested image platform after a build and checks image identity before a scan. Disconnects, deadlines, and capacity limits release worker resources.
sequenceDiagram
participant C as Control plane
participant W as Worker agent
participant D as Docker daemon
C->>W: Authenticated build request and source context
W->>W: Validate context and admit build
W->>D: Build image with validated settings
D-->>W: Build logs and result
W-->>C: NDJSON build events
C->>W: Inspect, scan, export, or extract image
W->>D: Read image metadata or tar stream
W-->>C: Metadata, findings, or image stream
References: crates/…/build_admission.rs• L4-79 crates/…/build_handler.rs• L78-229 crates/…/build_handler.rs• L229-467 crates/…/build_handler.rs• L523-717 crates/…/build_handler.rs• L756-889 crates/…/server.rs• L103-170 crates/…/handlers.rs• L41-120
Sandbox runtime
The sandbox runtime gives each agent run an isolated place to execute AI tools and work on a project. Docker is the normal backend, with Firecracker available when the host has been prepared. Direct host execution requires an explicit development-only opt-in.
Local and worker-hosted sandboxes use the same provider contract. The worker exposes create, execute, stream output, inspect liveness and status, read and write files, recover, stop, start, and destroy operations to the control plane. It accepts only sandbox-labelled containers and bounds file and output transfers.
The worker validates its sandbox work root at startup. An empty, relative, or unsafe data path fails before a request can bind a host directory into a sandbox. A stale sandbox is quarantined and must be recreated under the current isolation policy.
References: crates/…/plugin.rs• L137-205 crates/…/docker.rs• L264-309 crates/…/executor.rs• L374-620 crates/…/lib.rs• L356-471 crates/…/server.rs• L63-95 crates/…/server.rs• L229-338
Preview gateway
The preview gateway makes sandbox preview services reachable through the local proxy without exposing the sandbox network or a shared control token to application code. A background supervisor checks the gateway image, network policy, port binding, shared secret, and sandbox routes before it keeps the gateway pair.
A gateway failure disables workspace preview URLs but does not stop the main Temps service. Authenticated settings routes let operators inspect health and bounded logs, restart the gateway, upgrade its image, and change its port or upgrade mode.
References: crates/…/preview_gateway.rs• L334-401 crates/…/preview_gateway.rs• L1169-1380 crates/…/preview_gateway.rs• L37-47 crates/…/preview_gateway.rs• L114-319
Sandbox agents and plugin clients
The PTY and VM agents adapt isolated runtimes to host-side services. The PTY agent carries terminal control and raw output over a bounded frame protocol. The VM agent serves command and file requests inside a Firecracker guest. These channels keep the host-to-sandbox boundary small and do not carry Cloud account credentials.
The Rust, Node, and Python plugin SDKs provide a separate host-to-plugin channel. A plugin declares its manifest, receives matching launch settings, and accepts an authenticated WebSocket channel from Temps. This channel gives a plugin typed access to platform data without direct database access; it is not the temps-cloud-protocol contract.
References: crates/…/protocol.rs• L4-70 crates/…/lib.rs• L4-113 crates/…/runtime.rs• L95-145 crates/…/client.rs• L42-69 sdks/…/client.ts• L4-13 sdks/…/client.py• L4-7
Worker network and ingress
The worker network path turns control-plane snapshots into local reachability. A network sync loop obtains node allocation and peer state, reconciles the multi-host overlay and optional WireGuard mesh, and publishes shared peer and bind-address state for new containers.
A route sync client applies internal and public route snapshots locally and acknowledges a generation only after a successful apply. The local authorization lease limits how long cached routes and certificates can survive a control-plane outage. Refusal or lease expiry clears public access.
The internal proxy serves only the private *.temps.local zone and checks workload and project identity before forwarding. Public ingress serves only exact authenticated public routes, selects the matching certificate by SNI, and fails closed for unknown hosts, expired authorization, missing certificates, or mismatched SNI and Host values.
References: crates/…/network_sync.rs• L39-111 crates/…/network_sync.rs• L298-527 crates/…/route_sync_client.rs• L1-384 crates/…/public_ingress.rs• L21-277 crates/…/internal_proxy.rs• L4-47 crates/…/internal_proxy.rs• L363-449
AI gateway
The AI gateway is the local OpenAI-shaped entry point for model requests. It gives callers one request shape while the runtime chooses a configured provider, a user-supplied provider key, or the managed Cloud provider.
Provider routing
The gateway reads provider and request context from the local request, then sends the request to the selected provider. It tracks usage and preserves request context for traces and conversations. A deployment token cannot override the provider base URL.
References: crates/…/gateway.rs• L28-92 crates/…/gateway.rs• L43-71
Cloud-managed inference
For the managed provider, the gateway sends an opaque OpenAI-compatible request body through the Cloud link with a new request ID and request time. Cloud selects the managed provider and model, settles managed usage, and returns an OpenAI-compatible completion. The client retries short-lived backend failures with the same request ID, so a lost response does not create a second reservation.
The managed analysis path is narrower than chat proxying. It sends a locally approved question and evidence manifest, not raw source telemetry or local provider credentials.
References: crates/…/gateway_service.rs• L395-442 crates/…/lib.rs• L374-475 crates/…/messages.rs• L678-746 crates/…/messages.rs• L825-844
Change checklist
When these files or sections are changed, remember to consider these:
- Update crates/…/lib.rs, messages.rs, and the console-proxy message definitions together when a Cloud capability or message changes. Preserve additive decoding, defaults, unknown-value handling, and both client and backend deployments.
- Keep enrollment, telemetry, backup, notification, AI, and console-proxy calls on the same link credential and feature-gate rules. A new Cloud call must not export data merely because the instance is linked.
- Preserve the Cloud client's origin checks, redirect policy, request limits, and retry identity when adding an endpoint or WebSocket path.
- When changing local Cloud routes or enrollment side effects, preserve permission checks, audit events, and the rule that activation work cannot make an established link fail.
- When changing Cloud-primary telemetry, keep the durable handoff, acknowledgement settlement, byte cap, refusal gap, local spill path, and status counts aligned.
- When changing agent authentication or transport, keep bearer authentication, permission checks, mutual-TLS identity, HTTPS control-plane validation, trust roots, and handler-level guards aligned.
- When changing worker builds or image operations, keep validated build input, build arguments, cache namespace, platform checks, expected image identity, streamed events, shared capacity, deadlines, and disconnect cleanup aligned.
- When changing build limits, keep revision ordering and live-cap behavior aligned between heartbeat capacity, control-plane settings, request headers, and
BuildAdmission. A lower cap must drain active work without cancelling it. - When changing worker execution, keep immutable container identity, per-container ownership, output limits, cancellation cleanup, detached monitoring, and health-probe stop-only cleanup aligned.
- When changing runtime health, keep mutual-TLS mounting, node authentication, deployment permissions, durable lease state, session epochs, bounded bodies, and explicit unavailable or stale-session responses aligned.
- When changing worker services, keep private port binding, network and DNS state, provider-derived health probes, resource limits, volume inspection, backup credentials, and command lifecycle limits aligned.
- When changing route snapshots or public ingress, keep route generations, acknowledgement recovery, lease expiry, certificate preparation, SNI checks, and fail-closed behavior aligned.
- When changing worker sandbox routes or data paths, keep sandbox labels, name-based handle resolution, upload limits, path redaction, stream termination, startup path validation, and cleanup aligned.
- When changing agent configuration or schedule triggers, keep YAML sync, due-time state, trigger source identity, gate checks, and queue dispatch aligned.
- When changing managed AI request fields, preserve the OpenAI response shape expected by
temps-ai-gatewayand keep local approval of analysis evidence separate from Cloud transport.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Cloud backend is unreachable | Mirror data stays queued and Cloud status becomes degraded; local application work continues. | Bounded request timeouts, background flush, and capped retry backoff. |
| Instance token is rejected | Cloud calls stop draining and the link reports a credential problem that needs re-enrollment. | Persisted link state and explicit credential-rejected status. |
| Console access is disabled or its identity is revoked | Cloud console streams close and no browser request reaches the local router. | Consent, link, pinned-host, and identity checks during connection setup and stream handling. |
| Telemetry export is disabled | New export work stops and Cloud-primary projects return to local span storage. | Independent feature gates and the link's local fallback. |
| Cloud-primary telemetry reaches its byte cap | New spans are refused and a visible delivery gap is recorded. | Operator-set outbox cap and gap-window status. |
| Telemetry or backup acknowledgement is incomplete | The client keeps the submission or snapshot and avoids silent loss or duplicate settlement. | Stable submission IDs and full acknowledgement checks. |
| Managed backup credentials expire or lose session data | Backup uploads fail while enrollment still looks healthy. | Credential rotation and end-to-end storage of temporary token and expiry. |
| Protocol peer lacks a capability or message kind | The new feature is skipped while the older connection stays usable. | Capability intersection and kind-based envelope decoding. |
| Status reporting is not negotiated or has no provider | The Cloud console has no fresh instance facts beyond liveness. | Require both capability negotiation and a provider. Treat absence as normal. |
| Worker bearer token or permission is invalid | The control-plane operation is refused. An unguarded route could expose Docker control. | Authentication middleware and handler-level permission checks. |
| Required worker mutual-TLS identity is incomplete | The agent refuses to start instead of silently using an unsafe transport. | HTTPS and certificate configuration validation. |
| Worker build context or specification is unsafe | The image build is rejected before source extraction or Docker work. | Archive path checks, size and entry limits, regular-file checks, and specification validation. |
| Worker build limit is stale or lower than active work | New builds can exceed the current node policy or wait forever if admission is not coordinated. | Versioned live admission that drains existing work and blocks stale updates. |
| Worker build, export, scan, or image transfer exceeds capacity or deadline | The remote deployment cannot complete, but other node operations retain their capacity. | Shared image-operation slots, bounded streams, terminal events, and operation deadlines. |
| Docker exec times out or the request is cancelled | Child processes can continue after the HTTP request ends, or a health candidate can be incorrectly revived. | Pinned container identity, armed cleanup ownership, restart for normal execs, and stop-only cleanup for probes. |
| Docker returns an ambiguous exec result | The worker cannot prove whether work started or stopped. | Retain lifecycle slots and retry cleanup until Docker confirms termination. |
| Runtime health host is unavailable or its lease is stale | Authorization or health reporting is refused without using an uncertain session. | Restricted mTLS-only routes, durable lease state, session epochs, and explicit 503 or 409 responses. |
| Worker heartbeat or route sync fails | The control plane can mark the node stale or its route view can lag. | Heartbeat retry, route snapshot persistence, pending-ack retry, and lease expiry. |
| Control plane refuses a worker route request | The worker clears public ingress and cannot serve the refused view until access returns. | Clear the public snapshot on refusal and retry refusals on a short fixed interval. |
| Internal route metadata lacks project identity or Docker identity is stale | Workload traffic is denied instead of crossing project boundaries. | Cached source identity, current Docker inspection, project match, and fail-closed quotas. |
| Worker service command or data operation times out | The operation can retain worker capacity or leave a partial workload. | Per-container ownership, bounded output, deadlines, cleanup monitoring, and volume inspection before removal. |
| Worker sandbox path is empty, relative, or unsafe | Sandbox creation can bind an unintended host directory or fail on every request. | Startup path resolution and fail-closed configuration validation. |
| Sandbox request ends during creation or streamed execution | A sandbox can become untracked or a command can continue without an output reader. | Background create cleanup, response-owned stream cleanup, and process termination on disconnect. |
| Preview gateway image, network, secret, or route drifts | Workspace preview URLs fail or an old gateway can expose a shared token. | Image, network, secret, and route checks with fail-closed recreation. |
| AI provider response cannot be decoded | The gateway returns an upstream error instead of a false completion. | OpenAI-shaped response validation at the local gateway boundary. |
Key files
| File | Why to read it |
|---|---|
| crates/…/service.rs | Shows the local Cloud service lifecycle, consent gates, enrollment, managed backup setup, and task ownership. |
| crates/…/handler.rs | Shows the authenticated local Cloud API and operator actions. |
| crates/…/link.rs | Shows the shared link boundary, credential lifecycle, fallback behavior, and local health model. |
| crates/…/lib.rs | Shows the HTTPS client surface, enrollment, telemetry, backups, notifications, and managed AI. |
| crates/…/console_proxy.rs | Shows the optional Cloud console tunnel and bounded stream behavior. |
| crates/…/heartbeat.rs | Shows the WebSocket liveness and status channel. |
| crates/…/lib.rs | Defines protocol versioning, capability negotiation, and compatibility rules. |
| crates/…/messages.rs | Defines the shared Cloud message families. |
| crates/…/outbox.rs | Shows durable Cloud-primary telemetry handoff and gap reporting. |
| crates/…/backup_mirror.rs | Shows how local backup manifests become Cloud catalog entries or object uploads. |
| crates/…/executor.rs | Shows the common agent-run lifecycle and cleanup. |
| crates/…/preview_gateway.rs | Shows preview gateway reconciliation and status behavior. |
| crates/…/lib.rs | Defines worker identity, trust, transport, health, and service contracts. |
| crates/…/server.rs | Defines worker route assembly, mutual-TLS transport, heartbeat, platform reporting, and sandbox hosting. |
| crates/…/handlers.rs | Defines authenticated container control, execution lifecycle, image operations, terminal access, and output limits. |
| crates/…/exec_timeout.rs | Defines cancellation-safe Docker exec ownership and cleanup. |
| crates/…/build_admission.rs | Defines live build-cap admission and revision ordering. |
| crates/…/build_handler.rs | Defines remote image build, streamed events, image inspection, scanning, extraction, and export. |
| crates/…/runtime_health.rs | Defines the restricted runtime-health lease and report boundary. |
| crates/…/service_handlers.rs | Defines remote external-service creation, execution, health checks, backups, restores, and private port binding. |
| crates/…/network_sync.rs | Defines control-plane peer, DNS, allocation, overlay, and mesh sync. |
| crates/…/route_sync_client.rs | Defines route and public-ingress snapshot sync, acknowledgement recovery, and lease handling. |
| crates/…/internal_proxy.rs | Defines internal request forwarding and workload identity checks. |
| crates/…/public_ingress.rs | Defines public listener setup, certificate selection, and fail-closed behavior. |
| crates/…/sandbox_handlers.rs | Defines the remote sandbox worker contract and bounded file transfer. |
| crates/…/gateway_service.rs | Shows how local AI requests reach local providers or managed Cloud inference. |
| crates/…/client.rs | Shows the typed host-to-plugin request and event channel. |