Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
docs(transport): document the per-principal visual share and fix classification
Alfredo Lopez3f7bf1da8414
diff --git a/docs/architecture/codex-subscription-transport-contract.md b/docs/architecture/codex-subscription-transport-contract.mdindex 07867d8f0..3202d3c03 100644--- a/docs/architecture/codex-subscription-transport-contract.md+++ b/docs/architecture/codex-subscription-transport-contract.md@@ -440,6 +440,16 @@ behavior changes:the in-flight byte budget before it releases its visual slot, so everyrequest acquires in the order visual slot, byte budget, stream slot, andno two requests can wait on each other.++ **Per-principal visual share (B4).** In addition to the gate, each+ platform identity (`sub` plus sorted `hostRefs`) may hold at most 4+ visual entries (running or queued) of the gate's 10. A token whose `sub`+ is missing, empty or not a string is refused 401 before any gate or+ share is taken. When the share is full, the proxy answers 503+ `provider_unavailable` and logs `codex_proxy_admission_refused` with+ `reason: visual_host_share`. The share is released together with the+ visual slot: on read-deadline expiry, on client close before hand-off,+ and when the handler's finally block unwinds.- It requires the redeem response to carry `maxStreamDurationMs` greaterthan 0. An absent value is a contract violation, not a default.- It logs one `codex_proxy_attempt_finished` event per completion attempt,diff --git a/docs/architecture/grok-subscription-transport-contract.md b/docs/architecture/grok-subscription-transport-contract.mdindex 2d83e26a6..5b727d1ee 100644--- a/docs/architecture/grok-subscription-transport-contract.md+++ b/docs/architecture/grok-subscription-transport-contract.md@@ -117,6 +117,15 @@ so it never queues behind a visual stream, and a declared length above thevisual cap is refused 413 before reading. Anonymous, wrong-scope and admin requests keep theordinary limit.+**Per-principal visual share (B4).** In addition to the gate, each platform+identity (`sub` plus sorted `hostRefs`) may hold at most 2 visual entries+(running or queued) of the gate's 5. A token whose `sub` is missing, empty or+not a string is refused 401 before any gate or share is taken. When the share+is full, the proxy answers 503 `provider_unavailable` and logs+`grok_proxy_admission_refused` with `reason: visual_host_share`. The share is+released together with the visual slot: on read-deadline expiry, on client+close before hand-off, and when the handler's finally block unwinds.+The visual wait uses the request's single admission clock (arrival +`maxQueueWaitMs`, 60 s). Unlike the ordinary stream gate, it does not end atthe ticket's `exp`. A ticket that expired while its visual body waited is@@ -135,9 +144,9 @@ answered 503 `provider_unavailable` and logged asA client that disconnects while its request is queued frees its queue placeonly if Node sees the disconnect. Node keeps reading a queued request's socketuntil the unread body fills the request's buffer (about 16 KiB). A client that-disconnects before that is seen at once: the wait is aborted, the place is-freed, and the refusal is logged with `reason: visual_gate` and-`detail: stream request was aborted`. Every real visual body is larger than+disconnects before that is seen at once: the wait is aborted and the place is+freed silently (an aborted waiter is not gate saturation, so it is not logged+as `visual_gate`). Every real visual body is larger than8 MiB, so a disconnect is usually not seen while the request is queued. Theplace is then held until the grant or until the admission clock runs out(60 s). At the grant, Node reads the bytes that already reached the server.@@ -353,8 +362,9 @@ the proxy both surface a size refusal (`kind: 'size'`) as HTTP 413(#784; the control-api authorizer answered `invalid_request` for size toobefore it), while the Host raises `request_limit_exceeded` before itauthorizes at all — for the five size refusals listed under that code below —-`attachment_too_large` for the image budget refusals, `payload_too_large` for-the container bound (both classify as `ContextLengthExceeded`), and+`attachment_too_large` for the image budget refusals (classified as+`InvalidAttachment`), `payload_too_large` for the container, member and+element bounds (classified as `ContextLengthExceeded`), and`invalid_request` for the rest, which no amount of compaction would fix.That symmetry holds for a request and not for a response, which is why the