Tenant isolation

One Kubernetes namespace per tenant, and one process — platform-api — that decides which namespace a caller is in. Everything else follows from those two facts.

The tenant comes from the principal, never from the request

Every RPC except CatalogService.GetPricing and StreamGetPricing (the public, tenant-free price list; the public procedures are listed in platform-api’s cmd/server/interceptors.go) authenticates with a Firebase ID token sent as Authorization: Bearer <idToken>. The server verifies it with the Firebase Admin SDK — signature against Google’s JWKS, iss = https://securetoken.google.com/<project>, and aud = <project> — then resolves uid → tenant from a cached Firestore lookup. On first sign-in it provisions the tenant record and its namespace (tenant- + tenant id).

Sign-up is invite-only. With SIGNUP_INVITES_REQUIRED on (iac turns it on in every environment), a first sign-in is provisioned only when its verified email has a signup_invites document; the operator manages invites and the waitlist from the admin console (AdminService’s invite and waitlist RPCs). Any other first sign-in answers PermissionDenied with a google.rpc.ErrorInfo whose reason is NOT_INVITED and domain spookylabs.ai, carrying the caller’s waitlist position and total as metadata when the waitlist answered.

On the tenant-facing services, no request carries a namespace or a tenant id. agent_id is a bare name, a payment method is only ever the caller’s own. One tenant cannot name another’s agent because there is no field in which to name it.

Only AdminService takes a tenant_id, and it re-checks the caller’s email against the server’s ADMIN_EMAILS allowlist on every call. The comparison is case-insensitive, an unverified email address never counts, and an empty allowlist denies everyone — the correct failure mode for a misconfigured deployment, and the server warns about it at startup. IdentityService.WhoAmI.is_admin is a hint for the UI, not the enforcement point: the admin console is a static bundle on a public CDN, so anyone can patch that flag in a devtools console and get nothing for it.

GCP_PROJECT is load-bearing.

It is also the expected aud on every ID token. It must match the intended Firebase project; an incorrect audience policy trusts the wrong identity boundary or refuses legitimate callers.

The interceptors are full interceptors, not the unary helper

Both auth and admin are connect.Interceptor implementations rather than connect.UnaryInterceptorFunc. That is deliberate: the unary helper wraps unary calls only, and every stream in this API is server-streaming, so a unary-only interceptor would leave StreamRunEvents, StreamListNotifications and StreamDashboardStats unauthenticated.

The chain is OpenTelemetry, then error logging, then auth, then admin — OTel first so a rejected request is still traced, admin last so it reads the principal auth has just placed and fails closed if it is absent. CORS wraps the whole mux, because the SPAs and the API are different origins and a failed preflight never reaches a handler.

The tenant baseline

The baseline converges the tenant’s runtime prerequisites: a gVisor WorkerPool, the spooky-kagent Harness, a tenant snapshot location, credential-provider access and the prompt libraries. The model catalog and the three tool servers used for discovery are not copied into the tenant: the catalog is platform-api’s own, and the tool servers are declared once in Terraform. The custom runtime already contains its pinned skills; there is no per-tenant OCI skill-pull refresh loop.

Baseline convergence runs for newly resolved tenants and existing tenants. A completed baseline is separate from agent readiness or successful session execution. Dependency failures must not be reported as a ready tenant merely because the namespace exists.

References and service identity

Tenant-facing writes validate model and delegation references in the caller’s namespace. The API must not accept arbitrary namespace-qualified references merely because Kubernetes can resolve them. Agent-specific bindings and credentials are distinct from discovery credentials, which can list a catalog without being authorized to execute an agent’s tools.

An agent reaches the platform MCP endpoint through agentgateway with its own gateway key, as it reaches every tool server. The gateway relays the key’s tenant, agent name and immutable agent UID, and the endpoint trusts them only on a request the gateway forwarded. The wake tools check that UID against the current agent, then act on kagent’s schedules as the agent’s owner, so kagent’s creator scoping keeps every wake inside the tenant. A key that names no current agent can list the tools and call none.

Substrate actor identity, credential-provider grants and gateway authorization cooperate to enforce runtime service access. Network reachability alone is not caller identity. For model attribution and brokerage ownership, see The model gateway and The paper brokerage.

Quotas and suspension

Tenant quotas bound supported resource counts. Their effective defaults must remain visible to the operator; they are not monetary spend caps. Tenant suspension (AdminService.SuspendTenant) refuses the tenant’s people every RPC, reads included, holds new runs and stops the runs in flight. There is no per-agent suspension. Session suspension uses runtime lifecycle APIs rather than scaling each agent’s Deployment. Payment-standing gates are separate from both resource quotas and operator suspension. See Metering and billing.

Firebase authorized domains

Sign-in is signInWithPopup with GoogleAuthProvider, and authDomain stays at the project’s default spooky-labs.firebaseapp.com. Pointing it at developer.spookylabs.ai breaks sign-in: a custom authDomain requires Firebase Hosting, and GitHub Pages cannot reverse-proxy /__/auth/.

What does need configuring is Firebase’s authorized domains list — the hosts that sign users in, developer.spookylabs.ai and admin.spookylabs.ai, plus localhost — which is Terraform, as google_identity_platform_config.authorized_domains, and is a whole-list replacement.