Request Lifecycle
Request Lifecycle
Every request travels the same 14-step pipeline — from entry point to response.
Full Sequence Diagram
What & Why
Every request — HTTP, CLI, or MCP — travels the same 14-step pipeline. There is no special-casing per entry point. The CLI proxies to the HTTP server; MCP tool execution does the same.
The middleware stack is entirely stateless. All per-request state is encapsulated in a single RequestContext object built in step 7. This makes the system horizontally scalable — any instance can handle any request without affinity.
RequestContext — The Only Coupling Point
RequestContext is the only coupling point between middleware, services, and adapters. Nothing else is shared across layers.
Cache Layers
Sub-millisecond lookups. Scoped to a single worker process. Evicted on process restart. No network hop.
Shared across all instances. Supports stale-while-revalidate (SWR): serve stale data instantly while refreshing in the background.
Steps 5–13 run in full. Response is stored back in L2 at step 13.
hash(method + params + tenant_id)Tenant-scoped — no cross-tenant data leakageHTTP Reference
| Header | Value |
|---|---|
| Authorization | Bearer <JWT> |
| Access-Token | <direct token> |
| X-Tenant-ID | <tenant uuid> |
| Accept | application/json · text/plain |
| Param | Values |
|---|---|
| ?format= | json · text · agent |
| Code | Meaning |
|---|---|
| 200 | Success |
| 401 | Auth failed — invalid/missing token |
| 429 | Rate limit exceeded |
| 500 | Unhandled service / adapter error |