Data flows
Inference request
- The gateway authenticates from a periodically refreshed hashed-credential snapshot and bounds the request body and request ID.
- It reads the alias from the atomic in-memory route directory; PostgreSQL is not queried.
- It rewrites the alias to the common upstream model and forwards to the local vLLM Router.
- Response headers and bytes are streamed back; SSE chunks are flushed incrementally.
- Accounting is queued after completion and persisted asynchronously with bounded capacity.
Asynchronous apply
- An operator submits tenant-scoped desired state with an idempotency key.
- PostgreSQL returns the existing operation or stores a new pending operation.
- One replica claims it with
SKIP LOCKED, records a lease, and heartbeats during execution. - The handler validates tenant-owned targets and atomically converges the deployment.
- Completion and audit state are persisted. An expired lease can be recovered by another replica; retryable failures return to pending with bounded exponential delay.
Reconciliation
- A replica loads active deployments and their targets from PostgreSQL.
- Worker health/model endpoints are probed concurrently under a fixed bound.
- Healthy membership and routing policy produce a deterministic worker-set hash.
- If local state differs, the replica replaces its supervised router process and records an instance-owned generation.
- A complete route snapshot is published atomically; the previous valid snapshot survives temporary database or reconciliation failures.
Schema startup
- The process connects to PostgreSQL with a bounded pool.
- One connection obtains the migration advisory lock.
- Unapplied embedded migrations execute transactionally in filename order.
- The migration version is recorded in the same transaction.
- The lock is released before serving commands or traffic.
Provisioning
The durable workflow resolves a registered provider backend by cloud, runtime, and persisted adapter identity. RunPod elastic uses the native Pods adapter by default. Explicit SkyPilot manifests may add long-tail execution targets, but do not supply InferCrane’s price authority. AWS EC2 delegates API compatibility and STS to AWS CLI v2 while InferCrane retains idempotency, adoption, private-network, tag, and deletion policy. Both return a target that follows the same runtime and reconciliation path as an existing worker.Governed external fallback
- Reconciliation excludes policy-owned external targets from ordinary primary membership.
- Only when no primary is healthy, the coordinator loads an enabled, privacy-acknowledged policy, resolves its reference-only credential in memory, and checks the exact model mapping.
- A bounded request/cost batch is atomically reserved in PostgreSQL and prefetched into memory.
- The gateway authorizes each request from that in-memory lease before transmission; PostgreSQL never enters the inference path.
- The selected target and any denial are persisted in bounded request evidence. Requests are not replayed or duplicated after a possible send.