Experiential Labs platform · companion to the Platform Data Plan · updated 2026-11-22
Observability Architecture
How our gateway records every request, where each piece of that record lives, what kept breaking, what we tried, what we measured, and what is still waiting for a decision. It is written to be read top to bottom by someone who has never seen the system.
What this page is, how it relates to the plan, and where the work stands.
What this document is
This page is the long companion to the Platform Data Plan (platform-data-plan.html on the Desktop). The plan page is short on purpose. It lists the decisions, numbered D1 to D20, and the owner questions, each in a card marked "Decided", "Confirm" or "Your call".
This page holds the thinking behind those decisions. It explains how the system works, what went wrong with it, which experiments we ran, what the numbers were, and why each design won. Where the two pages give a number, it is the same number. Where this page once proposed something the plan later decided differently, the place is marked with the final decision (for example final: D6) or with a dated note (for example updated 2026-11-18).
The work covers five connected things:
Observability: the pages and API where a customer reads back every request they sent through our gateway, groups them into sessions and traces, and searches them.
The MemoryDB wallet: the fast, durable store that checks and charges money on every request.
Capture: saving prompts and responses to S3 in "segments", then loading them into ClickHouse for lists and search.
Retention and the Helicone move: how long data is kept, who decides, and how customers of Helicone (which we own) move to our stack with no change on their side.
Running through a Postgres restart: making sure a planned database restart does not break customers' API calls.
How to read it. Part 2 defines every term. Part 3 explains how the system works, piece by piece, as it runs in production. Part 4 lists what was not working, in the order we found it. Part 5 tells the story of the work, day by day: what we noticed, what we tried, what we learned, what we changed and what happened. Part 6 says where things stand. Part 7, at the bottom, lists every decision still open, with the same numbers as the plan page.
About the numbers. Every figure comes from a measurement, a log, a report or the code. Figures marked "live" were read from production on the date given (most on 2026-11-09). "Local" means a developer machine or a test cluster. "Preview" means the isolated test environment pr-902980, which is deliberately small (for example, its ClickHouse has one CPU), so preview numbers are a lower bound for production.
History of this page. It was first written on 2026-11-09 from production as built on main. The same day it gained: the glossary; the full infrastructure map; the MemoryDB double ledger in depth; the capture pipeline and the hidden Postgres write inside Supabase Storage; the November 9 refusals; the target architecture; a status table of every change; the simple diagram with every box and arrow explained; how our inboxes and outboxes work; a review against published engineering practice; every capture path; what we can learn from LiteLLM; and the sessions proposal. Dated sections were added on 2026-11-18, 11-20, 11-21 and 11-22. On 2026-11-22 the page was reorganized into this chronological order.
Status in one paragraph
Nothing of this work is merged to main, and none of it runs in staging or production. The owner's rule is that everything is proven in the isolated preview first.
All of it is one pull request, GitHub #2980, labelled do-not-merge until the owner approves it. Earlier it was split into 12 stacked PRs (#3090 to #3101); on 2026-11-21 the owner decided to land it as one PR, and the 12 were closed.
It is tested on preview pr-902980. On 2026-11-22 eight agents attacked it in rounds; twelve rounds are now merged into #2980 (head 79479dfd80) and deployed on the preview. The wallet, ClickHouse and Postgres failure tests passed there with money exact every time.
The preview ran #2980's code on main's deploy layout, so the PR's own layout changes (background units, dashboard edge, writeback app, direct announce and more) have not run anywhere yet. See What the preview could and could not test.
Still open: the owner decisions in Part 7, the speed of the Requests list at large scale, and a few gaps listed in Part 6.
Part 2
Definitions
Every term the rest of the page uses, in plain words. Skim it now and come back when a word is unclear.
The product in one paragraph
Experiential Labs runs an AI gateway. A customer's software sends its model requests to us, at https://api.experientiallabs.ai/v1, instead of sending them straight to OpenAI, Anthropic or another provider. We speak the same API as those providers (OpenAI Chat Completions and Responses, and Anthropic Messages), so a customer changes only a base URL and a key.
For each request we check the key and the organization's limits, reserve the money, pick a provider route, call the provider, stream the answer back, charge the real cost, and keep a record. If one provider fails, we can retry on another.
Observability is where the customer reads those records back: a Requests table, sessions, agent traces, search, charts and totals, in the dashboard at platform.experientiallabs.ai and through an API that their own agents can call.
The infrastructure pieces
Every piece of infrastructure the rest of this page names: what it is in general, and what it does for us. Pod counts are live production replica counts on 2026-11-09.
Cloudflare
A network company whose servers sit between the internet and your servers. Visitors connect to Cloudflare; Cloudflare forwards the traffic to you.
Ours: only api.experientiallabs.ai and platform.experientiallabs.ai. It decrypts HTTPS (TLS), runs the firewall (WAF) and sign-in rate limits, passes the real visitor IP (CF-Connecting-IP), and adds a secret header so our servers can refuse traffic that did not come through Cloudflare. Streams pass through for up to about an hour. It stores nothing and never challenges /v1. Not behind it: our GPU gateway VM, the status page and marketing site (Vercel), staging, previews, and Supabase.
AWS EKS and Porter
Kubernetes runs containers ("pods") on a pool of machines, restarts them when they crash, and scales their count. EKS (Elastic Kubernetes Service) is AWS running Kubernetes for you; you still pay for the machines and decide what runs on them. Porter is the deploy tool on top: each Porter "app" becomes one or more Kubernetes deployments.
Ours, production replicas live: edge explabs-api 12, gateway worker 30, control plane explabs-ctl 6, web 10, Project worker 64 (+1 broadcast). All in us-west-2, behind one AWS load balancer and ingress-nginx.
Gateway worker
Our serving process: a Python "front" plus the Rust engine (experiential). It authenticates the key, picks a provider lane, reserves money, calls the provider, streams the answer back, charges the real cost (settles), and buffers the capture.
The only process that talks to model providers. 30 pods, each admitting at most 64 requests at a time.
Caddy and the GPU gateway VM
Caddy is a web server and reverse proxy, a lighter alternative to nginx. It accepts HTTPS and forwards each URL path to a backend.
Ours: gateway.xplabs.ai is a GCP VM running Caddy, with one path per GPU lane (for example /ec/18160 is clef). Each GPU box (Azure, GCP, Lium, Arrakis) opens a reverse SSH tunnel to that VM, so the boxes need no public ports. Some boxes also run Caddy locally to spread requests across several model servers (clef's Azure box: 8 sglang servers behind Caddy on port 30100). Experiential Cloud models reach their boxes this way; Cloudflare is not involved.
MemoryDB
AWS's managed in-memory key-value database, compatible with Redis/Valkey. Reads and writes take well under a millisecond, and unlike a cache it is durable: a write is acknowledged only after it reaches a log copied across availability zones.
Ours: the "fast ledger". It holds each organization's live balance, open holds, spend caps and promo credits, plus the rate-limiter counters. It is the only store a production request waits on. See MemoryDB in depth.
Postgres (Supabase)
The relational database: tables, transactions, foreign keys. Supabase hosts it and adds auth, an HTTP API (PostgREST) and Storage on top.
Ours: one database, 1,336 GB live. System of record for keys, orgs, catalog, wallet history, request and attempt rows, usage events, capture pointers. Largest tables (live): audit_log 311 GB, gateway_attempts 238 GB, gateway_usage_events 188 GB, storage.objects 167 GB, gateway_requests 105 GB, gateway_chain_authority_receipts 67 GB.
S3 and Supabase Storage
S3 is AWS's object store: you put a file under a name and get it back by name. It is cheap, effectively unlimited, and has no database behind it that needs cleanup (vacuum). Supabase Storage is Supabase's file service. Its bytes sit in S3 that Supabase owns, but every file also gets a metadata row in storage.objects, inside our Postgres.
Ours: captures, capture documents and customer trace uploads go to Supabase Storage today, so each one is also a Postgres write. Our own AWS S3 holds RL artifacts, criminal-abuse artifacts, an empty capture archive bucket and Terraform state. See Captures and S3.
ClickHouse
A columnar analytics database. It scans billions of rows fast when you ask for sums, counts and percentiles over a few columns, but is poor at updating single rows.
Ours: every chart and total (usage_events, spend_facts) and uploaded external traces (trace_spans). Fed from a Postgres outbox. Not involved in gateway captures today.
SQS and dead-letter queues
SQS is AWS's message queue. A producer drops a message; a consumer takes it, works on it, and deletes it. If the consumer crashes, the message reappears after a timeout for another consumer. A dead-letter queue (DLQ) is where SQS moves a message after it failed a set number of times, so one broken message stops being retried forever and a person can look at it.
Ours: the illegal-content review queue (and its DLQ) in production, 76 messages waiting when checked. Captures do not use SQS: their queue is a Postgres table, gateway_capture_inbox, with no dead-letter shelf (298 rows stuck in metadata_pending since November 6).
ECS and Fargate
ECS and Fargate work together. ECS is AWS's simpler container scheduler (an alternative to Kubernetes/EKS). Fargate is a way to run ECS tasks without owning machines: you ask for "0.25 vCPU, 2 GiB" per task and AWS runs it. So "ECS on Fargate" means containers with no servers to manage, priced per task-second.
It suits queue workers better than EKS pods for three reasons. It scales on queue depth, separately from the serving cluster. A runaway job cannot take CPU or memory from gateway pods. A cluster release does not have to stop and drain it. Ours: the illegal-content review service and evals run on ECS Fargate. A capture-processing service exists but is switched off: its runtime setting is worker, so the 64 EKS Project worker pods do that work instead.
Outbox, writeback, drain
An outbox is a table a transaction writes "something needs to happen" into, in the same commit as the change itself, so the follow-up can never be lost. A background drain then does the follow-up and deletes the row. Writeback here means copying MemoryDB's receipts into Postgres.
Ours: receipt streams (MemoryDB to Postgres), settle_outbox (usage events), the ClickHouse outbox, and the capture inbox (which behaves like an outbox filled by Storage).
Public edge
A thin relay in front of the gateway workers. It passes each /v1 request on without reading or changing the body.
Ours: 12 pods of explabs-api. Its job is fairness: it gives each customer a share of its connections to the workers, so one heavy caller cannot block everyone. Because it is separate, a gateway release does not drop the connections callers hold to the edge.
Control plane
Our dashboard and admin API (a Python FastAPI app), plus background threads that copy data between stores.
Ours: 6 explabs-ctl pods. The threads are the ledger writeback, the settle drain, the ClickHouse exporter and the credit feed. In the new design it also receives customers' trace uploads (span ingest).
Web app
The Next.js dashboard that people use in a browser.
Ours: 10 pods. It renders pages on the server and forwards the browser's /api calls to the control plane with the signed-in user's identity.
Project worker
A pool of background worker pods that run jobs off the request path.
Ours: 64 pods (+1 broadcast) in EKS. On 2026-11-09 they processed captures and ran the wallet_check accounting pass. The new design keeps workers in EKS as separate deploy units and runs only the capture ETL on Fargate.
Preview environment
A full, private copy of the platform built for one pull request, used to test a change before it goes anywhere near customers.
Ours for this work: pr-902980, for PR #2980. It has its own AWS account, database branch and cluster, and is small on purpose: one edge pod, one control-plane process, one ETL task, and a ClickHouse with 1 CPU and 2 GiB. Its wallet runs on ElastiCache Serverless, not MemoryDB. Its real model has a fixed $5 budget for its whole life.
Helicone, Langfuse, OpenTelemetry
Helicone is an LLM observability proxy that Experiential Labs owns; its customers are to move onto our stack. Langfuse is a popular open-source tracing tool. OpenTelemetry (OTLP is its wire protocol) is the standard way programs send traces.
Ours: we accept Helicone's hosts, keys and headers, Langfuse's ingest API, and OTLP spans, so customers can send us data with tools they already use.
Request and money words
These describe one request's life and the money attached to it.
Word
Meaning here
Caller
Whatever sends a request to our /v1 API with an xpl_ key: a customer's app using the OpenAI or Anthropic SDK, a coding agent (Claude Code, Codex, Cursor), or a script. The caller is our customer's software, not a person. "While the caller waits" means between the request arriving and the last byte of the answer leaving.
Request id
request-<uuid>, minted by the gateway when it authorizes the call and returned as the x-request-id header. Every row about this request, in every store, carries this id. That is how rows for the same request are matched across stores later.
Attempt
One call to one provider. A request can have several attempts when the gateway fails over from one provider to the next.
Hold and settle
Before calling a provider the gateway reserves the worst-case cost (the hold). When the answer ends it charges the real cost and releases the rest (the settle). A card terminal does the same at a gas pump.
Receipt
A small record of one money movement (settle, release, credit), MemoryDB writes it in the same step as the movement, so a movement never exists without its receipt. The receipt also carries the request and attempt rows that are later copied into Postgres.
Capture
The saved prompt and response of one request. Kept only while the organization's capture switch is on and never for a request routed under zero data retention (ZDR).
Request path
Everything that happens while the caller waits. Anything on it adds latency to every customer request and can make requests fail.
Background
Work done after the caller is gone, by threads on the control plane or the Project worker. If it is slow, Postgres and the dashboards show new requests later than usual, and customer requests are still served.
Outbox, inbox, stream, drain
Ways of handing work from one step to the next without losing it. Explained in Inboxes and outboxes.
Lag
How far a background step is behind: the age of the oldest item it has not handled yet. The writeback normally lags about a second; on November 9 it lagged up to 5.8 minutes.
Backpressure
When a downstream step is slow and an upstream step has to wait, buffer, or refuse. The capture buffer filling up and refusing requests on November 9 was backpressure reaching the caller.
Fail closed, fail open
What a component does when a dependency is unavailable. Fail closed: refuse the request (safer for a promise like mandatory retention). Fail open: serve it and skip the extra step (safer for availability). The capture buffer fails closed today.
Lane, rung, provider
A provider is a company or server that runs models (OpenAI, Anthropic, our own GPU boxes). A lane (also called a rung) is one route to one model on one provider. A model can have several lanes in order; if the first fails, the gateway tries the next.
Wallet
The live record of each organization's money: balance, open holds, spend caps and promotion credit. It lives in MemoryDB.
Double ledger
Money is kept twice. MemoryDB holds the live balance the gateway checks on every request. Postgres holds the permanent history. Receipts carry each movement from the first to the second.
Writeback
The background job that reads receipts out of MemoryDB and writes them into Postgres, exactly once each.
Slot
The wallet spreads organizations over 64 fixed slots. Each slot has one receipt stream. A busy organization can be moved to its own slot so it cannot slow its neighbors.
Deny set
The list of blocked organizations and keys (quarantine, ban, spend lock, revoked key), kept inside MemoryDB. The hold script checks it, so a block works even when Postgres is down.
Deferred settle
A settle that could not reach the wallet in time. The answer is sent to the caller anyway, the hold stays in place, and the settle is retried in the background.
Spool
A durable copy of a deferred settle, written to Postgres while the wallet is unreachable, so the charge survives even if the worker that held it dies. A replay job lands it later, exactly once.
BYOK
"Bring your own key": a request served with the customer's own provider key. We charge nothing for the model, but the request still passes through the wallet with a zero-cost hold.
Nano-USD
The money unit in the ledger: one billionth of a dollar. Money tests compare totals to the nano-dollar.
Protected chain
A model route whose admission writes a receipt in Postgres before it is served (a "chain authority receipt"). On 2026-11-18, 52% of production requests ran on protected chains.
Observability data words
These describe what is stored about a request and how customers read it back.
Word
Meaning here
Capture switch
The organization's setting for storing prompt and response content. Metadata (model, tokens, cost, status, latency) is always recorded; content only while the switch is on.
ZDR
Zero data retention. A request routed under ZDR is never captured.
Segment
In the new design, captures are not uploaded one by one. Each pod appends them to a file on its own disk (a segment) and uploads the file to S3 every second or two, or when it reaches 16 MiB.
ETL
Extract, transform, load. Here: the capture loader on AWS Fargate. It reads each segment from S3, checks the organization's live erasure state, writes each request's body as its own encrypted object, and writes rows into ClickHouse.
Raw queue, control queue
Two SQS queues that announce new segments to the ETL. The raw queue carries gateway captures; the control queue carries customers' trace uploads (span ingest). They were split on 2026-11-21 so one cannot delay the other.
ClickHouse tables
usage_events and spend_facts (one row per request, for totals and charts; on main today); and in the new design: the requests table (the Requests list), spans (every step of every trace), session and trace summaries, and request_text (searchable text, up to 32 KB per request).
Rollup
A table of pre-computed totals (per hour, day or quarter hour), so a chart sums a few rows instead of millions.
Session
All the requests of one conversation or agent run, grouped by a session id the caller sends (or that we read from Claude Code, Codex and similar headers).
Trace and span
A trace is one run of an agent, shaped as a tree. Each node is a span: an LLM call, a tool call, a retrieval, a step. Spans come from two places: the customer's own code (over OTLP or Langfuse ingest) and the LLM calls our gateway serves.
Tool span
A span for a tool the agent ran. We can infer it from traffic: a model answer that asks for a tool, followed by a request carrying the tool's result.
Tag, judge, score
A tag is a question a customer defines ("did the agent give up?"). A judge model answers it for each captured request or session. A score is a number attached to a request or trace, by a judge or a person.
Dataset, review queue
A dataset is a saved set of requests or traces for testing. A review queue is a list of items for people to score by hand.
Retention, expiry, erasure
Retention is how long content is kept. Expiry is the date it is deleted. Erasure deletes every copy of an organization's content when it opts out or asks; one erasure job reaches every store.
Per-key storage
A storage setting on each API key ("follow the organization" or "do not store"), plus a per-request header. Both can only store less than the organization's switch, never more.
Reliability and process words
These describe how the system behaves when something fails, how we measure speed, and how changes are made and tested.
Word
Meaning here
Readiness
A check Kubernetes runs on each pod. A pod that fails it stops receiving traffic. If every gateway pod fails it at once, the edge has nowhere to send requests and returns 502 to everyone.
Breaker
A circuit breaker. After a few failed calls to a store, it "opens": for a short time every call is refused at once instead of waiting for a timeout. Then it tests the store again and "closes" when the store answers.
Prober
A background thread that tests a store while its breaker is open, so no customer request has to be the test.
Outage bound
How long the gateway keeps serving from its last good copy of keys, grants and prices during a Postgres outage: one 60-minute bound for every path, OUTAGE_SERVE_STALE_SECONDS in explabs/outage_bound.py.
Maintenance window
A planned period of 1 to 30 minutes, opened by an operator before a Postgres restart, during which Postgres refuses every chain change, so workers may keep serving protected chains from what they last read.
Admission slot, bridge thread
Each gateway worker admits at most 64 requests at a time. Inside it, the Rust engine calls back into Python through 4 "bridge" threads; a request needs one to be checked and admitted.
Fair share
A rule that divides limited capacity between organizations, so one busy organization cannot take it all.
p50, p95, p99
Percentiles. p50 is the median. p95 means 95 of 100 requests were at least this fast; it describes the slow tail.
Open-loop load
A load test that sends requests at a fixed rate whatever the answers, the way real clients do, so a slow server builds a real queue.
PR, CI, check
A pull request (PR) is a proposed change on GitHub. CI runs automatic checks on it (tests, lints, migration rules); each passing or failing job is a check.
Migration; expand and contract
A migration changes the database schema. Because the running code keeps using the database while a new release rolls out, a breaking change ships in two steps: first add the new shape beside the old (expand), later remove the old one (contract).
Round
One cycle of the 2026-11-22 adversarial testing: measure, compare designs, build the winner, redeploy, measure again.
!1039, #2980
Change numbers. "!" numbers are GitLab merge requests (the platform lived on GitLab until it moved back to GitHub on 2026-11-17). "#" numbers are GitHub pull requests.
Part 3
How the system works
This part describes production as built on main on 2026-11-09, when this investigation started. It goes from the short version, to one simple diagram with every box and arrow explained, to the full map, and then follows one request through every store. The new design that PR #2980 builds is told in Part 5; where it changed something described here, a dated note says so.
The short version
Each store does one job. While the gateway serves a request, it waits on only one store, MemoryDB. The other stores are filled in the background after the answer is sent, with one exception for captures that the correction below explains.
MemoryDB is the only store a production request waits on. Before the provider is called, it checks the rate limits and reserves the request's maximum cost from the organization's balance. After the answer ends, it charges the real cost. It keeps this data in memory for speed and also writes every change to a durable log, so a crash loses nothing.
Postgres is the system of record. About a second after each request is charged, background threads copy it into Postgres: the request row, its attempts, the usage event, and the hourly and daily rollups.
ClickHouse answers every chart and total. Each usage row is saved in Postgres together with a "send this to ClickHouse" note, in one transaction. A background thread reads the notes and copies the rows to ClickHouse. Because the row and the note are saved together, ClickHouse cannot miss a request that Postgres has.
Supabase Storage holds the prompt and response bodies. Postgres keeps only a small pointer row per request. The gateway gives the body to a separate capture thread, so a normal request does not wait for the upload. The exception is that each worker can hold only a limited number of bodies that are not uploaded yet. When Postgres is slow, uploads take longer, that space fills up, and new requests are refused (see the correction below).
Cloudflare sits in front of the two public hosts. It handles HTTPS encryption (TLS), runs the web application firewall (WAF) rules, and tells us the caller's real IP address. It stores nothing for us.
PostHog only gets product analytics events: page views, sign-ups, and the first gateway request. No request content goes there.
Observability reads three of these stores:
the request list and single requests from Postgres, through an index, one page at a time;
every number and chart from ClickHouse;
bodies from Storage, one request at a time.
Since !1039 merged on November 9, any API key of an organization can make these reads. A customer's agent can use its normal key to read the organization's own request log.
Correction. "The request never waits for the body" is only true while Postgres is fast. Here is why:
Each gateway worker keeps a copy of every capture in a buffer of limited size until the upload is confirmed.
A Supabase Storage upload is confirmed only after Supabase commits two rows in our main Postgres: a storage.objects row for the file and a gateway_capture_inbox row.
When Postgres is slow, those commits are slow, copies stay in the buffer longer, and the buffer fills.
Once it is full, the engine refuses each new request that would be captured with 503 capture_unavailable.
That happened on November 9 at 12:07, 13:05 and 14:17Z (123 requests, 76 orgs). See November 9 refusals.
The simple picture, piece by piece
This is the main diagram to remember. Below it, every box and every arrow gets a row: what it is, how it works, why it is there, and what happens when it fails. The fuller maps further down add our GPU boxes, SQS and Fargate.
Solid arrows are writes, dotted arrows are reads. The numbers match the "Every arrow" table. Arrows 1 to 7 and 12 happen while the caller waits; 8 to 11 and 13 happen in the background.
The two tables below explain the diagram. The first describes every box: what it is, how it works and why it is there. The second follows every numbered arrow: what moves along it, when, and what happens when it fails or slows. Terms are defined in Part 2.
Every box
Box
What it is
How it works
Why it is there
Caller (SDKs, agents)
The customer's code calling https://api.experientiallabs.ai/v1.
Speaks the OpenAI Chat Completions or Responses API, or Anthropic Messages. Usually streams the answer (server-sent events).
It is the product: the gateway is a drop-in replacement for a provider's API, so customers change only a base URL and a key.
Browser
A person using the dashboard at platform.experientiallabs.ai.
Loads Next.js pages; the pages call our /api routes.
Observability, keys, billing and settings live here.
Cloudflare
A network in front of our two public hosts.
Decrypts HTTPS (TLS), applies firewall (WAF) rules to the sign-in paths only, adds CF-Connecting-IP and a secret header, and forwards to our AWS load balancer. Streams can stay open for about an hour.
DDoS and bot protection for sign-in, and a trustworthy client IP for geography and abuse rules. It never challenges /v1, because an SDK cannot solve a browser challenge.
Public edge
12 pods of explabs-api that receive /v1 traffic.
Passes requests to the gateway workers unchanged. Each pod keeps 300 connections to the workers; one API key may use at most a quarter of them, and a quarter is always kept for keys below that share. A request over its key's share waits up to 1 s, then gets a 429 the caller can retry.
With a plain first-come, first-served pool, one caller streaming hundreds of long answers took every connection and blocked everyone (staging test, November 4). Because the edge is a separate, thin layer, a gateway release does not drop the connections callers hold to the edge.
Web app
10 pods of the Next.js dashboard.
Renders pages on the server and proxies the browser's /api calls to the control plane with the signed-in user's identity.
One place for sessions, cookies and page rendering; the control plane stays a plain JSON API.
Gateway worker
30 pods running a Python front and the Rust engine.
Authenticates the key, mints the request id, and decides whether the request may be captured and whether it needs zero data retention (ZDR). It then picks a lane (a provider route for the model), reserves money in MemoryDB, calls the provider, streams the answer back, charges the real cost, and buffers the capture. Each pod serves at most 64 requests at a time.
The only process that talks to providers, so routing, failover, pricing and limits are decided in one place. Rust keeps per-request overhead low.
Providers
OpenAI, Anthropic, Vertex, Bedrock, OpenRouter and others, plus our own GPU boxes (Experiential Cloud).
Receive the request in their own wire format. If one lane fails, the gateway can retry on the next lane for the same model.
The model does the work; we route, bill and record.
MemoryDB
AWS's durable in-memory database (Valkey).
Each money operation is one small Lua script that runs as a single uninterruptible step on the server (shard) that holds that organization's keys. A write is confirmed only after it reaches a log copied across availability zones.
In September every money operation locked the organization's row in Postgres, so one busy org's requests formed a queue that slowed everyone. MemoryDB answers in well under a millisecond and orgs never wait on each other. See MemoryDB in depth.
Control plane threads
Background threads inside the 6 explabs-ctl pods, next to the dashboard API.
The ledger writeback, the settle drain, the ClickHouse exporter and the credit feed. Each checks for new work about every second and claims a batch with a time-limited lock (a lease), so two pods never process the same batch.
They must keep running while other services are released. The ClickHouse exporter moved here from the Project worker because each Project worker release paused it, and every Spend report stopped updating.
Postgres
Our one Supabase database, 1,336 GB.
Tables, transactions, foreign keys, triggers. In production, request data arrives a few seconds after the request, copied in by the background threads.
The system of record: keys, orgs, money history, request rows, capture pointers. Authorization and billing need its transactions and constraints.
ClickHouse
A columnar analytics database.
Stores each column separately and compressed, so a sum over one column for one org reads a small fraction of the data. If the same row is inserted twice, ClickHouse later merges the copies into one in the background (ReplacingMergeTree). Queries add FINAL so they see one copy even before that merge.
On September 19, Postgres queries that summed a busy customer's usage over a time window hit the 8 s timeout. ClickHouse answers the same question in milliseconds.
Supabase Storage
Supabase's file service.
Bytes go to S3 that Supabase owns; every file also gets a row in storage.objects inside our Postgres, committed with the upload.
Bodies are too big for database rows (inline capture reached 748 GB in two weeks). The drawback is that each upload still commits that row in Postgres (see November 9).
PostHog
Product analytics.
The browser and a few server events send named events (page views, sign-up, first gateway request).
Product funnels and activation. It never receives request content.
Every arrow
#
From, to
What moves
When
If it fails or slows
1
Caller to Cloudflare
The HTTPS request with the xpl_ key
Every call
The caller sees a connection error; nothing is recorded.
2
Browser to Cloudflare
Page loads and dashboard API calls
As the person browses
The dashboard is unavailable; serving is unaffected.
3
Cloudflare to edge
api host traffic, plus the client IP and the secret header
Every call
Our servers refuse any request without the secret header (403). A 502 or 504 from us is changed to 503, because Cloudflare would replace a 502 or 504 body with its own page and our JSON error would be lost.
4
Cloudflare to web
platform host traffic
As the person browses
As arrow 2.
5
Edge to gateway worker
The same request over a pooled connection, plus a signed note of the caller's country, valid for 60 seconds, so the worker can apply country rules without looking up the IP address again
Every call
The edge retries once on a new connection if a retry cannot run the request twice. Otherwise the caller gets a 429 or 503 it can retry.
6
Gateway to provider
The request in the provider's wire format; the answer streams back
Every attempt
If the type of failure allows it, the engine retries on the next lane. The caller still gets exactly one answer.
7
Gateway and MemoryDB
Rate-limit check, money hold, settle; the settle appends a receipt
Twice per request (before and after the provider call)
The request is refused. MemoryDB is the only store the gateway cannot serve without.
8
MemoryDB to control plane
Receipts, read from 8 streams in batches of up to 500
About every second
Receipts stay in MemoryDB, which is durable, so none are lost. Postgres, the dashboards and capture processing all fall behind, because they all depend on these receipts.
9
Control plane to Postgres
One transaction per batch: wallet entries, request and attempt rows, a settle outbox row; then the drain writes the usage event and its triggers fill rollups and the ClickHouse outbox
About every second
The batch is retried. Postgres records each receipt id and skips an id it has already applied, so a retried batch never counts a request twice.
10
Postgres to control plane
ClickHouse outbox rows (the usage event and its spend facts)
About every second
Rows wait in the outbox. Spend reports show data only up to the oldest row not yet delivered, so a report never shows a period with rows missing.
11
Control plane to ClickHouse
Batches of up to 500 rows into usage_events and spend_facts, counted in ClickHouse before the outbox rows are deleted
About every second
Retried, with a longer wait after each failure. If a retry sends a row that already arrived, ClickHouse keeps only one copy (ReplacingMergeTree).
12
Gateway to Storage
One compressed file per record. Each request has two records: a prompt checkpoint and a complete record
After the request, from the capture buffer
The capture stays in the worker's buffer and is retried. If the buffer fills, new captured requests are refused with 503 (November 9).
13
Storage to Postgres
The storage.objects row and a gateway_capture_inbox row, in the same commit as the upload
Every capture upload
The upload waits for this commit, so a slow or failed commit makes the upload slow or fail. That is why arrow 12 backs up.
14
Web to control plane
Dashboard reads with the user's identity; agents call the same routes directly with a key
On page load and every 10 s on Requests
The page shows an error tile; serving is unaffected.
15
Control plane to Postgres
Request list pages (index seek, up to 200 rows), one request, attempts
Per read
A slow database slows the list. A sort that would have to read too many rows is refused with 422 instead of being run.
16
Control plane to ClickHouse
Aggregate queries for one org and window
Per chart
Busy: 429 with Retry-After. ClickHouse down: 503, with no Postgres fallback by design.
17
Control plane to Storage
One pointer row, then one compressed object
When someone opens a request
The drawer says the body is unavailable.
18
Web to PostHog
Named product events
As the person browses
Dropped silently; nothing depends on it.
System map
Solid arrows carry writes; dotted arrows carry reads or the capture side path. In production, the gateway worker does not write to ClickHouse or Postgres tables while it serves a request. There is one indirect exception, described in the warning about storage.objects below the map.
flowchart LR
SDK["SDKs, coding agents /v1 calls"] --> CF
BR["Browser dashboard"] --> CF
PRB["Status probe Lambda every 5 min"] --> CF
CF["Cloudflare TLS, WAF, client IP, origin secret header"] --> LB["AWS load balancer and ingress-nginx"]
subgraph EKS["EKS cluster, deployed by Porter"]
EDGE["Public edge, 12 pods relay and fair share"]
GW["Gateway worker, 30 pods Python front and Rust engine capture buffer: memory then disk"]
WEB["Web app, 10 pods"]
CP["Control plane, 6 pods dashboard and admin API"]
end
LB --> EDGE --> GW
LB --> WEB --> CP
GW <-->|"limit, hold, settle"| MDB[("MemoryDB")]
GW -->|"dispatch"| PROV["Third-party providers OpenAI, Anthropic, Vertex, Bedrock, OpenRouter"]
GW -->|"dispatch"| VM["GCP VM gateway.xplabs.ai Caddy, one path per lane"]
BOX["Our GPU boxes Azure, GCP, Lium, Arrakis"] -->|"reverse SSH tunnel"| VM
GW -.->|"raw capture upload, commits in Postgres"| ST[("Supabase Storage")]
CP -.->|"lists, one request"| PG[("Postgres")]
CP -.->|"charts, totals"| CH[("ClickHouse")]
CP -.->|"bodies"| ST
The request path. Everything a customer waits on: Cloudflare, the edge, a gateway worker, MemoryDB and a provider. Our own GPU boxes are reached through the GCP VM, not through Cloudflare. The dotted capture upload is the one place a customer request can still end up waiting on Postgres.
Everything that happens after the caller is gone: money receipts flowing into Postgres, credits flowing back into MemoryDB, usage into ClickHouse, and the capture pipeline with its Postgres commits.
The hidden Postgres write. "Supabase Storage" looks like S3, but it uses our database. Each upload, delete and metadata read touches the storage.objects table, in the same Postgres that holds the ledger. Since !1024 (November 5) the same transaction also inserts the gateway_capture_inbox row. So the capture path still waits on a Postgres commit. Our code does not issue that commit; Supabase Storage issues it inside the upload.
Write path: one request, start to finish
This section follows one POST /v1/chat/completions through production, store by store. It shows which steps the caller waits for and which happen later. In the diagram, everything above the note runs while the caller waits. Everything below it happens on background threads, normally within a few seconds.
sequenceDiagram
autonumber
participant C as Client
participant CF as Cloudflare
participant E as Public edge
participant G as Gateway worker
participant M as MemoryDB
participant P as Provider
participant S as Storage
participant CP as Control plane
participant PG as Postgres
participant PW as Project worker
participant CH as ClickHouse
C->>CF: POST /v1/chat/completions
CF->>E: forward with edge secret and CF-Connecting-IP
E->>G: relay through a fair-share slot
G->>G: authorize, mint request id, freeze consent and ZDR verdict
G->>M: rate limit check, wallet hold
G->>P: dispatch, fail over on error
P-->>G: stream tokens
G-->>C: stream, usage.cost, x-request-id
G->>M: settle, append receipt to stream
G-)S: raw capture object on the capture thread
Note over C,G: The caller is done here
CP->>M: drain receipt streams, about every second
CP->>PG: gateway_requests, gateway_attempts, wallet_entries
PG->>PG: settle_outbox row
CP->>PG: drain outbox into gateway_usage_events
PG->>PG: triggers fill hourly and daily rollups and the ClickHouse outbox
CP->>CH: export batch, count back, then acknowledge
S->>PG: storage trigger writes a capture inbox row
PW->>S: finished document, then gateway_captures pointer in Postgres
The request path writes only to MemoryDB and hands the body to a capture thread. Postgres, ClickHouse and the final capture document are all filled afterwards by background workers.
The steps in words
Cloudflare. Cloudflare decrypts HTTPS (TLS) for the two public hosts. It adds the caller's IP and a secret header that proves the request came through our zone. No browser challenge ever runs on /v1, because SDKs cannot answer one. Our servers reject any request without the secret.
Public edge. A thin relay that passes the request on without reading or changing it. It gives each API key a fair share of its 300 connections to the gateway workers, so one heavy caller cannot take every connection and make everyone else wait.
Gateway worker. The Rust engine authenticates the key and mints the request id (request-<uuid>, returned as x-request-id). It also decides, once, whether this request may be captured and whether it must use zero data retention; later steps reuse that decision. It then dispatches to a provider and fails over between providers when needed.
MemoryDB. MemoryDB first checks every rate limit in one step. It then reserves the request's maximum cost from the wallet (the hold), and when the response ends it charges the real cost (the settle). MemoryDB confirms a write only after it reaches its log in several availability zones, so the hold survives a crash without any call to Postgres. The settle appends a receipt, carrying the request and attempt rows, to one of eight streams.
Capture. The response bytes go to a capture thread, never to the loop that serves requests. That thread uploads one compressed raw object to Storage. A storage trigger then writes a small inbox row in Postgres. Correction: the capture stays in the worker's bounded buffer until that upload commits. The commit is a Postgres transaction (storage.objects plus the inbox row). If the buffer is full when a new request starts, the engine refuses the request. See Captures and S3.
Writeback (control plane). It reads the receipt streams in batches of 500 and writes gateway_requests, gateway_attempts and wallet_entries in one transaction. Each receipt is applied exactly once, and it is removed from MemoryDB only after the Postgres transaction commits. It is normally a few seconds behind. When Postgres was slow it fell further behind: it averaged up to 2.5 minutes behind in some hours on November 5, and fell up to 5.8 minutes behind on November 9.
Settle outbox. The writeback leaves a settle_outbox row. A separate drain turns it into the gateway_usage_events row. That row's triggers fill the hourly and daily rollups, the budget counters, and the ClickHouse outbox.
ClickHouse export (control plane). Takes batches of up to 500 from the outbox and inserts them into usage_events and spend_facts. It counts the rows back and only then deletes the outbox rows.
Capture writer (Project worker). Turns the raw object into the final document, explabs-gateway-captures/<org>/<hash>.json.zst, and writes the gateway_captures pointer. It needs the request row first, because that row holds the consent facts. The row is written later by the writeback (money is settled in MemoryDB first), so the body can arrive before the row exists. Updated: since !1024, an item whose request row is missing stays in the inbox as metadata_pending. It is retried forever, waiting 10 s at first and doubling up to 300 s. The old five-minute discard is gone, and there is no dead-letter shelf. Live: 298 such rows have been pending since November 6.
MemoryDB and the double ledger, in depth
This section explains the store that every request waits on, and why money is kept in two places.
What problem it solves. Every request has to answer two money questions while the caller waits:
before calling the provider: "may this org spend up to X right now?"
after the answer: "what did it actually cost?"
Before the double ledger, both answers were Postgres transactions that locked the organization's single row (organizations ... FOR NO KEY UPDATE). Postgres lets only one transaction at a time change a row, so one busy org's requests queued behind each other. The waiting held database connections and worker threads, and every other customer queued behind them.
This is what happened in the Koodos incidents: 40 to 57 transactions waited on one row, and admission took 20 to 145 seconds for every customer.
What MemoryDB is. A Redis-compatible database that keeps data in memory, so a read or write takes well under a millisecond, but writes every change to a multi-zone log before saying "done", so a crash or failover loses nothing that was acknowledged. Unlike Redis used as a cache, it is configured never to delete data to free memory (noeviction).
Why it removes the queue. Each money operation (reserve, settle, release, credit) is a small Lua script that runs atomically inside MemoryDB.
All of an org's keys share one hash tag (the part of the key name in braces), so they are stored on the same shard. That lets one script update the balance, the hold and the receipt in one step.
A script runs in microseconds, so even a busy org's operations finish before the next one arrives.
Different orgs never wait on each other.
Nothing holds a database connection or a worker thread while waiting.
Why "double". There are two copies of the money. MemoryDB holds the live balance that the gateway checks on every request. Postgres holds the permanent record used for history, invoices, the dashboard and audits. Every movement in MemoryDB appends a receipt, and background workers copy receipts into Postgres exactly once. Money flowing the other way (a purchase, an admin grant, a promotion) is written to Postgres first and pushed into MemoryDB by the credit feed.
MemoryDB key (per org, n = crc32(org) mod 8)
Holds
{fl:bl:receipts:n}:<org>:acct
balance, amount currently held, seed version
{fl:bl:receipts:n}:<org>:hold:<attempt>
one open hold: amount, caps it counts against, state, time
{fl:bl:receipts:n}:<org>:cap:<scope>
spend-cap window counters (spent, held), expiring with the window
{fl:bl:receipts:n}:<org>:promo:<promo>:<period>
promotion credit: granted, spent, held, written off, expiry
{fl:bl:receipts:n}:stream
the receipt stream for every org on shard n (8 streams total)
{fl:lim:...}
rate-limiter counters (requests and tokens per window)
sequenceDiagram
autonumber
participant G as Gateway worker
participant M as MemoryDB
participant W as Writeback, control plane
participant PG as Postgres
participant F as Credit feed
participant R as Reconciler
Note over G,M: First request of an org since a restart
G->>M: reserve
M-->>G: UNSEEDED
G->>PG: read balance, grants, promos once
G->>M: seed the org
Note over G,M: Every request
G->>M: reserve worst-case cost against balance, caps, promos
M-->>G: OK, or INSUFFICIENT_FUNDS, CAP_EXCEEDED, PROMO_EXHAUSTED
G->>G: call provider, stream answer
G->>M: settle actual cost, release the rest, append receipt
Note over W,PG: Seconds later, off the request path
W->>M: read up to 500 receipts per stream
W->>PG: one transaction: wallet_entries, gateway_requests, gateway_attempts, settle_outbox
W->>M: acknowledge and delete those receipts
Note over F,M: Money coming in
PG->>F: purchase, admin grant, promotion
F->>M: credit the org
R->>M: compare balances
R->>PG: record mismatches in wallet_differences
The gateway only ever waits on MemoryDB. Postgres learns about each request from the receipt, a few seconds later. A hold sweeper (not drawn) closes any hold still open after the late-cost window, for example when a worker crashed mid-request.
What this means for everything downstream
Money is right in real time even when Postgres is slow. Balances and holds never wait for the writeback.
Everything that reads Postgres sees each request only after the writeback copies it in: the request list, usage events, rollups, ClickHouse (fed from Postgres), and the capture processor, which needs the request row before it may store a capture.
The writeback is now the only path by which request data enters Postgres. When Postgres write throughput drops (an autovacuum on a 100+ GB table, a heavy migration), receipts pile up in the MemoryDB streams. Nothing is lost, because MemoryDB is durable and receipts are deleted only after commit, but every downstream consumer falls behind together.
Still on Postgres by design: batches, customer-plan (reseller) keys, and video jobs still reserve money in Postgres, because their money rules have not been moved to MemoryDB.
Pending: the "fast-ledger parity" fixes (auto top-up, credit floor, free refills, rollover, payment quarantine, signup scan, anti-abuse, grants reconciliation) are merged at 64d1d708e and verified on staging, but production runs 72edcb540 until Kion approves the deploy. See Changes and status.
Inboxes and outboxes
Data moves between our stores through a few standard handoff patterns. This section explains them, then lists every handoff we run, because the weak ones are where the November incidents started.
The problem they solve. Many steps here have to do two things: change a database and tell another system about it. For example, record a usage event and also send it to ClickHouse. If the code does the two separately, a crash between them leaves the systems disagreeing forever. This is called the dual-write problem. You cannot fix it by doing the second write first either, because then the first can fail.
Outbox. Write the message into a table (the outbox) in the same transaction as the change. Either both commit or neither does.
A separate process (the relay, or drain) reads the outbox, delivers each message, and deletes it only after the destination confirms. If the relay crashes after delivering but before deleting, it delivers again. So delivery is at least once. The receiver must therefore be idempotent: receiving the same message twice must have the same effect as receiving it once.
Inbox. The receiving side of the same idea. The receiver records each message's id as it processes it (or writes the message into an inbox table first and processes from there). A duplicate is recognized and skipped. When the sender may deliver a message more than once and the receiver skips duplicates, each message takes effect exactly once. That is the strongest guarantee that is practical between two systems.
Stream. An append-only log (here, a Valkey stream in MemoryDB). Producers add entries to the end. A group of consumers reads them, and each entry stays in the log until a consumer confirms it has handled it. It works like an outbox that lives in MemoryDB instead of Postgres.
Dead-letter shelf. Where a message goes after it has failed a set number of times, so one broken message stops being retried forever and a person can look at it. SQS has this built in. Our Postgres outboxes and the capture inbox do not.
sequenceDiagram
participant A as Producer step
participant DB as Its database
participant R as Relay
participant B as Receiver
A->>DB: one transaction with the change and the outbox row
Note over A,DB: both commit or neither does
R->>DB: claim a batch of outbox rows with a lease
R->>B: deliver the batch
B->>B: skip ids already applied, apply the rest
B-->>R: confirmed
R->>DB: delete the delivered rows
Note over R,B: a crash before the delete means the batch is delivered again, and the receiver skips it
The outbox pattern. The change and its message are saved together, so one cannot exist without the other. A retry is harmless because the receiver skips messages it has already applied.
Every handoff we run
Handoff
Kind
Written in the same step as
Drained by, how often
Duplicate protection
When the drain stops
Dead-letter shelf
Receipt streams {fl:bl:receipts:0..7}
Stream (outbox in MemoryDB)
The money movement, in one Lua script
Ledger writeback, control plane, about 1 s, 500 per batch
A unique key on (kind, receipt id) in Postgres, so a repeated receipt is skipped
Receipts wait safely; Postgres and everything after it lag
Rejected receipts go to balance_ledger_receipt_rejects
settle_outbox
Outbox
The request and attempt rows
Settle drain, control plane, about 1 s, SKIP LOCKED
Usage event is unique per request id
Usage events and rollups fall behind. If the drain stops reporting that it is alive (its heartbeat), settles write the usage event directly instead
None
gateway_usage_clickhouse_outbox
Outbox
The usage event (a trigger)
ClickHouse exporter, control plane, about 1 s, 500 per batch, 690 s lease
ClickHouse keeps one copy of a repeated row (ReplacingMergeTree), and queries use FINAL to see one copy. Rows are counted in ClickHouse before the outbox rows are deleted
Charts lag; Spend reports stop at the oldest undelivered row
None. A row stays until it is delivered, so one row that cannot be delivered holds Spend's data cutoff at that row's time
Credit feed
Outbox (Postgres to MemoryDB)
A purchase, admin grant or promotion
Credit feed thread, control plane
MemoryDB applies each event id (wallet_entries:<id>) once; after each pass the feed records how far it has read (a cursor)
New money does not reach live balances; a reconciler reports drift
None
gateway_capture_inbox
Inbox, filled by Storage
The storage.objects row of the upload
Capture processor, 64 Project worker pods
The object path is the primary key, so one file cannot be queued twice
Captures wait as metadata_pending until the request row arrives
None: 298 rows stuck since November 6
Illegal-content review queue
SQS queue
(a sweep finds new captured traffic)
ECS Fargate service
SQS redelivers until deleted
Messages wait in SQS
Yes, an SQS dead-letter queue
What this table shows. The money and usage handoffs follow the standard pattern closely. The message is saved in the same step as the change, a lease stops two pods from handling the same batch, and receivers skip duplicates.
The two weak spots are the ones the November 9 incident hit:
The capture inbox row is created by a Postgres commit that the gateway waits for before it frees buffer space. So a slow Postgres slows the gateway.
None of the Postgres handoffs has a dead-letter shelf. So a single bad item can wait forever or hold others back.
Captures and what goes into S3
This section explains how prompts and responses are saved today, where the bytes end up, and how that differs from where we want to be.
A capture is the saved prompt and response of one request. It is kept only for organizations whose capture switch is on, and never for a request routed under zero data retention. Captures feed the request drawer, content review, retention contracts and training data.
Why the worker buffers in memory, then on disk
The complete record does not exist until the stream ends. A streamed answer arrives over seconds or minutes. The worker writes two records per request: a prompt checkpoint at the start (so a crashed or very long request still leaves its prompt) and a complete record (prompt plus response) at the end.
The copy must survive until the upload is confirmed. If an upload fails, the worker retries from its copy. Throwing the copy away early would lose the capture.
Captures go to memory first because it is fast, and to disk when memory is full. Each worker allows 256 MiB of capture memory, then spills to local disk up to 4 GiB. Coding agents send prompts of several MB, and a caller body may be up to 128 MiB.
Admission is bounded. A worker holds at most 2,048 captures (and a byte budget) at once. When a new request arrives and the buffer is full, the engine refuses the request with 503 capture_unavailable instead of serving it uncaptured (native_capture.py, collector.rs::begin). It refuses (fails closed) because some orgs are under mandatory retention, and serving them without keeping a copy would break that promise.
Memory risk. Bodies are read into memory before they spill, and a pod's limit is 4 GB, so a burst of very large captured requests can push a pod over its limit and Kubernetes kills it, dropping every request on that pod. Helicone avoids this with a separate spillover container that holds bodies outside the serving process.
How a capture flows today
The gateway worker buffers the capture (memory, then disk).
It uploads the raw compressed record (<digest>.prompt.zst or .complete.zst) to the Supabase Storage bucket explabs-gateway-captures. Supabase stores the bytes on its S3 and, in the same Postgres transaction, writes the storage.objects row and the gateway_capture_inbox row.
Only when that commit returns does the worker free the buffer slot.
A processor claims inbox rows. Live: the 64 Project worker pods (the Fargate runtime exists but the switch is set to worker).
It reads the first 256 KiB of the object, then checks that the request's gateway_requests row exists (that row carries the consent, zero data retention and erasure facts). If not, the item waits as metadata_pending.
It downloads the whole object, writes the final document <org>/<hash>.json.zst and the gateway_captures pointer, and deletes the raw object.
Separately, the illegal-content review service (ECS on Fargate) finds newly captured traffic to uncensored models, puts it on its SQS queue, scores prompt windows with clef on our GPU boxes, and suspends abusive organizations. A message that keeps failing lands in its dead-letter queue.
What
Where the bytes live
Written by
Postgres rows it creates
Read by
Raw capture records (prompt checkpoint, complete record)
Supabase Storageexplabs-gateway-captures
Gateway worker
storage.objects + gateway_capture_inbox, per object
Capture archive (free-org traces older than 14 days)
Our AWS S3 explabs-capture-archive-…
Nothing yet
none
Empty (live)
Trace pipeline raw and processed buckets, SQS queue, KMS key
Planned in our AWS S3
Terraform code merged (!492)
none
Not created: no such buckets or queue exist in the AWS account (checked live)
The ideal split, and how today differs
The intended shape has three parts:
ClickHouse holds one small row per request (metadata, cost, latency, session ids, and a short truncated preview for search).
S3 holds the full prompt and response.
The frontend lists and searches from ClickHouse. When someone opens a request, the control plane checks authorization and fetches that one body from S3.
This design is sound, and it is where we are heading. The table shows how today differs, question by question.
Question
Today
Target
Where is the per-request summary?
Postgresgateway_requests (list) and ClickHouseusage_events (totals)
ClickHouse for list, search and totals; Postgres keeps only what money and authorization need
Where are bodies?
Supabase Storage, with a storage.objects row and a gateway_captures pointer row in Postgres per file
Our own S3, addressed by a deterministic key (org, request); no per-file Postgres row needed to find it
How does a body get stored?
Upload commits in Postgres; processor waits for the request row
S3 PUT, S3 notifies SQS, an autoscaled Fargate consumer loads summaries into ClickHouse and Postgres; consent facts travel inside the object
Is body text searchable?
No
A truncated text column with an n-gram or token index in ClickHouse, deleted with the body on erasure (Helicone keeps bodies up to 10 MB inline in ClickHouse instead)
Capture paths: what is kept on each surface
A request can reach us through many API surfaces (chat, Responses, batches, images, audio and more). This section lists what is stored for each one, and what it would take to close the gaps.
The rule on every path.
Content is stored while the organization's prompt storage switch is on, whatever key or plan serves the request: platform credits, the customer's own provider key, or a connected Claude or ChatGPT plan.
It is never stored for a request routed under zero data retention, and never stored with the switch off. Uncensored models are the exception. Their requests are always stored, and a request to them that asks for zero data retention is refused.
Metadata (model, tokens, cost, status, latency, key, end-user label) is recorded on every path whatever the switch says.
The list of capture paths (the catalog) lives in the repo as docs/capture-paths.md. It is on branch capture-batch-and-websocket (commit 0ed5eaaa1) together with the batch-line capture, and not yet on main.
Path
Prompt
Response
Why, or what blocks it
What closing it takes
Effort
Chat Completions (HTTP)
kept
kept
Uses the full pipeline. Consent is decided once at authorization, the engine copies the response as it streams (the response tap), and the capture writer stores it.
Nothing.
Responses (HTTP)
kept
kept
Same pipeline.
Nothing.
Responses over WebSocket (Codex)
kept
kept
Each turn runs through the Responses handler and its tap (engine 0.7.233). The raw request and its headers are not copied, because a WebSocket turn does not pass through the HTTP relay that makes that copy.
Optional: record the frame and headers too.
S
Anthropic Messages (Claude Code)
kept
kept
Same pipeline.
Nothing.
Batch lines
after !1088
after !1088
On the branch, each line's consent is frozen when its money is reserved. At settlement the prompt and the output line go through the same sink as a live request, and an errored line keeps the provider's error as its response. If the capture queue is full, the capture is dropped and logged, so a full queue never blocks settlement.
Merge !1088.
S
Request refused after it was accepted
kept
none, there was no answer
The ledger re-reads consent and zero data retention, then keeps the prompt.
Optional: store our refusal message as the response.
S
Request rejected before it was accepted (bad request, rate limit)
not kept
not kept
Only a content-free row in gateway_request_rejections (30 days, admin only). Many of these refusals happen before we know whose key it is or whether the body asked for zero data retention. An unknown key would store a stranger's content, and attackers can send rejected requests at almost no cost.
Probably leave as is. The one safe subset: authenticated 400s from an org whose switch is on, where the body parses and does not ask for zero data retention. Store a truncated, credential-redacted body for 30 days.
M
Embeddings
not kept
not kept
The engine records only chat, Responses and Messages (CaptureRequest.protocol), and the platform records a consent decision only for those three. Output can be very large: up to 2,048 inputs times about 3,072 numbers.
An embeddings capture record (the input text, dimensions, format). Store the response as metadata only (count, dimensions, usage), with vectors only behind a setting.
M
Images (generation and edits)
not kept
not kept
Same three-surface filter as embeddings. Each image comes back as base64 (about 1 to 3 MB each, times n), and edit uploads can be up to 20 MB per part. Kept inline, they break the capture record's 8 MiB limit.
Store each image as its own object in the capture bucket. The record carries a reference (hash, type, size, key). The drawer shows thumbnails through short-lived signed links.
L
Speech (text to speech)
not kept
not kept
The prompt is at most 4,096 characters, but the response is raw audio (up to 64 MiB), which the response tap cannot read.
A binary response kind in the Rust tap, stored as an object reference; an audio player in the drawer.
M
Transcription (speech to text)
not kept
not kept
The prompt is the audio upload (up to 25 MB), and the bytes never reach Python, only their size and hash. The response is a small JSON transcript. Voice can identify a person, so it is sensitive.
Capture the upload inside the Rust data plane to the spill directory, then store it as an object reference beside the transcript.
M to L
Video
not kept
not kept
An asynchronous job: create, poll, download. The job record holds no prompt. Providers keep the video only briefly (Veo: 2 days). Consent has to survive the job's life of about two hours.
Capture the prompt and reference image at create, the same way as Images. At the end, store the job's final JSON (small), or copy the MP4 (tens to hundreds of MB, a storage cost).
L
Decisions (/v1/systemone, /v1/decisions; the Clef judge)
not kept
not kept
The shapes are small JSON, so capturing them is technically easy. The risk is who calls it. Our own illegal-content review sends excerpts of other tenants' prompts to Clef, and the signup scan sends personal data (email, IP, name), both through an Experiential Labs org key. Capturing those would copy tenant content and personal data into our own org's store, outside the tenants' deletion rules. The docs state "decision requests are never captured". Volume is high: about 30k calls an hour by your figure, with Clef capped near 30 requests a second.
A decisions capture record (state or input as the prompt, the questions in the envelope, the answers as the response), plus a no-capture rule for our internal callers (per key, or the switch off on the Experiential Labs org).
S to M
Why the gaps exist
No document records a decision to leave media out. The gaps come from how the code is built. The capture record is shaped like a conversation (a list of messages and a JSON or streamed response), and four places each accept only the three conversation surfaces (chat, Responses, Messages):
the engine's capture start (native_capture.py);
its record type (capture/record.rs);
the platform's consent step (control_store.py, which passes over the other surfaces);
the platform's capture writer (capture_writer.py).
As a side effect, media requests have no stored zero-data-retention verdict. The settle step treats a missing verdict as "do not keep", so the gap errs toward keeping nothing, which is the safe direction.
Closing them, in order
Merge !1088 (batch lines). Already built.
A media reference part in the capture document. One shared design for bytes: each image, audio clip or video is its own object in the capture bucket, under the same key prefix as its document. The record holds the reference, and deleting the capture deletes the media with it.
Consent for every surface. Decide consent once at authorization and write the consent record (gateway_capture_authority, the row that says "this request may be captured") for embeddings, images, audio, video and decisions, so the zero-data-retention verdict is always definite.
Small text surfaces first: decisions (with the internal-caller rule), embeddings (metadata only) and speech prompts.
Byte surfaces next: images, then transcription, then video. Each needs a drawer view (thumbnail, audio player, transcript, video job card).
Fix the drawer's wording for surfaces that are never captured. Today it says "Nothing was kept … only while prompt capture is on", which suggests turning on capture would help.
Stored outside Observability's request log
Responses API conversation state, for 30 days (only while capture is on).
Batch input and output files, until shortly after the batch expires.
exp capture traffic from local machines, shown only as admin run statistics.
Traces customers upload or pull in through connectors (OTLP, Langfuse, Braintrust), in ClickHouse trace_spans.
Capture broadcast copies sent to the organization's own destinations.
Guardrail decisions, kept only as content-free counts.
Read path: what Observability calls
This section shows the other direction: what the dashboard and agents read when they open Observability, and which store answers each read. In short, lists and single requests come from Postgres, numbers come from ClickHouse, and bodies come from Storage.
flowchart LR
subgraph Readers
AN["Analytics tab"]
RQ["Requests tab refreshes every 10 s"]
DR["Request drawer"]
AG["Agent with an org key new in !1039"]
end
API["Control plane gateway_usage.py, spend.py"]
AN --> API
RQ --> API
DR --> API
AG --> API
API -->|"fence: sandbox and erasure state"| PG[("Postgres")]
API -->|"list: index page of up to 200 one request, attempts"| PG
API -->|"totals, latency, breakdowns 8 reads per pod, 2 per caller, else 429"| CH[("ClickHouse")]
API -->|"Spend analytics snapshot fenced at the export cutoff"| CH
API -->|"one body: pointer, then object"| ST[("Storage")]
Lists and single requests come from Postgres indexes; every aggregate comes from ClickHouse; bodies come from Storage one request at a time.
What you see
Route
Store
How it stays fast
Request list
GET /usage/requests
Postgres
Index on (org, created_at, request_id); cursor paging with a frozen window; 200 rows maximum per page; a sort that would need to read too many rows returns 422 instead of running
One request, attempts
/usage/requests/{id}, /attempts
Postgres
Primary-key reads; attempts capped at 256
Prompt and response
/prompt, or ?include_body=true
Storage
One pointer row, then one compressed object
Charts, totals, latency, by provider, label and key
/usage/timeseries, /latency, /by-*
ClickHouse
Columnar scan of one organization's rows; per-query time, byte and memory limits; 8 concurrent reads per pod, 2 per caller
Spend analytics (Pro admins)
/spend/*
ClickHouse
Each report reads data as of one fixed point in time (a snapshot); reads share a 12 s budget; a ready report is reused for 30 minutes
System prompt rollup
/usage/by-prompt
Postgres
The only remaining read that sums the Postgres ledger. Results are cached in each process, and API keys cannot call it
Store by store
This table sums up each store in one row: what it holds, who writes it, whether a request waits on it, and how long data is kept. The second table shows where the database's size sits.
Store
What it holds
Who writes it
On the request path?
Retention
Cloudflare
Nothing stored. TLS, WAF, client IP header, origin secret header
Gateway capture thread, Project worker, export jobs
No, the body is handed to a separate thread
Prompt and response pairs kept; unpaired prompts expire; per-contract 1 to 90 days
PostHog
Product analytics events only
Web app; one gateway event per org (first request)
No, best effort
PostHog's
Correction: the trace pipeline's AWS resources (explabs-traces-* buckets, an SQS queue and a KMS key, infra/traces) are defined in Terraform merged with !492 but were never created: none exist in AWS account 761200393827 (checked live). The code that would have used them (!493 to !525) was closed unmerged. Captures go to Supabase Storage.
Where the database's size is
Live on 2026-11-09: the database is 1,336 GB. Every update or delete leaves a dead row that autovacuum must clean up later. On large, constantly updated tables that cleanup is heavy, and it competes with every commit for disk throughput. The table lists the largest tables. Look at the "Dead rows" column: storage.objects and the chain receipts carry millions, which is what made vacuum heavy on November 9.
Table
Size
Dead rows waiting for vacuum
Retention today
Belongs in
audit_log
311 GB
40 k
None
Partitioned by month in Postgres, or cold storage after a window
gateway_attempts
238 GB
54 k
None
Postgres for recent money facts; history in ClickHouse
gateway_usage_events
188 GB
227 k
None
ClickHouse already has every row; Postgres needs only a window
storage.objects
167 GB
10.7 M
Follows files
Shrinks once captures move to our own S3
gateway_requests
105 GB
358 k
None
Postgres for a window; history in ClickHouse
gateway_chain_authority_receipts
67 GB
5.8 M
None
A retention window (or partitions dropped whole)
gateway_grants
62 GB
1 k
None
Review it. Public grants are now computed when needed and are no longer stored as rows
gateway_captures
59 GB
1.0 M
Pairs kept; unpaired prompts expire
Pointer index moves to ClickHouse or a deterministic S3 key
Sessions today
Observability has no session view yet. Requests are grouped in two ways, and only the weaker one is visible.
What the log shows: content hashes
At authorize the gateway computes two hashes of the request body. prompt_group covers the system prompt and tool definitions (the same agent configuration). conversation_group adds the first user message, because agents resend it every turn. The request list can filter by conversation_group, and the drawer has a "Show only this conversation" action. The hashes have known weaknesses:
Two conversations that start with the same message merge into one group.
When an agent compacts (summarizes) a conversation, the first user message changes, so the rest of the conversation lands in a new group.
A Responses API continuation sends only its new turn, so the hash covers that turn alone and does not match the earlier requests.
What is written but not read: the session key
Since October 16 every request records:
session_key: from our X-Explabs-Session-Id header, the Claude Code or Codex session headers, metadata.user_id, or prompt_cache_key, with the content hash as a fallback;
parent_response_id;
agent_key for Claude Code subagents.
These columns sit on gateway_requests only. They are not on the usage event and not in ClickHouse, and no index covers them. Only the admin trace inventory reads them.
Other things called "session"
A proxy traffic run is one run of the local capture process, from start to stop. It is not a conversation.
Uploaded traces land in ClickHouse trace_spans with real parent span ids, but no page shows them yet.
Why it is built this way
Most of these choices followed a specific incident. The date on each card is when the rule was set.
Sep 2026 incidents · balance ledger
Money moves in MemoryDB, not Postgres
Every reservation and settle used to lock the organization's row in Postgres. One busy tenant turned that row into a queue, and every customer waited 90 to 145 seconds before admission (September 12, 14 and 19). MemoryDB takes the hold and the settle; Postgres gets the rows a second later from the receipt streams.
Nov 4 · settle outbox
Usage events are written by a drain, not inside the settle
The usage event's triggers (rollups, budgets, the ClickHouse outbox, erasure) ran inside the settle transaction under the organization lock. Now the settle only writes a settle_outbox row, and a drain that runs every second writes the usage event, so those triggers no longer run under the lock. If the drain stops reporting that it is alive, settles go back to writing the usage event themselves.
Sep 19 · no ledger scans
Charts read ClickHouse, never the ledger
Six tenant usage reads summed gateway_usage_events over the window and hit the 8 second timeout for a tenant at 180,000 requests a day. Since then every chart and total reads ClickHouse, with no Postgres fallback, and a CI lint fails any new read that scans the ledger.
Sep 2026 · outbox to ClickHouse
ClickHouse is fed by an outbox, not a dual write
The usage event and the "send this to ClickHouse" outbox row are saved in one database transaction, so either both are saved or neither is. That means ClickHouse can never miss a request that Postgres has. The exporter counts the rows in ClickHouse before it deletes the outbox rows. If an export fails partway and is retried, ClickHouse may receive the same row twice. Reads use FINAL, which keeps only one copy, so totals are not counted twice. Summing materialized views would count that row twice, so they are not used.
Oct 20 · exporter placement
The exporter runs on the control plane
Spend reports show data only up to the oldest outbox row not yet delivered. When the exporter ran on the Project worker, each Project worker release paused it, and every Spend report stopped advancing. The export stalled for 31 hours on October 12 (a dead thread) and again on October 13 (a table name clash). Now, if the exporter fails to claim a batch, it waits and tries again instead of ending the thread.
Sep 20 · Oct 18 · bodies in Storage
Bodies live in object storage, Postgres keeps a pointer
Inline capture reached 748 GB of a 941 GB database in two weeks. Bodies now go to compressed Storage objects with one small pointer row each. Reads switched to objects behind an explicit gate, after it turned out that the mirror (a background copier meant to move old inline rows into objects) had never run in production.
Sep 22 · capture off the loop
The request loop never serializes content
Twelve gateway workers froze for five minutes and crashed after large bodies started being serialized on the request loop. Now the request loop only passes raw bytes to the capture thread, which does the serializing. That thread's queue holds at most 2,000 items and 256 MiB. Each new kind of captured content gets its own switch to turn off its capture.
Nov 9 · consent and ZDR
One switch decides what is kept
The organization's capture switch decides for every lane, own keys and plans included. A request routed under zero data retention is never captured. The decision is made once, when the request is authorized. If the decision is unknown, nothing is kept.
Sep 2026 · edge
Cloudflare guards the hosts but never challenges /v1
SDK traffic cannot solve a browser challenge, so the WAF's challenge and rate rules apply only to the sign-in paths. A secret header proves the request came through our zone. 502 and 504 are rewritten to 503, because Cloudflare replaced our JSON error and its request id with its own page.
Part 4
What was not working
The problems, in the order they showed up. For each one: what we saw, the evidence, and the cause. What we did about each is told in Part 5.
How to read this part
The problems fall into three groups.
The first group is incidents in production in early November (sections for November 5, 9, 10 to 13). They all trace back to one cause: a single Postgres database does almost every job, so anything that slows it slows customers.
The second group is risks and gaps that had not yet caused an incident: a planned Postgres restart would break the API, and the product lacked sessions, search and full traces.
The third group is problems the testing found while the new design was built, from 2026-11-18 to 2026-11-22. They are listed at the end of this part in one table, and each is told in full, with its fix, in Part 5.
Some history comes first. Several rules in today's design were set after incidents in September and October:
Money moved out of Postgres after one busy tenant's row lock made everyone wait 90 to 145 seconds.
Charts moved to ClickHouse after Postgres reads hit their 8 s timeout.
Bodies moved to object storage after inline capture reached 748 GB of a 941 GB database.
Content serialization left the request loop after twelve workers froze.
November 5: capture refusals while the writeback lagged
What we saw. Captured requests were refused with 503 capture_unavailable, up to about 24,000 an hour at 11:00Z.
Evidence. The ledger writeback, which copies each request from MemoryDB into Postgres, averaged up to 2.5 minutes behind in some hours that day.
Cause. The capture processor needs the request's Postgres row before it may store a capture, because that row holds the consent facts. With the writeback behind, the processor waited on request rows that had not arrived yet. Captures piled up in each gateway worker's bounded buffer, and a full buffer refuses new captured requests. This is the same mechanism as November 9 below, with a different slowdown.
November 9: capture refusals from a slow database
What we saw. At 12:07, 13:05 and 14:17Z, 123 requests from 76 organizations were refused with 503 capture_unavailable.
How we know. Kion's investigation. At the same times the ledger writeback fell up to 5.8 minutes behind. The same pressure probably explains promotion-usage-rollup-tick and house-lane-usage-live-refresh timing out since November 8.
Why it happened. Autovacuum on the largest, most-updated tables used up the database's disk throughput, so every commit slowed. The diagram follows the chain from there to the refused requests.
flowchart TD
A["Autovacuum on the largest churning tables storage.objects 167 GB, chain receipts 67 GB, gateway_captures 59 GB"] --> B["Postgres disk throughput used up"]
B --> C["Every commit slows"]
C --> D["Storage upload commits slow storage.objects and inbox rows"]
C --> E["Writeback falls behind up to 5.8 min"]
C --> F["Scheduled rollups time out"]
D --> G["Captures stay in each worker's buffer longer"]
G --> H["Buffer reaches its record or byte limit"]
H --> I["New captured requests refused 503 capture_unavailable"]
E --> J["Request rows, usage, dashboards late; capture processor waits"]
Vacuum started it. The underlying cause is that a customer request can still wait on a Postgres write. The capture buffer frees space only after a Supabase Storage upload, and that upload commits rows in Postgres.
Why tuning vacuum or raising buffer sizes is not the fix. Either change only raises the point at which refusals start. The next slow commit (a bigger vacuum, a migration, a Supabase incident) would refuse customers again. The fix is to change the design so that no customer request depends on how fast Postgres writes, and to move the tables that change the most out of the main database.
A second capture problem, found the same day.
What we saw. 298 capture items had been stuck in the gateway_capture_inbox as metadata_pending since November 6 (live count). By November 10 the count was 813, retried about 1,280 times since 11-06.
Why, first cause. The inbox has no dead-letter shelf, so nothing ever gives up.
Why, second cause. A code bug. A prompt whose request row never appears returns early at capture_inbox_worker.py:207, before the step that would drop it, so it is retried every 5 minutes forever.
The same day we audited every dashboard and API read for speed and errors. This section lists what was broken, what sat at the timeout, and what was slow.
How we know.
Source: production request logs (/explabs/production/containers, the request completed timing lines of the control plane and the web app), plus a few live Server-Timing reads.
Window: 2026-11-09 about 16:00 to 22:00Z, roughly 200,000 requests. Nothing was changed.
Not yet checked: the ClickHouse query log and pg_stat_statements (no access from here), and query plans (EXPLAIN) of the admin functions.
Broken: most calls failAt the timeout ceiling (about 8 s)Slow on a high-volume routeHealthy
flowchart LR
subgraph Callers
ADM["Admin browser"]
USR["Customer browser"]
ANON["Anonymous visitors, search engines"]
AGT["Agents and SDKs xpl_ key"]
PART["Partner export key"]
CRON["Cron and internal callers"]
end
subgraph Web["Web app routes, Next.js"]
W_TEL["/admin/telemetry page /api/admin/telemetry/usage /api/admin/telemetry/rejected-usage 16 of 31 and 5 of 10 failed"]
W_OV["/api/admin/orgs/[orgId]/overview p95 8.2 s, 3 errors"]
W_BROWSE["/api/admin/orgs/browse /api/admin/support/orgs p95 3.5 to 4.8 s"]
W_MODEL["/models/[modelSlug] page 42k calls, p50 1.0 s, 42 errors"]
W_DASH["/api/gateway/usage/daily, rollups /api/orgs/[orgId]/spend/* p95 1.3 to 1.6 s"]
W_CRON["/api/internal/users-context-fill p95 7.5 s, max 8.6 s"]
W_FLEET["/api/internal/ec-fleet/poll p95 48 s, 5 errors"]
end
subgraph CP["Control plane routes, FastAPI"]
C_PD["/api/gateway/usage/platform-daily /platform-rejected-daily 26 of 31 and 8 of 10 failed, 503 at 18 s"]
C_USERS["/api/admin/users, /users/{id} p95 8.1 s"]
C_ORGS["/api/admin/orgs, /orgs/{id} p95 8.7 s"]
C_EXP["/api/admin/accounts/export 260 calls, p95 8.2 s"]
C_POL["/api/admin/paid-only-lanes 17.6 s, all database"]
C_Q["/api/admin/abuse/quarantined 1.1 s waiting for a connection"]
C_MODELS["/api/models 10.5k calls, p50 2.0 s, 16 queries"]
C_SLUG["/api/models/{slug} 46k calls, p95 2.1 s, 22 queries"]
C_V1M["/api/v1/models p50 3.6 s, p95 6.3 s"]
C_ZDR["/api/orgs/{org}/zero-data-retention 3.6k calls, p50 1.2 s"]
C_USAGE["/api/v1/usage, /api/v1/key 40k calls, p95 1.3 to 1.7 s"]
C_APPROVE["/api/admin/catalog-drafts/approve-batch 49 to 85 s, publishes inline"]
end
CH[("ClickHouse usage_events FINAL, raw rows, all orgs")]
PGBIG[("Postgres big tables audit_log 311 GB, attempts 238 GB, usage_events 188 GB, requests 105 GB")]
PGCAT[("Postgres catalog tables models, lanes, observed stats")]
POOL[["Control plane database connection pool"]]
ADM --> W_TEL --> C_PD -->|"408 at 18 s"| CH
ADM --> W_OV --> C_ORGS
ADM --> W_BROWSE
ADM --> C_USERS
ADM --> C_POL
ADM --> C_Q
ADM --> C_APPROVE
PART --> C_EXP
C_USERS --> PGBIG
C_ORGS --> PGBIG
C_EXP --> PGBIG
W_BROWSE --> PGBIG
C_POL --> PGBIG
ANON --> W_MODEL --> C_SLUG
ANON --> C_MODELS
USR --> W_MODEL
USR --> W_DASH --> CH
USR --> C_ZDR
AGT --> C_V1M
AGT --> C_USAGE
C_MODELS --> PGCAT
C_SLUG --> PGCAT
C_V1M --> PGCAT
C_ZDR --> PGCAT
C_MODELS -.->|"holds connections"| POOL
C_SLUG -.->|"holds connections"| POOL
C_Q -.->|"waits for one"| POOL
CRON --> W_CRON --> PGBIG
CRON --> W_FLEET
C_USAGE --> PGBIG
classDef broken fill:#c0392b,stroke:#7f1d1d,color:#ffffff
classDef ceiling fill:#d9631e,stroke:#8a3b0f,color:#ffffff
classDef slow fill:#b7791f,stroke:#6b4610,color:#ffffff
classDef ok fill:#2f855a,stroke:#1c5236,color:#ffffff
class W_TEL,C_PD broken
class W_OV,C_USERS,C_ORGS,C_EXP,C_POL,W_CRON,W_FLEET,C_APPROVE ceiling
class C_MODELS,C_SLUG,C_V1M,C_ZDR,W_MODEL,C_Q,W_BROWSE slow
class C_USAGE,W_DASH ok
Each box is a route with its 6-hour figures. Red routes fail on most calls, orange routes sit at or past the database timeout, amber routes are slow on high-volume traffic, green routes are fine. The admin pages read the biggest Postgres tables, Telemetry reads raw ClickHouse rows, and the catalog routes hold many of the control plane's database connections, which every other route also needs.
Broken now: admin Telemetry
Symptom./api/gateway/usage/platform-daily failed 26 of 31 calls and platform-rejected-daily 8 of 10, each after about 18 s with a 503. The page's web routes (/api/admin/telemetry/usage, /rejected-usage) fail with them.
Cause. ClickHouse answers 408 Request Time-out: the query hits its 18 s execution limit (max_execution_time=18, log_comment=platform.gateway_usage.platform_read).
Why it is slow.clickhouse_usage_read.pyplatform() runs SELECT * FROM usage_events FINAL over every organization's raw events. For a 30-day chart, the query reads partitions back to August 27, because it allows extra days for requests that settle late. FINAL removes duplicate rows left by export retries at query time, across all those rows, and SELECT * reads every column. Traffic grew about 10x since the read was written.
Fix. A pre-aggregated platform rollup in ClickHouse (hour and day, by model and by organization). A finished day is summed once and never changes, so FINAL only has to run on the current day's rows. Select only the columns the chart needs. Raising the time limit would not fix it, because the scan keeps growing with traffic.
At the timeout ceiling
Route
Calls (6 h)
p50 / p95
Where the time goes
Likely fix
/api/admin/users, /users/{id}
81, 7
3.9 s / 8.1 s
/users/{id} is 8.1 s on every call, all database
Read the user card's usage and audit figures from rollups or ClickHouse
/api/admin/orgs, /orgs/{id}; web /admin/orgs/[orgId]/overview
14, 16, 20
8.2 s / 8.7 s
Database; web overview returned 3 errors
Same fix: do not sum the ledger tables while the caller waits
/api/admin/accounts/export
260
2.4 s / 8.2 s
A partner key reads page after page. Each page joins billing and usage data and takes close to the timeout
Precompute the per-account enrichment; page smaller
/api/admin/paid-only-lanes
1
17.6 s
All database
Read its query plan (EXPLAIN), then limit how much it reads
/api/internal/users-context-fill (cron)
72
6.1 s / 7.5 s, max 8.6 s
Database through Supabase
Will start failing as tables grow; move to a background job with its own budget
/api/internal/ec-fleet/poll
360
1.9 s / 48 s
Backend calls to the GPU fleet
Bound each box poll; poll in parallel
/api/admin/catalog-drafts/approve-batch
4
49 s / 85 s
A catalog publish runs inside the request
Return at once and publish in the background
Slow on high-volume customer and public routes
Route
Calls (6 h)
p50 / p95
Where the time goes
Likely fix
/api/models/{slug} (model page data)
46,230
0.8 s / 2.1 s
22 queries, 1.6 s of database time per call; about 300 ms waiting for a connection
Serve anonymous reads from a precomputed catalog snapshot, cached at Cloudflare
Web /models/[modelSlug]
42,060
1.0 s / 2.4 s
Calls the route above; 42 server errors, 372 abandoned by the visitor
Same snapshot; cache the rendered page
/api/models (catalog)
10,466
2.0 s / 4.7 s
16 queries, 1.5 s of database time, 333 KB response
Same snapshot
/api/v1/models (OpenRouter-style list)
1,435
3.6 s / 6.3 s
Database; agents call it on startup
Same snapshot plus the per-org overlay
/api/orgs/{org}/zero-data-retention
3,625
1.2 s / 3.3 s
Recomputes the per-model zero-data-retention route verdicts on every call
Cache per org; invalidate on policy or catalog change
/api/admin/abuse/quarantined
4
1.5 s / 6.4 s
1.1 s average waiting for a database connection
Caused by the connection pool pressure described below
Connection pool pressure. Several control plane routes spend hundreds of milliseconds waiting for a database connection before running anything. The measure is db_wait_ms: /api/models/{slug} waits about 300 ms on average, and /admin/abuse/quarantined about 1.1 s. The cause is that the catalog routes make many queries per call and hold connections that every other route needs. Serving the catalog from a precomputed snapshot would free those connections for every other route.
Healthy enough for now
/api/v1/usage (32k calls, p95 1.7 s), /api/v1/key (7.7k, p95 1.3 s), /api/gateway/usage/daily and /rollups (p95 1.3 to 1.6 s), /api/orgs/{org}/spend/* (p95 under 1.6 s). Unauthenticated /v1/models answers in about 0.17 s. /api/playground/chat is slow by nature (it waits for a model).
The two patterns behind nearly every finding.
Reads that sum raw rows while the caller waits: in ClickHouse for Telemetry, in Postgres for the admin directory reads. The fix is maintained rollups, which tenant usage already uses.
Postgres tables with no retention, which make every scan and vacuum slower. That is the same root as the November 9 capture refusals.
November 10 to 13: dashboard overload, a hot organization, and a slow drain
The next week brought a run of incidents. None of them broke /v1 outright, but each showed the same shared-database weakness from a new side.
November 10: the dashboard incident
What we saw. For about six hours, signed-in dashboard pages were slow or failing. /v1 was not affected.
Evidence and cause, in order.
Model-page traffic roughly doubled, and every model page made about 24 database calls.
Postgres hit its disk throughput limit.
The control plane queued requests for 10 to 18 seconds while its CPU looked idle. Each control-plane process can make only 8 database calls at once and waits with no timeout for a free slot, so the pods were waiting, not working, and the CPU-based autoscaler saw nothing to do.
Scaling the control plane to 30 pods by hand then used up the database pooler's 225 session slots and failed a release.
The incident write-up is incident-2026-11-10-control-plane.md and the database resize research is postgres-zero-downtime-options.md, both on the Desktop. The incident owner handed the long-term items to this plan.
Other findings that day.
One hot organization fell 17 minutes behind on its shared receipt stream, because the wallet's 8 receipt streams are shared by many organizations.
Release tooling had five separate faults:
finished-release recovery needed main's newest commit, so any merge broke it;
merge freezes depended on sessions messaging each other;
one GitLab 500 aborted recovery;
about 3,900 stale manual preview jobs broke a listing;
the smoke test's usage check waited 10 s while the writeback lagged 3 to 9 minutes, so a healthy release failed.
Lanes pointing at test hosts (webhook.site, lhr.life, oast) were left over from a penetration test.
Secrets in chat: the Supabase PostgREST JWT secret, Cloudflare tokens and R2 keys appeared in a conversation.
November 11: one expensive query
What we saw. One expensive dashboard query overloaded the primary Postgres. The balance-ledger writeback slowed, and captures refused about 3,400 requests.
Later that day, ad-hoc 7-day ledger scans and one busy organization slowed the writeback again. That organization's writeback fell 55 minutes behind. The cause was an organization-row convoy: many transactions in receipt apply and the settle drain queued on that organization's one row.
Also that day. A bad environment change crash-looped control-plane pods. It showed two places where unrelated jobs shared one deploy unit:
The ledger writeback ran inside the control-plane app, so it shared that app's environment, release and rollback.
One edge app served both /v1 and the dashboard's /api relay. Slow dashboard calls (13 s /api/models calls that day) occupied the same edge workers and connections as /v1.
The post-mortem listed ways to isolate the API from the dashboard (https://incident-2026-11-11.pages.dev).
November 12 and 13: the settle-drain incidents
What we saw. The settle drain slowed on both days.
Why. Multixact churn: bookkeeping Postgres does when many transactions lock the same rows. The buffers that would help, the multixact buffers, were still at their defaults of 256 KB and 128 KB. They can only change when Postgres restarts.
That is one reason a restart is needed. The next section explains why a restart is itself a problem.
A Postgres restart takes /v1 down
This is a risk, not an incident: it had not happened yet, but it would on the next planned restart.
Why this matters. Any change to the database's size or connection limit restarts Postgres. Supabase documents "usually less than 2 minutes". On our plan it offers no failover or blue/green switch, and read replicas cannot be promoted.
What would happen. Money already settles in MemoryDB, but today a short Postgres restart still breaks /v1 in two ways:
After about 60 seconds without the database, every gateway worker marks itself unready (explabs/gateway/worker.py, readiness blocker around lines 1616 to 1646), so the edge has no healthy worker and returns 502.
Before that, any request whose API key is not in the 2-second key cache does a direct Postgres read that can wait 10 to 30 seconds.
The same is true of an AWS RDS or Aurora failover (30 to 120 seconds), so this work is needed whichever database platform we end up on. With it, a planned resize, a max_connections change, or a Supabase incident stops being an API outage. Research report: ~/Desktop/postgres-zero-downtime-options.md.
How we know: a larger blocker in the code. A closer read of the code (infra item 1, November 10) found that even with every cache warm, each request runs authorize_model_chain against Postgres (control_store.py:2684). That check reads the chain epoch, the revision row and the protected-revision row, and for protected revisions it also takes a lease and writes a receipt. So during an outage every request fails after 10 to 30 s, and a stale key cache alone would save nothing.
The table shows what each step of a request does today when Postgres is gone. Look for "no stale fallback" and "fails": those are the steps that turn a restart into an outage.
What happens today during an outage
Step
Behavior
Model-chain check (every request)
Waits up to 10 s to connect and 30 s to check out; every request fails, warm keys included
Key and grant caches
2 s, no stale fallback
last_used update
Synchronous write once a minute per key, no error handling; that request fails
Limit policy caches (2, 10, 30 s)
Raise when expired; no last-good value
Catalog refresher
Keeps the last good state (fine)
Readiness
After about 60 s the probe pings Postgres; about 100 to 120 s in, every pod leaves the load balancer at once
MemoryDB writeback
Receipts wait safely in the streams; no backlog metric or alert exists
How much traffic it affects. On 2026-11-18 a read-only production query measured it: 27,171 of 52,347 requests in 10 minutes (52%) ran on protected chain revisions, each writing a receipt in Postgres at admission. So a restart would refuse about half of /v1 even after the other fixes. How that was solved is told under November 18.
Why we cannot just avoid the restart. Production Postgres is version 17.6 on a Supabase 4XL machine. The settings that would help only change on a restart: the multixact buffers, possibly the transaction and subtransaction buffers, maximum connections, and the machine size. Supabase gives our plan no failover or blue/green switch.
What the product lacked
Alongside the incidents, customers were missing features that observability tools usually have. These are product gaps, not outages.
No session view. Requests were grouped only by content hashes, which merge different conversations and split one conversation after compaction. The real session key was written to Postgres and never read. See Sessions today.
No search of request content. Bodies were compressed objects in storage, which cannot be searched.
No agent traces. The gateway sees only LLM calls. Tool calls and agent steps happen in the customer's code, and uploaded traces sat in ClickHouse trace_spans with no page and no link to gateway requests. Teams that left Helicone for Langfuse named this as their reason.
Many surfaces stored nothing: embeddings, images, speech, transcription, video and Decisions requests. See Capture paths.
One all-or-nothing storage switch per organization, no customer-set expiry, and no way to move Helicone customers over without changes on their side.
The pattern behind the problems
When the incidents are put side by side, a short list of structural flaws explains nearly all of them. The plan page's "What the current system teaches us" lists them, and each maps to the decision that removes it. The figures were checked against the code in review.
Read each row left to right: the flaw, the evidence for it, the lesson, and the decision (D1 to D20, Part 7) that removes it.
Flaw
Evidence
What we learn
Removed by
One Postgres does every job
A 1,336 GB database holds money history, catalog, auth, capture pointers, audit and analytics-shaped tables. The incidents of November 5, 9, 10, 11, 12 and 13 all trace back to pressure on it: vacuum, a heavy query, connection exhaustion and row-lock convoys.
A shared database turns any heavy job into everyone's outage. Isolation has to be designed in; tuning cannot add it later.
D1, D3, D4, D5
Hidden synchronous dependencies
The capture buffer waited on a Supabase Storage upload that commits a Postgres row. Every request checked the model chain in Postgres. last_used is throttled to once a minute per key but still runs inline. Readiness pinged Postgres. Promotion grants and plan caps still read Postgres on every request.
A dependency nobody drew on the diagram is the one that takes production down. Every request-path call has to be listed and justified.
D1, D2
Tables with no lifetime
audit_log (311 GB), gateway_attempts (238 GB) and chain receipts (67 GB) have no retention. storage.objects carried 10.7 million dead rows.
Unbounded tables slow every vacuum, scan and restart until one of them tips over.
D3
Reads that sum raw rows while someone waits
Admin Telemetry scanned every organization's raw ClickHouse events with FINAL and timed out. Admin directory pages took 8 s summing ledger tables. Model pages made 22 to 24 database calls each.
The rule "read a rollup, never the raw window" existed but was enforced only for tenant usage reads. A rule that is not enforced everywhere decays.
D4, D5
Queues without a shelf or an age alarm
Hundreds of captures stuck in metadata_pending from November 6 and retried forever. One bad ClickHouse outbox row could freeze Spend. An appeal pipeline was dead for 9 days before anyone noticed. Wallet drift is logged, not paged.
Retry-forever hides failures. The signal that matters is the age of the oldest item.
D9
Fail-closed side jobs
Capture refused customer requests because storing a copy was slow: up to about 24,000 an hour on November 5, and 123 requests from 76 organizations on November 9.
A side job may refuse a customer only when a stronger written promise requires it.
D2
Limits per process, load per fleet
30 control-plane pods used up the pooler's 225 sessions. The autoscaler watched idle CPU while requests queued for 18 s. One busy organization fell 17 to 55 minutes behind on a shared receipt stream.
Budgets must be fleet-wide and checked before a deploy. Isolation must be per organization wherever one tenant can saturate a shared path.
D6, D11
Shared deploy units
One edge app serves both /v1 and the dashboard. The ledger writeback has run as its own Deployment since November 11, but it still shares the control-plane app's configuration, release and rollback.
Things that fail differently should deploy separately.
D11
Release and repository process carried by people
Merge holds coordinated by chat. Recovery broke when main moved. 3,900 stale manual CI jobs broke a listing. On November 10 there were 144 open merge requests, and 66 had already landed. Migration versions collided.
Process that depends on everyone remembering fails at the busiest moment. Automate the guard, or remove the need for it.
D17
Built but never switched on
The S3 and SQS Terraform was merged but never applied. A capture mirror had never run. A Fargate capture service was built and left at zero tasks.
A merge is not a launch.
Principle 7, D17
Monitoring that missed money
Writeback lag had no alert until November 11, and wallet drift still has none.
Monitor what money depends on as closely as the API.
D6, D9
A dependency crash that only a real restart shows found 2026-11-18
In the first preview restart rehearsal, every psycopg-based Python service segfaulted about 5 s after Postgres came back.
A failure path that only runs during a real outage has to be exercised by a real outage. Simulated failures test our code, not our dependencies.
D16
Secrets in chat
The Supabase JWT secret, Cloudflare tokens and R2 keys were exposed in conversations on November 10, and a GitLab token needs rotation.
Credentials need a path that never passes through a chat.
D18
Problems the testing uncovered, November 18 to 22
Once the new design was built, we tested it hard: restart rehearsals, end-to-end flows, security and money attacks, a load test, and on November 22 eight adversarial agents working in rounds. Every round found something. The table lists each problem with what we saw and why it happened. Some were in the new design, some were on main, and some were in the preview's own plumbing.
The last column points to where Part 5 tells the fix and the numbers after.
Date
Problem
What we saw
Cause
Told in
11-18
Services crash after a real restart
Gateway worker, control plane, capture ETL and project worker all segfaulted about 5 s after Postgres returned, in both runs. A 41 s outage became 65 to 88 s of errors.
psycopg 3.3.4 crashed when the Supavisor pooler greets a client without connection settings.
In rehearsal round 2, requests at the cut still hung 22 to 37 s.
Behind Supavisor a statement waits about 8 s for an upstream and fails; statement errors did not count toward the breaker, and connection validation retried up to five times before the connection could be cut. The credential release used its own connections outside the breaker.
Seventeen, found by the end-to-end flows: a ClickHouse migration that would have failed every deploy, the usage export stopping after minutes of traffic, every session read answering 500, tool spans never inferred, two segment writers destroying each other's files, and more.
Pieces built in separate worktrees, first run together.
A crafted Host header let anyone make the public edge call internal servers; read-scoped admin keys could read every org's captured prompts; the Helicone response cache could fill the wallet's MemoryDB and stop all money; a flood of random keys could lock out new keys.
New routes and shared clusters without the guards the old paths had.
/v1/systemone answered intermittent 503s, 0.8% to 2.2% of calls per hour.
One of two upstreams was dead, and the remaining one sat on a 250 ms lossy tunnel where a 2 s health check sometimes failed, marking it down for 3 to 5 s.
Continuations broken by an outage, and in steady state
Every Responses continuation needed a full resend during an outage, and conversations started during it stayed broken. Separately, with the MemoryDB ledger and async cleanup on, every continuation was dropped.
Conversation state lived only in Postgres; a steady-state bug in the cleanup path.
After the span-sink fix, uploaded traces still did not reach Observability.
The control pods lacked CLICKHOUSE_TRACE_PROJECTION_ENABLED; main's deploy script gives it only to the Project worker. Fixed by dropping the gate; verified on the preview at 79479dfd80.
The work in the order it happened, from the first investigation on November 9 to the adversarial rounds on November 22. Each step says what we noticed, what we tried, what we learned, what we changed and what happened.
How the work unfolded
The work had three phases.
Understanding (November 9 to 11). We read production: the stores, the routes, the incidents. We read how Helicone and LiteLLM solve the same problems, and checked our design against published engineering practice. Kion set the direction: no customer request may depend on how fast Postgres writes. We wrote designs and analyses, and put the first questions to the owner.
Deciding (November 11 to 17). The designs became a final plan with twenty decisions, D1 to D20, reviewed by seven reviewers. On November 17 the wallet options were tested for real, and the owner decided to build everything in one change, now.
Building and proving (November 18 to 22). The build was checked in layers: restart rehearsals, end-to-end flows, attacks, a load test, and finally eight adversarial agents working in rounds on the preview. Each check found problems; each problem was fixed and re-measured.
The diagram below shows the shape of the timeline.
flowchart LR
A["Nov 5 to 13 incidents in production"] --> B["Nov 9 to 11 research, target, infra plan, Kion Sync"]
B --> C["Nov 16 to 17 final plan D1 to D20, wallet tests"]
C --> D["Nov 18 reassessment, restart rehearsal"]
D --> E["Nov 19 to 20 Clef 502s, UX gaps, plan review, retests"]
E --> F["Nov 21 one PR, load test fixes"]
F --> G["Nov 22 11 adversarial rounds"]
The work from incidents to rounds. Each box is told in its own section below.
November 9: research, how others solve the same problems
Before designing anything, we looked at three things: how Helicone, which we own and whose customers would move to us, builds sessions and search; how LiteLLM, the most widely used open-source LLM gateway, moves spend into its database; and what published engineering practice says about each pattern we use. The findings shaped every later decision, so they come first.
How Helicone does it
From the Helicone source in our organization. Their proxy runs on Cloudflare Workers, logs go through SQS, and almost everything is read from one ClickHouse table.
flowchart LR
APP["Client with Helicone-Session-Id, -Session-Path, -Session-Name headers"] --> W["Cloudflare Worker proxy Durable Objects, KV"]
W --> LLM["Providers"]
W -->|"raw body"| S3[("S3")]
W -->|"log message"| Q[["SQS queue"]]
Q --> J["Jawn consumer handler chain"]
J -->|"one row per request bodies up to 10 MB inline"| CH[("ClickHouse request_response_rmt")]
J -->|"bodies over 10 MB"| S3
J --> PG[("Postgres orgs, keys, prompts")]
UI["Sessions page polls every 1 to 2 s"] -.-> J
J -.->|"GROUP BY session id at query time"| CH
Helicone stores bodies of up to 10 MB in ClickHouse beside the metadata, so search and sessions run as plain ClickHouse queries.
The table compares Helicone with us topic by topic. The "Us today" column is where the gaps show.
Topic
Helicone
Us today
Session identity
Three headers. A session is the requests sharing Session-Id and Session-Name. There is no session table; it is grouped on every query.
session_key derived from several headers, written to Postgres only, not read
Session tree
Built in the browser from Session-Path strings (/plan/step-1); folders aggregate latency and cost
None; content-hash grouping on a flat list
Session list
Name picker, filters on session totals, columns for cost, tokens, requests, latency and users, live polling, export
None
Session detail
Waterfall timeline, expandable tree table, request drawer, session tag
Request drawer only
Body search
ILIKE on body columns with an n-gram bloom index; bodies kept 3 months; large bodies searched by a truncated preview
No body search; bodies are only in object storage
Live updates
Polling every 1 to 2 seconds
Polling every 10 seconds
Billing and limits
Separate
Same request path, settled in MemoryDB
Their weaker spots, which we should not copy:
Sessions are recomputed from raw rows on every query.
The session list can only sort by date.
The tree comes from path strings, not parent ids.
Body search can scan whole partitions on short or case-insensitive terms.
Session feedback is broken in their current code.
What LiteLLM teaches
LiteLLM is the most widely used open-source LLM gateway. We read its repository at commit 1ddc9130 (November 9, 2026). It has changed a lot recently:
spend now flows through a Postgres outbox;
budgets use reserved holds in Redis, much like ours;
its router, Redis stores, ClickHouse writer and price-list refresher now run in Rust.
Its main weakness remains. Between the request and Postgres, the spend record is held only in memory, so a crash or a full queue can lose it.
flowchart LR
subgraph LiteLLM
LR["Request"] --> LW["Logging worker in-memory queue, 50k"]
LW --> LQ["Spend queue in memory, 64 MB, oldest dropped when full"]
LQ -.->|"optional"| LRL["Redis list 100k rows"]
LQ --> LPG[("Postgres: spend log and delivery row, one transaction")]
LPG --> LWK["Projection worker SKIP LOCKED, parks after 5 tries"]
LWK --> LD[("Daily spend tables")]
end
subgraph Ours
OR["Request"] --> OM[("MemoryDB: settle and receipt, one atomic step")]
OM --> OW["Writeback exactly once per receipt"]
OW --> OPG[("Postgres")]
OPG --> OX["Outbox drains"] --> OCH[("ClickHouse")]
end
Both designs end in an outbox. LiteLLM's first hop is in memory and can drop charges under load or on a crash; ours writes the receipt durably in the same step that moves the money.
The table compares LiteLLM with us topic by topic. The last column says whether we should copy it.
Topic
LiteLLM
Us
Take it?
Getting spend into Postgres
In-memory logging worker, then an in-memory queue that drops the oldest past 64 MB, then a Postgres transaction writing the spend row and a delivery row together.
MemoryDB writes the receipt in the same atomic step as the settle; the writeback applies it exactly once.
No. Ours is more durable.
Draining an outbox
Claims 500 rows with FOR UPDATE SKIP LOCKED and applies them in one transaction. Retries back off with jitter up to 300 s. A row that keeps failing is parked after 5 attempts with an alert. Exposes pending count, parked count and age of the oldest. Clears applied rows after a day.
Same claim-and-apply, but no parked state, no attempt cap and no oldest-age alarm on most handoffs.
Yes, the parking and metrics. This is the dead-letter gap from the best-practice review.
Hot counter rows
One multi-row upsert per batch in a fixed table order. SET LOCAL lock_timeout on every rollup, with the batch requeued when the lock times out. A single writer per job via a lease, and cron jobs staggered across replicas.
Counters moved to MemoryDB and rollup triggers; cron jobs already carry budgets and staggered minutes.
Yes, lock_timeout plus requeue on our rollup and drain transactions.
Pricing problems
Stores unpriced cost as NULL instead of 0, records why a request cost nothing, splits each cost into its parts, and checks captured spend against the provider's bill daily, alerting below 90%.
Unpriced-settle alarms and a nightly bill comparison exist (after the October incident).
Partly: add a stored "why zero" reason per request and the per-part cost breakdown.
Price list refresh
Rejects a fetched price list with fewer than 50 models, or one that shrank by more than half, and keeps a bundled backup.
Catalog drafts are reviewed; regressions need a probe.
Yes, the shrink guard is cheap insurance on any automated price sync.
Large content
Prompts are off by default. Media is replaced with "[image omitted]", every string is cut to 2,048 characters, and credentials are masked. The full payload can go to S3 under a key computed at request time and written into the log row.
Full content in object storage; nothing truncated.
Yes, the request-time key (the body's location is known from the request, so no pointer row has to be written) and the media placeholders for previews and search text.
Sessions
A session id read from many client headers: LiteLLM's own, x-claude-code-session-id, Codex session-id and thread-id, x-session-id, and the session part of Anthropic's metadata.user_id. Claude Code subagents become child sessions, and a parent-session header links them.
session_key already reads the Claude Code and Codex headers and metadata.user_id, and records agent_key; not yet shown anywhere.
Add x-session-id, Helicone's headers and the parent-session link.
Retention
Spend logs retained by age and by size, with Postgres range partitions dropped whole, because "batched DELETE leaves dead tuples autovacuum cannot reclaim".
No retention on the largest tables.
Yes. This is our November 9 cause.
Rate limits
Reserves estimated tokens before the call and reconciles after. Fails open to per-pod memory when Redis is down, unless set to fail closed. Its "sliding window" is a fixed window that allows about twice the limit at a boundary.
Exact rolling windows; MemoryDB required.
No.
Failover
Never puts the only deployment of a model in cooldown. Needs a minimum request count before judging a failure rate. Cools down only on 429, 401, 402, 404, 408 and 5xx. Has separate fallback chains for context-window and content-policy errors.
Breakers, lane demotion and slow-lane recovery.
Worth comparing with ours: the "never cool down the last option" rule and the separate context-window fallback.
Privacy
Logging can be turned off per request, per key and per callback. Each team's logs can go to its own tracing account. Guardrails can be set to mask content only in what gets logged.
One org-wide switch, zero data retention per request, broadcast to the org's destinations.
Maybe a per-key "do not store" flag, which also solves the internal Decisions callers.
What not to copy
An in-memory, best-effort first hop for money events.
Two spend paths running side by side and reconciled with queries.
Prompts stored as JSON columns in the transactional database. It is why they needed ORM memory workarounds, size-based cleanup and partitioning.
Fetching the price list at runtime from a public GitHub branch.
One plugin interface for logging, limits, budgets and guardrails, which hides what runs on the request path.
Failing open when the limiter store is down.
Best-practice review
Each row takes one well-established engineering practice, what the source says, and how our system measures up. Sources were read on 2026-11-09.
Write the message in the same transaction as the change; a relay publishes it afterwards; delivery is at least once.
follows for money and usage: receipt streams, settle_outbox, the ClickHouse outbox and the credit feed are all written in the same step as the change. gap for captures: the inbox row is created by a Storage commit that the gateway waits for.
Captures: make the durable handoff something that does not depend on our database (an S3 PUT whose event lands on SQS).
Because delivery can repeat, the receiver records message ids and skips duplicates.
follows: receipts are unique by (kind, receipt id); MemoryDB applies each credit event id once; one usage event per request id; ClickHouse collapses repeats.
Keep this rule for every new consumer, including the capture loader: S3 events can arrive twice.
After a set number of failed receives, move the message aside so it stops blocking or looping; alarm on the shelf; keep it longer than the main queue; redrive after a fix.
follows on the illegal-content review queue. gap on every Postgres handoff: 298 capture items stuck in metadata_pending since November 6, and one bad ClickHouse outbox row would hold Spend's cutoff indefinitely.
Give each handoff an attempt count, a parked state with the last error, an alarm, and a redrive command. SQS gives this for free in the target design.
Queue length and failure rate show trouble late. The age of the oldest unprocessed item shows it early. A one-hour outage needs double capacity for another hour to catch up.
partly: Spend reports already stop at the oldest undelivered outbox row, but there is no single alarm on oldest-item age for the receipt streams, settle outbox, ClickHouse outbox and capture inbox.
One alarm per handoff on oldest-item age, plus headroom to drain faster than traffic arrives.
Reject excess work at the first service that sees it, instrument every rejection, and alarm on rejection volume.
follows at the edge (fair share, retryable 429) and on key reads (!1039). gap: the capture buffer sheds the customer's request because a background step is slow, deep inside the worker.
Capture should not refuse customers; spill outside the serving process, count skipped captures, and alarm. Mandatory-retention orgs need an explicit rule (decision below).
Backpressure on one shared queue punishes every tenant on it. Use per-tenant limits, sharding, or a spillover queue for a noisy tenant.
partly: receipts are sharded by org into 8 streams; the capture buffer is one shared pool per pod, so one org's very large bodies can fill it for everyone.
Per-org budget in the capture buffer, or per-org fairness in the loader queue.
Duplicates collapse only at background merges, so reads use FINAL, which is cheap when the query filters on key columns. Put the tenant in the ordering key; order columns by increasing cardinality.
follows: every read is filtered to one org and uses FINAL; we do not sum materialized views, because a retried insert would be counted twice there.
A session table should order by (org, session, time) so one session's rows sit together.
The Bloom-filter indexes Helicone uses (ngrambf_v1, tokenbf_v1) are now deprecated. The dedicated text index (a real inverted index, GA from 26.2) is the recommended way, queried with hasToken, hasAllTokens and hasPhrase.
not built: no body search today.
A text index on a truncated, privacy-gated preview column. Check our ClickHouse version first.
A MemoryDB write succeeds only once it is in the multi-AZ log; reads from the primary always see the latest write. A script blocks its shard while it runs, so keep scripts short; multi-key scripts need all keys in one slot (hash tags).
follows: one hash tag per org shard, short scripts, reads from the primary, a reconciler that reports drift.
Keep scripts small as money rules grow (the parity fixes add logic); watch per-shard CPU.
Dropping or detaching a whole partition is far faster than a bulk DELETE and avoids vacuum work entirely. By default, autovacuum waits until 20% of a table's rows are dead. On a 200 GB table, that is a lot of cleanup at once. Per-table settings can lower the threshold.
gap: the largest tables have no retention and no partitions; storage.objects carries 10.7 million dead rows; vacuum on these tables caused November 9.
Time partitions plus a retention window for gateway_chain_authority_receipts, audit_log and the per-request ledger tables (their history is in ClickHouse); per-table autovacuum settings meanwhile.
Put the large payload in object storage and pass only a reference. S3 notifications arrive at least once, usually within seconds, possibly duplicated, and not in order.
target: matches the planned S3 to SQS to Fargate pipeline.
The loader must not assume order: a request's complete record can arrive before its prompt checkpoint. Treat the complete record as authoritative and deduplicate by key.
OpenTelemetry names a conversation gen_ai.conversation.id (still marked Development). Helicone uses three headers: session id, a slash path like /plan/step-1, and a session name.
partly: session_key accepts several inputs but neither of these.
Accept Helicone's headers and the OpenTelemetry attribute as session inputs, so customers switch without code changes and traces from other tools line up.
Ideas beyond parity
Sessions computed once, not per query. Helicone groups raw rows on every page load. A session table in ClickHouse, updated by the same exporter that writes usage, makes the session list a plain sorted read and allows sorting by cost, length or errors.
Trees from real links. We already record parent_response_id and subagent keys. A tree built from them is exact, where Helicone's path strings are only as good as the caller's labels.
Search that respects consent by construction. Store the searchable preview under the same key as the body, so erasure, retention and ZDR delete both in one step, and a test can prove nothing searchable outlives its body.
One loader, many uses. The Fargate pipeline that loads captures can also compute the session summary, the search preview and the offline tags in the same pass, so each capture is read from S3 once.
This section pulls the research together into two lists: what our data needs before a real session view can exist, and which practices from the review we should adopt.
What a complete session view needs here
A session id on the analytical row. Copy session_key, parent_response_id, agent_key, plus an optional session name and path, onto the usage event and into ClickHouse usage_events. Sort the ClickHouse table so one session's rows sit together.
Session totals that are not recomputed per page. Turns, duration, cost, tokens and errors per session come from ClickHouse, ideally a session table kept current by the exporter. They never come from the Postgres ledger.
Real parent edges. Build the tree from parent_response_id, subagent keys and an optional path header, not from strings alone.
Headers that match Helicone's. Accept Helicone-Session-Id, -Path and -Name next to X-Explabs-Session-Id, so teams can switch without code changes.
A session list and a session detail page. Waterfall timeline, tree, cost rollups, and the existing drawer, plus a batch body read for one session.
Search inside sessions. A searchable text projection of captured bodies, kept in ClickHouse with a token or n-gram index and the same consent, ZDR and erasure rules as the objects. The full bodies stay in Storage.
Rules to keep while building it
Nothing new on the request path. Session fields are computed at authorization, where the hashes are already computed, and travel in the existing receipt and outbox.
No aggregate over the Postgres ledger on a read path. Any new figure is a ClickHouse column or a maintained rollup.
Searchable text inherits every privacy rule of the body it came from: capture switch, ZDR, retention, and organization erasure. Deleting a body must delete its search text.
Large or slow reads go through the existing fences: ClickHouse read slots, per-query limits, and the per-organization key limit.
Schema changes ship in two releases. The first adds the new shape beside the old one (expand); a later release removes the old one (contract). This is needed because the deployed code keeps running against the new schema until the next release.
Next: the plan for session parity and search, with the order of the changes and the decisions it needs from you.
November 9: the target Kion set
The November 9 refusals made one thing clear: a customer request could still end up waiting on a Postgres write, through the capture buffer and Supabase Storage. Kion's direction answered that directly. The section below is the target as first drawn on November 9. Two parts of it changed later in review: the spillover sidecar was cut (D2 keeps memory, then the pod's disk, then a metadata-only record), and the queue became two queues on November 21.
Target architecture, as drawn on November 9
Kion's direction for this work has three parts. First, the request path never depends on how fast Postgres writes. Second, captures land in our own S3, S3 announces each new capture on SQS, and one durable pipeline on ECS Fargate loads them into Postgres and ClickHouse in the background; the same pipeline also runs offline tagging. Third, tables that change constantly get a retention window or move out of the main database. The unmerged trace pipeline stack (!492 to !525) is the starting point.
flowchart LR
C["Client"] --> CF["Cloudflare"] --> E["Edge"] --> G["Gateway worker"]
G <-->|"limit, hold, settle"| M[("MemoryDB")]
G --> P["Providers and our GPUs"]
G -->|"capture via spillover sidecar, S3 PUT, consent facts inside"| S3R[("Our S3 raw bucket")]
S3R -->|"object created event"| Q[["SQS capture queue with dead-letter queue"]]
Q --> FG["Fargate pipeline, scales on queue depth step 1 ETL, step 2 offline tagging"]
FG -->|"processed body"| S3P[("Our S3 processed bucket key = org and request")]
FG -->|"summary row, preview, session ids"| CH[("ClickHouse")]
FG -->|"only what money and authorization need"| PG[("Postgres")]
M -->|"receipts"| WB["Writeback"] --> PG
PG -->|"outbox"| CH
UI["Dashboard and API reads"] -.->|"lists, search, totals"| CH
UI -.->|"one body, after authorization"| S3P
Nothing on the left of the S3 PUT touches Postgres. A slow database delays the right-hand side, never a customer.
What changes, and why each piece is there
Our own S3 instead of Supabase Storage for captures. An S3 PUT writes no row in our database, so the buffer slot frees as soon as S3 confirms. storage.objects stops growing with traffic.
SQS instead of a Postgres inbox table. S3 announces each new object on SQS. AWS scales the queue for us, retries are built in, and a message that keeps failing moves to a dead-letter queue instead of being retried forever. updated 2026-11-21: two queues now, one for gateway captures and one for span-ingest segments, each with its own consumer and dead-letter queue, so a span flood cannot delay captures.
Consent facts travel with the capture. The gateway already decides consent and zero data retention once, at authorization. If it writes that decision into the capture object, the loader no longer has to wait for the writeback to create the request row. Erasure still takes priority: if an org opts out after the upload, its objects must still be deleted.
Fargate consumers that scale on queue depth, outside the serving cluster. One pipeline does both loading (ETL) and offline tagging. The EKS Project worker then stops processing captures.
Capture never refuses a customer (decision needed): when a worker's capture buffer is full, the worker either moves the capture to a separate helper container (a sidecar) or skips it and counts the skip. Either way it serves the request. Orgs under mandatory retention need an explicit rule.
Retention on the churning tables. A window or partitioning for gateway_chain_authority_receipts, audit_log, and the per-request ledger tables, whose history already lives in ClickHouse.
November 9 and 10: making /v1 survive a database outage
Part 4 explains why a short Postgres restart breaks /v1 today. This section is the first plan to fix it, written on November 9 and 10. The infra plan below later added a blocker this plan missed (the model-chain check on every request), and the November 18 work replaced the 5-minute stale limit with the MemoryDB deny set and a 60-minute bound.
flowchart LR
REQ["/v1 request"] --> GW["Gateway worker"]
GW --> KEY{"Key and grant in cache?"}
KEY -->|"fresh, under 2 s"| SERVE["Serve"]
KEY -->|"stale or missing"| PG[("Postgres")]
PG -->|"answers"| SERVE
PG -->|"errors or slow: breaker opens"| STALE{"Last good value under 5 min old?"}
STALE -->|"yes"| SERVE
STALE -->|"no, brand-new key"| REFUSE["Refuse with a retryable 503"]
SERVE --> MDB[("MemoryDB: reserve and settle")]
MDB -.->|"receipts queue, written back when Postgres returns"| PG
During a Postgres outage the gateway keeps serving known keys from its last good data, money keeps settling in MemoryDB, and the receipts land in Postgres when it comes back. Only callers the gateway has never seen are refused. updated 2026-11-18: the 5-minute stale limit is superseded: blocks come from the MemoryDB deny set and allowed answers are served for up to 60 minutes; protected chains also need a maintenance window.updated 2026-11-21: Fixed. On 2026-11-20 keys and grants were bounded at 15 minutes in the code. Every outage path now uses one 60-minute bound, OUTAGE_SERVE_STALE_SECONDS in explabs/outage_bound.py, pinned by a test.
The table lists each change, how it works, what it buys and what it risks. Some rows carry later updates, marked with their date.
#
Change
How it works
Benefit
Drawback or risk
1
Don't mark workers unready when the database is unreachable
Readiness reflects whether the worker can serve: catalog loaded, MemoryDB reachable. A failed Postgres ping becomes a warning and a metric, not an unready verdict.
The edge keeps routing to workers through a database restart instead of returning 502 for every request.
A worker that truly cannot serve must still fail its own requests fast, which is what change 5 does. Monitoring must alert on the database itself, not rely on pods going unready.
2
Serve cached key and grant data up to about 5 minutes old when Postgres errors updated 2026-11-18: superseded: blocks live in MemoryDB, so allowed answers are served for up to 60 minutes of outage.updated 2026-11-21: Fixed. On 2026-11-20 keys and grants were bounded at 15 minutes in the code. Every outage path now uses one 60-minute bound, OUTAGE_SERVE_STALE_SECONDS in explabs/outage_bound.py, pinned by a test.
The authority cache keeps the last good answer per key hash beside the 2-second fresh entry. On a Postgres error or open breaker, a lookup returns the last good entry if it is under the stale limit. The limit is one setting.
Every key that has called in the last few minutes keeps working through a restart. That covers nearly all real traffic.
Your decision: during an outage, a key revoked, an org banned or quarantined, or a spend lock applied in the last few minutes can keep working until Postgres returns, up to the stale limit. A brand-new key cannot be served, because it has nothing cached.
3
Serve the last good pricing, plan and promotion data
The pricing, plan-discount and promotion caches already exist. On a refresh error they keep serving the previous value instead of failing the request.
Requests keep being priced and admitted with the terms that applied a moment ago.
A price or promotion change made during the outage applies only after recovery. Charges in that window use the previous terms. For a few minutes this is acceptable; it should be logged.
4
Move the key "last used" timestamp off the request path
Today the request path writes last_used per key. Instead, record it in memory and flush it in batches every minute or so, dropping failures.
Removes a Postgres write from every request, which helps load as well as outages.
"Last used" in the dashboard can lag by a minute or two, and can lose a value if a pod dies before flushing. It is informational, so that is acceptable.
5
Fail fast with a circuit breaker
A breaker around Postgres calls on the request path opens after a few consecutive errors or timeouts. While open, calls skip Postgres at once and use the fallbacks above. It probes again every few seconds.
Requests stop waiting 10 to 30 seconds per lookup; a short outage costs milliseconds, not timeouts. Also protects Postgres from a thundering herd when it comes back.
A wrongly tuned breaker could open on a brief blip and serve stale data unnecessarily. Thresholds need testing under load.
6
Alert on the MemoryDB writeback backlog
Page when receipts waiting in the MemoryDB streams exceed a threshold or their age passes a few minutes.
An outage longer than planned is visible before the backlog grows large. Usage and billing in Postgres catch up on their own when it returns.
None. MemoryDB is durable, and receipts are deleted only after Postgres commits them, so a backlog loses nothing.
What still breaks during a database outage
Responses API continuations (previous_response_id), whose state lives in Postgres.
An organization's or key's very first request, which has nothing cached.
Keys still on the Postgres ledger path: batches, customer-plan (reseller) keys and video.
Captures, until they move to our own S3 (see Target architecture); today a slow Postgres can refuse captured requests.
The dashboard, sign-in and admin pages: about 1 to 3 minutes of errors. They can show a maintenance banner.
updated 2026-11-18: also still broken: protected model chains outside a planned maintenance window (52% of production traffic), pods starting during the outage, and new quarantines, bans or key revokes, which are written to Postgres first.
How a resize then runs
Build and test changes 1 to 6, including a 3-minute database cut under load on staging. updated 2026-11-18: rehearsals run on the preview only, per the owner, and the bar is a 10-minute cut; 41 to 70 s cuts have run so far.
Rehearse the resize on the existing restored-backup project platform-2tb-rehearsal-20261029: time the restart and confirm the staged max_connections value survives it.
In production, stage max_connections with no restart, pick the quietest hour, freeze deploys, and make sure no disk change happened in the last 4 hours.
Announce maintenance on the status page, trigger the compute change (one restart applies both), watch /v1 keep serving and the writeback backlog drain, then raise the pooler's pool size (no restart).
Alternatives considered
The table compares the other ways to change the database size, by downtime and effort. The first row is the recommendation.
Option
Downtime
Effort
Notes
Resize in place after changes 1 to 6 (recommended)
/v1: none for known keys; dashboard: 1 to 3 minutes
1 to 2 weeks
Also protects against unplanned Supabase incidents and future RDS failovers.
Second Supabase project kept in sync by logical replication, then switch
Seconds to minutes at the switch
3 to 6 weeks per move
Works for our tables (production has wal_level=logical and 80 slots). Auth and Storage schemas need Supabase support. About 6.7 TB of capture files to copy. Scheduled jobs and webhooks must not run on both sides. Needs max_slot_wal_keep_size raised from 3 GB (about 8 minutes of writes) first.
Move to AWS Aurora or RDS (Blue/Green, or Aurora Serverless v2 online resize)
Under a minute per switch afterwards
2 to 4 months
The only path to real high availability. Means self-hosting Auth, PostgREST and Storage and replacing pg_net, Vault and preview branches.
A PgBouncer we control, paused during the switch
Seconds of queued requests
Part of either move above
Does not cover PostgREST or Auth, and cannot hide a 2-minute restart on its own.
Also worth doing: consider point-in-time recovery, and ask Supabase about an Enterprise plan with an SLA (the Team plan has none).
November 9 and 10: the first questions for the owner, and the analyses behind them
Each decision below says what is being decided, why it matters, the options, and what we recommend.
Final: D8 · Decision 1 · search
May a text copy of prompts and responses live in ClickHouse for search?
Why it matters. Nobody can search the content of requests today. Bodies sit in object storage, which cannot be searched. Helicone keeps whole bodies inside ClickHouse, so its search works, but every search scans everything, bodies vanish after 3 months, and large bodies lose all non-English characters.
Options. (a) No search. (b) Whole bodies in ClickHouse, as Helicone does. (c) A trimmed copy of the message text only: no images, audio or files, with a size cap per request. It has a real text index and is stored under the same key as the body, so deleting the body (erasure, expiry, opt-out) deletes it too.
Recommendation: (c), worked through in Analysis 1. It gives fast search inside a session and across the organization at a fraction of the storage. It holds only what the organization already agreed to store, never zero-data-retention traffic. Build it with the S3 capture pipeline, so each capture is read once.
Final: D2 · Decision 2 · capture under pressure
When capture can't keep up, serve the request uncaptured, or refuse it?
Why it matters. Today the gateway refuses the customer's request (503 capture_unavailable) when its capture buffer is full. On November 9 that refused 123 requests from 76 organizations because Postgres was slow. Refusing protects a promise to keep everything. Serving protects availability.
Options. (a) Keep refusing for everyone. (b) Serve everyone and count the missed captures. (c) Serve and count for everyone, except traffic we must keep: uncensored models, which are always retained, and organizations with a contract to retain everything. That traffic keeps refusing.
changed in review: D2 cuts the chain to memory then a metadata-only record, counted per tier; uncensored traffic is no longer must-keep, per the live privacy policy; only written retention contracts refuse.
Recommendation: a fallback chain that ends in (c), worked through in Analysis 2, with an alarm on missed captures. Once captures go straight to our own S3, the buffer fills only when S3 itself is down, so either branch should almost never happen.
Final: D14 · Decision 3 · media
For images, audio and video, store the bytes or only a summary?
Why it matters. These requests store nothing today. An image is about 1 to 3 MB, a speech response up to 64 MB, a transcription upload up to 25 MB, and a video tens to hundreds of MB. Customers who use these surfaces will expect to see what they sent and got back.
Options. (a) Summaries only: type, size, duration, prompt text. (b) Bytes for everything. (c) By kind: store images and audio as their own objects, deleted with the capture. For video, store the prompt, the reference image and the job's result, and copy the MP4 only for organizations paying for retention. For embeddings, store the input text and a summary of the vectors.
Recommendation: (c), with costs per surface in Analysis 3. It covers what people look at, keeps the cost proportional, and lets paid retention include video.
Capture Decisions requests for customers, and exclude our own callers?
Why it matters. Decisions requests (/v1/systemone, /v1/decisions) are never stored, whoever calls them. Customers' decisions would be useful in Observability. But our own content review sends excerpts of other tenants' prompts to Clef, and the signup scan sends personal data, both through an Experiential Labs key. Storing those would copy tenant content and personal data outside the tenants' deletion rules.
Options. (a) Keep not storing any. (b) Store all of them. (c) Store customers' decisions under their storage switch. Mark our internal keys "do not store content", and keep only what the quarantine decision needs: scores, matched tags, which window of which request was judged, and the decision taken.
Decided: (c). The judged request's own capture is the evidence, and it follows its tenant's rules. The per-key storage setting that makes this possible is the same one customers get.
Final: D14 · Decision 5 · per-key storage
May a key store content when its organization's switch is off?
Recommendation: no. A key can only tighten the organization's setting: store less, or expire sooner. That keeps the organization's switch a promise the whole organization can rely on.
Final: D13 · Decision 6 · retention defaults
What changes first in retention?
Recommendation: ship customer-set expiry and paid retention first, since both only shorten or extend what a customer chose. A default expiry for free organizations, and an archive of valuable data for our own use, come after the terms and privacy pages are updated, because the privacy page currently promises pairs are kept "as long as capture stays on". updated 2026-11-20: the owner answered "free plan: we retain". The plan reads that as no free-plan expiry at all; that reading awaits his confirmation. Until then the code keeps the free-default switch, switched off.
Final: D12 · Decision 7 · Helicone provider keys
What happens to a provider key sent through Helicone's proxy hosts?
Decided by the no-change goal (Nov 10): on Helicone hosts, accept the customer's own provider key per request, use it for that call only, never store it, and record the request as the customer's own-key traffic. Anywhere else, the usual rule stays: a provider key is stored as a connection first.
Analysis 1: searching request content
What people need. Find the request where the agent said a certain thing, inside one long session or across the organization, in any language, within about a second. Today no content search exists. Bodies are compressed objects in storage, and the only searchable fields are ids, labels and conversation handles.
The fact that shapes the design. An agent sends its whole conversation so far on every call. In a 3,000-turn session, request 3,000 contains turns 1 to 2,999 again, request 2,999 contains turns 1 to 2,998, and so on. Indexing every request's full prompt stores turn 1 three thousand times, so storage and search time grow with the square of the session length. That is why Helicone's search is slow, and why it deletes bodies after 3 months.
The idea. For each request, index only what is new in it: the messages added since the previous turn, plus the model's response. Each piece of text is indexed once. For example, searching "refund policy" in a session returns the three requests where that text first appeared or was answered, in under a second; clicking one opens the full conversation from S3. The text index works like the index at the back of a book: it jumps straight to the matches instead of reading every request.
Option
Speed
Storage
Privacy and deletion
Effort
A. Whole bodies in ClickHouse (Helicone)
Slow: their n-gram index is too small to skip anything, so every search scans
Every body stored twice; grows with the square of session length
A second full copy to delete; they expire it after 3 months, which also loses the data
M
B. New text only, in ClickHouse with a text index
Fast: ClickHouse's inverted text index (generally available from 26.2; production runs 26.6) finds tokens without scanning, filtered to one organization or session
Each request stores only the messages that are new since the previous turn, plus its response, without images or files, capped per request. Volume grows with session length, not its square
Same key as the body object, so erasure, expiry, opt-out and zero data retention delete both in one step; a test can prove nothing searchable outlives its body
M
C. Separate search engine (OpenSearch, or a search-on-S3 engine such as Quickwit)
Fast, with richer ranking
Similar to B
A third system holding customer text, with its own deletion path to keep in sync
L, plus a new system to run
D. Scan objects on demand
Seconds to minutes for a long session; unusable across an organization
None extra
Simplest
S
E. No search
n/a
None
Simplest
none
Recommendation: B. Index each request's new text plus its response, in ClickHouse, with the text index. Keep every character (no ASCII stripping), and cap each request's indexed text, for example at 64 KB, recording when it was cut. updated 2026-11-18: built at 32 KB per request with a token index. The full conversation for a match is rebuilt from the session, and the full body is one object read. Search runs scoped to the organization, optionally the session, and combines with every Requests filter.
Conditions: only content the organization already agreed to store goes in; never zero-data-retention traffic; it is built with the S3 capture loader so each capture is read once; and the privacy page names it as part of stored content.
Analysis 2: when capture cannot keep up, including fallbacks
What happens today. Each gateway pod holds a capture in a buffer until its upload commits. The buffer holds up to 2,048 records and 256 MiB in memory, then spills to up to 4 GiB of local disk. A Supabase Storage upload commits a row in our Postgres, so a slow database fills the buffer. A full buffer makes the engine refuse the customer's request: 123 requests from 76 organizations on November 9. The refusal exists so that traffic we must keep is never served without its copy.
Falling back instead of refusing. A full buffer is the last stage of a chain. Each stage should give the capture somewhere else to go before the customer is affected:
flowchart LR
REQ["Request served"] --> B["In-memory buffer"]
B -->|"normal"| S3A[("Our S3, primary region")]
B -->|"S3 slow"| SP["Spill to a sidecar's disk, outside the serving process"]
SP -->|"when S3 recovers"| S3A
SP -->|"primary bucket failing"| S3B[("Second bucket, other region")]
SP -->|"disk full too"| META["Keep a metadata-only record: sizes, hashes, model, reason missed; count and alarm"]
META -->|"must-keep traffic only"| REF["Refuse new requests of that traffic"]
The customer is affected only after every other place to put the capture is full, and then only for traffic we are required to keep.
The table compares three ways to behave when capture cannot keep up. Read the "Customer impact" and "Fits the must-keep promise" columns together: only an option good on both is acceptable.
Option
Customer impact
Captures lost
Fits the must-keep promise
Effort
A. Refuse (today)
Requests refused whenever Postgres is slow
None
Yes
none
B. Serve, count the miss
None
Every capture during the slowdown
No, for uncensored and contract traffic
S
C. Fallback chain (diagram)
None, except must-keep traffic after every fallback is exhausted
Only when memory, sidecar disk and both buckets all fail; then a metadata record remains
Yes
M
D. Keep less (prompt only, or truncated) under pressure
None
Part of each capture
No
S
Details that make C work:
The sidecar. Spilled bytes live in a separate container in the same pod, so a burst of large bodies cannot push the serving process out of memory. Its disk should survive a container restart. A pod deletion loses whatever is still spilled, which is why the second bucket exists.
Must-keep traffic is known before the call. Uncensored models and organizations with a contract to retain everything are decided at authorize, so the gateway knows which requests may be served uncaptured and which may not.
Every miss is visible. The metadata record says why the capture was missed, and an alarm fires on the rate of missed captures per organization. A missed capture is never silent.
Postgres leaves the chain entirely. With captures going to our own S3, a slow database can no longer fill the buffer at all. This fallback chain only matters when S3 or the pod itself is in trouble.
Recommendation: C. Build it with the S3 capture pipeline. Until then, a smaller version is worth shipping on its own: serve and count for all traffic except must-keep traffic.
Analysis 3: images, audio, video and embeddings
What is at stake. These requests store nothing today, so a customer using them sees only metadata in Observability. Keeping media costs storage, but object storage is cheap. S3 Standard is about $0.023 per GB per month, and moving cold data to Infrequent Access (about $0.0125) or Glacier Instant Retrieval (about $0.004) cuts that by 2 to 6 times.
Surface
Typical size
Storage cost per 100,000 requests, per month kept (S3 Standard)
What people look at
Recommendation
Images (generation, edits)
1 to 3 MB per image
about $2 to $7
The image itself, as a thumbnail
Store each image as its own object, deleted with the capture; drawer shows a thumbnail through a short-lived link
Speech (text to speech)
about 1 MB per minute of audio; up to 64 MB
about $2 to $10 for typical clips
Playing the clip
Store the audio as its own object; audio player in the drawer
Transcription (speech to text)
up to 25 MB upload; small JSON transcript
up to about $58 at the 25 MB maximum
The transcript, sometimes the audio
Store the transcript always; the audio only on paid retention. Voice can identify a person, so default to less
Video
tens to hundreds of MB per job
about $230 to $2,300 at 100 MB to 1 GB
The prompt, reference image, a frame, the result status
Store the prompt, reference image, the job's result and one poster frame; copy the MP4 only on paid retention, before the provider deletes it (Veo keeps videos for 2 days)
Embeddings
up to 2,048 inputs, each about 3,072 numbers
large, and rarely useful to look at
The input text, how many vectors, dimensions
Store the input text and a summary of the vectors (count, dimensions, usage); vectors themselves only behind a setting
Recommendation: store by kind, as in the last column. Images and speech are cheap and are what people want to see. Transcription audio and video files are expensive or sensitive, so they are kept in full only for organizations that pay for retention. Embedding vectors are kept only on request. In every case the media is its own object under the capture's key prefix, so deleting a capture deletes its media. After 30 days, media moves to a cheaper storage class automatically.
Order: the shared media-reference part of the capture document first, then images and speech, then transcription, then video.
November 10: the infra plan after the dashboard incident
On November 10 the dashboard overloaded for about six hours (told in Part 4). The incident owner handed the long-term items to this plan. Items 10 and 11, and the state-placement analysis, come from the November 11 post-mortem's list of ways to isolate the API from the dashboard. The detailed designs for items 1, 2, 5, 6 and 7, with code references, are at the end of this section.
One idea runs through all of these items: every wait on Postgres must be bounded, visible, and survivable. A request should give up quickly with a clear error instead of queueing. Background jobs should run at a set pace instead of as fast as possible. The paths customers depend on should keep working on cached facts for a few minutes when Postgres is gone.
#
Item
What is wrong today
Plan
Size
First step
1
/v1 through a short Postgres outage, and the API request path off Postgres (post-mortem item 2)
Every request checks the model chain in Postgres (authorize_model_chain, control_store.py:2684), even with warm caches. Key and grant caches last 2 s with no stale fallback. last_used is a synchronous write. About 100 s into an outage, every pod fails its readiness check and leaves the load balancer at once.
Take the chain check off the request path first (chain revision rows never change, so they can be cached forever; protected revisions for 15 s).
Then: readiness that depends on the catalog and the money store only; last-good keys, grants, limits and prices for a few minutes; last_used buffered and flushed every 60 s; a circuit breaker with short checkouts on the request path; an alert on writeback age and backlog.
L
Cache immutable chain revision rows, behind a shadow comparison
2
Control-plane database access
8 sessions per process, borrowed with no timeout. The web app gives up after 20 s, but the control plane keeps working on the abandoned request for up to 120 s. The autoscaler watches CPU, which stays idle while pods wait.
A larger bounded pool that gives up after a few seconds with a retryable 503. A deadline header from the web app, so abandoned work stops at its next database call. An alert on database wait (p95 over 2 s for 5 minutes) instead of scaling on it. A deploy guard that refuses a replica count whose connections would exceed the pooler budget (200 of 225 session slots). Finish transaction mode (!1100).
S to M
Pool wait timeout and the deadline header
3
Resize Postgres without downtime
Any change to compute size, max_connections or pool size restarts Postgres, usually for under 2 minutes. Our plan has no failover or blue/green, and read replicas cannot be promoted.
Item 1 first, so /v1 rides through a restart (see Restarting the database with zero downtime). Then a rehearsed, announced in-place window that batches every restart-only setting. Longer term: a second Supabase project with logical replication for cutover, or a move to Aurora. Both are large and need their own decision.
M, then L
Rehearse a restart on staging and measure what breaks
4
Reads that grow with workers times organizations
Every gateway worker re-reads some tables on every tick: geo_purchase_gated_orgs (scanned about once a second), organization provider policies, the paid-organizations list, and credential release, which leaves a transaction open around the credential fetch. Stale gateway_workers rows are never cleaned.
Read by change: a version number per table, and re-read only rows newer than the last version seen, like the geo-gated sync already does. Close the transaction before fetching a credential. Delete worker rows not seen for a day. The per-tick reads and lane security are designed on the Catalog Architecture page, sections 11 and 12.
M
Index the geo scan; close the credential transaction
5
Pace wallet_check
64 Project worker pods each ask every 5 s; the winner checks the next 500 organizations and starts over immediately. A full pass of 417,000 organizations finishes every 4 minutes, nonstop.
The state row decides when the next batch may start: a short gap between batches, and one full pass every 45 to 70 minutes. Old pods keep asking and simply get "nothing to do". Later, check only organizations whose wallet changed, with one full sweep a day.
S
One additive migration; measure one batch on production
6
Capture pipeline
813 captures in metadata_pending are retried every 5 minutes forever, because a prompt whose request row never arrives returns early (capture_inbox_worker.py:207) before the step that would drop it. There is no dead-letter state. Every processed capture writes storage.objects in the main database about three times. A full buffer refuses customers.
Now: fix line 207, add a parked state with a reason after 24 hours or 300 attempts, page on parked rows that must be kept, add a replay command, and process claimed captures in one batch. Erasure must still reach parked rows. Then: the S3, SQS and Fargate pipeline in the database plan above, and the capture fallback chain in Analysis 2.
S now, L later
Fix line 207 and park the 813 rows
7
Release tooling
Releases only need their commit to be on main, but finished-release recovery still requires main's newest commit (production-deploy.yml:396), so any merge breaks it.
Merge freezes rely on sessions messaging each other.
gitlab_ci._read fails on the first GitLab error.
About 3,900 stale manual preview jobs broke a listing that reads at most 500.
The smoke test's usage check waits only 10 s, while the writeback lagged 3 to 9 minutes that day.
Pin recovery by containment like releases, which removes the need for a merge freeze. Until then, the release job blocks merges through GitLab's protected-branch setting and always restores it.
Retry GitLab reads 4 times with backoff.
Stop preview tooling from creating manual jobs that are never run, and clean old ones automatically.
Size the smoke test's wait from the measured writeback lag, with a clear "writeback lagging" failure.
Let finished-release recovery refresh its fleet proof right before the evidence recheck. The proof must be under 30 s old there, but the GitLab active-jobs query alone can take about 16 s plus retries, so a recovery can expire on timing alone (it happened once on November 10; the retry succeeded).
S to M
Retry in gitlab_ci._read
8
Lanes pointing at test hosts
Some organization-owned lanes point at webhook.site, lhr.life and oast addresses, left over from a penetration test. Customer endpoints can point anywhere except the deny lists.
Disable those lanes now. Then restrict organization-owned lane hosts: refuse known request-capture and tunnel domains, and require a verified host for new custom endpoints.
S
Disable the lanes (a production write)
9
Rotate exposed secrets
The Supabase PostgREST JWT secret, Cloudflare tokens and R2 keys appeared in chat on November 10.
Rotate each, update every consumer (Porter env groups, CI variables, local operator files), and confirm the old values are refused. Rotating the JWT secret signs out every session and invalidates service tokens, so it needs a short announced window.
S
Today: Cloudflare and R2 first; JWT secret in a planned window
10
Read replica for dashboard reads (post-mortem item 1)
The control plane and web app read everything from the one primary Postgres. On November 11 one expensive dashboard query overloaded it, the balance-ledger writeback slowed, and captures refused about 3,400 requests. Later, ad-hoc 7-day ledger scans and one busy organization slowed the writeback again. A read replica already exists and is unused.
Route control-plane and web reads that can tolerate a few seconds of lag to the replica, through one typed replica client. It falls back to the primary when lag passes a threshold, and reads from the primary right after the user saved something.
Inventory every read first. Dashboard, admin, analytics and listings can use the replica. Read-after-write, money and admission, chain and release machinery, settle and writeback, and anything inside a write transaction stay on the primary.
Roll out behind a flag, staging first.
Related cheap fix: replace the control plane's per-process lock around PostgREST calls with a connection pool.
Whether the catalog gets its own database is evaluated, not decided (see below).
M
Confirm the replica's size and lag; inventory reads; ship the replica client behind a flag
11
Separate deploy units (post-mortem item 4)
The ledger writeback (explabs-ctl-production-ledger-writeback) runs as a separate deployment inside the control-plane app, so it shares that app's environment, release and rollback. On November 11 a bad environment change crash-looped control-plane pods. One edge app (explabs-api-production) serves both /v1 and the dashboard's /api relay, so slow dashboard calls (13 s /api/models calls that day) occupy the same edge workers and connections as /v1, and every edge deploy touches both.
(a) Make the writeback its own Porter app with its own environment, release and rollback. (b) Split the edge into one app for /v1 and one for the dashboard /api relay. This isolates processes and deploys, not the database: pods also fail on CPU, memory, connection pools, crash loops, bad configuration and failed deploys, and separate apps contain those. It belongs with the four-writeback-pod change (!1146).
S
Writeback as its own app; then the edge split
Where per-request state lives final: D1, D6
Taking the API request path off Postgres means every kind of state a request needs must live somewhere a request can read in microseconds to a few milliseconds, with the right guarantees.
Silen's concern about MemoryDB is that it is "just a cache store". The distinction matters. AWS ElastiCache is a cache, but MemoryDB is AWS's durable in-memory database. It acknowledges a write only after the write reaches a transaction log copied across availability zones, so an acknowledged write survives a node failure (AWS documentation).
Two questions stay open: is that durability enough for us as the system of truth for live balances, and should a single AWS service hold that role? The wallet tests answer the first question with data. The table gives the options for each kind of state a request needs, with a recommendation per row:
State a request needs
How exact it must be
Worker-memory snapshot (like !1171)
MemoryDB
Durable Objects
Recommendation
Key and authorization (key, organization, grants)
A revoked key must stop within seconds; a new key must work at once
Fits: the whole key set fits in memory, refreshed by a version poll. A brand-new key not yet in the snapshot falls back to one database read
Possible, but adds a network hop for data that rarely changes
Possible; another vendor on every request
Worker-memory snapshot with a version poll of a few seconds, a database fallback for unknown keys only, and never caching a refusal
Catalog, prices, routes, promotions
Minutes of staleness are acceptable; changes are published
Already done: the catalog is a published snapshot in worker memory, and !1171 did the same for the :free list with zero database reads per request (about 0.07 cores to refresh)
Not needed
Not needed
Worker-memory snapshot (today)
Model-chain checks
Revision rows never change; protected revisions change rarely
Fits: cache revision rows forever, protected revisions for 15 s
Not needed
Not needed
Worker-memory cache, the first step of item 1
Rate limits
Approximate within a second is fine; must be shared across workers
Does not fit: each worker would see only its own traffic
Fits: shared counters, today's limiter
Fits: one object per organization
MemoryDB (today), or Durable Objects if the wallet moves
Balances, holds, spend caps (money)
Exact, durable, one organization updated in order, never overspent
Does not fit: not durable, not shared
Fits: atomic scripts per organization shard, multi-AZ durable log; Silen's concern is its role, not its durability
Fits: one object per organization, strongly consistent and durable, but slower per write and on another vendor
Decide with the wallet tests. Postgres stays the permanent record, written in the background either way
Captures
Must not be lost for must-keep traffic
Only as a short buffer
No
No
Our S3 (database plan step 2)
Request rows and usage history
Exact, but can arrive seconds later
No
Only in transit (receipts)
Only in transit
Postgres and ClickHouse, written in the background (today)
Restarting the database with zero downtime final: D16
Why we need a restart. Production Postgres is version 17.6 on a Supabase 4XL machine (16 GB of shared buffers, 480 connections). Several settings that would help can only change when Postgres restarts:
the multixact buffers, still at their defaults of 256 KB and 128 KB. Multixact churn (bookkeeping Postgres does when many transactions lock the same rows) hurt us in the November 12 and 13 settle-drain incidents;
possibly the transaction and subtransaction buffers (1,024 each today);
the maximum number of connections;
the machine size itself.
We want all of them in one restart.
What a restart costs today. Set the new values without restarting (supabase postgres-config update --config multixact_member_buffers=256,multixact_offset_buffers=128 --no-restart), then resize the machine in the dashboard, which restarts Postgres once. Postgres is unavailable for about 2 to 5 minutes. During that time every route that reads the database fails, and so does /v1, because each request reads Postgres to authorize and reserve.
Why "zero downtime" can't mean Postgres never pauses. On a managed Postgres with a single primary, Supabase gives our plan no failover or blue/green switch, so the database itself always pauses during a restart. Zero downtime has to mean something else: customers notice nothing, because nothing they call needs Postgres during those minutes.
How we get there
Requests stop needing Postgres (infra item 1). Money checks already run on MemoryDB. What is left is moving API key checks, permissions and the catalog into worker memory or MemoryDB, as laid out in Where per-request state lives. Then a /v1 request never makes a Postgres round trip.
Every write a request causes waits instead of failing. Receipts already wait in MemoryDB's streams and are applied when Postgres returns; the writeback did exactly this at 20 times normal backlog this week. Captures and usage records get the same treatment: they queue (in S3 and MemoryDB) and are applied afterwards.
The dashboard reads from the replica (infra item 10). updated 2026-11-18: no read replica exists in any environment yet, so dashboard pages error during a restart. During the window, dashboard pages keep working from the read replica. Things that write, such as creating a key or changing a setting, answer "try again in a minute". That is only visible to people in the dashboard, not to API traffic.
The restart becomes one planned maintenance step, made easy by separate deploy units (infra item 11): pause the scheduled jobs and the writeback, restart Postgres, resume them, and watch the backlog drain.
What customers see after that.updated 2026-11-18: protected model chains need a planned maintenance window opened before the restart; see What changed on 2026-11-18. No /v1 errors. Dashboards and usage figures run a few minutes behind until the backlog drains.
The alternative, and why it comes second. A blue/green database copies data to a new instance by logical replication, then switches over. It still freezes writes for a few seconds at the switch, and on Supabase it is much more work. Making requests independent of Postgres also protects us from unplanned database trouble, which blue/green does not. Prefer it. The full options are in postgres-zero-downtime-options.md on the Desktop.
Until then: if the restart can't wait, do it in a short announced window at the lowest-traffic hour, with every restart-only setting in the one restart. Expect 2 to 5 minutes of /v1 errors.
Should the catalog get its own database? final: D5
Evaluated, not decided. The catalog (models, lanes, aliases, chain tables, publishing) is joined in the same transactions as keys, organizations and admission: authorization reads them together, and chain publication fences admission. Moving it to its own database would mean either giving up those joins or copying the data both ways.
The table weighs the options for where that data lives.
Option
What it buys
What it costs
Keep it in the main database
Nothing changes; transactions stay simple
Catalog reads and publishes keep competing with money writes
Serve catalog reads from the replica
Dashboard catalog pages leave the primary; the gateway already reads a published snapshot
Small: part of item 10. Publishing stays on the primary
Its own database
Full isolation of catalog load
About the primary's compute again (around $1,000 a month), plus rewriting every transaction that joins the catalog with keys or admission, and the chain-publication fence. Large
Recommendation: serve catalog reads from the replica first. Consider a separate database only if catalog writes still hurt the primary afterwards.
Being built in the incident session, not duplicated here: per-organization write batching for receipt apply and the settle drain (removes the organization-row convoy that put one organization's writeback 55 minutes behind on November 11), a CI gate on hot-path queries with alerts, heavy cron jobs moved to ClickHouse, and blue/green deploy work (!1195, !1197).
Order of work
The table orders the infra items by when they should be done, and says why in that order.
When
Items
Why in this order
Today
9 (rotate secrets), 8 (disable the test-host lanes), and the fixes already shipping: catalog view cache, !1104, !1105
Exposed credentials and attacker-style endpoints are live risks
This week
6 now (line 207, parking, batch, alerts); 7 GitLab read retry and stale job cleanup; 5 pacing; 2 pool timeout and deadline
Small and independent; each removes a known load source or failure
Next two weeks
10 read replica (inventory, client, flag); 11 writeback as its own app, then the edge split; 7 recovery pinning; 7 smoke wait; 2 database-wait alert, pooler guard and !1100; 4 read-by-change for the per-tick reads
Need a staging soak
This month
1 (chain check off the request path, then stale caches and the breaker); 3 rehearsal on staging
Touches every /v1 request; ship behind a shadow comparison
This quarter
6 S3 and SQS pipeline; 3 longer-term database options
New infrastructure
Decisions for this plan
changed in review: blocks now come from a MemoryDB deny set, so allowed answers stay valid through an outage without letting blocked organizations spend.updated 2026-11-18: stale allowed answers are now bounded at 60 minutes; protected chains are served through a planned maintenance window, after a MemoryDB witness design was built and dropped.updated 2026-11-21: Fixed. On 2026-11-20 keys and grants were bounded at 15 minutes in the code. Every outage path now uses one 60-minute bound, OUTAGE_SERVE_STALE_SECONDS in explabs/outage_bound.py, pinned by a test.
Final answers at the time:
stale keys and grants up to 5 minutes for "allowed" answers (D1);
protected chain revisions refused with a retryable 503 during an outage (D1);
recovery pinned by containment (D17);
MemoryDB stays the live wallet (D6);
catalog reads from the replica, no separate catalog database (D5);
restart via decoupling, Aurora reconsidered only if needed (D16);
the wallet_check period stays Kion's call.
Silen: during a database outage, may keys and grants be served from a cache up to 5 minutes old? Recommendation: yes for "allowed" answers, never cache a refusal, and count every stale answer.
Silen: during an outage, refuse protected chain revisions with a retryable 503, or record their receipts in MemoryDB and write them back later? Recommendation: refuse first (simple and safe), then add the MemoryDB receipts if outages prove common.
Release owners: pin recovery by containment, which removes merge freezes, or a job-enforced freeze? Recommendation: containment.
Kion: is a 45 to 70 minute wallet_check pass acceptable for drift detection, given the reconciler also runs?
Silen: where live balances live: MemoryDB (durable, today) or Durable Objects. Recommendation: decide from the wallet tests, not from the cache question.
Silen: a separate database for the catalog. Recommendation: replica first.
Silen: the longer-term database option (second Supabase project with logical replication, or Aurora). Recommendation: decide after item 1 ships and one rehearsed restart, when we know how much downtime remains.
Detailed designs
Consolidated from the load-resilience proposals page (main 01a7a4b01, 2026-11-10). The catalog follow-ups (promotions by audience, the shared catalog base, the per-tick reads, lane host security) are on the Catalog Architecture page.
What the research found
Changes item 2
Every /v1 request touches Postgres
Even with every cache warm, each request runs authorize_model_chain: the chain epoch, the revision row, the protected-revision row, and for protected revisions a lease and a receipt write (control_store.py:2684, model_chain_authority.py:110). During an outage every request fails after 10 to 30 s. A stale key cache alone would save nothing.
Changes item 5
Releases no longer need main's head
A production release checks only that its commit is contained in main (chain_release_approval.py:325). Only finished-release recovery still requires main's head (production-deploy.yml:396). The merge freeze can shrink to recovery, or disappear if recovery is pinned the same way.
Changes item 4
Stuck captures are a code bug
A prompt whose request row never appears returns before the step that would drop it (capture_inbox_worker.py:207), so it is retried every 5 minutes forever. That fits the 813 rows retried about 1,280 times since 11-06.
Design detail: control-plane database access
Each control-plane process can make 8 database calls at once and waits forever for a free slot; replace that with a larger bounded pool that gives up quickly, stop work the website has abandoned, and alert on database wait rather than scaling on it.
Today
The incident write-up says "one lock"; since August it is a pool of 8 sessions (client.py:389), each with its own lock, borrowed from a queue with no timeout. The lock dates from a June race in the shared PostgREST session, not reproduced since the HTTP/1.1 pin.
The website gives up after 20 s; the control plane's HTTP timeout to PostgREST is 120 s with no deadline passed down, so abandoned requests keep queueing and running.
Porter autoscales on CPU and memory only. There is no custom-metrics path for this cluster.
!1100 (Supavisor transaction mode for the control plane's direct connections) is green and needs a rebase. It frees up to 7 session slots per pod. PostgREST traffic is not affected by it.
Design
Bounded pool.EXPLABS_POSTGREST_CONCURRENCY (default 32) instead of 8; borrow with get(timeout=min(remaining deadline, 5 s)); on timeout raise DatabaseBusy and answer 503 with Retry-After. Hidden queueing becomes fast, visible shedding.
Deadline from the website. The website sends X-Explabs-Deadline (now + 19 s). Every database call checks the remaining time before borrowing and caps its read timeout at it. A route abandoned by the website stops at its next database call.
Size against PostgREST, not just pods. PostgREST has its own Postgres pool on Supabase's side; more control-plane concurrency than about twice that pool only moves the queue. Check PostgREST's pool size for the current compute before choosing 32.
Alert, do not scale, on database wait. More pods add load when the database is the bottleneck (the 2026-09-05 floor of 10 doubled database time). Publish db_wait_ms from the request log as a CloudWatch metric; page at p95 over 2 s for 5 minutes and drive the status page's Dashboard component from it. Lower the CPU target to about 40% once pods shed instead of waiting.
Pooler budget as a deploy guard. Sum of session clients across apps ≤ 200 of 225; transaction pool plus PostgREST plus Supabase internals ≤ 440 of 480. Fail the deploy when replicas × connections per pod would exceed it.
Design detail: /v1 through a database outage
The Observability page's plan (readiness that ignores Postgres, stale-OK caches, a breaker, a writeback backlog alert) is right, but it misses one blocker: every request makes a Postgres round trip for the model-chain check, and that has to come off the request path first.
What happens today during an outage, step by step, is the table in Part 4. The design below changes each step.
Design
For each read the gateway needs, the table gives how fresh it must normally be, how stale it may get, and what the gateway does when Postgres fails.
Read
Fresh
Stale allowed
When Postgres fails
Chain revision rows (immutable)
forever
n/a
Serve from cache
Protected revisions and worker lease updated 2026-11-18: decided: a planned maintenance window; receipts are not recorded in MemoryDB.
15 s
5 min
Serve from cache; receipt writes need an owner decision (refuse protected revisions with a retryable 503, or record receipts in MemoryDB and write them back)
Key authority, grants
2 s
5 min (owner)
Last good value; never cache a "no"
Limit policies
as now
10 min
Last good value, counted
Prices, promotions
as now
10 min
Last good value, logged
last_used
Buffered in memory, flushed every 60 s, dropped on failure
Breaker in GatewayDatabase.transaction(): open after 3 connect or checkout failures in 5 s, probe every 2 s. Request-path checkouts use the request deadline capped at about 500 ms, not 30 s.
Readiness = catalog loaded and MemoryDB reachable. The breaker state is a metric, not a reason to leave the load balancer.
Alerts: writeback age over 120 s or backlog over 50k (from stream length and oldest pending id, every 10 s); any stale value served; breaker open; a Postgres probe on the status page.
Still broken during an outage, by design: brand-new keys, continuations, batches and video (Postgres money path), captures, the dashboard. updated 2026-11-18: captures no longer depend on Postgres in the new design; also broken: protected chains outside a window, pod starts and new blocks.
Design detail: pacing wallet_check
Keep the accounting check running, but let the state row decide when the next batch may start, so one full pass takes about 45 minutes instead of running back to back forever.
Today: 64 Project worker pods each call wallet_check(500) every 5 s; the winner checks the next 500 orgs and wraps around immediately. Production measured 1,550 to 2,000 orgs a second, a full pass every 3.5 to 4.5 minutes, nonstop.
alter table public.wallet_check_state
add column next_run_at timestamptz, add column pass_started_at timestamptz;
-- app_settings: wallet_check_batch_gap = '3 s', wallet_check_pass_period = '45 min'
-- inside wallet_check, after the skip-locked select:
if v_state.next_run_at is not null and clock_timestamp() < v_state.next_run_at then
return 0; -- same meaning as losing the lock today
end if;
-- start of a pass: pass_started_at = now()
-- after a batch: next_run_at = clock_timestamp() + batch_gap
-- at the wrap-around: next_run_at = greatest(pass_started_at + pass_period,
-- clock_timestamp() + batch_gap)
Safe for the deployed build: same signature and return type; old pods keep calling every 5 s and get 0.
Sizing: 417k orgs is about 840 batches; with about 2 s per batch and a 3 s gap a pass takes about 70 minutes, so set the period to match. Measure one batch on production first (it must stay under PostgREST's 8 s limit).
Next: raise the worker interval to 30 s with jitter; later check only orgs touched since their last check (a dirty set from the wallet triggers), with a full sweep once a day.
Design detail: the capture pipeline
Stop the endless retries with a dead-letter state and a one-line fix, process captures in batches to cut database round trips, and then move the raw hop to our own S3 and SQS so a slow database can never refuse a customer.
Why rows loop
metadata_pending covers five different conditions: no request row, org deleted, complete record waiting for its request row, projection not ready, and any write failure. Backoff caps at 5 minutes and attempts are unlimited. The bug: a prompt with no request row returns at capture_inbox_worker.py:207 before admission, which would have dropped it.
Now (one migration and a small worker change)
Dead-letter. Add parked_at and park_reason; park after 300 attempts or 24 h in a waiting state; split the outcome into request_missing, projection_wait, admission_error, upload_error (still accepting the old name). Erase non-retained prompts with no request row after 6 h. Retained rows are never deleted automatically; they park and page.
Erasure must still win. A parked row would block an org's opt-out forever, so the claim also returns parked rows of orgs that meet the erase rule.
Replay.gateway_capture_inbox_replay(paths or reason, limit), service-role only, behind a full-scope admin route, audited.
Fix line 207 so prompts without a request row reach admission's drop rule.
Batch. Send all 8 claimed records through one write_batch and delete their raw objects in one call: about 3 times fewer database round trips. Process complete records first so prompts get the cheap "superseded" erase.
Alerts on the existing engine: oldest ready row over 10 minutes; any new parked row; any parked retained row.
Do not add consumers blindly
Each processed capture writes storage.objects about three times in the main database, which is the mechanism behind the November 9 refusals. Add parallelism in steps, watching commit latency and capture_unavailable.
Later: our own S3, SQS and Fargate
The work is split into three phases, each with a clear "done when" test.
Phase
Work
Done when
P1
Adapt the never-applied Terraform (infra/traces, !492) to an ECS task role; apply in staging, then production
Reviewed plan; alarms routed
P2
S3 sink (reuse !493) and SQS-to-Fargate loader; only the raw hop moves; consent facts travel in the object; the loader rechecks generation, erasure and deadline before storing
Processed documents at deterministic keys in our bucket; ClickHouse rows; complete records carry settle facts so the loader stops waiting for the request row
storage.objects stops growing
P5
Remove the Supabase inbox trigger and table
Blocker carried from !509: the gateway must stop retrying a raw upload once its authority deadline passes.
Design detail: release tooling
Messages between sessions cannot enforce a merge freeze; remove the dependency where possible, enforce it with the release job where not, and make the smoke and recovery tools tolerate the conditions they are run in.
(a) Merge freeze
Remove the cause. Releases already pin by containment. Pin finished-release recovery the same way (a reviewed recovery commit contained in main), and merges stop mattering.
Until then, enforce with tooling. The release job sets main's "allowed to merge" to No one through the protected-branch API right after the journal begins, records an expiry, and restores the setting on every exit path. A scheduled pipeline every 5 minutes restores it if the journal is not in flight and the expiry has passed, so a crashed job cannot freeze main forever. Needs a maintainer-scoped token held only by the protected production job.
Rejected: a required pipeline job (an MR already green stays mergeable); approval rules (manual); merge trains (serialize but do not freeze).
(b) Smoke check vs writeback lag
The usage-evidence check in smoke_gateway_v1.py:1041 polls for 10 s. On November 10 the writeback was 3 to 9 minutes behind, so a healthy release failed. Proposal: read the writeback lag (section 2's metric), set the budget to clamp(10 s + 2 × lag, 10 s, 180 s), and fail with a distinct WRITEBACK_LAGGING (lag=N s) when lag is the reason. Still fail hard if the lag metric is missing.
(c) writer_inventory GitLab 500s
gitlab_ci._read raises on the first error with no retry, so one GitLab 500 aborts recovery. Retry GETs 4 times with jittered backoff (about 15 s total) on 5xx, 429 (honoring Retry-After) and transport errors; never on other 4xx; restart the job listing from page 1 after a mid-walk failure so the result is one consistent listing. It stays fail-closed.
November 10: the database and capture plan final: D2, D3, D11
This is the work Kion's threads point to. The November 9 refusals showed that a customer request can still end up waiting on a Postgres write, through the capture buffer and Supabase Storage. The goal is that no customer request depends on how fast Postgres writes, and that the tables that change the most stop growing without limit in the main database.
Where it stands
Fast-ledger parity fixes (!1053, !1056, !1058, !1059, !1060, !1061, !1062, !1063, !1064, docs !1054): merged at 64d1d708e and verified on staging. They are live: production moved from 72edcb540 to ac6b6938f on November 10 (floor epoch 98), with their 9 migrations and everything merged before it, including !1039. After it lands: run the !1053 backfill with false, then bring Kion the charging-mode decision.
S3 and SQS capture pipeline: not built. The Terraform for our own buckets, queue and key was merged in !492 but never applied, so none of those resources exist in AWS. The code stack !493 to !525 was closed unmerged. It is the starting point, rebuilt onto current main.
The steps, in order
Apply the infrastructure. Create the raw and processed capture buckets, the SQS queue with its dead-letter queue, and the KMS key from infra/traces (Terraform from !492), after review. This is a production write, so it goes to Kion.
Gateway writes captures to our S3. The worker uploads each capture straight to the short-retention raw bucket. An S3 upload writes no row in our database, so the capture buffer frees a slot as soon as S3 confirms, whatever Postgres is doing. The consent and zero-data-retention verdict, which the gateway already decides at authorize, is written inside the object, so the loader never has to wait for the request row.
S3 announces, SQS queues, Fargate loads. S3 sends an event for each new object to SQS. A Fargate service that scales on queue depth then, in one pass:
reads the object;
writes the processed document to the long-retention observability bucket, under a key built from the organization and request;
writes the summary row to ClickHouse;
writes only what money and authorization need to Postgres;
runs offline tagging.
S3 events can arrive twice or out of order, so the loader deduplicates by key and treats the complete record as the final word.
Capture never refuses a customer (decision 2 below). When the buffer is full, the worker serves the request and counts the skipped capture, except for organizations that must retain everything. Spillover moves into a sidecar outside the serving process, so a burst of very large bodies cannot push a gateway pod out of memory.
Every background worker moves to ECS Fargate (Kion Sync). updated 2026-11-18: superseded: workers stay in EKS; Fargate runs the capture ETL only. The legacy Project worker pods leave EKS, and capture loading, offline tagging, exports and the other background jobs run as ECS services and batch jobs that scale on their own queues, away from the serving cluster.
Dead-letter handling everywhere. Every Postgres handoff (receipt streams, settle outbox, ClickHouse outbox, credit feed) gets an attempt count, a parked state with the last error, an alarm on the age of its oldest item, and a redrive command. SQS gives the capture queue this for free.
Retention on the churning tables. Time partitions with a retention window for gateway_chain_authority_receipts (67 GB, no retention), audit_log (311 GB), and the per-request ledger tables, whose history is already in ClickHouse. Old partitions are dropped whole, which costs no vacuum work. storage.objects stops growing once captures leave Supabase Storage.
ClickHouse becomes the list and search store. The request list, session views and search read ClickHouse; bodies come from S3, one request at a time. See the sessions proposal.
Open merge requests that belong to this plan
Each row is one open merge request, what it does, its state on November 10, and the next step it needed.
MR
What it does
State
Next step
!1047
Moves MemoryDB billing, reservations, settlement and capture into a private Rust extension
Required checks failing; needs unpublished engine 0.7.235; author hold
Owner decision on Rust in platform images, then publish the engine, bump pins, get CI green
!1001
The request row keeps the real refusal reason on the balance ledger instead of a generic quota message
Clean, tested, 74 commits behind
Rebase, re-run checks, merge
!999
A busy ClickHouse usage read waits up to 4 s for a slot instead of answering 429 at once
Clean, tested
Rebase, merge
!1012
Captures that arrive before their request row keep their 5-minute wait during an opt-out cleanup
Migration version collides with main
Renumber, rebase, merge
!578
Drops the retired capture copier's leftover SQL (functions, queue, trigger)
Behind; edits other migrations' headers by mistake
Renumber, revert the header edits, re-derive from live definitions
!1088
Captures batch lines like live requests; adds the capture-path catalog
CI running
Merge when green
!972
Pages when the ledger writeback or the credit feed falls behind
Needs rebase
Rebase, merge (part of step 5)
!1002 / !1065
Two competing ways to serve admin telemetry from ClickHouse summaries
Both clean
Pick one (the review favors !1002), close the other
!1033
Grouped alert rules, threshold history and PagerDuty delivery
Scans the ledger every minute; no retention
Read the hourly rollup, stagger the cron minute, add retention
!588 / !596
Keep sandbox demo usage current by moving it, not adding more; then drop the old generators
Hourly UPDATE on hot tables; design aged
Redo as a fresh MR
!933 / !935
Batched balance settlement prototype (off by default); traffic replay of the November 2 row-lock slowdown
Draft and unchecked
Decide whether still needed now that MemoryDB is live
Where main stood on November 10 and 11: changes and status
This table records the changes related to this work on main as of November 10 and 11, each with its state. It shows what was already live, what was merged but waiting for a deploy, and what was still open, before the new design was built.
updated 2026-11-18: this table shows main as of November 10 and 11. The new build is on unmerged PR #2980 and 12 local split branches; see What changed on 2026-11-18.updated 2026-11-20: the split branches are now open PRs #3090 to #3101, none merged.
done live in production ·
built merged or provisioned, not in use ·
waiting merged, waiting on a deploy or a decision ·
not started
Change
Status
Detail
MemoryDB balance ledger in production
done
Reserving and settling money no longer lock the org's row in Postgres. Burst test Nov 4: 30 req/s for one org with flat latency and no effect on neighbors.
Settle outbox and ClickHouse export on the control plane
done
Usage events and rollups are no longer written inside the money transaction.
Gateway uploads captures without its own Postgres call (!1024)
done
Live since Nov 5. The upload still commits rows in Postgres, inside Supabase Storage.
Capture inbox throughput
done
Project worker raised to 64 pods; inbox drained (62 new items when checked).
Status page and fleet-wide alarms
done
status.experientiallabs.ai reads the probe alarms that page PagerDuty.
Live: production floor epoch 98 on ac6b6938f (Nov 10), which contains these. After it lands: the !1053 backfill (run with false) and a charging-mode decision for Kion.
Capture processing on Fargate (switch)
built
The service and the switch exist. The switch is set to worker, so the Project worker still does the work. The service does not yet scale on queue depth.
Illegal-content review on SQS and Fargate
done
Runs in production with a dead-letter queue; scores with clef on our GPUs.
Trace pipeline AWS resources (raw and processed buckets, SQS, KMS)
built
Terraform merged (!492) but never applied: no buckets or queue in the account.
Gateway writes captures to our S3; SQS-driven loader (!493 to !525)
not started
Stack closed unmerged; revive and rebase onto current main.
Consent facts inside the capture object (!498 idea)
not started
The loader would no longer wait for the writeback to create the request row.
Capture never refuses a customer
not started
Needs an owner decision for mandatory-retention orgs.
Capture spillover outside the serving process
not started
Protects gateway pods from out-of-memory kills on large bodies.
Dead-letter handling for captures
not started
298 rows stuck in metadata_pending since Nov 6 (live). SQS provides this built in.
Retention or partitioning for churning tables
not started
gateway_chain_authority_receipts 67 GB with no retention; audit_log 311 GB; ledger tables whose history is in ClickHouse. The empty capture archive bucket is a first step for free-org captures older than 14 days.
ClickHouse as the list and search store for requests
not started
Summary row with session ids and a searchable preview; Postgres keeps only money and authorization facts.
Request log API for any org key, agent prompt, per-org key read limit (!1039)
done
Merged Nov 9 as 9594290d1; live since the Nov 10 release ac6b6938f. Any org key reads its own request list, one request with include_body, attempts and the ClickHouse rollups; "Copy agent prompt" above the Requests table; 10 reads/s with bursts of 30 and 4 in flight per org per control-plane pod.
/v1 survives a database outage: no unready on DB loss, stale key and grant cache, last good pricing, batched last-used, circuit breaker, writeback backlog alert
not started
1 to 2 weeks. Needs your decision on the stale limit for keys (about 5 minutes). See Surviving a database outage.
Database resize and max_connections raise in one rehearsed window
not started
After the item above; rehearse on platform-2tb-rehearsal-20261029 first.
Admin Telemetry: platform rollup in ClickHouse instead of SELECT * ... FINAL over raw rows
not started
Page broken: most loads time out at 18 s. See API audit.
Admin directory reads (users, orgs, overview, accounts export) off the ledger tables
not started
At the 8 s statement timeout. Needs query plans first.
Catalog snapshot for /api/models, /api/models/{slug}, /api/v1/models, cached at Cloudflare for anonymous reads
not started
About 58k database-heavy calls per 6 hours; a snapshot would free control plane database connections.
On branch capture-batch-and-websocket (0ed5eaaa1), not yet on main.
Infra items from the November 10 incident (outage-proof /v1, control-plane pool, resize, per-tick reads, wallet_check pacing, capture parking, release tooling, test-host lanes, secret rotation)
Consolidate all background workers on ECS Fargate; remove the legacy Project worker pods from EKS
not started
updated 2026-11-18: superseded: workers stay in EKS; Fargate runs the capture ETL only. Agreed in the Kion Sync, Nov 11. See Database plan.
Full agent traces: caller trace ids on every request, live OTLP span ingest, one trace view combining customer spans and our LLM calls, a trace API and exp traces CLI
Gateway and per-organization wallet at the edge (Durable Objects or celld)
open decision
Proposed in the Kion Sync; analysis in Going faster at the edge recommends prototyping the non-money parts first. updated 2026-11-18: decided: no edge gateway; measured instead (D15).
Capture embeddings, images, speech, transcription, video and decisions
not started
An engine change per surface plus a shared media-reference part; decisions need a no-capture rule for our internal callers first. See Capture paths.
Per-org admission cap for high-volume customers (Koodos)
waiting
All 108 failures in the Nov 4 burst were this cap; the enterprise label lifts it per org, Kion's decision.
Snapshot: every open merge request on November 10
On November 10 we reviewed every open merge request on GitLab, read-only, to see which ones belonged to this plan and which were stale. The list is kept here as a record. It went stale on November 17, when the platform moved to GitHub and GitLab main was frozen.
Show all 144 merge requests (GitLab, November 10)
updated 2026-11-18: stale. This list is from GitLab on November 10; the platform moved to GitHub on November 17 and GitLab main is frozen.
All 144 open merge requests on 2026-11-10 (73 by Kion, 71 by Silen), reviewed read-only against main. Nothing was merged, closed or commented on. Current main is being deployed to production now, so everything already merged goes live with it.
Counts: 9 ready, 21 rebase then merge, 25 need changes, 17 need a decision, 6 drafts, and 66 already on main that should be closed.
Ready to merge (9)
Checks pass and the change applies cleanly to main.
MR
Author
Title
What it does
Next step
!1088
Silen
Capture batch lines
Batch requests get their prompts and responses stored like live requests when storage is on; adds the capture-path catalog
Merge when CI is green
!1087
Silen
Out-of-credits offers once
The out-of-credits prompt stops promising matches the org has already used
Merge
!1082
Silen
Bulk delete private models
Org admins select several of their private models and delete them at once
Merge
!1049
Silen
Overview card overlap
Overview cards stop drawing over each other on short or narrow windows
Merge, or close if !1070 lands
!1046
Silen
Classify org_plan_starts
Fixes the deletion test that broke after !910 by classifying a new table
Merge after a retention call
!1009
Kion
E2B template built once
Each RL worker builds an E2B sandbox template once, instead of every trial racing to build it (9 of 16 episodes failed)
Merge
!935
Silen
Gateway traffic replay
A load test that reproduces the November 2 hot-org slowdown locally
Merge (test tooling only)
!885
Kion
Usage copy progress logs
The usage history copy script logs its plan, a heartbeat and time left
Merge if the copy has not run yet, else close
!302
Silen
Trace export scrubber
Removes secrets and personal data before any trace export and blocks ineligible traces
Merge; migration sorts below main's newest
Rebase, then merge (21)
Still needed and sound, but behind main or with small conflicts.
MR
Author
Title
What it does
Next step
!1076
Silen
Payment risk review
Refunds wait for an operator's Keep / Refund / Email choice in Slack; single-card 3DS waiver
Rebase (one conflict)
!1070
Silen
One Usage page
Merges Overview and Observability Analytics into one Usage page
Rebase (three conflicts)
!1012
Kion
Capture wait during opt-out
Captures that arrive before their request row keep their wait during an opt-out cleanup
Renumber its colliding migration, rebase, merge
!1001
Kion
Refusal reason on request row
On the balance ledger, the request row keeps the real refusal reason instead of a generic quota message
Rebase, re-run checks, merge
!999
Kion
Usage reads wait for a slot
A busy ClickHouse usage read waits up to 4 s for a slot instead of answering 429 at once
Rebase, merge
!972
Silen
Writeback lag alert
Pages when the ledger writeback or credit feed falls behind
Rebase (one test conflict)
!888
Kion
Rename to offline tagging
Renames the illegal content review pipeline to offline tagging
Redo the rename on current main, after !628
!876
Kion
Remove local model registrations
A full admin can remove an org's local model while keeping its history
Rebase; measure catalog publish time first
!821
Kion
Repurchase after cancel
Buying a plan again after cancelling opens a fresh checkout
Rebase, merge
!698
Kion
Remove redundant HTTP tests
Removes 16 duplicate test cases; no product change
Rebase and re-run CI, or close as low value
!628
Kion
Clef capture isolation
When one capture download fails, only that capture is retried, not the whole review batch
Rebase, merge before !888
!477
Silen
Docs: unknown message fields
Docs say unknown message keys are ignored and disclosed, not rejected
Rebase
!439
Silen
Hide drained models
Models drained for good leave /v1/models and the storefront
Rebase (two conflicts)
!436
Silen
Dollar formatter floor
Daily-cap refusals never round a total up to the limit
Rebase
!413
Silen
Uncensored fallback discount
Uncensored requests served by the regular model bill at 50% off
Large rebase (8 conflicts)
!404
Silen
Reconcile runtime v2
Three slow nightly reconcile checks read the day efficiently
Rebase (two conflicts)
!387
Silen
Tenant origin dispatch
Customer endpoints get the engine's port and address deny lists
Rebase (five conflicts)
!283
Silen
Model page Quickstart
One closable Quickstart on every model page
Rebase (one conflict)
!108
Kion
Trim admin search whitespace
Admin searches ignore pasted leading or trailing spaces
Rebase, run CI (it never ran), merge
!107
Kion
Credit removal is not a refund
Admin copy says removing credits does not refund a Stripe payment
Rebase, merge
!95
Kion
Docs: pin one provider
Docs section on pinning one provider for a request
Rebase, merge
Needs changes first (25)
A colliding migration version, failing checks, or a problem the review found.
MR
Author
Title
What it does
Next step
!1085
Silen
Provider routing transparency
Lane order from a visible score breakdown; provider placement controls
Read the hourly rollup instead of the ledger every minute; add retention
!1022
Kion
Comp with conversion choice
Grants a comp and saves the convert-to-paid choice in one step
Renumber colliding migration; return 409 instead of a 500 on re-grant
!958
Kion
Admission reasoning probes
Small admission probes leave room for reasoning
Finish per its own list, or close (draft, paused)
!791
Kion
Stripe fulfillment recovery
Finds Stripe events whose credit never landed and replays them
Port two later webhook changes; add retention and paging
!705
Silen
Promotion exact build, chunk probes
Earlier fix for the same job
Close in favor of !1052
!596
Kion
Drop demo generators
Drops the generators !588 replaces
Redo with !588
!588
Kion
Sandbox usage conveyor
Keeps sandbox demo usage current by moving it, not adding more
Redo as a fresh MR (hourly UPDATE on hot tables)
!578
Kion
Drop capture copier SQL
Removes the retired copier's leftover functions, queue and trigger
Renumber, revert header edits, re-derive from live definitions
!539
Kion
Seed review alert rule
Seeds the default rule for !538
Rework with !538 (draft)
!538
Kion
Review backlog alert
Alerts when the content review queue backs up
Rework on current alert vocabulary (draft)
!456
Silen
Promotion rollup cursor
Earlier rework of the same job
Close (replaced by the exact build on main)
!417
Silen
Withdrawn lane refusal copy
A withdrawn lane refuses as 'temporarily unavailable'
Confirm replaced by lane_out_of_service, then close
!407
Kion
Dependency audit in CI
OSV audit of uv.lock and pnpm-lock.yaml
Split out unrelated edits, then rebase
!388
Kion
Pro bonus eligibility
Pro checkout stops showing a bonus that payment would not grant
Re-derive the money functions from live definitions
!334
Silen
OpenRouter listing BYOK price
The OpenRouter-style listing prices BYOK-first models at the lane the caller pays
Redo on current main
!300
Silen
Demo content read gate
Demo refresh reads captures through the read gate
Fix failing checks
!298
Silen
First-request sweep read gate
The farm sweep reads captures through the read gate
Fix failing checks and conflicts
!258
Silen
Drop per-org overflow (held)
Removes the old per-org credits-overflow columns
Held contract change; fix failing checks when released
!240
Silen
Models page speed round 2
Service worker, prefetch, deferred Stripe, compression
Fix failing check and four conflicts
Needs a decision from you (17)
The code may be fine; the question is whether we want it.
MR
Author
Title
What it does
Next step
!1065
Kion
Telemetry from summaries
Larger rewrite of the same, with a projection that slows every usage insert
Close if !1002 is chosen
!1057
Kion
Weak payment holds keep purchases
Weak payment-pattern holds still quarantine but stop auto-refunding and cancelling plans
Reverses your refund policy: your call
!1047
Kion
Rust MemoryDB transactions
Moves MemoryDB billing, reservations, settlement and capture into a private Rust extension
Decide on Rust in platform images; needs an unpublished engine release; checks failing; author hold
!1005
Kion
Chain route copy
An org alias may copy the route a protected alias serves, unblocking custom models and RL runs
Needs sign-off from the chain-authority owner
!1002
Kion
Telemetry from usage cells
Admin telemetry sums quarter-hour cells in ClickHouse instead of every event
Pick this or !1065 (review favors this one)
!869
Kion
Staging spend ceiling
A $50 monthly cap on staging provider spend
Built on deleted code; rebuild or close
!697
Kion
Plan rollout
Shared daily core tokens rollout (draft, on hold)
Likely close
!624
Kion
Subscription core v2
Versions paid core token allowances per subscription
Plans moved to daily credits; likely close
!612
Kion
Clef shared score cache
Shares Clef scores across workers in Postgres
Design obsolete; re-propose or close
!609
Kion
Paid entitlement restore
Restores advertised paid token allowances (draft)
Likely close
!518
Kion
Local stack runs ClickHouse
Local and trial stack run ClickHouse
Your call
!402
Kion
Inbox proof before access
Requires email proof before signup sessions and API keys
Reverses the instant-signup design: your call
!117
Kion
Trace tags: node runner
Tagging node runner
Same decision as !110
!112
Kion
Trace tags: run API
Tagging runs with leased claims
Same decision as !110
!111
Kion
Trace tags: deletion
Trace tags follow their capture out
Same decision as !110
!110
Kion
Trace tags: ClickHouse
Trace tag tables in ClickHouse
Keep this lane beside request classification, or drop
!54
Kion
Disable prompt-repeat sweep
Disables a paused sweep that reads the retired capture table
Delete, port or leave paused
Drafts (6)
Not proposed for merging yet.
MR
Author
Title
What it does
Next step
!933
Silen
Batched settlement prototype
Lighter balance locking for well-funded orgs, off by default
Draft, do not merge; likely close now that MemoryDB is live
!487
Silen
Moonshot provider
Adds Moonshot (Kimi) as a house and BYOK provider
Draft, far behind
!318
Silen
Node fast cap prototype
Batch cap while a :fast request runs
Draft
!311
Silen
Jev image input docs
Documents image input for Jev
Draft, clean and green
!255
Silen
MiniMax house provider
Adds MiniMax as a house provider
Draft, CI failing
!53
Silen
Pro renewal dunning
One payment-failed email, then spaced retries for past-due Pro
Draft; migration collides
Already on main, close (66)
Their changes landed through merge-train bundles or later work, but the merge requests were left open.
MR
Author
Title
Where it landed
!1020
Kion
Refusals don't reverse payments
folded into !1057
!955
Kion
Ledger step 4 limiter SQL
landed via !943 and !951
!928
Kion
Settle usage off org lock
replaced by the settle outbox
!926
Kion
Quote test records cost
landed as !944
!865
Kion
GeoIP refresh
!863
!855
Kion
Engine pin 0.7.226
main is on 0.7.234
!735
Kion
DeepSeek promo for all Pro
campaign ended Nov 2
!729
Kion
First-purchase eligibility
!815
!632
Kion
Clef chunk token count
!1031 removed tokenization
!537
Kion
Review suspension rule
bundle 23
!536
Kion
Review Clef retry
bundle 23
!535
Kion
Review release fixes
bundle 23
!468
Silen
Capability refusals counted
!663
!459
Kion
Keep Clef output
request classification metadata
!432
Silen
EC fleet console
bundle 20
!429
Silen
Throttled lane not cover
bundle 20
!427
Silen
Drain by cache size
bundle 19
!426
Silen
Spend gate card copy
bundle 19
!423
Silen
Bedrock BYOK docs
bundle 19
!412
Silen
Drain always stops
bundle 19
!410
Silen
Remove house Bedrock
bundle 19
!397
Silen
Lane status hold
bundle 19
!386
Silen
Header-hold cap
bundle 19
!382
Kion
Activity from ClickHouse
!586
!362
Silen
Bundle 18 candidate
on main; pin now 0.7.234
!361
Silen
Publish-deferred alert
bundle 20
!355
Silen
Name credit grants
bundle 17
!354
Silen
Draft snapshot tolerant
bundle 17
!353
Silen
Evals import
bundle 17
!342
Silen
Refusal sweep bounds
bundle 17
!340
Silen
Fast reserve
bundle 17
!337
Silen
Azure unmapped retire
bundle 17
!333
Silen
Capture mirror budget
bundle 17
!332
Silen
Batch ZDR
bundle 17
!331
Silen
OpenAI 12h cache billing
bundle 17
!330
Silen
Image rates display
bundle 17
!324
Silen
Reasoning header hold 300 s
bundle 17
!323
Silen
Dedicated :fast lanes
bundle 17
!306
Silen
:fast priority tier
!312
!246
Silen
client_test retry filter
bundle 8
!227
Silen
Deletion retry walk
bundle 8
!226
Silen
Vertex glm-5.2 reasoning
bundle 8
!225
Silen
Private endpoint gate
bundle 8
!224
Silen
Infra denylist private
bundle 8
!223
Silen
Video generation active
on main
!220
Silen
Abuse private DNS
on main
!206
Silen
Deletion cascade pgTAP
bundle 6
!153
Silen
Uncapped capture
!197
!150
Silen
Capture completeness
!197
!116
Kion
Drop fixed-path copy
fold into !578
!115
Kion
Deploy replica URL
!197
!114
Kion
Copier reads replica
!197, copier later deleted
!113
Kion
Mirror attempt protocol
!197
!109
Kion
Signup scan uncertainty
rewritten as Clef (!1074)
!69
Kion
Admission wait as 503
main kept a retryable 429 by design
!66
Kion
Gateway cutover to Storage
main went another way (!1024)
!65
Kion
Capture writer
!197
!64
Kion
Prompt-group labels
!197
!63
Kion
Capture writer SQL
!197
!62
Kion
Pointer counts
!197
!60
Kion
Pointer deleters
!197
!59
Kion
Capture writer role
!197
!46
Kion
Evaluations via signed links
!197
!45
Kion
Intelligence reads objects
!197
!43
Kion
Broadcast reads objects
!197
!42
Kion
Capture content views
bundle !197
Kion Sync, November 11: what is agreed, new, or conflicting
From the Granola note of Silen and Kion's sync on November 11. Each point is checked against this plan and, where the note says something exists, against the code on main.
Agreed: the note and this plan say the same thing
Each row is one point from the Kion Sync note and where this plan covers it.
Kion Sync
Where it is in this plan
The gateway writes to Postgres on the hot path today; the target is to remove that
Same four stores, plus SQS between S3 and the loader
New: the note adds these, and the plan now includes them
Four quadrants. Infrastructure is four layers: inference, controller (EKS), data, and workers. Each can move to a different cloud on its own, which is how an enterprise customer's data-residency requirement is met. This becomes a test for every design here: does it lock a quadrant to one vendor?
Two S3 buckets, not prefixes. A short-retention bucket for raw gateway dumps and a long-retention bucket for observability data. This matches the two buckets in the unapplied Terraform (!492). The storage layout now shows two buckets.
All workers move to ECS Fargate.changed in review: D11 keeps workers in EKS as separate deploy units scaled on queue age; only the capture ETL runs on Fargate. Delete the legacy Project worker pods from EKS and consolidate every background worker into the ECS pipeline, not only capture processing. The database plan now says this.
Chunk deduplication exists. The note says a background job deduplicates repeated conversation chunks across stored traces and replaces them with pointers. On main this is explabs/trace_dedup (pilot in !837, durable backfills in !854): a batch job that packs traces into deduplicated generations in S3 and can rebuild the originals. It is not yet part of the live capture path. It fits the search design, which also stores each piece of conversation once.
Online tagging. Kion is setting up tagging that classifies requests as they arrive, not only offline. In this plan it runs as a step of the same ETL pipeline, after the load.
Conflicting or open: needs a decision
ClickHouse and Postgres are peers. The note says ClickHouse is for fast aggregations, not all reads. This plan moves the request list, session views and search to ClickHouse and keeps Postgres for money and permissions. These fit if "peers" means each read goes to the store that suits it: lists, totals and search on ClickHouse; point lookups of keys, organizations and settings on Postgres. One open item is where a single request's metadata is read from. ClickHouse can serve it fast when its table is sorted for it; Postgres already does.
Long term: the gateway and wallet on Cloudflare's edge. The note proposes moving the gateway and the per-organization wallet to Cloudflare, with a Durable Object per organization (as Helicone does for its wallet and rate limits), for lower latency and global coverage. It names the tradeoff: less flexibility than a multi-region EKS Helm chart. This plan keeps the gateway in EKS and the wallet in MemoryDB, and the four-quadrant goal argues against locking the gateway to one vendor. The analysis under Going faster at the edge compares Durable Objects and celld, a self-hosted Durable Objects runtime that would keep the model without the lock-in.
Designing sessions, traces and search
With the research done and the target agreed, the next question was what customers should actually get. The proposal below was written between November 9 and 11. It starts from Helicone's weak spots, read in their source code, and designs each piece to avoid them. Several of its open points were later settled in the final plan; each is marked with its decision (for example final: D7).
Proposal: sessions and the Requests page
The goal is everything customers like about Helicone's sessions view, without its weak spots, built for agents rather than single LLM calls. That means:
one trace per agent run, shaped the way the customer's pipeline is built;
fully usable from an API and a CLI: everything on screen is also available through the API;
a three-hour agent session opens as fast as a short one;
search works inside a session.
The Requests page at /observability/requests stays the main table: filter it, sort it, open any request, and group it by session when you want the session view.
Where Helicone falls short, and why
From their source code (commit 6b057cd, October 19) and their public GitHub issues:
What customers see
The cause in Helicone's code
What we do instead
It stopped fitting once products became agents
Helicone records one row per LLM call and groups rows by a session header. Customers who moved from single calls to agents (MCP, tool use, loops) need one trace per agent run with every LLM call, tool call and loop iteration nested in it, named and tagged their way. Teams that left Helicone for Langfuse name this as the reason, and say their agents now read traces through a CLI more than anyone opens a dashboard.
Full agent traces that combine the customer's own spans with our LLM calls, custom span names and tags, and a trace API and CLI (below).
A long session is slow to open
The session page asks for 500 full requests at a time, prompts and responses included (the maximum is 1,000). An agent resends its whole conversation on every call, so each request is large. For a three-hour session with 60,000-token prompts, one page is about 120 MB of JSON. Large bodies sit in S3, so the browser fetches one link per request, and nothing renders until the slowest one arrives.
The session view first loads a skeleton: one small row per request (id, parent, step, model, start, duration, tokens, cost, status), about 200 bytes each. A 5,000-request session is about 1 MB. Bodies load one at a time, only for the request you click.
The totals at the top of a session are wrong for long sessions
Start, end, cost, token and request totals are computed in the browser from the page that is loaded. On a 3,000-request session the header shows the first 500 requests' numbers as if they were the whole session. Requests older than 90 days drop out without notice.
Totals come from a stored session summary row, so the header is correct on first paint, whatever the session's length. No silent age cutoff.
Sessions are hard to list and sort
There is no session table. Every view groups all of the organization's requests by session id at query time. The list can only sort by date: the page receives a sort setting and never sends it. Filters on totals run after the grouping. They added a session table once and reverted it the next day.
A session summary table, kept current as requests settle. The list is a plain sorted read, sortable by cost, duration, number of requests, errors or most recent activity, with filters on any total.
Opening one session scans the whole organization
The "switch session" menu on the detail page runs the full session-list grouping over three months of all requests, every time any session opens.
Previous and next session come from the summary table's index.
The tree can be wrong
The hierarchy comes only from splitting a path string like /plan/step-1. Two calls on the same path collapse into one node, and there are no real parent links.
The tree is built from real links we already record (parent_response_id, Claude Code subagent ids) plus an optional path header. Repeated steps stay separate nodes.
Sessions are not usable from the API
There is no way to get one session by id, its tree, or its requests. The documented recipe uses an older endpoint that pages 10 at a time and probably returns broken body links for most requests. Their MCP server's session tool only lists sessions. The real workaround, raw SQL, is behind a feature flag and capped at 10,000 rows.
Everything the page shows has an API endpoint: one session, its skeleton, its requests by cursor, search inside it, and a streamed export. Agents get the same endpoints through the agent prompt.
Search inside sessions misses things
Body search is a case-insensitive substring match over full bodies. Its index is too small to skip anything, so every search scans. Bodies stored in ClickHouse are deleted after 3 months. For bodies over 10 MB, only a preview is searchable, and that preview drops every non-ASCII character, so Chinese, Japanese or emoji text is never found.
A real text index over the message text of each request, keeping all characters. Search returns the matching requests with a highlighted snippet, inside one session or across the organization.
The page is heavy in the browser
The waterfall chart draws every request as SVG (1,000 requests make a 25,000-pixel image). Neither the tree table nor the waterfall is virtualized. The session is rebuilt on every render, and the whole response is serialized just to compute a cache key.
Virtualized rows and a canvas timeline that draw only what is on screen; the tree is built once, in a background thread.
Live mode refetches everything
Live mode reloads the full page, bodies included, every second (every 2 seconds for the list).
Live mode asks only for requests newer than the last one shown and appends them.
Navigation and export are thin
No arrow-key navigation in the session view. A link to a request on another page does not open it. Export covers one page, and selected-session export stops silently at 500 rows. An unknown session id shows an empty skeleton forever.
j and k (or arrow keys) move between requests. Every request and node has a stable link that opens the drawer from anywhere. Export streams the whole session or filter. An unknown id shows "Session not found".
Full agent traces final: D7
A gateway only sees the LLM calls. Tool calls, retrieval, loop iterations and the agent's own steps happen in the customer's code. A full agent trace therefore combines two sources: the spans the customer's code emits, and the LLM calls our gateway serves. Half of this exists: the gateway reads the caller's W3C traceparent header and exports each call as a span nested under the caller's span, but only to the customer's own Langfuse (observation_export.py). We do not keep that link for our own view.
Need
Today
Proposal
One trace per agent run, with LLM calls, tool calls and loops nested
Sessions grouped from headers; our view has only LLM calls. Uploaded traces sit in ClickHouse trace_spans with no page and no link to gateway requests.
Record the caller's trace id and parent span id on every gateway request (from traceparent). Accept the customer's own spans live over OTLP and through the SDK. Store both in one ClickHouse span table, so the trace view shows the customer's steps with our LLM calls nested where they happened. Sessions become one way of grouping traces.
Spans named, grouped and tagged the customer's way
Fixed request fields; tags through one header
Span names, types (LLM, tool, retrieval, step, custom), attributes and tags come from the customer's spans. OpenTelemetry GenAI attributes and Langfuse's and Helicone's span shapes are accepted as sent. Our LLM spans inherit the name and tags of the span that called them.
Agents read traces without a dashboard
The request log API and agent prompt (!1039); no CLI
The trace API below, plus CLI commands in the exp CLI customers already install (exp traces list, exp traces get <id>, exp traces search), with output an agent can read: the tree first, bodies only on request.
Running it in their own cloud
Not offered for observability
The four-quadrant model allows the data layer in the customer's cloud; the same trace API then reads their stores.
The default integration: headers on the LLM requests
Customers should not need an SDK to get full traces. Everything that structures a trace can ride on the LLM requests they already send through the gateway:
Grouping: a session or run id (X-Explabs-Session-Id, or Helicone's Helicone-Session-Id, -Path and -Name). Coding agents already send their own session ids, which the gateway reads today.
Nesting: the standard traceparent header, which most HTTP and OpenTelemetry clients already send and the gateway already reads.
Step names, tags and the end user: a step name such as /plan/research/search-1, tags, and the user. The same fields are also accepted in the body fields provider SDKs already expose (metadata, user, safety_identifier), for clients that cannot add headers.
What we work out without being told. In agent traffic, tool use is visible in the LLM calls themselves:
A model response that asks for a tool (tool_calls) is followed by a request carrying the tool's result. Pairing the two gives a tool span with its name, arguments, result, and how long the tool took: the gap between the response ending and the next request starting.
Each round trip in a session is one loop iteration.
Subagents come from the subagent headers (Claude Code's agent id) or from a session nested under another one's traceparent.
When an SDK or OpenTelemetry is still useful. Only for work that never touches an LLM: a retrieval step whose output is not sent to a model, plain code a customer wants timed, or a step that fails before any LLM call. Those spans are accepted over OpenTelemetry, or through the Helicone-compatible SDKs, as an optional extra.
Custom tags scored by Clef as calls arrive final: D10
Customers define their own tags in plain words, and every new call or trace that matches is scored automatically as it arrives. Examples: "the agent gave up on the task", "the user asked for a refund", "a tool call returned an error the model ignored", "the answer cites a source". They can then filter, count, alert on and export by those tags, in the dashboard, the API and the CLI.
How it works.
Define a tag: a name, a yes-or-no question or a 0-to-1 scoring rubric, a threshold, and its scope: which spans it reads (LLM calls, tool calls, or a whole session) and which traffic it covers (keys, models, tags, or a sample rate). The same registry already holds our own policy and descriptive tags (public.classifier_tags); customer tags are rows owned by their organization.
Score as calls arrive: the ETL pipeline's tagging step, which runs after a capture is loaded and is the online tagging Kion is building, sends each matching span to Clef, our decision model, through /v1/systemone. Clef answers every tag question at once, with a score per tag. This is off the request path, so the customer's call is never slowed.
Store the scores with the span in ClickHouse (a tag-score map, as spend_facts.tag_scores already does for our own tags), and the matched tags as span tags. A whole-session tag is scored when the session goes quiet, and again if it resumes.
Use them: filter and sort the Requests table and trace views by tag, chart tag rates over time, send an alert or webhook when a tag fires, and run a tag over past traffic on request (bounded and priced up front).
Rules it follows.
It reads only content the organization's storage switch allows, never zero-data-retention traffic. Scores are deleted with the capture.
Each organization sees only its own tags and scores.
Each scored span is a decisions call billed to the organization at Clef's rates. A sample rate and a monthly cap keep cost predictable.
Capacity is the main constraint. Clef tops out near 30 requests a second today, shared with our own content review. Customer tagging needs either more Clef capacity on our GPU boxes or per-organization quotas, with sampling as the default for high-volume customers. This is the item to size before launch. updated 2026-11-18: superseded: any judge model, with a starvation guard that keeps our own content review served.
Where everything is stored final: D3, D4
One store per job. Money and permissions need transactions, analytics need fast scans, and bodies need cheap space, so each lives where it fits.
Store
What goes there
Shape
MemoryDB
Live money and rate limits only
Per-organization balance, holds and limit counters. Receipts stream out to Postgres.
Postgres
Money, keys, organizations, permissions, and a short recent window of request rows
Ledger tables partitioned by time, old partitions dropped; the long history lives in ClickHouse. No bodies.
ClickHouse usage_events
One small row per request
Organization, time, request id, model, provider, key, end user, status, error, tokens, cost, latency, plus new fields: session id, parent id, path and name.
ClickHouse sessions (new)
One row per session
Organization, session id, first and last time, request count, errors, tokens, cost, models, users, name. Recomputed after each export batch, so totals are always right. updated 2026-11-21: span sessions fold from per-trace parts.
Session-ordered copy (new)
The same request rows, sorted by session
Ordered by (organization, session, time), so opening one session reads a few blocks instead of scanning the organization.
ClickHouse spans (new)
Every span of every trace
Organization, trace id, span id, parent span id, name, type (LLM, tool, inferred tool, retrieval, step, custom), start, duration, status, attributes, tags, and custom tag scores from Clef. The customer's own spans and our LLM calls (linked by request id) sit in one table, ordered by (organization, trace, start), so one trace reads in one pass.
ClickHouse request_text (new)
Searchable text
Organization, session, request id, and that request's new messages plus its response, with a text index. Same key as the body, so it is deleted with the body.
Our S3, raw bucket
What the gateway uploads, short retention
One object per capture as the gateway wrote it, consent facts inside. Deleted once the loader has processed it (Kion Sync: short-retention bucket for raw gateway dumps).
Our S3, observability bucket
Full bodies and media, long retention
captures/<org>/<day>/<request>.json.zst for the processed body, with its images and audio beside it under the same prefix. Repeated conversation chunks are stored once and referenced (the trace_dedup format). Retention follows the organization's settings.
SQS
"New capture arrived" messages
S3 sends one per object; Fargate loads it into ClickHouse and Postgres. A dead-letter queue holds the ones that keep failing.
How the data gets there
flowchart LR
GW["Gateway worker computes session id, parent, path and name at authorize"] -->|"rides the receipt"| PG[("Postgres usage event row")]
PG -->|"ClickHouse outbox"| EX["Exporter"]
EX -->|"1 insert"| UE[("ClickHouse usage_events now with session fields")]
EX -->|"2 recompute only the sessions in this batch"| SS[("ClickHouse sessions one row per org and session")]
CAP["Capture loader"] -->|"message text, consent-gated"| TX[("ClickHouse request_text text index")]
CAP -->|"full body"| S3[("Object storage")]
API["Observability API"] -.->|"session list, totals"| SS
API -.->|"skeleton, request list"| UE
API -.->|"search"| TX
API -.->|"one body, after authorization"| S3
Session fields are computed once, at authorize, and travel with the usage row. ClickHouse keeps a summary row per session, recomputed from the usage rows after each export batch, so a retried batch can never double-count.
Session fields on every request. The gateway already computes session_key at authorize, from our session header, the Claude Code and Codex headers, or metadata.user_id, with a content hash as the last resort. It also records parent_response_id and agent_key. Next to these we add:
Helicone-Session-Id, -Path and -Name, so a team can switch without code changes;
x-session-id and a parent-session header, as LiteLLM reads;
the OpenTelemetry attribute gen_ai.conversation.id on uploaded traces.
These fields ride the existing receipt and outbox into the usage row and into ClickHouse. Nothing new is added to the request path.
A session table in ClickHouse. One row per organization and session: first and last time, request count, error count, tokens, cost, models used, users, name, and the newest request id. After each export batch, the exporter recomputes the summary only for the sessions that batch touched, reading their rows from usage_events. Recomputing from the rows, instead of adding the batch's numbers to a running total, means a batch that is sent twice gives the same result. That is the same reason we read with FINAL and avoid summing materialized views today. updated 2026-11-21: for span sessions, recomputing from every row got slower as sessions grew (2.8 to 3.1 million rows, 21 to 64 s per write at 30,000-span sessions). The summary is now folded from one part per trace (ClickHouse 0053), and only the touched traces are recomputed.
Fast reads of one session. To read one session's requests without scanning the organization, ClickHouse needs the rows stored in session order. That means either a copy of the session columns ordered by (org, session, time), written by the exporter, or a projection on usage_events. The trade-off: the load test in !1065 measured a projection on usage_events raising insert time by 35 to 90%, so a separate session-ordered table written by the exporter is the safer start.
Search text. The capture loader writes the new message text of each captured request (only what was added since the previous turn, plus the response; see Analysis 1), without media bytes, into a ClickHouse table with a text index (an inverted index, generally available from ClickHouse 26.2). This table is keyed exactly like the capture object, so erasure, retention and zero data retention delete both together. Only requests that were allowed to be captured ever appear in it. (Decision 1 below.)
The request list moves to ClickHouse as well. It keeps cursor paging on (org, time, request id) and gains sorting and filtering on any column, including session fields. Postgres then keeps only what money and authorization need.
The API
Each row is one endpoint, what it returns, and why it is better than the Helicone equivalent.
Endpoint
Returns
Why it beats Helicone
GET /api/orgs/{org}/traces, /traces/{id}, /traces/{id}/search
Agent traces: list with filters, one trace as a tree of spans (customer spans and our LLM calls), and search inside it
Helicone has no trace tree; Langfuse users name this as the requirement
GET/PUT/DELETE /api/orgs/{org}/trace-tags
Custom tags: define a question or rubric, threshold, scope and sample rate; read tag rates; start a bounded backfill
Automatic scoring of every new call by our decision model; Helicone has no equivalent
POST /v1/traces (OTLP)
The customer's own spans, live, from any OpenTelemetry SDK
Today spans can only be uploaded or pulled after the fact
GET /api/orgs/{org}/sessions
Sessions, sortable by recent activity, cost, duration, requests or errors, with filters on any total and cursor paging
Their list sorts only by date and filters after grouping
GET /api/orgs/{org}/sessions/{id}
One session's summary: totals, time span, models, users, name
They have no get-by-id
GET /api/orgs/{org}/sessions/{id}/skeleton
Every request of the session as a small row (id, parent, path, model, start, duration, tokens, cost, status), streamed as JSON lines
They send full bodies to draw a tree
GET /api/orgs/{org}/sessions/{id}/requests?cursor=
The session's requests with the request list's fields, by cursor
OFFSET paging capped at 1,000 per page
GET /api/orgs/{org}/sessions/{id}/search?q=
Requests in the session whose prompt or response matches, with snippets
No search inside one session
GET /api/orgs/{org}/requests/search?q=
The same search across the organization, combinable with every list filter
Substring scan with a 3-month window
GET /api/orgs/{org}/sessions/{id}/export
The whole session, bodies included, as streamed JSON lines
Export stops at 500 rows
GET /api/orgs/{org}/usage/requests?after=
Only requests newer than a cursor, for live tailing
Live mode refetches the full page every second
Every endpoint works with any organization key, inherits the per-organization read limit from !1039, and is added to the agent prompt and the request log docs. Bodies stay one request at a time, behind the same authorization as the request drawer.
The Requests page
/observability/requests is the one table for finding and reading requests. Sessions are a way of grouping that table, not a separate product.
Filter on any column: model, provider, key, end user, status, error class, session, path, cost range, latency range, tokens, time. Search text and filters combine. Filters live in the URL, so a link reproduces the exact view.
Sort by time, cost, latency, time to first token or tokens. Sorting stays exact while paging, because the cursor freezes the window as it does today.
Group by session. A toggle turns the table into the session list: one row per session with its totals. Opening a row shows the session view: a summary header, a timeline that draws only the visible part, and a tree built from real parent links. The request drawer opens beside both.
Conversation view that shows what changed. An agent resends the whole history on every call. The session view shows each turn's new messages, with earlier turns folded, so a three-hour session reads like one conversation rather than 3,000 copies of it.
Keyboard and links. j and k (or the arrow keys) move between requests and between nodes, Enter opens the drawer, and Escape closes it. Every request, session and node has a stable link that opens it even when it is not on the loaded page.
Live. New requests are added at the top as they settle, without reloading what is already shown.
Columns and saved views. Choose and reorder columns; save a filter, sort and column set as a named view.
Traces. A request opens inside its agent trace when one exists: the customer's steps and tool calls around it, our LLM calls nested in place.
Export and agent access. Export streams the current filter or session. "Copy agent prompt" stays at the top right, and the prompt gains the session endpoints.
Speed targets
Each row is one action a customer takes, the speed target for it, and how the design meets it.
Action
Target
How
Open the Requests page
under 1 s to first rows
The first page renders on the server; the summaries stream in after
Open a 5,000-request session
under 1.5 s to the full timeline
The summary row plus about 1 MB of skeleton; no bodies
Open one request's body
under 500 ms
One authorized object read
Search inside a session
under 1 s
Text index scoped to the organization and session
Session list, any sort
under 500 ms
Plain sorted read of the session table
New request appears in live view
within about 5 s of settling
The export lag plus the tail poll
Order of work
Session fields on usage_events in Postgres and ClickHouse, the caller's trace id and parent span id from traceparent, plus the extra session headers. Additive, safe for the running build.
The session table and the session-ordered copy, filled by the exporter, with a one-time backfill from history.
The span table, tool spans inferred from LLM traffic, live OTLP span ingest (optional for customers), the trace and session API endpoints, the exp traces CLI, and the agent prompt update.
Custom Clef tags on customer traces: the tag registry for organizations, the tagging step in the ETL pipeline, filters and alerts, after Clef capacity is sized.
The Requests page "group by session" toggle and the session view: skeleton, canvas timeline, tree, folded conversation, keyboard and links.
The request list on ClickHouse, with sorting and filtering on every column, and live tailing.
Search text and its index, after decision 1, together with the S3 capture pipeline so each capture is read once.
The edge and the wallet: three options, then real tests
The Kion Sync raised a bigger idea: run the gateway and each organization's wallet on Cloudflare's edge. Two questions followed. Would the edge make requests faster? And is MemoryDB the right home for live money, or is it "just a cache store", as the owner worried? We compared three options on paper first, then ran the comparison for real on November 17.
Going faster at the edge: Durable Objects vs celld final: D15
The idea from the Kion Sync. Run the gateway and each organization's wallet on Cloudflare's edge. Each organization gets one Durable Object that holds its balance, holds and rate-limit counters, and the gateway runs near the caller. Helicone does this: its Cloudflare Worker uses Durable Objects for rate limiting and for its wallet.
What a Durable Object is. A small single-threaded program with its own storage, addressed by name, for example wallet:<org id>. Cloudflare runs exactly one copy of each object at a time, so every request for that organization passes through one place, one at a time. That gives the same "one organization's money is updated in order, without locks" property our MemoryDB Lua scripts give today.
What celld is. A self-hosted runtime for the same programming model, from Deno (celld.dev, version 0.6.2 beta, Apache-2.0). An existing Cloudflare app (Workers, Durable Objects, KV, Queues, D1, R2) runs on our own machines. Each object ("cell") keeps its state in its own SQLite database, replicated to a bucket we own (S3, Google Cloud Storage or Azure Blob). Exactly one machine owns a cell at a time, assigned by a conditional write to the bucket, so no separate consensus service is needed.
MemoryDB (today)
Cloudflare Durable Objects
celld (self-hosted)
Where state lives
One AWS region, replicated across availability zones
Cloudflare's network; each object lives in one location, near where it was first used
Our machines; durable state in our bucket
Time to make a write durable
About a millisecond (multi-AZ log)
Local SQLite write, replicated by Cloudflare; a few milliseconds
About 90 ms per durable write in one region (their measurement)
One organization's ceiling
One shard handles the organization's scripts; microseconds each
Soft limit of 1,000 requests per second per object (Cloudflare docs)
One writer per cell; bounded by the 90 ms durable write unless writes are batched
When a machine fails
Automatic failover, no acknowledged write lost
Cloudflare moves the object
About 20 s to fail over, no acknowledged write lost (their test)
Latency gain for callers
None: callers reach us-west-2
The gateway answers near the caller, but the object still lives in one place, and the provider call dominates request time
Only as close as the machines we run
Cost
A fixed cluster
$5 a month plus $0.15 per million requests and $12.50 per million GB-seconds (Cloudflare pricing)
Our machines plus bucket requests. They claim about $49 a month for up to 2,500 active cells on one 8 GB node, against about $4.15 per active object-month on Cloudflare
Four-quadrant fit (move each layer to any cloud)
AWS-only service, but standard Valkey; replaceable by any Redis-compatible store
Cloudflare only
Runs anywhere with a bucket; the same code also runs on Cloudflare
Maturity
In production for our money path
Generally available; celld's page cites a major Durable Objects incident on July 16, 2026
Beta
What this means for speed. Most of a request's time is the model provider. Moving the gateway to the edge saves the trip from a distant caller to us-west-2 (tens to about 150 ms for callers far from it), and makes refusals and cached answers fast everywhere. It does not make the model faster. A per-organization object helps a different problem: it isolates a busy organization completely. That is the problem behind the 17-minute receipt lag one hot organization caused on November 10.
Durable Objects are the fastest way to get the edge and the per-organization isolation, but they put the gateway and wallet on one vendor. That conflicts with the four-quadrant goal and with customers who need their data in a specific place.
celld keeps the Durable Objects programming model while running on our machines and our bucket, so the same code could run on Cloudflare or anywhere. Its 90 ms durable write is too slow for a hold and a settle on every request (two writes would add about 180 ms), and it is beta. It is a good fit for state that changes less often, such as per-organization settings, limits configuration or session summaries, and for customer-hosted deployments that cannot use Cloudflare.
Recommendation.
Keep the MemoryDB wallet for now. It is live and faster per write than either option. Run the eight tests in the wallet comparison before deciding anything else.
Fix the hot-organization problem inside the current design first: give a busy organization its own receipt stream or shard, so it cannot fall behind everyone on its shard. updated 2026-11-18: built as 64 fixed slots with a move protocol, not a stream per organization.
updated 2026-11-18: the prototype was cut and measured instead: a Durable Object wallet adds about 100 ms per call from Oregon. Prototype the edge for the parts that do not hold money: TLS and routing near the caller, cached key checks, and fast refusals. Measure the latency gain for callers outside the US before moving anything else.
If the per-organization object model proves itself, write it against the Durable Objects API so it can run on Cloudflare or on celld. changed in review: D15 cuts this abstraction and the edge prototype until a consumer exists. Decide where it runs per quadrant and per customer, and do not move the wallet until a prototype shows write latency and failover that match MemoryDB under our heaviest organization's load.
The wallet: MemoryDB vs Durable Objects vs celld, and how to choose final: D6
Tests run, 2026-11-17. The comparison was run for real, from us-west-2, with the same wallet logic on each backend. MemoryDB hold p99 3.9 ms, Durable Objects 396 ms, celld 45 ms; a hot organization at 500 req/s: 8.7 ms, 6,549 ms with 43% refused, 172 ms. No backend lost money. MemoryDB stays. Full table and findings (slot move freeze, failover window, celld disks, far callers) under D6 in platform-data-plan.html.
What the wallet must do on every request. Before the provider call: check the organization's rate limits and reserve the worst-case cost against its balance, spend caps and promotion credit (a hold). After the call: charge the real cost, release the rest, and record a receipt that Postgres applies later. A wrong answer either lets an organization overspend or refuses a paying customer. A slow answer adds directly to every request's latency.
How each option does it.
MemoryDB (today): one Lua script per hold or settle, run atomically on the shard that holds the organization's keys. Every organization's receipts go to one of 8 shared streams, which the control plane drains into Postgres.
Durable Objects: one object per organization. It keeps the balance and holds in its own storage and handles one request at a time. Receipts go to Postgres through a Cloudflare Queue or a batch export.
celld: the same object model on our machines, with each organization's state in SQLite replicated to our bucket.
The table compares the three wallet backends on the questions that matter for our traffic.
Question for our traffic
MemoryDB
Durable Objects
celld
Added latency per request (hold plus settle)
About 1 to 2 ms in-region
Two round trips to the object, plus its storage write; depends on how far the object lives from the gateway
About 180 ms if each write waits for the bucket (90 ms each)
Busiest single organization
Bounded by one shard and its receipt stream; a hot organization fell 17 minutes behind on November 10
Soft limit of 1,000 requests per second per object
One writer per cell; about 11 durable writes per second unless batched
A busy organization slowing others
Possible: organizations share shards and the 8 receipt streams
No: each organization is its own object
No, as long as the machine has capacity
A machine fails mid-request
Failover within the cluster; acknowledged writes kept
Cloudflare moves the object
About 20 s for that organization's cells to move
Data residency and portability
AWS, standard Valkey
Cloudflare only
Any cloud with a bucket
Operating effort
Managed; in production now
Managed by Cloudflare
We run it; beta
Tests to run on our traffic
All three run the same wallet logic against the same replayed traffic, on staging, with no real money. The gateway traffic replay tool from !935 already reproduces the November 2 hot-organization slowdown, so it is the starting point. Each test reports the same numbers for all three.
Each row is one test, how it is run, and the bar it must pass.
Test
How
Pass bar
1. Everyday latency
Replay a normal production hour (all organizations, real request mix)
Hold plus settle under 5 ms at p99 seen from the gateway
2. One hot organization
One organization ramps from 10 to 500 requests per second, with streaming calls of real lengths, while all others run normally
Its own p99 stays under 10 ms; no receipt backlog older than 60 s
3. Neighbors stay unaffected
During test 2, measure every other organization
Their p99 does not change by more than 1 ms; their receipts are not delayed
4. No overspend under races
Many concurrent holds against a nearly empty balance, a spend cap and a promotion; then compare the final balances with an exact replay
Zero overspend; every refusal correct; balances match to the nano-dollar
5. Kill a node under load
Stop the node (or shard primary) holding the hot organization mid-test
No acknowledged hold or settle lost; seconds unavailable reported per organization
6. Postgres slow or down
Pause Postgres writes for 10 minutes during test 1
Requests keep serving; receipts wait and apply exactly once afterwards
7. Callers far away
Run test 1 from clients in Europe and Asia (edge options only)
Report the time-to-first-byte change against today
8. Cost
Project each option's monthly cost from the measured request count and active organizations
Reported, not pass/fail
What would fix each option's weak spot
MemoryDB, the hot organization: give a busy organization its own receipt stream, or raise the stream count and assign streams by organization, and drain streams in parallel with one writer each. If one shard's CPU becomes the limit, spread organizations across more shards (the hash tag already keys each organization's data together). Keep the scripts small as money rules grow.
Durable Objects, the 1,000 per second limit and the vendor: a very busy organization splits its balance across a few sub-objects, each holding a slice that is topped up from the main one. Place objects near the gateway with location hints. Send receipts to Postgres through a queue, with the same exactly-once apply we use today. Portability stays the open cost.
celld, the 90 ms write: do not wait for the bucket on every request. Give each organization's cell a budget lease taken from its balance, debit holds against it in memory, and write the cell's state durably every few hundred milliseconds or when the lease runs low. A crash then risks at most the unwritten part of one lease, bounded by the lease size, and the next owner reconciles it from the receipts. Add a warm standby to shorten the 20-second failover, and run it in shadow next to MemoryDB until it is out of beta.
Expected outcome, to be confirmed by the tests:updated 2026-11-18: tested: MemoryDB stays, on 64 fixed slots rather than per-organization streams. MemoryDB with per-organization streams wins on latency and cost for our traffic. Durable Objects win on isolation and edge reach, at the price of vendor lock-in. celld is the portable choice for customer-hosted deployments once its write path is batched.
Moving Helicone customers over with no change on their side final: D12
The goal. We own Helicone and its infrastructure, so a Helicone customer should change nothing: no new base URL, no new key, no new SDK, no new header. Their code keeps calling Helicone's hosts with Helicone's keys, headers and SDKs. Behind those hosts, our gateway serves the traffic, our stores keep the data, and our dashboard shows it, with their full history.
What Helicone customers use today, and must keep working
Proxy hosts:oai.helicone.ai, anthropic.helicone.ai, gateway.helicone.ai (upstream chosen by Helicone-Target-URL), ai-gateway.helicone.ai (one OpenAI-compatible endpoint with model strings like gpt-4o-mini/openai), and vendor hosts such as groq, together and openrouter.
Keys:Helicone-Auth: Bearer sk-helicone-…, usually with the customer's own provider key in Authorization.
About 60 Helicone-* headers: properties, user id, session id, path and name, request id, cache, retries, fallbacks, rate-limit policy, prompts, omit request or response, moderation, security, and response headers such as Helicone-Id.
SDKs:@helicone/helpers and helicone_helpers (manual logger posting to /custom/v1/log), @helicone/async and helicone_async (OpenTelemetry spans to /v1/trace/log), @helicone/export, and @helicone/mcp.
REST API on api.helicone.ai: request and session queries, feedback, scores, properties, users, prompts, datasets, evaluators, webhooks signed with HMAC, and HQL (SQL over their own logs).
How we serve it 1:1
Same hosts, our backend. Helicone's DNS and Cloudflare zone stay. Their proxy hosts route to our gateway and api.helicone.ai to our API. During the move, Helicone's own worker can run in front of our gateway, so traffic can shift one host and one customer at a time and roll back by switching the route back.
Same keys.updated 2026-11-18: only organizations and keys are imported; members cannot sign in yet (owner question 8). We import Helicone's organizations, users and sk-helicone-… keys (hashed). Each Helicone organization maps to one of our organizations, and its keys authenticate on our side exactly as before.
Their provider keys keep working as sent. A Helicone proxy customer sends their own OpenAI or Anthropic key with each request. On Helicone hosts our gateway accepts that key per request, uses it for that call only, never stores it, and records the request as the customer's own-key traffic. (Our usual rule is to store a connection first; here the no-change goal wins.)
Every header honored.updated 2026-11-20: corrected: the moderation, LLM-security and token-limit headers are enforced, with documented differences (see What changed on 2026-11-20). Lytix forwarding, experiment columns and a few legacy headers are not served yet, and the response names them in X-Explabs-Ignored-Headers. Each Helicone-* header maps onto the matching feature: properties to tags, user id to the end-user label, session id, path and name to session fields, request id to our request id, omit headers to "do not store", retries and fallbacks to our failover, rate-limit policies to key limits, cache headers to a response cache. Responses carry Helicone's response headers (Helicone-Id, cache, rate-limit) as before. A header we do not support yet passes through harmlessly and is counted, so we know what to build next.
Same SDK endpoints. The manual logger's /custom/v1/log routes and the async logger's /v1/trace/log accept exactly what Helicone's SDKs send, so the published @helicone/* and helicone_* packages keep working unchanged. We keep publishing those packages, now pointed at our endpoints by default.
Same REST API. Our API answers Helicone's routes in Helicone's request and response shapes, backed by our stores. The session routes gain what Helicone never had (one session by id, its tree, search inside it), so customers get more from the same API.
Same history.updated 2026-11-18: built to copy the first 32 KB of text per request, not the full bodies into S3; the copy is switched off. We copy Helicone's ClickHouse request_response_rmt rows and S3 bodies directly into our ClickHouse and S3, mapping properties, sessions, feedback and scores. Customers see their full history from the first day.
Same dashboard links, then ours. Helicone's dashboard URLs redirect to the matching pages in ours once each page has parity: requests, sessions, users, properties.
Features Helicone has that we need to match
Response cache, prompt registry with versions, datasets, feedback and score APIs, HMAC-signed webhooks, per-request rate-limit policies, token-limit handling, HQL, user metrics, a per-request moderation switch, and an MCP server. updated 2026-11-20: token-limit handling and the moderation switch are now built and enforced. Each one we have not built yet is answered from Helicone's existing service during the move, so nothing breaks while we catch up.
Order of work
Import organizations, users and keys; map Helicone organizations to ours.
Gateway accepts Helicone hosts, keys, headers and per-request provider keys; shift one host at a time behind Helicone's worker.
Copy history from Helicone's ClickHouse and S3.
Serve Helicone's log endpoints and REST API from our backend.
Fill the feature gaps; redirect the dashboard page by page.
Open question:updated 2026-11-18: still open as owner question 7; the original plan's "keep plan terms until renewal" is a recommendation, not a decision. do Helicone customers become ordinary Experiential organizations with our plans and billing, or keep Helicone's plans as they are for now?
Keeping valuable data, and letting customers set expiry final: D13
Some captured data is worth far more than the rest: long, successful agent sessions, expensive tasks, rare languages or countries, or anything a customer pays us to keep. Today nothing distinguishes it. Pairs are kept with no calendar expiry, unpaired prompts expire after 2 hours, contract organizations can set 1 to 90 days, uncensored traffic is kept forever, and free organizations cannot turn capture off.
changed in review: the live privacy policy says new uncensored requests follow the same capture and ZDR controls; only historical captures keep the old retention.
What exists to build on
Classifier tags (public.classifier_tags, scored by Clef in the offline review): policy tags for abuse, and five descriptive tags including taskKnowledge and economicValue. Scores land in ClickHouse spend_facts.tag_scores. Coverage is uncensored traffic only, with no backfill.
Country on every request (gateway_requests.request_country, request_region) and on every organization (organizations.geo_country), plus signup context. No retention or tagging rule reads them, and ClickHouse has no country column yet.
Lineage and size: prompt and conversation hashes for deduplication, session key, tokens, cost, tool calls, finish reason, client app.
Three eligibility verdicts that disagree: the trace inventory's training_use, the training catalog's decision (which has no permission evidence recorded yet, so everything reads "missing scoped permission"), and the capture rules themselves.
An empty archive bucket, explabs-capture-archive-761200393827-usw2, created by hand and tagged for free-organization traces older than 14 days. No code or decision backs it yet.
Proposal
One value tag per capture, computed by the loader. When the Fargate loader processes a capture, it writes a small set of facts next to the summary row: country and region, plan tier, eligibility for our own use (never for BYOK, connected plans or zero data retention, per terms sections 4 and 6), session length, success, cost, tokens, deduplication hash, and the classifier's descriptive scores once classification covers mainstream traffic.
One eligibility verdict. Fold the three verdicts into one function the loader calls, so "may we keep this for our own use" has one answer, with a reason.
Retention classes instead of one rule:
Customer-set: the organization's own expiry, which always wins for their own copy.
Paid retention: organizations that pay to keep data get the period they bought, and can set their own expiry date within it, for all traffic or per tag, key or project.
Valuable, eligible: data our value rule marks as worth keeping (for example, sessions above a length or cost, under-represented countries or languages, high economicValue scores) moves to the archive bucket on cheaper storage and stays.
Everything else: expires after a default window. For free organizations, the archive bucket's plan was 14 days of hot storage.
Safety retention: uncensored traffic stays in its own unbounded archive, as today, and is not a training source. changed in review: applies to historical captures only; any own-use archive is opt-in and excludes own-key, ZDR, private-mode and Helicone organizations (D13).
Customer expiry controls. Settings gets a retention section: a default expiry for the organization (from 1 day to the plan's maximum), overrides per API key, project or tag, and a "keep" flag on a session or request from the request drawer. The API gets the same controls. Expiry deletes the body object, its search text and its pointer together.
Terms and privacy first. The privacy page promises pairs are kept "as long as capture stays on", and one of its lines about own-key traffic is already out of date. Any default expiry, and any archive for our own use, needs those pages updated before it ships.
Choosing what gets stored, per key and per caller final: D14
Today there is one switch per organization. Storing content is all or nothing for every key, and the only per-request control is zero-data-retention routing.
Per key: each API key gets a storage setting, "follow the organization", "store" or "do not store", plus an optional expiry. A key can tighten the organization's setting. Whether a key may loosen it (store when the organization says no) is part of the decision below; the safe default is no.
Per request: a header (and the Helicone Omit-Request / -Response headers) can turn storage off for one request. It can only tighten.
Our own Clef calls: the content review sends excerpts of other tenants' prompts, and the signup scan sends personal data, both through an Experiential Labs key. Storing those prompts again would copy tenant content and personal data outside the tenants' deletion rules. The quarantine decision does not need the prompt; it needs the outcome. So the internal keys are set to "do not store content", and the decision service keeps only the result it already records: the scores, the matched tags, the window of the source request it judged, and the decision taken. The judged request's own capture is the evidence, and it follows its tenant's rules.
Customers' Decisions traffic: stored like any other request under the organization's switch, once the decisions capture record exists.
November 16 and 17: the final plan, D1 to D20
By November 16 the designs and analyses above were turned into one plan, the Platform Data Plan. It answers each open question with a numbered decision. Seven reviewers then checked it from different angles: facts, reliability, money, privacy, cost, product and simplicity. Their review changed several answers this page had given.
What the review changed. Where the review changed an answer this report had given, the place is marked changed in review. The main changes:
Capture keeps only a memory buffer, then a metadata-only record. There is no sidecar disk and no second-region bucket.
Uncensored traffic follows the same capture controls as every model.
Blocks (quarantine, ban, revoked key) are enforced inside MemoryDB.
Postgres keeps request rows 120 days for money work only, and partitions drop only after ClickHouse parity.
Only the capture ETL runs on Fargate.
The Durable Objects abstraction and the edge prototype are cut.
OpenTelemetry and Langfuse ingest are co-primary with headers.
Two new decisions: erasure (D19), and scores and datasets (D20).
The seven principles
Every decision follows from seven rules. If a later change is unclear, these rules decide it.
A customer request waits only on the provider and one fast, durable store. No Postgres read or write, no object upload and no analytics query sits on the request path. Everything else happens afterwards, from a durable queue. The few flows that still touch Postgres are named in D1.
Each store does one job. MemoryDB holds live money, limits and blocks. Postgres holds the permanent record of money, accounts, keys and configuration. ClickHouse answers every list, total, trace and search. S3 holds bodies and media. A read has one home.
Every handoff uses one outbox primitive. Each item has an idempotent receiver, a parked state, a replay command and an alarm on the age of its oldest item. Nothing retries forever, and nothing is lost without being counted.
Every wait is bounded, and every shed is visible. Reads have a deadline, pools have a size, queues and streams have a memory budget, and recovery is paced with jitter. Every refusal and every dropped capture is counted. Scaling follows the real bottleneck (queue age, database wait), not CPU.
Tables have a lifetime, and data has an erasure path. Every table gets a retention rule on the day it is created. Every copy of customer content, including search text, spans and tag scores, is reachable by one erasure job.
Money fails closed, and side jobs fail open. A request that cannot be priced and limited correctly is refused. A request whose only problem is that a copy cannot be stored is served, and the loss is counted.
Built is not live. A change is done when production shows it working: the resource exists, the switch is on, the metric moved.
The twenty decisions
Each decision is one line here; the plan page has the reasoning, the rejected options and the tests. Part 7 lists which ones still carry an open owner question.
#
Decision
Why, in one line
D1
Requests never touch Postgres, and blocks never depend on a snapshot
Every Postgres incident was becoming an API incident; blocks live in the MemoryDB deny set so allowed answers can be served through an outage.
D2
Captures go to our S3; a full buffer drops the copy, not the customer
Capture refused customers on November 5 and 9 because a copy was slow to store.
D3
Postgres keeps money, accounts and configuration, and every table has a lifetime
Unbounded tables (311, 238 and 67 GB with no retention) slow every vacuum and restart; request rows are kept 120 days for card disputes.
D4
ClickHouse answers every list, total, trace and search
One home per read; Postgres keeps the money record, not a display copy.
D5
An allowlist of dashboard reads goes to the replica; the catalog stays in the main database
Takes dashboard load off the primary without rewriting transactions that join the catalog with keys.
D6
MemoryDB stays the live wallet, across 64 fixed receipt slots
The only tested backend fast enough for the request path; slots isolate a hot organization.
D7
One Requests table, agent traces from headers or OpenTelemetry, and a CLI first
Customers moved to agents; headers need no code, OpenTelemetry covers steps the gateway cannot see.
D8
Search indexes each request's new text only
Agents resend the whole conversation; indexing only new text keeps size proportional to the session, not its square.
D9
One outbox primitive with a shelf and an age alarm
Retry-forever hid stuck captures and stalled exports.
D10
Customers define tags; a judge scores them on captured traffic
Lets customers find "the agent gave up" without reading every trace; any judge model, so Clef capacity does not block it.
D11
Things that fail differently deploy separately, in one orchestrator
The November 11 crash loop took the writeback down with the control plane; workers stay in EKS, only the capture ETL runs on Fargate.
D12
Helicone customers change nothing, after legal clears the move
"Zero customer change" covers every surface they touch; moving their stored data changes a sub-processor.
D13
Customers set expiry; any archive for our own use is opt-in
The buyers we want are buying control; the privacy page promises pairs are kept while capture is on.
D14
Tighten-only controls; media stored by kind
The org switch is a promise to the org's admins; media cost and sensitivity differ by kind.
D15
The gateway stays in EKS; Cloudflare does TLS, WAF and caching
A Durable Object wallet measured about 100 ms more per call from Oregon; the provider call dominates latency.
D16
Restarts become maintenance, not outages
Decoupling requests from Postgres protects against unplanned trouble too; blue/green does not.
D17
Guards in tooling, not in chat
Merge holds coordinated by chat failed; recovery is pinned by containment.
D18
Credentials never pass through chat
Secrets were exposed in conversations on November 10.
D19
One erasure job reaches every copy, and the ETL checks it live
Copies multiply (segments, queues, text, spans, tags); a segment in flight must not recreate deleted content.
D20
Scores and datasets from traces
Teams judge and test their agents from the same data they observe.
The design as built
The diagram shows the shape PR #2980 builds. Compare it with the simple picture in Part 3. The main differences: captures go to a segment file on the pod's disk and then to our own S3, not to Supabase Storage; two SQS queues feed a capture ETL on Fargate; ClickHouse holds the request list, spans, session summaries and search text; and the edge admits span ingest per organization.
flowchart LR
C["Caller"] --> E["Edge fair share per org"]
E --> G["Gateway worker keys, grants, catalog in memory"]
G <-->|"hold, settle, deny set"| M[("MemoryDB wallet 64 slots")]
G --> P["Providers"]
G -->|"capture appended"| SEG["Segment file on the pod's disk"]
SEG -->|"every 1 to 2 s or 16 MiB"| S3R[("Our S3 raw bucket 7 days")]
CP["Control plane OTLP and Langfuse ingest"] --> SEG2["Control segments"] --> S3R
S3R -->|"gateway segments"| QR[["Raw queue"]]
S3R -->|"span segments"| QC[["Control queue"]]
QR --> ETL["Capture ETL on Fargate"]
QC --> ETL
ETL -->|"one object per request"| S3O[("Our S3 observability bucket")]
ETL -->|"requests, spans, sessions, request_text"| CH[("ClickHouse")]
M -->|"receipts"| WB["Ledger writeback"] --> PG[("Postgres money, accounts, 120-day rows")]
UI["Dashboard and API"] -.->|"lists, search, traces"| CH
UI -.->|"one body"| S3O
As built in PR #2980, not merged. For a known key on a plain model chain, the request path ends at MemoryDB and the segment, and touches neither Postgres nor ClickHouse. It still touches Postgres in five named cases (D1): protected model chains outside a planned maintenance window (about 52% of production traffic), Responses continuations the outage cache does not hold, keys a worker first sees during a Postgres outage, pods starting during an outage, and new blocks during an outage.
November 17: the owner's timing call
The plan first spread the work over "this month" and "this quarter". On November 17 the owner decided to build everything in one change now. The same day the platform moved from GitLab back to GitHub, and the wallet comparison ran for real (results under the wallet: MemoryDB stays).
The full wallet test, from us-west-2, with the same wallet logic on each backend: all three were correct (0 mismatches in about 4,500 calls, 0 drift under races and faults). MemoryDB was the only one fast enough for the request path: hold p99 3.9 ms, against 396 ms for Durable Objects and 45 ms for celld. A hot organization at 500 req/s had p99 8.7 ms, against 6,549 ms (43% refused) and 172 ms. Cost per month: $946, $1,447 and $238.
The 25 places where this report and the plan disagreed, and how each was settled
A full pass over the planning conversation found 25 places where this report and the plan disagreed. Each is settled here; the ones that change a promise to customers were also listed as owner questions.
Conflict
Decision
Reason
Production ClickHouse version (report 26.6, repo 25.8)
Measured on November 17: production runs 26.6.1.2455, so the search gate (26.2 or later) is met. CI and preview images move from 25.8 to 26.6.
A decision cannot rest on an unverified number.
Search cap and index (64 KB n-gram vs 32 KB token)
32 KB, token splitter
An n-gram index is 5 to 10 times larger; 32 KB covers a typical turn of about 8 KB with room.
Capture fallback chain vs pod memory on 128 MiB bodies
Memory, then the existing fsynced local-disk outbox, then metadata-only
The disk outbox already exists in the serving pod and answers the memory risk without a second region or a sidecar process.
Uncensored traffic "always stored" vs live privacy policy
Follow the live policy: same controls as every model
The published policy is the promise in force.
All workers to Fargate (Kion Sync) vs workers in EKS
Workers stay in EKS as separate deploy units; only the capture ETL on Fargate
One orchestrator for a small team; Kubernetes is portable across quadrants.
Per-organization streams vs fixed slots
64 fixed slots with a move protocol
No dynamic stream lifecycle, no polling of idle streams, wallet keys stay atomic.
Edge prototype and Durable Objects API
The comparison tests run with real deployments; the edge gateway is not built
The owner asked for measured outcomes.
Stale allows up to 5 minutes
Blocks come from the MemoryDB deny set; allows stay valid through an outage
Money review: blocks must not depend on a snapshot.
Stale prices and limits up to 10 minutes
Prices and limits live in memory and MemoryDB, refreshed by version; an unreadable fact refuses
Money fails closed.
Postgres window (short, 90 days, 120 days)
120 days, money work only
Card-dispute lookback.
Where one request's metadata is read
ClickHouse, like every list
One home per read.
Helicone scope (full endpoint list vs four steps)
The full list: hosts, auth, every header, response headers, SDK endpoints, REST API, webhooks, history copy
"Zero customer change" means every surface a customer touches.
Default integration (headers only vs headers and OpenTelemetry)
Both, co-primary
Headers need no code; tool and custom spans happen in customer code and need OpenTelemetry.
Tag judge (Clef only vs any model)
Clef default, any model allowed
Clef capacity no longer blocks the feature.
Keeping valuable data (our own archive) vs opt-in
Opt-in, broad exclusions, switched off until the terms change
The buyers we want are buying control.
Per-key storage "opt in" beyond the org switch
Tighten only
The org switch is a promise to the org's admins.
Media to a cheaper storage class
Lifecycle rule for media objects only, never small chunks
Infrequent Access and Glacier bill a 128 KB minimum per object.
Readiness on snapshot age
Readiness ignores snapshot age; snapshot age pages
Failing readiness on age would empty the fleet during a Postgres outage, the exact case D1 protects.
Stuck capture count (298 vs 813)
Both are dated counts from different days; the fix and parking make the number zero
Facts review.
November 10 vs 11 dashboard overload
November 10
The incident timeline.
Session list and live view targets missing
Added to the measures
Requirements from the sessions analysis.
Raw objects deleted on processing vs kept 7 days
Kept 7 days
Replay and erasure checks need the raw copy for a short window.
Chunk dedup across organizations
Within one organization only
Erasure and cross-tenant leakage.
Timing (this month vs this quarter)
Everything in one MR now
Owner, November 17.
PostHog missing from the target diagram
Unchanged: product analytics events still go to PostHog; it holds no request content
Stated so the omission is not read as removal.
November 18: reassessment, protected chains, and the first restart rehearsal
On November 18 we stopped and checked what was really true. The build had grown fast, and several claims in this report and in the November 16 plan no longer matched the code. This section has four parts: where the build stood, which claims were superseded, how protected chains were made to survive a restart, and what the first real restart rehearsal showed.
Reassessment, 2026-11-18. Nothing of this work is merged to main, and none of it runs in staging or production. The build lived on GitHub PR #2980 (7 failing checks at the time) and in 12 local split branches. Since then the split PRs were opened; see the 2026-11-20 note above.
Several claims in this report and in the original final plan of November 16 are now superseded. Two decisions were made after the report was written:
protected model chains survive a planned restart through a maintenance window;
the MemoryDB "witness" design for unplanned outages was built and then dropped.
Every correction is listed in What changed on 2026-11-18, and the places in the text are marked updated 2026-11-18.
Where the build stands.
Nothing of the build is merged to main. GitHub PR #2980 (branch obs-data-plan, head 98d1ff2ed) is the reference and fails 7 checks: hot-path-query-budget:gate, migration-guard, migration-lock-budget:apply, obs-e2e, Newly introduced secrets, integration-tests (ordinary) and Web checks.
It is split into 12 pull requests, not 13: the wallet is folded into the request-path PR, and restart work and the GitHub guards share one PR. On 2026-11-18 the 12 branches were local only. updated 2026-11-20: they are open as PRs #3090 to #3101, none merged, all with failing checks.
Merged to main so far: preview plumbing (#3022, #3028, #3044, #3051, #3061), one pgTAP fix (#3024) and the psycopg upgrade (#3046, live in production since 15:58Z on 2026-11-18).
The owner's rule for this work: nothing goes to staging or production; everything is proven in the isolated preview first.
The engine change for media and Decisions capture is in progress, not released.
Superseded claims
Each row names a claim made in this report or in the original final plan (November 16), and what is true now.
Claim
Where it was made
What is true now
During an outage, allowed answers up to 5 minutes old are served
Blocks come from a deny set in MemoryDB, so allowed answers are served through an outage, bounded at 60 minutes. updated 2026-11-21: Fixed. On 2026-11-20 keys and grants were bounded at 15 minutes in the code. Every outage path now uses one 60-minute bound, OUTAGE_SERVE_STALE_SECONDS in explabs/outage_bound.py, pinned by a test.
Request and attempt rows kept in a 90-day window
Original plan D3
120 days, which covers the card-dispute lookback.
A per-organization receipt stream for busy organizations
Original plan D6; this report, edge and wallet analyses
64 fixed slots, each with one receipt stream, and a move protocol for a hot organization.
Every background worker moves to Fargate
Original plan D11; this report, Kion Sync and Database plan
Workers stay in EKS as separate deploy units scaled on queue age. Fargate runs only the capture ETL.
updated 2026-11-20: corrected. Of 51 headers handled, the moderation, LLM-security and token-limit headers are enforced, with documented differences (see What changed on 2026-11-20). Only organizations and keys are imported, so members cannot sign in. History copies the first 32 KB of text per request, not the full bodies.
The engine change for media and Decisions capture is prepared as an engine PR
The plan, decision 12
In progress, not released.
Protected model chains: a planned maintenance window, and the witness design that was dropped
Why it matters. A read-only production query on 2026-11-18 found 27,171 of 52,347 requests in 10 minutes (52%) on protected chain revisions. Each one writes a receipt in Postgres at admission. The receipt proves four facts at that moment: the worker is enrolled in the current release, the alias floor allows it, the revision is still the alias's current one, and the key and grant are live. So a Postgres restart refused about half of /v1.
First design: a MemoryDB witness (built, reviewed twice, dropped). A counter and an in-flight set in MemoryDB, required by SQL triggers on every chain-authority write, let a pod cut off from Postgres prove that no chain change had happened since its last read, and so keep admitting protected requests through an unplanned outage. It was built (nine migrations, worker code, an operator runner), then went through an adversarial review and a verification review. It was dropped for three reasons:
It was large: nine migrations and three moving parts (MemoryDB tokens, Postgres intents and per-worker observations).
Its failure mode was costly: losing MemoryDB fleet-wide while the mode was on froze every chain transition, releases included, for 61 minutes.
A much simpler design meets the owner's actual requirement, which is to restart Postgres without hurting API traffic. Unplanned outages were not the goal.
None of its migrations reached main or any hosted database, so removing it needed no reversal migration.
Decision: a planned maintenance window. Before a restart, an operator opens a window of 1 to 30 minutes (POST /api/admin/chain-maintenance). How it works:
The window starts 30 s after the call. From the call to the end, Postgres refuses every chain-authority write: release floors, revocations, alias floors, and repoints of a protected alias. Seventeen guard triggers do this, and they are disabled outside a window, so normal traffic pays nothing.
Workers read the window every 2 s. While Postgres is down they admit a protected request from their last read, until 5 s before the window ends, and the receipt is recorded when Postgres returns.
No partition can change the chain during the window, because Postgres itself refuses every change, so no witness is needed.
A window cannot end early, releases cannot begin during it, and catalog publication waits for it to end.
During an unplanned outage, protected requests still get a retryable 503.
Rejected: a setting on the hot app_settings row; refusing writes only from the start, which lets a write land after a pod's read; ending a window early, which is unsafe for a pod that is cut off; and the witness.
Tested. The window passed review fixes and a local end-to-end flow (flow 12) running production's own release code. In the final run, a 40 s cut inside a window served 1,527 of 1,527 requests. 259 protected requests were served during the cut, each with exactly one receipt, and spend equalled served cost exactly. Without a window, every protected refusal was a 503 with Retry-After.
Still open:
Flow 12 is not in CI.
The preview has no protected chains, so the window was never exercised there.
One protected request in flight at the cut waited 30 s before its retryable 503.
Restart rehearsal on the preview
Postgres was restarted on preview pr-902980 in four rounds under steady load, fixing what each round found.
Round 1: every Python service crashed after recovery; see the lesson below.
Round 2: requests at the cut still hung 22 to 37 s.
Round 3: one worker refused a known key for the whole outage, because it had never cached it.
Round 4: zero errors on known keys through a 46 s cut with a window and a 70 s cut without one. The slowest request took 1.41 s, and every charge was recorded exactly once, MemoryDB and Postgres equal to the nano-dollar.
Limits. The cuts were short (41 to 70 s) on a small database branch, not the 10-minute cut on production-sized data. The preview has no protected chains. The MemoryDB failover game day has not run. A key a worker had never read was refused by that worker with a retryable 503, as designed.
Lesson: a dependency crash that only a real restart shows.
What we saw. In round 1, the gateway worker, control plane, capture ETL and project worker all exited with a segfault about 5 s after Postgres returned, in both runs. A 41 s outage became 65 to 88 s of customer errors, and the restarting fleet hit the database a second time.
Why. psycopg 3.3.4 crashed when the Supavisor pooler greets a client without connection settings. No unit test or simulated outage (a pool pointed at a dead port) had shown it.
The fix. An upgrade to psycopg 3.3.8 in #3046, live in production since 15:58Z on 2026-11-18.
A failure path that runs only during a real outage has to be exercised by a real outage.
Why rounds 2 and 3 failed, traced from the worker logs:
Round 2, requests hanging 22 to 37 s. Two causes:
Behind the Supavisor pooler a pooled connection is handed out at once, but the statement then waits about 8 s for an upstream and fails ("Failed to connect to database"). That is a statement error, and only checkout failures counted toward the breaker. The pool then validated the next connection, which waited 8 s again, up to five times, and the validation ran before the connection could be cut.
The dispatch credential release used its own connections outside the breaker. Its 1 s server-side timeout never fired while Supavisor held the statement, so it waited about 8 s, then retried for about 8 s more.
Round 3, a known key refused. The refusing worker had served no chat for that key before the cut (another worker had). After the cut the edge moved the key's connection to it, and its first-sight grant read hit the open breaker. The 17 s after recovery is the breaker's designed close: a fleet that opened together must not close together.
A later run went further: 11 back-to-back restarts with Postgres down 525 of 604 s, still 0 errors on known keys.
Checking the build: five layers
Building is not proof. So the build went through five layers of checking, each by agents that did not write the code. By November 18 the first four had run; the fifth, the preview stress test, continued through November 22.
Requirements trace. Every owner message from the planning conversation was matched to the code that delivers it. It found 15 gaps. The worst: the new Requests page would show an empty history on deploy, because nothing backfilled it. Fixes came in three waves: history backfill, per-key do-not-store leaking conversation state, a wrong header in the docs (first); seed data, capture backfill, the value tag and country filter, prompt and conversation grouping (second); the remaining Helicone gaps, a public CLI, wallet replay, engine media capture and rehearsals (third).
End to end. Real requests were driven through gateway, segments, S3, SQS, ETL, ClickHouse, the APIs, tagging, retention and erasure on a dedicated EC2 stack, checking every store. All 11 flows ran; 10 passed, and tag scoring stopped at the judge because no local provider accepts its strict format.
Seventeen integration bugs were found and fixed, each with a regression test: a ClickHouse migration that would have failed every deploy, the usage export stopping for good after minutes of traffic, every session read answering 500, tool spans never inferred, a new lane answering 500 and idle workers 503, per-key retention never matching, two segment writers destroying each other's files, no trace tag ever scoring live traffic, and every keep-flag re-stamp failing. Five smaller issues went to owners. The suite lives in docker/tests/obs_e2e.
Tenant isolation and security.
High, fixed: a crafted Host header let anyone make the public /v1 edge call internal servers; read-scoped admin keys could read every org's captured prompts through 10 new routes.
Medium: the Helicone cache stored answers the caller asked not to store (fixed); unclamped span timestamps let one org push a whole segment to the dead-letter queue; the Helicone REST API had no rate limit; trace SQL exposed columns that do not exist.
Held: trace SQL tenant isolation and escapes, cursors, Target-URL, webhook SSRF guards, link signing, ingest size limits, span origin forgery.
Money (local Valkey and Postgres). Critical: the Helicone response cache could fill the wallet's MemoryDB and stop all money, so the cache moves to its own evicting cluster. High: out-of-memory and read-only errors were not treated as "wallet unavailable" (fixed); a flood of random keys could lock out new and returning keys. Medium: one long write transaction stalls the deny-set feed; usage could double count under a reclaimed export lease; a Helicone cache hit was served to blocked keys.
Load at 10x (dedicated EC2).
High: an unauthenticated flood of random keys could deny every real key not yet in a worker's memory. Fix: a filter of all key hashes, so unknown keys get a 401 for free.
Medium: the partition dual-write cost about 5% throughput and 43% more WAL on a quiet machine (the first 28% figure came from an overloaded laptop). It was redesigned as a key-only change log drained after commit, about 2% on the request path. Also medium: a few free orgs could saturate a process's report reads, and the re-file sweep could be made to rescan for days.
Measured: the key snapshot is 134 MB at 1M keys and 7.1 GB at 50M.
Held: change-table pruning, the KMS key cache, S3 request rates.
Privacy and erasure. Two holes found and fixed: a Helicone cache save landing after an org purge, and ClickHouse rows written late for records captured before an erasure.
Failure injection.
Critical: the Helicone cache could fill the wallet's cluster (as above); dropping a column would break every write to the three partitioned tables, which led to the dual-write redesign.
Fixed: MemoryDB out-of-memory is now a retryable 503; the ETL pulls only what it can work; loops back off; the sweep stops resending.
Open: segment directory lost on pod restart; contract traffic admitted during a long S3 outage; a pod with uncertain facts over-granting promotions; the reconnect stampede.
Held: a killed Valkey primary under 7,500 reservations/s gave only retryable 503s for 9 s; the ETL deletes a message only after ClickHouse confirms.
The first preview deploy found two bugs, both fixed: every database client opened 32 sessions at creation (63 MB each), and ClickHouse schema errors parked good export rows. One adversarial pass at fc396d4f2 found four issues, all fixed.
November 19: the Clef 502s, and what Observability was still missing
Intermittent failures on the Clef judge
What we noticed. Clef, our decision model, is called through /v1/systemone. It scores content for our own review, and in the new design it is the default judge for customer tags. From the evening of November 18, a small share of its calls failed fast with 503s: 0.8% to 2.2% per hour on November 19 (the ledger showed 271, 260, 670, 598, 319 and 469 an hour from 09:00Z).
How it is wired. The gateway reaches Clef through a GCP VM (exp-model-gateway-01). Its public Caddy sends Clef traffic through two more local Caddy processes. The last one, clef-priority-pool, balances between two upstreams: an Azure tunnel on port 18160 and a "U.S. Clef replica" on 18170, each capped at 32 requests. It health-checks each upstream every 5 s with a 2 s timeout, marks it down after one failure, and retries a failed request only once, after 100 ms.
What we found. Two failures combined:
The 18170 replica was dead. Nothing listened on it; its tunnel had disconnected at 03:50:08Z, and its owner was unknown. So the pool ran on one upstream with no slack.
The remaining upstream sat on a lossy tunnel with about 250 ms round trips. Now and then its health check took longer than 2 s (11 times in 90 minutes). Each miss marked it down for 3 to 5 s, and during that window every request got an instant 503. About 75% of the 503s fell inside those windows; most of the rest came from the 32-request cap filling while the box was slow.
The evidence lined up minute for minute: the VM access log and the ledger counted 86 and 73 failures at 14:23, 118 and 116 at 14:30, 49 and 42 at 14:39. The VM itself was healthy (disk 18%, 11 GiB free, load 0.2).
What we changed. With the owner's approval, only the pool's config: a 5 s health timeout, 3 consecutive misses before marking down, passive max_fails 3, and no single-retry limit, so a request can wait up to 5 s for a free slot. It was a graceful reload at 15:33:58Z, with a backup kept.
What happened. In the 30 minutes before, 20,077 calls completed and 112 failed (0.55%), p50 480 ms, p95 1,231 ms. From 15:34 to 16:05Z, 22,780 completed and 0 failed, p50 484 ms, p95 1,132 ms. The pool log showed no more "no upstreams available". Still open: replacing the dead 18170 replica, whose owner is unknown.
The UX gaps audit
What we noticed. The owner wrote on November 19: "the production data isn't great I can't test all of the different features. it's also missing a bunch of the stuff I asked for or we planned for like metadata previews of requests, etc. and the top bar for observability has too much going on right now".
What we did. An audit listed every ask from the owner's messages and the plan, 40 in all, and checked each against the code and a live preview, with screenshots. Before the pass: 27 built, 7 partial, 6 missing.
Built in the same pass:
a short preview of each request in the list;
a hover or Space "quick look" card (question, answer, tokens, cost, latency, time to first token, session, step, end user, key, error, tags);
a one-row top bar instead of 11 controls on two lines.
After: 30 built, 6 partial, 4 missing.
Four items went to the owner: a natural-language query box over traces (and which model pays for it); redeploying a preview with fixture data so every feature has something to show; removing the free-plan expiry switch (decision 3); and whether session-tree hovers may fetch text per node.
Also that day. #3034 merged on main at 22:39 UTC. It removed the early-access rule, so the new pages would go live for every customer on deploy, while the pipeline that fills them stays off by default.
November 20: plan review, corrections, and the security retest
A full plan review on November 20 checked the plan's claims against the code once more. It found one number that was wrong in a way customers would feel, and it proposed four simplifications. The same day a security retest and a load test ran on the preview.
Plan review, 2026-11-20. Still nothing is merged to main, and none of it runs in staging or production. The 12 split pull requests are open on GitHub as #3090 to #3101, each labelled do-not-merge, and every one has failing checks (4 to 20 per PR), PR 1 included (updated 2026-11-21: closed; everything lands as one PR, #2980). #3034 is merged, so the new pages go live for every customer on deploy.
Corrected in this report:
the outage bound in the code is 15 minutes, not 60 (updated 2026-11-21: fixed, one 60-minute bound);
the Helicone moderation, LLM-security and token-limit headers are enforced, not ignored;
the free-plan retention answer is not yet confirmed.
See What changed on 2026-11-20. Owner decisions that are built only as provisional defaults are listed on the plan page.
Where the build stands.
Nothing is merged to main. PR #2980 (head 9b88cfb95) is the reference and fails 8 checks. updated 2026-11-21: #2980 is now the one PR that lands; see What changed on 2026-11-21.
The 12 split PRs are open on GitHub as #3090 to #3101, each labelled do-not-merge. Every one has failing checks (4 to 20 per PR at 06:38 UTC). PR 1 (#3090) fails obs-e2e, postgres17:proofs, Web checks and integration-tests (ordinary). updated 2026-11-21: all 12 are closed.
The open PRs were built from c4b50c33f. The stack is rebuilt locally from 9b88cfb95, which carries the fix for PR 6, and is not pushed yet. updated 2026-11-21: superseded by the one-PR decision.
Migration numbers: the stack keeps its numbers (20271101000100 upward) while it is built and previewed. Each PR is renumbered above main's newest migration only at merge time, when it is pointed at main. updated 2026-11-21: #2980's migrations were renumbered above main's newest when it was squashed, and are renumbered again at merge if needed.
#3034 is merged (2026-11-19, 22:39 UTC). It removed the early-access rule, so the new pages go live for everyone on deploy. The pipeline that fills them (capture to segments, the ETL, the tag worker) is off by default, and its switches are not yet in the GitHub deploy workflows. updated 2026-11-21: an availability endpoint now lets each page hide a feature with no data and say why, and one release variable list feeds the GitHub production and staging workflows.
Corrections.
Outage bound. This report and the plan say allowed answers are served for up to 60 minutes of a Postgres outage. The code bounds keys and grants at 900 seconds (15 minutes) in two places (_MAX_STALE_SECONDS in explabs/gateway/admission_scope.py, _GRANT_MAX_STALE_SECONDS in explabs/gateway/control_store.py). An outage longer than 15 minutes would give every key a retryable 503. This is being fixed with one shared constant and a test that pins it. updated 2026-11-21: fixed in explabs/outage_bound.py (60 minutes).
Helicone safety headers. The moderation, LLM-security and token-limit headers are enforced, not ignored. Differences from Helicone: LLM security uses our managed guardrail models instead of Prompt Guard and Llama Guard; when the security check cannot run we refuse with a retryable 503 where Helicone lets the request through; on the AI gateway host moderation uses our safety model because the caller sends no OpenAI key; and the token-limit context window comes from our catalog. Lytix forwarding, experiment columns and a few legacy headers are still not served, and the response names them in X-Explabs-Ignored-Headers.
Owner decisions. Decisions 3, 4, 5, 9, 10, 13 and 14 on the plan page are built with provisional defaults, not decided by the owner. For example, the wallet runs on 1 MemoryDB shard; the Terraform comment that says "Decided: 2" is wrong, and 2 is only the recommendation.
Alarms. The wallet and Helicone cache alarms are created with no action by default, so nothing pages yet. updated 2026-11-21: every alarm root now requires its topic and refuses an empty one; the outbox alarms moved into an infra/ops-signals Terraform root.
The plan review's top risks, in order, are on the plan page under Shipping (updated 2026-11-21: with status for each).
Four simplifications proposed
The review also asked where the build could be smaller. It proposed four cuts, each with a trade-off: one capture destination instead of three modes (A), folding the low-volume background apps into one (B), opening the maintenance window automatically from the restart tool (C), and table lifetimes without a shadow copy (D). All four wait for the owner; they are cards A to D in Part 7.
The security retest
A security retest ran against preview pr-902980 on November 20 (build 37d8b2ef4), with org keys for three organizations, a do-not-store key, five scoped admin keys and two imported Helicone keys. The preview's API and ClickHouse were not reachable from the tester's laptop, so the Helicone host ingress was reviewed in code instead. Nothing touched staging or production, and every key and webhook made for the test was revoked or deleted afterwards.
Finding
Severity
Fix
Erasure left frozen Helicone webhook payloads (request and response bodies, plain text) in Postgres; a retrying delivery could still send erased content, and a parked one kept it 30 days.
High
Fixed (a4533c6a94). Migration 20271128010400 makes erasure clear every frozen payload of the organization's webhooks, and a parked delivery keeps no body. A new pgTAP suite fails on the old function.
Helicone webhook create stored any https destination (cloud metadata address, loopback names, our own admin URL, URLs with credentials), with no count cap, so one key could fan one request out to many outbound posts. A bad sampleRate caused a 500.
Medium
Fixed (4a169b8161). Create applies the delivery transport's own destination rules, sampleRate must be 0 to 100, and an organization has at most 50 webhooks. Delivery already re-checked every address, so nothing internal was ever reached.
The observability fixture script, in local mode, would seed any database URL, including a hosted Supabase project.
Low
Fixed (bad5652616). Local mode refuses hosted Supabase hosts.
What held: read-scoped and support admin keys never saw content; another organization's key got 404 on every new route and 0 rows from trace SQL; spans and Langfuse calls that named another organization still landed in the caller's own; do-not-store and per-request storage headers stored nothing; admin scopes refused everything outside their set; trace SQL escapes were refused; 40 concurrent reads got fast 429s; no new database function or table is open to the anon or authenticated roles.
Observed, not fixed:
the capture ETL stalled during the run (the load test found why; see November 21);
two branch migrations shared version 20271120600000 (a merge from main resolves it);
under a do-not-store key, span names and Langfuse trace names are still stored, which is documented metadata and deserves a sentence in the docs;
the preview's out-of-credits message links the production credits page;
a read admin key sees a 12-character prompt group hash, which could confirm a known prompt (low);
Helicone webhooks can be replayed by design (Helicone's own signature has no timestamp), while our trace-tag webhooks sign a timestamp.
The UX review with real data
An agent used Observability, Quality, settings and admin on pr-902980 as an owner would, with data made through real paths: chat, Responses and Messages sessions, OTLP and Langfuse traces, tags, scores, a review queue and a dataset. It worked in light, dark and phone widths, and compared the pages with Helicone, Langfuse and OpenRouter.
The fixes landed on November 21 (8d995b3a4f):
fresh rows say the text may still be processing instead of "storage was off";
search mode drops the empty Preview column;
failed requests read 0 credits, not "free";
the Quality page no longer says tagging is off and running at once;
empty charts say so;
score targets, dataset items and run lines read as text;
a failed score-type name shows the validator's sentence.
740 related web tests pass. Five questions went to the owner (cards 17 to 21), plus whether the requests read should carry a per-row "stored" flag, so a missing preview can say "not stored" or "not yet".
November 21: one pull request, and fixing what the load test broke
Two things happened on November 21. The owner decided to land the whole data plan as one pull request instead of twelve. And the load test that started the day before showed, step by step, where the new pipeline broke under realistic traffic.
How the load test worked. An EC2 load generator sent open-loop traffic to pr-902980 on November 20 and 21: arrivals at a fixed rate whatever the answers, with a 30 s client timeout like an OTLP exporter's default. The mix was 45% OTLP protobuf, 30% OTLP JSON and 25% Langfuse batches, about 74 spans per request, across 48 test organizations with skewed session sizes. About 4.2 million spans were offered; ClickHouse held 1.73 million spans, plus 1.2 million synthetic request rows inserted to test the reads.
The preview is small on purpose (one edge pod, one control-plane process, one ETL task, a 1-CPU ClickHouse that already used about 0.95 of its core at idle, a quarter of it on its own system logs), so every ClickHouse figure is a lower bound for production. The full report is /tmp/obs-build/audit/load-2026-11-20.md.
The text below is the day's account. The tables after it give the before and after numbers.
Update, 2026-11-21. Still nothing is merged to main, and none of it runs in staging or production. The owner decided to land everything as one pull request, #2980; the 12 stacked PRs (#3090 to #3101) are closed. #2980 was squashed, keeps do-not-merge until the owner approves, and is tested on preview pr-902980. The capture ETL now reads two queues, the edge admits span ingest per organization, and a load test, a security retest and a UX review ran on the preview. See What changed on 2026-11-21.
Where the build stands.
The owner decided to land everything as one pull request, #2980. The 12 stacked PRs (#3090 to #3101) are closed.
#2980 was squashed; the old history is kept on branch obs-data-plan-backup-20261120. Its migrations were renumbered above main's newest and are renumbered again at merge if needed. It keeps do-not-merge until the owner approves it.
CI: every check passed at 78c2ec15fc (2026-11-21, 00:13 UTC); the run at 1a9e27bf09 (00:24 UTC) failed Code checks and migration-lock-budget:apply. #2980 now conflicts with main, so its current head 7a6df21588 has no checks until main is merged in.
The preview pr-902980 is the test environment. Main PRs that let it run the branch: #3133, #3145, #3175, #3176, #3243, #3248 and #3252. #3238 was closed as a duplicate.
The capture ETL, redesigned under load. A load test on the preview showed gateway captures waiting behind span-ingest segments: both shared one raw queue, and span loads wait on a single writer, so no gateway capture was stored for over an hour. The fixes, in order:
Two queues. The raw bucket announces segments/gateway/ to the raw queue and segments/control/ (span ingest) to a new control queue. Each has its own consumer (8 slots for captures, 2 workers for spans), dead-letter queue and backlog alarm. A first fix parked span messages in memory; it held captures at 4.1 to 7.5 s until the park filled, then a capture waited over 3 minutes. The park is deleted. Being built now: the raw consumer forwards a control message that reaches the wrong queue.
Grouped writes. A segment's span batches are written together, at most 5,000 spans and 4 MiB per group (the first groups, 18 to 21 MB, were refused by the ClickHouse ingress). A segment the ledger already holds is skipped when the sweep announces it again.
Inline inference. Request text used to arrive 87 to 170 s after a gateway call: the inference message always waited 60 s, then queued behind span writes on the same writer. Now a stored request whose usage row exists is inferred at once with its own writer; otherwise it waits 10 s, doubling. Text arrived in about 18 s in 2 of 3 probes; the third waited on the usage exporter's own lag.
Session parts. Each write used to recompute the whole session from every span: 2.8 to 3.1 million rows and 21 to 64 s per write at 30,000-span sessions, which cut the ETL from about 480 to about 100 spans/s. Now ClickHouse migration 0053 keeps one part per session and trace, recomputes only the touched traces, and folds the parts (about 37,000 rows read, p50 330 ms). The first full rebuild of an existing big session runs in slices of 500 traces (the longest statement 3.3 s), because as one statement it took 103 to 126 s and never finished inside the 45 s timeout.
Throughput. About 56 spans/s before grouped writes, about 480 after on short sessions, and about 300 spans/s at the latest measurement, all on the preview's 1-vCPU ClickHouse.
Edge fairness.
What we saw. One organization's flood used to slow every other organization's ingest. Under a 4-organization flood, a quiet organization's p50 was 14.7 s and 34% of its requests got a 503 from the edge's shared shedder.
What changed. The edge now admits span ingest per organization: 8 in flight each, a 64 budget past which only organizations below their fair share get in, a 96 ceiling, and a fast 429 or 503 with Retry-After. It learns which organization a credential belongs to from the control plane's answer to an authenticated request, never from a header. The map holds at most 200,000 entries and forgets one after 10 minutes. The control plane also caps in-flight ingest per process, refusing the organizations that fill it, never a quiet one.
Result. The quiet organization's p50 was 0.61 s (p95 1.34 s) with no 503.
Load numbers.
Span ingest at 50 requests a second (about 74 spans each): p50 13.9 s and 2,871 refusals before; 0.48 s and 101 after. Langfuse scores were one ClickHouse insert each inside the request; now one write per batch.
At 4x overload: goodput 46.4 requests a second (capacity), p95 2.1 s, no client timeouts; before, 24 requests a second and 6,861 timeouts.
One control-plane process saturates near 3,600 to 3,800 spans/s, so 10x production (about 50,000 spans/s at peak) needs 18 to 20 ingest processes and a ClickHouse write group of at least 16 vCPU.
Reads at 1.2 million requests on the 1-vCPU preview: sessions, traces, scores and trace SQL meet the 2 s target; the Requests list does not (p95 2.8 to 9.1 s), nor does Helicone request/query (p95 6.64 s).
Production enablement. One outage serve-stale bound of 60 minutes in explabs/outage_bound.py, used by every path and pinned by a test. An availability endpoint, GET /api/orgs/{org}/observability/availability, so pages explain a missing feature instead of showing empty columns. One release variable list for the GitHub production and staging workflows. Every alarm root requires its topic.
Security retest. Three findings, all fixed: erasure now clears frozen Helicone webhook payloads when capture is turned off or content is deleted; webhook destinations are validated at create and capped at 50 per organization; the fixture script refuses hosted databases. Tenant isolation, read-scoped admin keys, do-not-store and trace SQL escapes held.
Full tables and the remaining limits are on the plan page under Load and scale, and Security.
Span ingest, before and after
Compare the rows: the same offered rate of 50 a second before and after the fixes, then a 4x overload. Watch the p50 and the refusals (503) columns.
Build
Offered/s
OK/s
p50
p95
503
Timeouts
Before (37d8b2ef4)
50
37.3
13.9 s
16.8 s
2,871
16
After the ingest fixes (1a9e27bf09)
50
48.0
0.48 s
1.45 s
101
0
After the ingest fixes, 4x overload
200
24.3
15.7 s
29.4 s
6,967
6,861
After edge admission (3ab24ef686), 4x overload
200
46.4
not reported
2.1 s
not reported
0
Fairness: a quiet organization during another's flood
Four organizations sent 150 requests a second; four quiet organizations sent 8. Before the fix, 34% of the quiet organizations' requests got a 503 from the edge's shared shedder.
Requests
OK
503
429
p50
p95
Quiet organizations, before
495
411
168
not reported
14.7 s
22.3 s
Quiet organizations, after
513
501
0
12
0.61 s
1.34 s
Flooding organizations, before
13,551
4,262
4,227
5,062
14.5 s
24.2 s
Flooding organizations, after
13,592
3,778
0
9,814 (fast)
0.51 s
1.18 s
Capture pipeline, before and after
Each row is one stage of the pipeline, how it behaved before, and after the fix.
Stage
Before
After
Langfuse scores
One ClickHouse insert per score (about 250 ms each), inside the request; 3,501 single-row inserts in 120 s; p50 13.9 s at 50 requests a second
One write per batch
ETL span throughput
About 56 spans/s (one write cycle per ingest request)
About 480 spans/s with grouped writes on short sessions; about 100 spans/s once sessions reached 30,000 spans; about 300 spans/s in the latest measurement
Grouped inserts
18 to 21 MB, refused by the ClickHouse ingress (16 MiB cap)
At most 5,000 spans and 4 MiB per group, configurable
Gateway captures during a span backlog
None stored from 22:33Z for over an hour (shared queue)
4.1 to 7.5 s in 13 of 13 probes with 2,500 to 4,000 span segments waiting (in-memory park). The park later filled and a capture waited over 3 minutes; now span segments have their own queue.
Session summary per write
2.8 to 3.1 million rows read, 21 to 64 s
About 37,000 rows read, p50 330 ms (folded from per-trace parts)
First rebuild of a big existing session
One 3.4 to 4.0 million-row statement, 103 to 126 s, past the 45 s timeout, retried on every write
Slices of 500 traces; the longest statement 3.3 s
Request text after a gateway call
87 to 170 s
18 s in 2 of 3 probes; the third took 86 s because the usage exporter itself lagged 43 s
Reads at 1.2 million requests
Target: p95 under 2 s for lists and under 1.5 s for detail views, measured on the busy 1-vCPU preview ClickHouse after the fixes above. Per-organization read quotas worked: 24 concurrent sorted-list readers in one organization got 402 refusals and 2 answers in 40 s, while a quiet organization kept reading (10 of 10), at p50 3.4 s instead of 1.1 s because the single core was full.
Read
p50 / p95
Verdict
Requests, default 24 h
2.54 / 2.84 s
Over
Requests, 30 days
2.35 / 2.91 s
Over
Requests, 30 days sorted by cost
5.86 / 9.08 s
Over
Requests, end-user filter
4.82 / 5.27 s
Over
Requests, session filter (7 days)
1.20 / 1.38 s
OK
Search 7 days
2.18 / 3.25 s
Over
Sessions 30 days, sorted by cost
1.09 / 1.67 s
OK
Session detail
1.21 / 1.48 s
OK
Traces 30 days and trace detail
0.81 / 0.91 s
OK
Scores
0.57 / 0.61 s
OK
Trace SQL
0.91 / 1.23 s
OK
Helicone request/query
4.25 / 6.64 s
Over
Helicone session/query
0.58 / 0.85 s
OK
November 22: the adversarial rounds
Where the day started. The build was correct in tests but untested at scale in many places, and the owner wanted maximum speed for search and everything else, deep load tests, and real comparisons of alternatives. So on November 22 a team of agents attacked the build in rounds.
Update, 2026-11-22. #2980 is now one commit, 2172de142f, on top of current main, with the customer docs on the new docs site. The secret scan flagged example values in the docs (none were real credentials); they were changed to obviously fake values. At 05:40 UTC, 32 checks pass, 2 are still running and none fail.
Still open: the owner's decisions; the Requests list speed (p95 2.8 to 9.1 s at 1.2 million rows; target 2 s); and a from-scratch rebuild of preview pr-902980 on the new head. Details are in the plan page, under Build status and Shipping.
How a round works. Each agent owns one area and works on its own branch. It measures a baseline, compares at least two designs with numbers, builds the winner with tests, and writes a report. The coordinator merges the branches into #2980, redeploys preview pr-902980, and the agents measure again. Production and staging are off limits; heavy load on the shared preview is announced first and kept under 10 minutes per run.
Eight agents attack the build in rounds. Each agent owns one area: search and reads, the gateway hot path, ingest and the capture pipeline, chaos (failures under load), security, web speed, UX and API clarity, and seed data.
Each round has the same steps:
measure a baseline;
compare at least two designs with numbers;
build the winner on its own branch;
the coordinator merges the branches into #2980 and redeploys preview pr-902980;
the agents measure again.
Round 1 numbers are local (the preview was being rebuilt), on a 1-vCPU ClickHouse sized like the preview's. Round 1 is deployed to the preview as e61892b57d; round 2 follows with a from-scratch rebuild.
The day ran in this order: round 1 locally; round 2 on the rebuilt preview; round 3 with the failure tests on the live preview (12:00 to 16:20 UTC); round 4 on the live preview (17:10 to 17:50 UTC); rounds 5 to 9 closing the wallet-outage gaps (17:50 to 19:20 UTC); rounds 10 and 11 on the gateway after that; and a completeness check at 22:00 to 22:30 UTC.
Round 1: measuring locally, and the first fixes
Round 1 ran on local machines while the preview was being rebuilt. The search numbers come from a test set of 50 million requests in one organization. Every agent found something; the biggest wins were in search and in the capture pipeline, where one design choice cost more than ten times the throughput.
Search. The request text table was laid out for writing, not for searching. Sorting it by day and time, with larger granules, lets a search read newest first and stop at a full page. Two real bugs also showed: a search with no filters named every request id in the window, and a quoted search did not match the exact phrase.
Gateway. Compared with main, the new request path halves median latency, because the per-request Postgres reads are gone. The limit of one worker is Python's GIL plus the engine's 4 bridge threads, not any store.
Capture pipeline. The loader split each segment's writes by API key, and every ClickHouse write costs about 0.2 s whatever its size. One write per segment, plus a group commit across workers, gave about twelve times the throughput.
Chaos. Failures under load found that span uploads broke in a Postgres outage, and that Responses continuations broke in an outage and, through a separate bug, in steady state. Three designs were compared for continuations; the table is in the bullets below.
Round 1: search and reads
Each row is one kind of read, its time before and after round 1, and the change that made the difference.
Read
Before
After
Change
30-day text search, 50M requests in one org
2.8 s for a phrase (1.2M rows)
100 to 210 ms
request_text sorted by day and time with 256 KiB granules; read newest first, stop at a full page
Search with filters, 50M rows
3.4 s
0.45 s
text checked batch by batch, inside each batch's time range
Search inside one small trace
549 ms
71 ms
bloom filter on trace id; trace search capped at 30 days
Requests list, key filter, 50M rows
4.9 s
0.75 s
filters applied first (PREWHERE); minmax indexes on sort columns
30-day sort by cost, 50M rows
540 ms
306 ms
removed a read cap that turned off ClickHouse's top-k granule skipping
Traces list
690 ms
15 ms
one merge per page
Postgres calls per Requests page
11 (320 to 480 ms)
2
two read-only functions; nothing per-org cached, so edits show on the next read
Bugs found: a search with no filters named every request id in the window (385 MiB read even with no match); a quoted search did not match the exact phrase. Both fixed. Two ClickHouse tables (not on main or production) were changed in place, so round 2 recreates the preview's ClickHouse.
Round 1: gateway hot path
Compared with main, the data plan halves median gateway latency (20 ms to 11 ms), because the per-request Postgres reads are gone. CPU per request is about the same (about 7 ms). A 5 MB prompt takes about 150 ms instead of 31 s.
One worker saturates at about 165 req/s. The limit is Python's GIL plus the engine's 4 bridge threads, not the wallet, Postgres or capture.
Fixes: a stuck wallet slot move no longer stalls every tenant on a worker (neighbors' median wait 1,188 ms to 0.5 ms); plan facts in 1 round trip instead of 3; no model built per request; about 10% less CPU and a 2 to 4 times lower p99.
Compared: the Lua wallet script beats WATCH/MULTI by 8 to 16 times; local credit leases rejected (they allow overspend); settle batching worth 9 times later, not needed yet.
Round 2: grant and limit caches move to 60 s with change-feed invalidation, so an edited limit still applies within 2 s.
Round 1: ingest and the capture pipeline
All runs used the preview's 1-vCPU ClickHouse. The After column gives the speed-up over Before in brackets.
Setup (1-vCPU ClickHouse)
Before
After
Empty table, big segments
405 spans/s
4,802 spans/s (11.9x)
Small segments
335 spans/s
4,214 spans/s (12.6x)
1.5M spans already stored
333 spans/s
2,074 to 2,143 spans/s (6.2 to 6.4x)
Cause. The loader split each segment's writes by API key, and every write costs about 0.2 s regardless of size.
What changed. Now one write per segment, plus a group commit across workers. Gateway captures are stored 16 at a time instead of one by one. Hostile payloads (2.3 MB body, 40 random keys, a 1,500-deep chain) all land within their caps.
Compared and rejected: ClickHouse async insert (4 to 27 times slower); protobuf over JSON (decode is under a tenth of the per-span cost); Kinesis over SQS (the queue carries only small notifications).
Found on the preview: the requests_history import, which every production org runs before the new table takes over, moves only 73 to 195 rows/s, and one day stalled 10 minutes in the trace cleanup. Lead cause: one delete per 1,000 touched traces with no trace-id index, and a failed delete grows the next batch. Round 2 fixes it.
Round 1: chaos (failures under load, local)
10-minute Postgres outage: 596 of 603 span uploads failed as bare 500s. Fixed: 0 of 181 in a rerun.
Wallet store stalled 5 s: money exact; every refusal now retryable (3 were 500s before).
ClickHouse down 3 minutes: 0 request errors.
Responses continuations during a Postgres outage: every one needed a full resend, and conversations started during the outage stayed broken after it. Designs compared: per-worker memory cache (58% locally, about 8% on 12 workers), shared outage spill in the Helicone cache cluster (95%), both (97%). Chosen: both, with purge on storage-off, ZDR, deletion and erasure; a per-org cap; a TTL equal to the 60-minute outage bound; and the explicit resend error as the fallback.
A steady-state bug: with the MemoryDB ledger and async content cleanup on, every continuation was dropped. Fixed (14 of 14 now succeed).
Preview limit: the preview's wallet runs on ElastiCache Serverless, not MemoryDB, so failover is simulated with network cuts.
Round 1: security
All 49 Helicone REST handlers blocked the control plane's event loop; one slow key could freeze every org on a pod (a fast request waited 2,028 ms; now 3 ms).
An auth-header trick let a tenant dodge its per-org ingest bucket and fill the edge's org cache; one client could hold all 8 shared admission slots. Both fixed.
Copying 1,000 items into a dataset: 23.1 s to 2.8 s, now bounded per org. Read-only admin keys no longer see score comments.
Round 2: every customer ClickHouse read must carry the per-org quota key.
Round 1: web speed and UX
Requests page JavaScript 176 KB to 83 KB gzip; the first table page streams with the HTML; setup reads run in parallel. The Data controls page's 5.1 s zero-data-retention read is cached for shared catalog data only.
UX: finding why a request failed goes from about 6 clicks to 2 (status badges filter); error classes in words; tag picker by name; empty tables offer the last 7 days; API errors name the fix (missing vs invalid key, which org a key belongs to). Main's documented /usage/requests parameters keep working, with tests proving identical rows, plus a deprecation notice.
Round 1: seed data
Every preview rebuild now seeds four extra orgs (a second tenant with storage off, a Pro ZDR org, a 1M-request org over 30 days, a sandbox), five role logins, about 70 real gateway calls and agent traces. On the preview the seed took about 32 minutes (the old history import ran first and slowly; round 2 runs the bulk first). Seeded logins now skip onboarding.
Every round-1 design comparison followed the same method. The gateway agent, for example, compared the Lua wallet script with WATCH/MULTI (the script won by 8 to 16 times), rejected local credit leases because they allow overspend, and measured settle batching (worth 9 times, but not needed yet). The ingest agent rejected ClickHouse async insert (4 to 27 times slower), protobuf over JSON (decode is under a tenth of the per-span cost) and Kinesis over SQS (the queue carries only small notifications).
Round 2: what the rebuilt preview showed (deployed as e00169bd7f)
Round 2 ran on the preview, with real pods, a real pooler and other agents' load. Problems appeared that no local test could show. The most serious: half of brand-new organizations failed their very first call, and one heavy organization could starve the others before any fault was injected.
New orgs failed their first call.
What we saw. About half of brand-new orgs got a 503 "account facts cannot be read" on their first request (16 of 30).
Why. Two causes, both from the data plan. The gateway's Postgres pool now sits idle for minutes, so the pooler closes connections silently. And the first-time load ran under a 0.75 s limit meant for single-row reads. Main is not affected the same way, because its pool stays busy.
Fix. A connection idle 30 s or more is checked before use, and every first-time load (key, org facts, wallet seed) gets 2 s and one retry after a lost connection. New alarms fire on slow or failed first loads.
Result. Through the real "Create key" route, 8 of 8 new keys succeeded on their first call (about 0.8 s, including OpenAI).
One heavy org starved everyone.
What we saw. In the wallet window, 60 req/s across 30 orgs made a light org fail 34 to 46% of its calls before any fault was injected.
Why. Per-org caps let 30 orgs hold all 4 engine slots first come first served; model listings took a slot; and the edge counted fairness per key, so 30 keys counted as 30 customers.
Fixes. A worker-wide fair admission budget (a freed slot goes to the org holding the fewest); listings never take a slot; and the edge now groups connections by organization through an opaque tag the worker returns (stripped both ways, never the org id).
The Postgres outage switch flapped. Per-request logging writes shared the request path's 4 connections, and the switch's check opened a fresh connection on a database at its connection limit. Fixes: logging writes use their own connection; the check keeps one warm connection of its own. Production has the same kind of limit (a shared session pool), so the fix is in code, not a bigger limit.
Live prompts were not searchable for 25+ minutes. The step that makes captured text searchable ran on one worker at about 2 tasks/s; other agents' load queued 3,248 tasks ahead, and 380 failed into the dead-letter queue. Fix: 8 workers with batched writes; a test shows a prompt behind 160 queued tasks becomes searchable in 3.4 s (16.6 s before). Dead-letter replay and an alarm are next.
History import 50x faster. The import every production org runs before the new requests table takes over moved 73 to 195 rows/s on the preview and stalled 10 minutes once. Each batch rebuilt summaries by reading the whole org. Now rows are written first and summaries rebuilt once per org with bounded statements: 9,957 rows/s locally; 1M rows in about 2 minutes, 10M in about 20 (was about 35 hours). A test proves the summaries equal the old method's; deleted orgs are never rebuilt.
Traces from storage-off orgs vanished. They were accepted and then dropped by the pipeline. Now they keep their structure and timing with no text; no text was ever stored.
Unknown storage header stored nothing.X-Explabs-Storage: full silently disabled storage. Now any unknown value is refused with an error naming the valid values.
Every customer ClickHouse read now counts against its org's quota, enforced by a test; signed-in users get a per-user read limit.
Web. Pages start their data reads on the server while the page is built (Data controls 2.31 s to 1.30 s, Sessions 4.1 s to 1.8 s locally); popups wait for idle; tables load the next page only when you scroll to the end, with Load more after 5 pages.
Search scales with threads. At 50M requests in one org: 30-day search 106 to 219 ms on 1 thread, 46 to 93 ms on 4; rare filters 0.75 to 1.2 s on 1 thread, 0.26 to 0.35 s on 4; 8 threads adds nothing. Recommendation: at least 4 vCPU per concurrent heavy reader, max_threads 4.
Found on main, outside the data plan. A sign-up refused because the mailbox already exists (plus-tag folding) shows a code step that never sends a code; the preview's admin seed leaves token columns NULL, which breaks the auth service's user list. Each gets its own small PR on main.
Round 3 and the failure tests on the live preview (12:00 to 16:20 UTC)
Round 3 broke things on purpose. The chaos agent cut the wallet store off, took ClickHouse down, and restarted Postgres eleven times, all under load, and checked that money stayed exact after each. A stand-in model (a mock provider) carried much of the test traffic, so the tests did not depend on a real model's budget.
The table gives the results. Every outage was survived with money exact. The fixes listed below it close the slow edges the tests found.
Test
Result
Wallet store cut off: three 10 s cuts and one 35 s cut, one gateway server deleted mid-cut (ElastiCache Serverless, new connections only)
Errors only inside the cuts, all retryable, none a server error. They stopped 2.5 s after recovery. Replacement server ready in 50 s. Money exact: 2,098 served calls = 2,098 rows, charges equal to what callers were told. With the stand-in model at 5 req/s, 2,715 of 3,000 served and every served call has exactly one request, attempt and usage row.
ClickHouse down 3 min 52 s
0 errors of 4,026 requests; money exact; every queue drained.
Postgres outage: 11 restarts, about 459 of 615 s unreachable, longest 74 s
0 errors on 3,060 stand-in-model requests and on span uploads; money exact (3,285 rows, 112,692,400 nano both ways). The database-outage signal fired for the whole outage. 45 continuations needed a resend: the documented preview gap (no shared conversation cache).
Captures during the outages
None lost. 335 requests waited for their pointer because their Postgres row arrived late (up to 9 minutes) during the outages; all were captured and stored, encrypted. Round 4 writes pending pointers in their own quick pass.
Ingest scale-out
One control server tops out at about 3,500 to 4,000 spans/s; three reach 13,146 (3.3x). Overload is refused fast, never a timeout. A 10-minute run at 120 req/s on three servers: 9,432 spans/s, p95 0.59 s, 0.5% fast refusals.
Live prompts searchable under that load
All 10 checks within 0.3 to 20.7 s. Before the round-2 and round-3 fixes, a prompt waited over 35 minutes.
New org's first call
8 of 8 succeeded through the real mint route (0.4 to 1.0 s); earlier today 16 of 30 failed.
What these tests found and fixed:
The capture pipeline used the customers' read limit. Its 8 workers were refused by the 2-per-org cap, and refused batches waited 5 minutes, so a 5,000-task backlog grew. Now the pipeline has its own read budget and a refused batch retries in 3 s.
A busy ClickHouse slows every page. With the preview's single CPU busy catching up, unchanged reads got about 2x slower. Decision: production customer reads get their own read-only ClickHouse compute.
Quiet servers failed the first requests after a lull. Connections the pooler had closed while idle were counted as a database outage. The round-2 check missed connections the pool opened by itself; round 4 covers them.
An unreachable wallet held requests up to 36 s and starved unrelated requests of admission slots. Round 4 fails fast: refuse for 2 s after a failure, bound each request's wallet wait to about 2 s, 0.5 s connect timeout (measured connect p99 85 ms).
The edge's org-fairness tag could be forged and its memory flooded. Both fixed; the tag is now an HMAC under the existing edge/worker signing key.
A wallet-ledger bug dropped why an answer was cut off. Fixed: the reason is recorded after the ledger write.
The ClickHouse quota change in round 2 would have broken the second production deploy (the Spend reader held the quota directly, so its plain check query was refused). Fixed with a Spend-only role.
A cold edge refused bursts from new keys behind one address for about 15 s. Round 4 lets the first request learn the key while its siblings wait up to 250 ms.
The preview's $5 real-model budget ran out. The relay holds the worst case per call and never refunds it. A small PR on main can settle each call to its real cost.
Round 4 on the live preview (17:10 to 17:50 UTC, build 771a91c317)
Round 4 re-ran the round-2 and round-3 checks on a build that carried their fixes. The table compares the two. It also found one new, serious problem: readiness depended on the wallet store.
Check
Round 2
Round 4
First requests after 28 idle minutes
4 x 503
0 errors
/v1/models during wallet cuts
25 x 429
0 errors of 90
Successful calls held over 3 s during cuts
45
11
Error type during cuts
429 to every organization
retryable 503 on wallet lanes only, p95 0.34 s
Money
exact
exact: 1,543 calls = 1,543 rows, charges equal to what callers were told
Failed request reason on a phone
1.8 to 3.9 s
0.81 to 0.84 s
CI on #2980
5 checks failing (round 3)
all 34 checks pass
New finding (high), fixed in round 5: a gateway worker reported itself not ready whenever the wallet store was unreachable. A wallet outage longer than about a minute would have taken every worker out of service, turning a wallet-only outage into a full one. Readiness no longer depends on the wallet store; wallet outages are contained per request by the breaker.
Read concurrency: letting 4 of a user's reads run at once instead of 2 saves about 1.7 s on a large org's Overview, but needs more than one ClickHouse core. It is now a setting (default 2); production sets 4 once customer reads have their own compute of 4 or more vCPU.
A round-3 CI catch: after a key rotation, servers kept the old model access for up to 60 s because of the longer access cache, so requests in that window failed. Fixed: the cache refreshes as soon as the revision a server serves changes.
The session detail slowdown, and the read limiter
On the preview, session detail went from 0.77 s in round 2 to 2 to 3.7 s. The search agent suspected the round-3 query change and tested it under preview-like conditions: a ClickHouse 26.6 container limited to 1 CPU and 2 GiB, holding 271,606 sessions in 477,795 rows, with a background writer holding the core at about 85%. All three variants return the same neighbors.
Table state, ms p50 / p95
A: round-2 one-step (2 reads)
B: round-3 two-step (2 reads, shipped)
C: one statement with shared keys (1 read)
unmerged, quiet
279 / 293
129 / 153
215 / 218
unmerged, about 85% busy
502 / 676
378 / 422
340 / 801
unmerged, busy, largest session
521 / 1,001
398 / 609
304 / 491
merged (after OPTIMIZE FINAL), quiet
76 / 89
75 / 124
101 / 109
merged, about 85% busy
189 / 286
111 / 187
306 / 409
What we learned. The round-3 two-step was not the regression; it is the fastest or about equal in every state, so nothing reverted. The slowdown came from what the page waited on: the preview was 2x slower on unchanged reads, and the organization's read cap was 2 standard reads shared by every user and key of that organization. The web agent and the search agent were reading the same organization in the same windows, so one page's reads queued behind the other's on one busy core.
One session page makes at most 3 or 4 ClickHouse reads at once; a test pins that a single page never meets the read limiter at the default cap. A refusal (the 429 seen at 17:15) needs a read to wait more than 4 s. The fix: the number of reads one actor runs at once is now a setting, EXPLABS_CLICKHOUSE_READS_RUNNING_PER_ACTOR (default 2, production 4, accepts 1 to 8, a wrong value fails the boot), and an organization's cap is never below one actor's.
New keys after a cold start, and capture visible in under 5 seconds
Cold start.
What we saw. 120 new keys, each sending 4 concurrent requests from one address, through a cold edge: only 8 of 480 succeeded; the rest got 429.
What changed. Requests of the same key now wait up to 250 ms for its first answer, then join the organization it taught.
Result. 480 of 480.
Guards kept. A flood of 200 random keys from one address still meets the cap of 2 untrusted places. Waiters are bounded at 1,000 per process. A 401 or 403 forgets the key at once. Only an authenticated answer refreshes an entry, so a revoked key never keeps its share.
Capture to visible. On an idle preview a capture took p50 4.3 s and p95 5.8 s to be stored. Most of that was the 2 s seal interval plus about 1 s waiting for the S3 notification. Two changes were modeled from measured stage timings (S3 notification 0.7 to 1.2 s, queue 33 ms, load p50 1.1 s and p95 2.8 s); the model reproduced the measured baseline (5.66 s against 5.8 s).
Seal
Announced by
Seal p95
p50
p95
2 s
S3 (before)
2.46 s
3.84 s
5.66 s
2 s
writer (a)
2.46 s
2.93 s
4.73 s
1 s
S3 (b)
1.30 s
3.02 s
4.75 s
1 s
writer (a+b, shipped)
1.30 s
2.10 s
3.82 s
Cost. Both changes together cost about $13 more per busy gateway pod a month (S3 and SQS at us-west-2 list prices: $9.08 before, $22.14 after), about $157 a month for 12 pods. Quiet traffic costs nothing extra.
How it ships. The direct announcement ships behind a switch, off by default. The S3 notification is kept as a backstop, and the ETL defers S3's copy for 30 s so the two copies do not double-load. It is not yet measured end to end (card 35).
Not pursued. Kinesis or Kafka instead of SQS: SQS's queue wait is 33 ms, so another transport cannot buy the seconds that matter.
The preview's model budget. The real preview model (preview-gpt-4.1-mini) stopped answering at 14:44:10Z: 649 attempts failed with 403 in 14 minutes. The preview relay holds the worst case for every call and never refunds it. A one-word request with max_tokens=1 holds $0.00082 against a real cost of about 150 times less; $5 over 1,366 calls is $0.0037 held per call against $0.000018 spent. Settling each call to its provider-reported cost would make $5 last about 277,000 calls instead of about 1,400 (card 33).
Rounds 5 to 9: closing the wallet-outage gaps (17:50 to 19:20 UTC)
Round 4 showed that a wallet outage was mostly contained, but not fully. Answers were still held back, unknown keys still waited, and readiness would pull every worker. Rounds 5 to 9 were one gateway agent working through those edges one at a time. The summary comes first; the round-by-round account follows.
Readiness no longer depends on the wallet store. In a 90 s wallet cut on the round-5 build, both gateway servers stayed in service throughout (184 samples, 0 not-ready, 0 restarts). Before, a cut over 60 s would have taken every server out of service.
A request never waits out a wallet outage. If a charge cannot be recorded within 2 s, the answer goes back to the caller and the charge is retried in the background for up to 5 minutes. The hold taken before the call stays until then, so an org can never overspend, and a retry can never charge twice. In the 90 s cut the slowest successful call took 0.36 s; money was exact after recovery (1,868 calls = 1,868 records).
Pending charges survive a server dying. Each charge waiting on the wallet is also written to Postgres (off the request path, only while the wallet is unreachable) and replayed exactly once by the balance-ledger worker; the request's own final record follows its charges, so usage records stay complete. Worst case before this: up to 64 unrecorded charges per server, about $0.30 to $32. An alarm fires if a saved charge waits over 10 minutes.
No customer request is the outage test. A background ping checks the wallet store every second during an outage; unknown-key checks and the model list stop waiting after 0.5 s. A structural test fails if any gateway code connects to the wallet store outside the one shared, protected client.
Found by the CI agent: after a key rotation, the longer access cache kept old model access for up to 60 s (fixed), and a tool span could be renamed to the generic "tool" when its result arrived in a later batch (fixed; a real customer-visible bug).
flowchart LR
R["Request on a wallet lane"] --> B{"Wallet breaker"}
B -->|"closed"| W[("MemoryDB wallet")]
B -->|"open"| F["Fast retryable 503 within about 0.5 s"]
PR["Prober thread pings every 1 s"] -.->|"closes the breaker when the store answers"| B
W -->|"settle cannot land in 2 s"| D["Answer sent anyway; settle deferred"]
D --> Q["In-memory queue retries up to 5 min"]
D --> SP[("Postgres spool durable copy")]
Q -->|"lands once"| W
SP -->|"replay after 60 s, if the worker died"| RL["Balance-ledger worker"] --> W
How a wallet outage is contained after round 11. The hold taken before the call stays until its settle lands, so an organization cannot overspend, and a settle that lands twice is a no-op, so nobody is charged twice.
Round 5: readiness, unknown keys, and settles that held the answer
What we saw on the round-4 build: in a cut, readiness turned "not ready" after 3.6 s; some served requests finished 12 to 15 s late; an unknown key's 401 took about 4.5 s.
Why. The readiness probe pinged MemoryDB through the wallet's client and paid its synchronous cluster rediscovery (3.6 s); a cut over the probe's 60 s failure window would have pulled every worker. The engine answers a non-streaming request only after its settle returns, and the settle retried for up to 15 s on the request's thread. The "minted in the last five minutes" check for unknown keys was not behind the breaker and used redis-py's default 10 retries.
What changed. Three things:
Readiness is now the catalog, the lane lifecycle and the key filter, nothing else.
One MemoryDB breaker is shared by the limiter, the wallet, the policy cache and the recent-mint check. The recent-mint check now makes no retries and gives an unknown key the retryable 503 at once (without MemoryDB a filter miss cannot tell a key minted a second ago from a random one).
A settle now holds its request at most 2 s. After that, a queue (one thread, bounded at 50,000) retries the same settle and receipt for up to 5 minutes.
Why a background settle is safe. The hold taken before dispatch stays until the settle lands, so the available balance is only ever lower in the meantime. The settle script is a no-op on a hold that is no longer held, so a retry never debits twice. A settle that never lands leaves its hold to the existing forfeit sweeper: nothing charged, a visible forfeit receipt.
Round 6: keeping the usage record complete
What we found. A failed attempt whose settle was deferred, followed by the request's failure terminal, put the terminal in the receipt stream first. The writeback finalizes a request's usage event once, so the event missed that attempt. Money was right; the record was not.
Designs compared. Re-finalizing in SQL when a late attempt row lands would mean reversing and rewriting the usage event, its rollups and its ClickHouse outbox payload inside a hot money function. Keeping the order at the source needs no SQL change. The second won: a request's terminal waits in the queue behind its own deferred attempts, never another request's.
The worst case of an in-memory queue. A deferred settle is lost only if the worker dies during the outage. Each worker admits at most 64 requests, so at most 64 pending settles per worker: about $0.32 to $3.20 at a mean charge of $0.005 to $0.05, and up to about $32 if all 64 were $0.50 long-context calls. The old design forfeited every in-flight settle of any outage over 15 s, with no worker death needed, so the new one never loses more.
Rounds 7 and 8: a durable spool for deferred settles
To make a worker's death cost nothing, each deferred settle now also gets a durable copy in Postgres (balance_ledger_spooled_settles):
It is written on the queue's thread, never the request's, under the request-path bounds (0.5 s checkout, 0.75 s statement).
If Postgres is also down, the settle stays in memory only, as before.
The balance-ledger worker replays rows older than 60 s, oldest first, 200 per pass, every 15 s. An alarm fires when the oldest row passes 600 s.
Round 8 spooled the request's own terminal record too, with a rule in SQL that a terminal is never replayed while any settle of its request is still spooled.
Tests. On a real Redis cluster a worker deferred and spooled three settles in a cut, then died; the replay landed all four (one had landed from the live queue), each charged exactly once, and replaying again changed nothing. pgTAP: 22 of 22 on pr-902980 in a rolled-back transaction. The two migrations were folded into one before either reached main. Cost: one insert and one delete per deferred settle, nothing while MemoryDB is healthy.
Round 9: no request is ever the test call
What we saw in a 90 s cut on the round-5 build: readiness held, no success was held and money was exact, but 18 of 20 unknown keys took 4.2 to 4.9 s, and 4 of 97 model listings took 4.8 to 7.8 s.
Why. After each 2 s open period, the breaker let one call through to test the store. At the low request rates of these paths, that call was nearly always a customer request, and it paid the dead store's read timeout plus a cluster rediscovery that dials every node; a security-group cut drops those connection attempts. That is 4 to 8 s.
What changed. A background prober pings MemoryDB every 1 s while the breaker is open, and only its success closes the breaker, so every request during an outage is refused at once. Request-facing reads (the unknown-key check, the listing's deny-set read) run on a separate small thread pool with a 0.5 s budget. One function builds every gateway MemoryDB client, and a structural test fails any code that builds one elsewhere.
Read during a stall
Round 8b
Round 9
Unknown-key check, preview 90 s cut
4.2 to 4.9 s
bounded at 0.5 s
Listing deny read, preview 90 s cut
up to 7.8 s
bounded at 0.5 s
Unknown-key check, local SIGSTOP
max 754 ms
max 502 ms
Listing deny read, local SIGSTOP
max 3 ms (SIGSTOP accepts connects, so the rediscovery cost does not reproduce locally)
max 506 ms
Rounds 10 and 11: booting during an outage, and the last slow calls
Round 10, a worker that starts during a wallet outage.
Problem. The limiter's boot check raised on any failure, and the wallet's client discovered the cluster in its constructor, so a worker could not start while MemoryDB was out.
What changed. Clients now connect on first use, inside the breaker. The boot check logs, leaves the breaker open and retries every 5 s. Readiness, which no longer asks MemoryDB, lets the pod serve everything that does not need the wallet.
Kept. A refusal from a reachable store (a permissions error) still stops the boot, because that is a configuration error.
Bring-your-own-key calls are not served in a wallet outage. Even a zero-cost call places a hold, which runs the ban and revoke check and carries the record that lands the request in Postgres. Serving them would need a second path; that is card 36.
Listings outside cuts. Measured on the preview from a laptop: an invalid-key 401 took 86 ms at p50, a listing 50 ms after another 80 ms, but a listing after 0.5 to 6 s idle 210 to 360 ms (max 1.1 s). Two refresher paths replaced the listing's memo inputs even when nothing changed, forcing a re-plan of about 820 routes; both now skip equal rows. That was not proven to be the whole cause, so two timing log lines were added to split a slow listing.
An unknown-key 503 with the wallet up. Three paths could answer it. A private 1 s backoff beside the breaker could refuse every unknown key for a second after one slow read; it is gone. The client was built inside the first unknown key's check; it is now built at boot. The remaining causes now log a reason. Two log fields from rounds 7 and 8 were not in the log schema and were renamed.
Round 11, the forced-kill run. On build b14d6afd6d the spool proof passed and a worker booted during the outage with 0 restarts.
Money was exact. The plan page records the forced-kill result: each attempt was charged exactly once. There were 3,766 attempts, 3,766 settle receipts and 135,576,000 nano-USD, and the wallet equalled Postgres, which equalled what callers were told. The spool emptied under 7 s after recovery.
Speed was not. Two spooled requests answered after 6.8 and 9.3 s despite the 2 s bound, a listing took 2.45 s, one got a 429, and an unknown key took 1.48 s.
Why. A hot wallet call that found the cut ran on the caller's own thread and paid the read timeout plus the rediscovery, seconds per call. The settle's 2 s bound was checked only between tries. And slow wallet calls held the engine's 4 bridge threads, which listings also need.
The fix. Every wallet, limiter and promotion-policy call runs on its own 32-thread lane with a 0.5 s budget, at a cost of about 11 microseconds per call. Two tests pin it: a reserve under a 5 s hang answers in under 0.7 s, and a settle gives up in under 2.3 s. Both fail on the old code.
Case
Before round 11
Expected now
A spooled (deferred) request's answer
6.8 to 9.3 s
2 s defer bound plus about 0.5 s at most
Listing
up to 2.45 s
its own work plus at most one 0.5 s bridge wait
Unknown keys
up to 1.48 s
same as listings
A listing can still pass 0.6 s if every bridge thread is held at the moment of the cut. Cutting that further would mean serving GET /v1/models without a bridge permit, an engine change proposed only if the next measurement still misses.
The completeness check (22:00 to 22:30 UTC, preview build 16fa66ead2)
The last pass of the day asked a different question: is everything the plan promised for Observability actually built, wired into a page, documented in English and Japanese, and working on the preview? It matched 40 planned capabilities with a light API sweep of about 45 calls and a code reading.
Result. Almost everything is built, wired, documented and working. Measured on the preview:
the Requests list: 1.3 s cold and 0.4 s warm;
request detail 210 ms, body 1.0 s;
session list 774 ms, detail 505 ms, skeleton 884 ms, turns 1.9 s (slow for a 4-request session);
an OTLP span visible in its trace and session within 45 s;
dataset export 2.3 s for 10 items.
Search matched whole words, quoted phrases and joined terms such as INV-20391. It has no prefix match (Lisb finds nothing), now documented as "How search matches".
Gaps.
"Proxy traffic" on the Requests page is local capture (exp capture on a customer's machine), not the Helicone proxy hosts. It is platform-admin only, and its data, like trace uploads and Langfuse and Braintrust pulls, lands in the legacy trace_spans table, so it never reaches Requests, Sessions or Traces. (Fixed and verified in Round 12.)
No traces list page, no trace SQL screen, and no per-user totals page or tag-key picker (both needed before Helicone's /users and /properties links can redirect to ours).
Docs gaps: the own-use archive opt-in, and the Helicone SDK log endpoints.
Media and Decisions capture wait on an engine release.
These became card 37 in Part 7.
Round 12: page speed, new routes, and why uploads never arrived
Page speed. The conversation view now shows its first turn 40 to 77 ms after the click (target under 1 s; it was 1.3 to 1.7 s), with a layout shift of 0 on the demo org and 0.0078 on Atlas. The session page is back near its baseline: Atlas 1.0 s against 0.98 s, and the demo org's median about 1.0 s against 0.81 s. The slower back-to-back reloads on the demo org come from the preview's cap of 2 ClickHouse reads at a time per viewer; production plans 4. The tag filter and the Users view were verified live.
New routes. A per-upload DELETE route: it answers 404 for another organization's upload or a malformed id and 202 for the caller's own, and afterwards the receipt and the stored file are gone and erasure of the upload's spans is queued. And a new admin read, GET /api/admin/background-jobs, that shows the background jobs and the settings they run with.
The upload experiment.
Problem. Round 11 sent uploads, exp capture batches and the Langfuse and Braintrust pulls through the same span sink as OTLP. On the preview, uploads were accepted but never reached Observability.
How we looked. The new background-jobs read showed that the control pods did not have CLICKHOUSE_TRACE_PROJECTION_ENABLED. Main's deploy script gives that setting only to the Project worker; #2980 moves trace projection to the control plane, but its deploy-script change never reached the preview.
What changed. The gate is dropped. The projection loop starts wherever the observability store and the span sink exist, so it no longer depends on a setting the deploy may or may not give.
Production note. Segment capture is off in production, so there is no span sink there. Uploads and exp capture batches wait in their queue (they are not lost) until segments are switched on.
Verified on the preview (79479dfd80, 01:35 to 01:42 UTC). The background-jobs read showed trace projection "started" on the control pod. The 4 waiting uploads were processed when the pod started: the exp capture file on its first attempt, and two agent traces after 3 attempts each while the pod was starting (the cause is not yet read from the logs). The sessions and traces APIs answered 200. The demo agent trace shows the agent, then an LLM call (gpt-6-luna, 42 tokens in, 7 out), then the tool execute_tool lookup_refund, with the tree intact. The exp capture trace is one LLM span, and the Northwind copy landed in its own organization.
Storage controls hold. Northwind has capture off, and its stored batch has content_stripped true: no prompt and no tool arguments or result, while the model and token counts are kept. The demo org's batches keep their content.
Deleting a processed upload. The route answered 202. The trace answered 404 after 12 s, then the session did too. The receipt, the stored object and the deletion job were gone. The deletion worker takes one job per pass, so 3 deletions took about 2 minutes. All test data was deleted afterwards and every admin key minted for the test was revoked.
Still open, not blocking. The 3 retries at pod start deserve a look in the logs, and the name "Local capture" and who sees it are still an open UX decision (card 37).
What it led to. If one setting from the PR's deploy script was missing, others could be too. That question became the audit in the next section.
What the preview could and could not test
How the isolated preview works. A preview is put together from three sources:
The controller comes from main. The controller is the trusted program that creates the preview's cloud resources. It runs main's code, because only reviewed code may run with its credentials.
The images come from the PR. Python, the web app, the Rust engine, and the ClickHouse and Postgres migrations are all built from #2980's head.
The deploy layout comes from main. Which apps exist, how many instances each runs and which settings each gets is decided by main's scripts/porter/deploy_porter_apps.sh, main's helper scripts and main's preview provisioners. Two seed scripts are the exception: the Supabase seed and the observability fixture run from the PR's head.
So every preview round ran #2980's code on main's layout. Where #2980 changes the layout itself, in scripts/porter/ and scripts/preview/controller.py, the change never reached the preview.
How we found out. Uploads never reached Observability, and the admin background-jobs read showed the projection setting missing from the control pods (Round 12). An audit then compared main's deploy tooling with the PR's, line by line, and sorted every claim in the rounds, the decision logs and both reports.
What it means for earlier results. The audit sorted 172 claim rows into three classes. The same claim can appear in more than one source.
Class
Rows
Meaning
Key examples
A. Still valid
103
Depends only on image code, or on parts main already deploys: segment capture, the preview capture ETL, the MemoryDB ledger with its writeback service inside the control app, the two-worker gateway fleet, the tag and dataset workers, and Helicone host routing.
Wallet cut behavior (errors only inside cuts, readiness held, workers booting during a cut). The restart rehearsals. Search, read and page speeds. The UX walk and the security retest. Capture to stored on the S3-notification path, p50 4.3 s and p95 5.8 s.
B. Not yet proven on the PR's layout
46
Depends on a deploy or controller change that only #2980 makes.
The background units, the dashboard edge, the writeback app and queue-age autoscaling never ran; the settle drain and usage export ran inside the control servers, so "every queue drained", the exporter lag of 2 to 43 s and "searchable under 21 s" describe main's layout. Helicone webhook delivery ran nowhere, and the separate Helicone response cache was never provisioned. Direct announce never ran: p50 2.10 s and p95 3.82 s are a model, and the measured S3-notification path is p95 5.8 s. The 3,900 s startup budget never applied (main's check allows about 5 minutes). Upload projection on the control plane did not run before round 12; it has since been verified on the preview at 79479dfd80. Ingest speed and fairness were measured on main's shared /v1 edge.
C. Valid only because of a hand-applied step
23
The preview was changed by hand for the test.
The control plane scaled to three servers with kubectl scale for the ingest step-up (13,146 spans/s). The stand-in model lane built with kubectl and aws, which every money-exact count on that lane depends on. Hand SQL: a dead-lane rung, orgs marked verified, onboarding stamps. 1.2 million request rows inserted by hand for the read tests. The node pool cap raised by hand. pgTAP run by hand in rolled-back transactions.
Deliberate fault injection (security-group cuts, pod kills, Postgres restarts) is the experiment itself, so it does not count as a hand step. Two corrections came out of reading the code: the control plane's database pool bound of 32 is the image's own default, so those claims are A; and turning off the control plane's queue workers moves only the settle drain and the usage export, not erasure or trace projection.
The options.
(a) Land the controller and deploy-script changes on main first, each opt-in and off by default, as AGENTS.md requires for a new deploy prerequisite. Then redeploy pr-902980 and re-run the B claims. This is the recommendation: it keeps the trust boundary and proves the layout before #2980 merges.
(b) A preview mode that deploys with the PR head's scripts. It proves the exact layout in one step, but unreviewed code would run with the controller's credentials, so it needs the owner's sign-off.
(c) Prove it on staging after merge, switching each unit on there. The proof comes later and costs a staging rehearsal round.
Whichever option is chosen, the C steps get replaced: the control instance count set in the deploy, the stand-in model lane provisioned through the controller, and test data loaded through the fixture. This is card 38 in Part 7.
November 23: can we move off Helicone?
The question. Does #2980 let us turn off Helicone's own infrastructure? Two read-only checks answered it: a code audit of main and the #2980 branch, and a live inventory of our AWS, Porter, Supabase, ClickHouse and DNS.
Answer: not yet. #2980 builds a Helicone-compatible layer on our platform. Helicone's own services (worker, jawn, US and EU databases, the S3 body bucket, the dashboard) must keep running after it lands, because unserved traffic is forwarded byte for byte to Helicone US, EU stays on Helicone, and prompts, webhook configurations, org members, stored provider keys, and scores and feedback have no importer.
Our side runs nothing Helicone-related today. All Helicone code is only on the #2980 branch; there is no app, AWS resource, table, DNS record or cost tag ($0 a month), and the Helicone cache cluster was never created (roughly $300 to $700 a month per shard pair if built). So moving off Helicone is a merge-and-cut-over decision on #2980, not a teardown of our own infrastructure.
Helicone's stack is in Helicone's accounts.api.helicone.ai points at Helicone's own jawn-prod-blue-green load balancer. Nobody here can read those accounts, so their size, traffic and cost are unknown.
Nothing can show it is safe to turn off. The edge counts neither forwarded requests nor 421s, and the worker's header counters are never emitted.
The path. Owner decisions, then read access to Helicone's accounts, then the missing importers and forwarded-traffic metrics, then deploy #2980 and move hosts one at a time, then turn off Helicone US once forwarded traffic is measured at zero (then EU), and delete Helicone data last. The plan page has the full account, under "Moving off Helicone: where it stands". docs/helicone-move.md points to a decision log, /tmp/obs-build/decisions/helicone.md, that does not exist.
Part 6
Where it stands now
The state at the end of 2026-11-22: what is built, what the numbers are, what is still open, and how big production needs to be.
Build state
One pull request. Everything is in GitHub #2980 (branch obs-data-plan). Its head is 79479dfd80 (round 12). At 16fa66ead2 it changed 1,453 files against main, added about 241,600 lines and added 72 Postgres migrations. It was built by 14 parallel workstreams, each in its own worktree with fixed file ownership and a decision log; the logs are in platform-build-decisions.html.
Merged nowhere yet. "Merged" on this page means merged into the PR branch. Nothing of #2980 is on main, and nothing runs in staging or production. It keeps do-not-merge until the owner approves it.
CI. At 05:40 UTC on 2026-11-22, with #2980 as one commit (2172de142f), 32 checks passed, 2 were running and none failed. Round 4's CI was fully green (all 34 checks). Every check passed on f7cd3b5bbe (31 checks). The later heads pass every check that has finished; on 79479dfd80 CI is still finishing, with the integration tests last. GitHub reports #2980 as mergeable with main.
Preview. pr-902980 runs 79479dfd80, with all twelve rounds. The wallet, ClickHouse and Postgres failure tests passed there with money exact every time.
Waiting outside the PR. The engine change for media and Decisions capture is engine PR experientiallabs/experiential#1412 (not merged, not released). It is opt-in: the pin bump alone changes nothing. Several small main PRs let the preview run the branch: #3133, #3145, #3175, #3176, #3243, #3248 and #3252 (#3238 was closed as a duplicate).
Results, before and after
The table collects the headline numbers from every phase. "Local" means a developer machine or test cluster; "preview" means pr-902980, whose 1-CPU ClickHouse makes its read numbers a lower bound for production.
Preview figures ran #2980's code on main's deploy layout. Some of them, such as the 3.3x ingest scale-out, the 21 s search time and the 3.82 s capture model, are not yet proven on the PR's layout or needed a hand-applied step; What the preview could and could not test lists which.
Area
Before
After
Where
30-day search, 50M requests in one org
2.8 s (phrase, 1.2M rows)
100 to 210 ms on 1 thread; 46 to 93 ms on 4
local
Search with filters, 50M rows
3.4 s
0.45 s
local
Search inside one trace
549 ms
71 ms
local
Requests list, key filter, 50M rows
4.9 s
0.75 s on 1 thread; 0.26 to 0.35 s on 4
local
Traces list
690 ms
15 ms
local
Postgres calls per Requests page
11 to 14
2
local
Request drawer
14 database calls, 403 ms
4 calls, 293 ms
preview
Capture pipeline, spans/s on 1 ClickHouse CPU
about 400
about 4,800 (empty) / 2,100 (1.5M stored)
local
Session summary per write
2.8 to 3.1M rows, 21 to 64 s
about 37,000 rows, p50 330 ms
preview
History import per production org
73 to 195 rows/s
about 10,000 rows/s; 10M rows in about 20 min (was about 35 hours)
preview, then local
Live prompt searchable, with a backlog
25+ min
3.4 s in the test
preview, then local
Live prompt searchable under 120 req/s
35+ min (morning)
under 21 s, 10 of 10 checks
preview
Capture to stored, idle
p50 4.3 s, p95 5.8 s
modeled p50 2.10 s, p95 3.82 s (not yet measured end to end)
preview, model
Span ingest at 50 req/s
p50 13.9 s, 2,871 refusals
p50 0.48 s, 101 refusals
preview
Span ingest at 4x overload
24.3 req/s, 6,861 timeouts
46.4 req/s (capacity), 0 timeouts
preview
Trace ingest, 1 vs 3 control servers
4,029 spans/s
13,146 spans/s (3.3x)
preview
Quiet organization during another's flood
p50 14.7 s, 34% got 503
p50 0.61 s, no 503
preview
New keys after a cold edge (120 keys x 4)
8 of 480
480 of 480
local
Median gateway latency vs main
20 ms (main)
11 ms; a 5 MB prompt about 150 ms instead of 31 s
local
New org's first call
16 of 30 failed
8 of 8 succeeded through the real mint route (0.4 to 1.0 s)
preview
Postgres down 10 minutes
746 errors of 3,956
0 of 3,956; money exact
local
Postgres outage, 11 restarts, 459 of 615 s unreachable
n/a
0 errors on 3,060 requests; money exact
preview
Wallet store cut off
4 server errors; 34 to 46% failing before any cut
0 server errors; errors only inside cuts, all retryable, p95 0.34 s; money exact
preview
90 s wallet cut
a cut over about 60 s would take every worker out of service
0 not-ready in 184 samples, 0 restarts; slowest success 0.36 s; 1,868 calls = 1,868 records
preview
Worker killed holding spooled charges
up to 64 charges per worker lost (about $0.30 to $32)
3,766 attempts, 3,766 receipts, charged exactly once; spool empty under 7 s after recovery
preview
ClickHouse down 3 min 52 s
n/a
0 errors of 4,026 requests; every queue drained
preview
Managed MemoryDB failover (real MemoryDB)
n/a
every organization refused for 14.1 s (14 to 15.5 s in two runs); no money lost
AWS
Data controls page, first data
2.31 s
1.30 s
local
Requests page JavaScript
176 KB gzip
83 KB gzip
local
Session, trace, API Keys pages (desktop, warm)
1.57 s, 1.59 s, 1.25 s
1.18 s, 0.70 s, 0.55 s
preview
A failed request's reason on a phone
1.8 to 3.9 s
0.81 to 0.84 s
preview
Finding why a request failed
5 to 6 clicks
2 clicks
preview
Tag starvation guard (customers asking 100 judge calls/s)
our review held 6.9/s
24.0/s
local
Clef judge 503s
0.55% (112 of 20,077 in 30 min)
0 of 22,780
production VM
Earlier, on 5 million requests in one org on a 16-core ClickHouse, the reads measured: first page 47 ms median, cost sort 681 ms, a 5,000-request session 124 ms, search 128 to 543 ms, session list 38 ms. In the browser a 5,000-request session draws in 186 to 228 ms (1.4 s at 4x slower CPU and 50 Mbit/s), and first rows show in 241 to 410 ms.
Remaining gaps
The Requests list at large scale. This is the biggest open performance item. At 1.2 million rows on the busy 1-vCPU preview it measured p95 2.8 to 9.1 s against a 2 s target (ClickHouse alone: p50 1.02 s, p95 5.39 s, plus 13 Postgres calls, about 0.8 s). It still reads the old usage events beside the new table until the history backfill stamps the environment. The follow-up run stopped on 2026-11-21 while waiting for the backfill and produced no result; the test has not been re-run since the round fixes. Helicone request/query is also over target (p95 6.64 s).
The PR's deploy layout. The background units, the dashboard edge, the writeback app and queue-age autoscaling, Helicone webhook delivery and the separate Helicone response cache, direct announce, and the 3,900 s startup budget have not run anywhere (What the preview could and could not test, card 38). Uploads and exp capture batches wait in their queue in production until segment capture is switched on there.
Ingest and the pipeline.
One ingest process saturates near 3,600 to 3,800 spans/s (about 200 microseconds a span). The fair cap refuses fast, but cannot stop queueing in front of admission; the fix is more processes.
A write that touches many traces of one huge session still reads most of that session; a per-session write lane would isolate it.
The tail of the text delay is the usage exporter's own lag (2 to 43 s); a notification from the exporter would remove the polling.
Hostile payloads (2.3 MB bodies, 40 random attribute keys, a 1,500-deep span chain) were accepted as designed, but their landing in ClickHouse was not observed during the load run.
The raw consumer was being taught to forward control messages that reach the wrong queue. Dead-letter replay and an alarm for the text step were next.
The 1 s seal and direct announcement are modeled, not yet measured end to end.
Restarts and outages.
Not yet run: a 10-minute cut on production-sized data, and the MemoryDB failover game day (its script is allowed only against staging, and the preview's ElastiCache Serverless cannot answer the failover question). Rehearsals so far: 41 to 70 s cuts, 11 restarts with 525 of 604 s down, all on a small preview database.
Protected chains were tested only locally (flow 12); the preview has none, and flow 12 is not in CI. One protected request in flight at the cut waited 30 s before its retryable 503.
No read replica exists in any environment, so replica routing is untested against one, and dashboard pages error during a restart.
Responses continuations: the shared spill needs the Helicone cache cluster, which previews lack (card 27); 45 continuations needed a resend in the preview outage test.
From failure injection: the segment directory is lost on pod restart; contract traffic is admitted during a long S3 outage; a pod with uncertain facts can over-grant promotions; the reconnect stampede.
From round 9: the first hot wallet call of a cut still pays one failing call before the breaker opens.
Both stores down at once plus a worker death: the old forfeit path still applies (accepted).
The money and chaos attacks have not been re-run against every fix.
Product. Local capture, trace uploads and connector pulls now reach Observability (verified in round 12), but the "Local capture" name and who sees it are still open (card 37); there is no traces list page and no trace SQL screen; session and tree previews are not built; media and Decisions content waits on the engine release; Helicone members cannot sign in yet, and full Helicone bodies are not copied (32 KB of text per request); session turns take 1.9 s and dataset export 2.3 s for small inputs. Two docs gaps remain (archive opt-in, Helicone SDK endpoints).
On main, outside the data plan. A sign-up refused because the mailbox already exists (plus-tag folding) shows a code step that never sends a code; the preview's admin seed leaves token columns NULL; Next.js 16.4.1 has 7 moderate advisories. Each gets its own small PR (card 32). The Clef pool's dead U.S. replica (18170) still needs an owner.
Sizing for production
Production today averages about 50 gateway requests a second, roughly 500 at peak. The load test sized each stage for ten times that: at an assumed 10 customer spans per gateway request, about 50,000 spans a second at peak, or about 700 ingest requests a second.
Stage
Measured unit cost
Need at 10x peak
Recommendation
Span ingest (control plane)
About 3,700 spans/s per Python process
50,000 spans/s
Its own deployment, 18 to 20 processes at peak, autoscaled on CPU. Recompute the per-organization limits as fleet-wide numbers, because they are per process.
Edge relay
About 1 CPU at 200 requests a second with 50 KB bodies
About 700 requests a second
4 or more edge pods for ingest, or route ingest from the ingress straight to the ingest deployment.
Capture ETL span writes
480 spans/s per writer on short sessions; about 100 spans/s at 30,000-span sessions (before session parts)
5,000 to 50,000 spans/s
Session parts first (done), then more tasks, since each task has one writer: 10 to 100 tasks on a sized write group.
ClickHouse write group
1 vCPU: about 480 spans/s with about 60% of the core in merges
50,000 spans/s
A separate write compute group of at least 16 vCPU.
Queues
One queue for all sources (at the time of the test)
Separate control queue (done 2026-11-21) and an alarm on the oldest message age per source.
Reads
Requests list p95 5.4 s at 1 million rows on a busy 1-vCPU ClickHouse
About 50 million rows per large organization
Run the history backfill and stamp it (drops the union), use the read compute group, run totals beside the page, cut the 13 Postgres calls, and re-measure on production-size compute.
Customer reads get their own ClickHouse compute. On the preview, the capture pipeline catching up after the failure tests used 979 of 1,000 millicores, and every customer read slowed about 2x (the 30-day Requests page 552 to 995 ms). In production, customer reads go to their own read-only compute group, sized at least 4 vCPU per concurrent heavy reader, with max_threads 4 (8 threads adds nothing), and EXPLABS_CLICKHOUSE_READS_RUNNING_PER_ACTOR=4. A cost-sorted copy of the requests table was tested and rejected (13% more write time, 25% more disk, and the default view got 2x slower).
Gateway workers. One worker saturates at about 165 req/s (Python's single core plus the engine's 4 bridge threads), so the worker count follows peak request rate.
Wallet. One MemoryDB shard (one primary, two replicas) costs about $946 a month and holds all 64 slots. The receipt streams are budgeted at 4.8 GB (a 60-minute outage at 150 req/s with 4,460-byte receipts). Finished-charge records at 10x traffic would be about 52 of the wallet's 102 GB if kept 24 hours. Cards 9 and 10 decide shards and that window.
Cost of the new capture path. Batched segments cut the new S3 and SQS bill from about $3.5k a month to about $0.7k; the plan's target is about $1k a month for S3, SQS and Fargate at today's volume.
Steps that would touch staging or production, listed so nothing is lost; none run while the work stays in the preview: Terraform applies for trace storage, trace tags, the control-plane role, the audit archive and the Helicone cache cluster; alarm wiring; a read-only ClickHouse compute group and the per-environment backfills; checking the read replica's statement timeout; turning on EXPLABS_CAPTURE_DIRECT_ANNOUNCE with defer_s3_notifications after infra/traces is applied. Before each switch, confirm its alarms have an action.
Part 7
Decisions
Every decision still open, then the ones already made. The numbers and letters match the cards on the plan page.
Open decisions
Each card says what is being decided, what the code does today, the options and their trade-offs, and a recommendation. Cards marked Confirm are ones where the owner gave an answer that we read one way and need confirmed. Cards marked Your call need a decision. Decisions 3, 4, 5, 9, 10, 13 and 14 are built with a provisional default so the code could move forward; the owner asked for more information on them and has not decided them. #2980 stays do-not-merge until they are answered.
Nothing here runs in staging or production while the decisions are open.
Simplifications proposed by the November 20 plan review
Your call · A
One capture destination
Today. Capture can write three ways: inline into Postgres (production's default), segments (pod disk, then S3, then the ETL into ClickHouse), and a mirror state that writes both and gates reads. Every capture feature is tested three ways, and the read gate caused two bugs on the preview that week.
Proposal. Once segments run in an environment, make it the only mode there and delete inline and the mirror.
Trade-off. Segments depend on S3, SQS and the ETL being up (the pod disk buffers up to 2 GiB when they are not), while inline needs only Postgres; but inline keeps capture load on the Postgres the plan is moving off.
Recommendation: yes, after segments are proven in production.
Your call · B
Fold the new background apps into one
Today. The plan adds about five Porter apps (wallet writeback, trace-tag worker, dataset-run worker, Helicone webhooks, deploy units), each with its own spec, readiness check, alarms, CPU booking and place in the release order.
Proposal. One background app runs several worker processes.
Trade-off. Fewer things to deploy and watch, but you lose per-worker scaling on queue backlog and per-worker AWS roles (one role would hold the union of permissions), and a bad deploy of one worker restarts all.
Recommendation: partly. Fold the low-volume workers (tags, dataset runs, Helicone webhooks). Keep the wallet writeback (money) and the capture ETL (heavy, its own AWS role) separate.
Your call · C
Open the maintenance window automatically
Today. Before a planned Postgres restart, an operator opens the window, waits until every pod has seen it, then restarts. Forgetting it means protected chains (52% of traffic) get retryable 503s for the whole restart.
Proposal. The restart tool opens a window sized to the restart, waits for readiness, restarts, and reports.
Trade-off. A window freezes releases and catalog publishing for its length and cannot be ended early, so it must open only as part of an actual restart command, never on its own.
Recommendation: yes.
Your call · D
Table lifetimes without copying
Today (D3). Big tables (gateway_attempts is 238 to 311 GB) get a partitioned shadow copy kept in step by a change log and triggers on hot tables, then a cut-over. The copy is slow, the triggers sit on the busiest tables, and a column added later on main was already missed once in testing.
Proposal. Create the new partitioned table, send new writes to it at a cut-over, and read old plus new through a view for the 120-day retention window; drop the old table when the window passes. No copy, no dual-write triggers.
Trade-off. Reads through the view are a little slower while both tables exist, uniqueness across both needs care, and the old table lives 120 more days.
Recommendation: yes.
Retention, tags and access
Confirm · 3 · provisional default
Free plan: "we retain, not subject to any term"
Our reading. Free-plan organizations get no expiry of their captured data (we keep it), and this is not put into a terms change. So the built-in "free default expiry of 14 days, maximum 30" is removed rather than shipped switched off, and the free plan has no customer-set expiry control. Paid plans keep their expiry controls.
The code now. The switch is still there: free_default_enabled (off), free_default_days (14) and free_max_days in the retention settings, returned by explabs/api/routes/retention.py. With the switch off, free orgs get no forced expiry, which matches "we retain".
If confirmed, the switch and its three fields are removed from the settings, the API and the page. If you meant that free orgs can still set a shorter expiry themselves, the expiry controls open to the free plan instead, and the switch is still removed.
Your call · 4 · provisional default
Who pays for, and controls, the judge that scores a customer's tags
What this is. A customer defines a tag, such as "did the agent give up?". A judge model (Clef by default, or one they pick) reads each captured request and answers. That judge call is itself a model call: whose account makes it?
A (built). Through a key inside the customer's org, named "Trace tagging", system-managed, expiring every 15 minutes. Each judge call shows in their own usage. Their privacy settings (no-training, provider allowlist, ZDR, rate limits) apply automatically. Cost spreads across each customer's own balance.
B. Through our house account, then a fee. The customer sees one "tagging fee" line per period. Their privacy settings do not apply, so the judge needs a second copy of each org's policy logic. Every customer's judge traffic runs through one house organization: the hot-row problem behind the September and November incidents; on 2026-10-03 the house org ran out of credits and everything it funded stopped.
Recommendation: A. It is the only option where a customer's own privacy choices govern a model reading their data, and it keeps money spread out. The owner wrote "share more? not sure"; A has not been chosen.
Your call · 5 · provisional default
Revoking access to a private model takes up to 2 seconds
What changed. Every request used to check Postgres for whether the org may use a private model, one of the reads that turned database incidents into API outages. Now each worker keeps that list in memory, refreshed every 2 s from a change feed.
The cost. After a revoke, requests in flight and any in the next 2 seconds still go through. The same window already applies to revoking API keys. Money blocks (quarantine, ban, spend lock, revoked keys) are not affected: the wallet enforces them within about 1 second.
Recommendation: accept. If revocation must be instant, private-model requests go back to one Postgres read each and fail again during an outage. (The 15-minute outage bound on this list noted on November 20 is fixed: it uses the one 60-minute bound.)
Your call · 6 to 8 · the Helicone move
Legal, pricing and sign-in for moved Helicone customers
The plan (D12). Helicone customers change nothing. Our gateway answers Helicone's hostnames behind Helicone's own DNS; anything we do not serve yet is relayed unchanged to Helicone. History is copied; EU data stays on Helicone's EU stack. Everything is built and tested; the history copy and the DNS switch are off.
6. Legal sign-off first. Moving data from Helicone's stack to ours changes a sub-processor; DPAs usually require written notice (often 30 days) and a right to object. Recommendation: legal reviews the DPA and assignment clause, then we send notice. Until then the gateway can still serve Helicone traffic by relaying it.
7. Which plan and price. Options: keep their Helicone plan until next renewal, move to ours at once, or keep Helicone pricing forever. Recommendation: keep it until renewal; "change nothing" includes their bill.
8. How members sign in. Only orgs and keys are imported today. Options: import members by email with an emailed code on first sign-in, bridge Helicone's login, or ask everyone to sign up again. Recommendation: import by email; no passwords or shared session secrets move.
The wallet
Your call · 9 · provisional default
How many MemoryDB shards the wallet runs on
Today. One shard (one primary, two replicas), about $946 a month, holding all 64 slots. When AWS fails it over, every platform-funded request for every org gets a retryable 503 for about 14 to 15.5 s (measured twice on real MemoryDB). No money is lost.
Options. 1 shard: all orgs affected, about $946/month. 2 shards: half the orgs per failover, about $1,900/month. 4 larger shards (needed only at 10x traffic): a quarter, about $7,600/month.
Recommendation: 2 shards. It halves the blast radius of the most likely wallet outage for about $950 a month more. More shards do not make a failover shorter. The Terraform comment "Decided: 2 for production" is wrong; 1 ships until you choose.
Your call · 10 · provisional default
How long finished charges are kept in the wallet
What these are. A short record of each settled hold. It stops a late or repeated settle (a retry, a replayed receipt, a re-run writeback) from charging twice. Kept 24 hours today.
The trade. A few GB today; about 52 of the wallet's 102 GB at 10x traffic. One hour would shrink them 24 times, but the longest receipt delay seen in production was 55 minutes (November 11), so a late settle could charge twice.
Recommendation: keep 24 hours now; if traffic grows toward 10x, drop to 6 hours, never 1.
Your call · 36
Serve bring-your-own-key calls while the wallet store is down
Today. In a wallet outage, platform-funded calls get a fast retryable 503 (D6). BYOK calls get the same, because even a zero-cost call places a hold that runs the ban and revoke check and carries the record that lands the request in Postgres.
Option. Check bans and revoked keys from the gateway's in-memory copy (already used during a Postgres outage), and record the request through the Postgres spool built in round 7.
Trade-off. Customers on their own keys keep working through a wallet outage; the cost is a second, outage-only record path, and a ban or revoke made seconds before the outage could be missed until it ends.
Recommendation: build it.
Partial · 11
Rehearsals before any database restart
Done. Four preview rounds under load (41 to 70 s cuts), then 11 restarts; zero errors on known keys. Protected chains tested only locally (flow 12). The psycopg fix (#3046) is live in production.
Not yet run. The 10-minute cut on production-sized data, and the MemoryDB failover game day (its script runs only against staging, and the preview's ElastiCache Serverless cannot answer the failover question). A production restart that keeps protected chains serving needs the maintenance window, which ships with the request-path part of #2980.
Tools, traces and the Requests page
Your call · 13 · provisional default
How customers get the traces CLI and MCP server
What it is. A command line (list, get and search traces, sessions and requests; tree-first JSON; cursors) and an MCP server, so a customer's coding agent can debug their traces. The customer who left Helicone for Langfuse said "we give our agents the CLI".
Today. Both are commands of the private platform package (explabs-traces, explabs-traces-mcp); no customer can install them.
Options. (a) exp traces inside the public engine CLI customers already install: one tool, one login, ships with the next engine release. (b) A separate public package: its own schedule, but a second tool and login. (c) Keep it private: customers get nothing.
What they are. Kion's offline tagging: background runs that score captured traffic against our own tag bank on rented GPU nodes running Clef, with results in ClickHouse and an erasure thread. One table (migration 0010) was applied by hand to the shared ClickHouse on 2026-10-15.
The overlap. #2980 builds customer tags scored online. Both store tag scores in ClickHouse, both must be erased with the capture, and their ClickHouse migration numbers conflict. Today there are two tag-score stores and two erasure paths; if both land separately, an erasure can miss one.
Recommendation: keep Kion's PRs and reconcile with Kion: one tag-score store and one erasure path, renumber whichever side is not applied. If the lanes stay separate, the erasure job (D19) must name Kion's tables before either merges.
Your call · 17
Requests sent without a session
Today. Such a request shows its trace id as a green session link, so every one looks like a one-request session. Helicone and OpenRouter show nothing there.
Trade-off. An empty cell matches the tools customers know and stops one-call "sessions" crowding the list; the link keeps one click to that call's trace.
UX recommendation: show "-" and keep the trace in the drawer.
Your call · 18
Listing refusals that happen before admission
Today. Requests refused before admission (an unknown model 403, a bad header 400) are not in the Requests list; only /admin/errors sees them. Helicone shows every call.
Trade-off. Listing them shows customers every call they made; they have no request row today, so the table would read a second source.
UX recommendation: list them, marked "Refused before a model"; these are the 400s customers debug first.
Your call · 19
Default sampling for a new tag: 10% or 100%
Today. The tag editor defaults to 10% of sessions; the API defaults to 100%. On low traffic a new tag at 10% can look broken for days.
Trade-off. 100% shows results at once on low traffic; 10% keeps the judge calls the customer pays for low on busy traffic. One default in both places removes the surprise either way.
UX recommendation: 100% under the existing budget cap.
Your call · 20
Requests table on a phone
Today. At 390 px only Time, Status and Model fit; Preview, Session and Cost sit behind a horizontal scroll.
Trade-off. Cards are readable on a phone but are a second layout to build and keep in step.
UX recommendation: cards with the preview first.
Your call · 21
Session and tree previews
Today. The sessions list shows no first-question preview, and the session tree no per-step text (UX gaps 25 and 27).
Trade-off. Previews make a session readable without opening it; they show only where capture runs in segments mode and the org stores prompts.
UX recommendation: build both before launch.
Your call · 22
When the old request-API parameter names stop working
Today. Main documents /usage/requests parameters (attribution_label, cache_hits_only, status=error, sort=oldest, conversation, cursor_ts / cursor_id / cursor_after) that #2980 had replaced, which would have broken customers' billing jobs. They now keep working with identical rows, proven per parameter, and answers carry a deprecation notice.
Recommendation. Remove them on 2027-05-21. From 2027-02-21, send a Sunset header and email the admins of orgs whose keys still use them. Billing jobs run monthly and are rarely touched; six months covers two quarterly reviews.
Your call · 23
One-click thumbs up or down in the request drawer
Today. Marking a bad answer takes 3 clicks plus creating a score type first. LangSmith and Helicone make it one click.
Recommendation: add it, backed by a built-in score type created on first use. Trade-off: one more control in the drawer and a built-in score type every org gets.
Your call · 24
Update session and trace summaries in the background
Today. Every span write recomputes the session and trace summaries before it returns. With long sessions stored, this limits the capture pipeline (about 2,100 spans/s on one ClickHouse CPU, against 4,800 on an empty table).
Recommendation. Recompute every 1 to 2 s in the background, so summaries may lag new spans by up to 2 s. It is the next large speedup, but it weakens today's guarantee that a summary is current when the write returns.
Your call · 37
Observability gaps from the completeness check
Local capture ("Proxy traffic"). Fixed and verified on the preview in round 12: all of it goes through the same span sink as OTLP. Your call: rename it "Local capture", and decide who sees it (recommendation: every org admin, as a self-serve way to get traffic in).
A Traces list page. The API exists; no page lists traces on their own. Recommendation: add it, since agent-framework users think in traces.
A trace SQL screen. API only today. Recommendation: hold until customers ask.
Users view and tag filters. Built and verified live on the preview in round 12: per-user totals and a tag-key picker, which also gives Helicone's /users and /properties links somewhere to land.
Operations and small calls
Confirm · 27
Give previews the Helicone cache cluster
Production has it; previews do not, so the shared outage spill for continuations (decision 25) cannot be tested on a preview. Recommendation: a preview-plumbing PR on main provisions it, sized small. Trade-off: one more resource per preview, in cost and setup time.
Your call · 28
Light-mode text contrast
In light mode the lighter grey (--muted-2, #8f8f8f) is 3.1:1 against the page, and the muted grey on the soft accent is 4.1:1; WCAG 2.2 AA needs 4.5:1. Dark mode passes. It affects every page. Recommendation: --muted to #6b6b6b and --muted-2 to #707070. Trade-off: grey text gets slightly darker and the third level of emphasis mostly goes away.
Confirm · 30
Membership-read audit records stay a background write
When a member reads an org page, the "who looked" record is written after the answer. A web pod killed hard can lose at most the last 1,024 records (typically the last second or two). Writing first would add about 27 ms to every org-gated request and fail reads whenever the audit database is down; a local disk spool would cost about 1 ms but web pods have no persistent disk. Recommendation: keep it.
Your call · 32
Found on main, outside the data plan
Sign-in bug (production): a sign-up refused because the mailbox already has an account (you+one@ then you+two@) shows a code step, but no code is sent; a small PR makes it say the account exists, waiting for approval. Preview seed bug: four login-token fields left empty break the auth user list. Onboarding suggestions: label the last button as finishing; one card-verification prompt instead of a banner plus a popup; name a new org from the email domain or person's name. Next.js 16.4.1 has 7 moderate advisories fixed after 16.4.4, and its build fails every other run; the upgrade belongs in its own PR.
Your call · 33
Raise preview pr-902980's real-model budget once
Each preview gets $5 of real model calls for its life. The relay holds the worst case per call ($0.0008 to $0.004) and never refunds, while a call really costs about $0.000018, so pr-902980 spent its $5 in about 1,400 calls and has refused every real-model call since 14:44 UTC on 2026-11-22. Recommendation: raise it once by $5 so you can try Playground and live chat (it bends the "never renews" rule for one preview). Separately, a small main PR to settle each hold to its actual cost would make $5 last about 277,000 calls.
Confirm · 35
Make a stored prompt searchable within 5 seconds (about $160 a month)
On a quiet preview a stored prompt becomes searchable in 4.3 s typically and 5.8 s for the slowest 1 in 20, mostly the 2 s upload interval plus about 1 s waiting for the storage notification. Built: upload every 1 s and have the uploader post the queue message itself (the notification stays as a backstop). Modeled slowest 1 in 20: about 3.8 s (typical 2.1 s); either change alone reaches only about 4.7 s. Cost: about $13 more per busy gateway server a month, about $160 for 12 servers. The direct message ships behind a switch, off by default. Recommendation: keep both. Not yet measured end to end.
Your call · 38
How to prove the deploy-layout changes
Today. The isolated preview deploys #2980's images with main's controller and deploy script, so the PR's layout changes have run nowhere: the background units, the dashboard edge, the writeback app and queue-age autoscaling; the Helicone webhook worker and response cache; direct announce; and the 3,900 s startup budget. 46 audited claims wait on this.
Options. (a) Land the controller and deploy-script changes on main first, opt-in and off by default, then redeploy the preview and re-run. (b) A preview mode that deploys with the PR head's scripts; it crosses the trust boundary, since unreviewed code would run with the controller's credentials, and needs your sign-off. (c) Prove it on staging after merge, at the cost of a staging rehearsal round and a later proof.
Recommendation: (a). It keeps the trust boundary, follows the rule for new deploy prerequisites, and proves the layout before #2980 merges.
Hand steps to replace either way. Set the control instance count in the deploy, provision the stand-in model lane through the controller, and load test data through the fixture.
Your call · 39
Moving off Helicone
Today. #2980 serves Helicone customers on our platform but keeps Helicone's own stack running behind it; nothing Helicone-related runs on our side yet.
Decisions before any shutdown. EU (an EU deployment, keep Helicone EU, or end EU service); read-only Helicone keys (build a read-only scope, or ask customers to mint full keys); plans, billing and ai-gateway credits for Helicone orgs; customer-owned gateway domains; the 11 unadapted vendors, Bedrock and prompt generation; legal for the history import; keep or delete the "switch from Helicone" marketing pages; and read-only access to Helicone's accounts to size and cost its stack.
Recommendation. Grant the read access first; every later step needs the numbers.
Decisions already made
The final plan's twenty decisions, D1 to D20, are in November 16 and 17, each with a one-line reason. These are the other decisions taken along the way, with their reasons.
Decision
Reason
1. Rollout: ship to everyone. The new Requests table, Quality page, retention settings and per-key storage controls go live to every customer when #2980 deploys; no early-access gate.
Owner decision. #3034 removed the early-access rule on 2026-11-19. The pipeline that fills the pages is off by default, so the availability endpoint hides a feature and says why instead of showing empty columns.
2. Uncensored models follow the published privacy policy. New requests follow the same capture and ZDR rules as every model; historical captures keep their original retention.
The published policy is the promise in force.
12. Engine release for media and Decisions capture: yes.
Opt-in: the pin bump alone changes nothing; each surface turns on after its writer, retention rules and media handling exist. In progress as experiential#1412.
15 and 16. Provider key and laptop Docker. 15: no action needed. 16: 51 stale containers from other sessions stopped (not removed).
Housekeeping.
25. Responses conversations during a Postgres outage: each worker keeps recent state in memory, and during an outage only it spills to the Helicone cache cluster and copies into Postgres after.
In a local 10-minute outage, 0 of 146 continued turns worked today; memory alone kept 58% locally (about 8% on 12 workers), the spill alone 95%, both 97% (142 of 146). Conditions: only content the request may store, never ZDR; purge on storage-off, ZDR, org deletion and erasure; at most 60 minutes; a per-org cap; never the wallet store; any miss falls back to the explicit resend error.
26. Smaller technical calls: every customer ClickHouse read carries the per-org quota key; grant and limit caches move from 2 s to 60 s with change-feed invalidation; ingest limits stay per pod; main's documented request-API parameters keep working.
Fairness enforced by a test; edits still apply within about 2 s; the edge's per-org admission is the fleet-wide control; live callers must not break.
29. Failed requests open on the reason in the drawer, above Keep and Scores.
Finding why a request failed is the most common task; now 2 clicks, down from 5.
31. Round-2 calls: a new org's first load gets 2 s and one retry, idle connections checked; fair admission worker-wide and by org at the edge, listings never take a slot; the outage check keeps a warm connection and logging writes use their own; an answer cut by its length limit is a warning, not an error; an unknown X-Explabs-Storage value is refused while Helicone omit headers stay lenient; wallet-outage refusals stay retryable; the text step runs 8 workers.
Each follows a round-2 finding; an unclear storage value must store less, never more.
34. Failure behavior from the preview tests: money fails closed with a retryable error; wallet calls refused for 2 s after a failure with each request waiting at most about 2 s; quiet servers' closed connections are not an outage; the capture pipeline has its own read budget; customer reads get separate ClickHouse compute; at least 4 vCPU per heavy reader.
Worst case dropped from 36 s to about 2.5 s locally; a busy pipeline slowed every page 2x; a cost-sorted table copy was rejected (13% more write time, 25% more disk, the default view 2x slower).
One pull request. The data plan lands as #2980; the 12 stacked PRs are closed.
Owner decision, 2026-11-21.
Everything now, in one change.
Owner decision, 2026-11-17.
Protected chains survive a planned restart through a maintenance window; the MemoryDB witness was dropped.
The witness was large (nine migrations), and losing MemoryDB would freeze releases for 61 minutes; the owner's requirement was planned restarts.
MemoryDB stays the live wallet on 64 fixed slots.
Hold p99 3.9 ms against 396 ms and 45 ms; correct on every backend.
The two-queue ETL; the in-memory park deleted.
The park only moved the cliff: a capture waited over 3 minutes once it filled.
Settles defer after 2 s, with a Postgres spool.
Never loses more than the old design, answers the caller, and a dead worker's charges still land exactly once.
Readiness never depends on Postgres or the wallet store.
A store outage must not pull every worker out of service.
This page's first questions (November 9 and 10): search on new text only (D8), a capture fallback chain cut to memory, disk, then metadata (D2), media stored by kind (D14), customer Decisions captured and internal Clef callers storing outcomes only (decided November 10, D14), keys may only tighten storage (D14), customer expiry first (D13), provider keys on Helicone hosts used for one call and never stored (decided November 10, D12).