Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions desktop/src-tauri/src/connections/compatibility.json
Original file line number Diff line number Diff line change
Expand Up @@ -2043,5 +2043,26 @@
"remember_memory",
"search_memory"
]
},
{
"id": "sqlite-early-release-16e1cb20-v1",
"serverCommit": "16e1cb206c45b4236136014b4f67e55415baa9e2",
"contractSha256": "8b3411dec4247dc8d7f971fc242a32991fa1600085a06c28395fcb9edb2a289e",
"artifactSha256": "c5abe9842e9539758ddf8abfe66fb6f0c0cc9e885a7a47149197baddb27e7dbe",
"operations": [
"get_access_principal",
"get_artifact_revision",
"get_capabilities",
"get_connection_identity",
"get_default_scope",
"get_liveness",
"get_readiness",
"get_scope",
"get_server_info",
"get_stats",
"list_scopes",
"remember_memory",
"search_memory"
]
}
]
2 changes: 1 addition & 1 deletion desktop/src-tauri/src/transport/operations.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"contractSha256": "72650c82272bf04fed94885723f6b5076801d09d2c74ce86636b61110b5666e1",
"contractSha256": "8b3411dec4247dc8d7f971fc242a32991fa1600085a06c28395fcb9edb2a289e",
"operations": {
"get_liveness": {
"method": "GET",
Expand Down
2 changes: 2 additions & 0 deletions desktop/ui/src/generated/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4793,6 +4793,8 @@ export interface components {
correlate_until?: string;
/** @description Present only for allow, bound to this phase, identity, target, policy, and exact payload. */
binding?: string;
/** @description Present and true only on a before_send allow issued while protection is disabled. The executor may forward the response of this request to its caller while it arrives. The completed response still requires before_release with this request's binding. */
early_release?: boolean;
/** @description Exact Core-configured endpoint, present only on an allow for before_send when X-PowerContext-Resolve-Target was authorized for a service principal. */
target_endpoint?: string;
/**
Expand Down
2 changes: 1 addition & 1 deletion desktop/ui/src/generated/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

// Generated from openapi/powercontext.yaml. Do not edit.
export const contractSha256 = "72650c82272bf04fed94885723f6b5076801d09d2c74ce86636b61110b5666e1";
export const contractSha256 = "8b3411dec4247dc8d7f971fc242a32991fa1600085a06c28395fcb9edb2a289e";
export const operations = {
"get_liveness": {
"method": "GET",
Expand Down
7 changes: 7 additions & 0 deletions docs/en/docs/operate/context-protection.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ is separate from its five-minute response-correlation deadline. Pass it as `requ
Current policy, identity, and retained context dependencies are checked again. A release permit cannot authorize a
new request, and correlation never extends the send deadline. These permits do not provide exactly-once execution.

While protection is `disabled`, an allowed `before_send` also returns `early_release: true`. It permits the executor
to forward the response of that request to its caller while it arrives, because this mode inspects no response. The
permission belongs to that one request and is settled before any byte is forwarded; Core does not interrupt a response
that is already being forwarded. The executor still calls `before_release` with the complete response, which
correlates it with the request binding. In `shadow`, `advisory`, and `enforcing` modes the field is absent and the
executor releases nothing before `before_release` allows it.

The public carrier currently supports complete JSON. With explicit `allow_streaming=true`, the local protected
transport also supports OpenAI Chat SSE with a single choice and Responses SSE ending in a successful
`response.completed` event. Other streaming profiles are withheld. It buffers and checks the complete stream before
Expand Down
14 changes: 12 additions & 2 deletions docs/en/docs/operate/deploy-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ The gateway adds a built-in cost-guidance instruction (S) to every request on th

On Responses, the text becomes the first content block of the developer message that follows the client's first developer message, which is where Codex places its own `developer_instructions`. Without such a message, the gateway inserts a new developer message after the client's first developer message, or before the first user message when the request has no developer message. On Chat, the gateway appends the guidance to the first system message, or inserts a system message before the first user message. The text is identical on every request, so it stays part of the cached prefix. Core checks it as part of the final request like any other request text. It is independent of context injection, capture, and replay.

### Streamed replies

By default the gateway releases a reply only after it is complete and `before_release` has allowed it, so a streaming client receives the whole stream at once when the model has finished.

While Core's protection mode is `disabled`, an allowed `before_send` carries `early_release: true`, and the gateway forwards a streamed Chat Completions reply to the client while it arrives. This applies to a request with `stream: true` on `/gateway/v1/chat/completions` whose provider answers HTTP 200 with `text/event-stream`, on an API-key upstream. The client receives the provider's bytes unchanged. The gateway still buffers the reply, calls `before_release` with the complete body, and captures the turn; these steps run after the client has the reply and no longer delay it. In `shadow`, `advisory` and `enforcing` modes, on a gateway that discovered an enforcing Core at startup, on the Responses route, with an OAuth subscription, and for provider errors or non-streamed replies, the reply is released only when complete. A gateway started against an enforcing Core ignores the permission until it is restarted.

The response body ends when the provider's body ends. A client that disconnects before the provider has finished cancels the call with `request_cancelled`: the provider request is dropped and the turn is not captured. Once the client has been handed the end of the stream (`data: [DONE]`) or the whole provider body, its disconnect no longer cancels the call. The release record and capture then get up to 20 seconds after the connection ends, within the original 180-second deadline and the shutdown drain limit; the model permit stays held until they finish or are stopped. If the provider stops in the middle of a forwarded reply, the gateway ends the client connection abnormally instead of completing the stream, so a partial reply is not mistaken for a complete one.

A forwarded reply that exceeds the response buffer limit is forwarded to its end, but it is not captured and gets no release record; the call record is `withheld` with a `buffer_limit_exceeded` attempt. A release check that fails or a Core that becomes unavailable after the reply was forwarded cannot recall it: the call record shows that outcome together with `early_release`, and the turn is not captured.

### Gateway byte capacity

The Rust gateway discovers `context_protection` once at startup through `/v1/capabilities`. Model routes require the complete `ContextProtectionCapabilities` DTO defined by OpenAPI: `check_versions`, `payload_versions`, `reuse_versions`, `reuse_families`, `enforcing`, and `limits` with `payload_bytes`, `binding_bytes`, `prepared_contexts`, `dependencies`, `send_seconds`, and `correlate_seconds`. Missing or mistyped required fields pause admission even when the input capacity is present. The check/payload versions must include v1, and `limits.payload_bytes` must be a positive integer. A failed query, incompatible version, incomplete DTO, or invalid capacity pauses both model routes with HTTP 503; `/healthz` and configured Core/MCP forwarding remain available. Restore the Core contract and restart this gateway to rediscover capacity. Every model send and response release still requires its own Core check. If Core lowers a limit before the gateway restarts, that check can reject the call; increasing a Core limit does not enlarge this gateway's startup allowance until restart. Startup diagnostics distinguish transport failure, query rejection, malformed/incomplete responses, unsupported versions, and invalid capacity using fixed messages without Core error values.
Expand All @@ -228,9 +238,9 @@ The Rust gateway discovers `context_protection` once at startup through `/v1/cap

Provider response buffering defaults to at most 1 MiB for both fixed-length and chunked/SSE responses. The transport's explicit buffer limit can reduce this ceiling. Input `payload_bytes` does **not** declare an output allowance. Core's response configuration, content checks and the JSON/RPC envelope impose their own limits, so even a body below 1 MiB may be refused. The UDS client's 8 MiB RPC-response parser ceiling is a separate direction and is not model-body capacity.

A response buffer overflow discards the response and returns HTTP 400 with `response_buffer_limit_exceeded`. No provider content is released and the call is not retried. The execution observation retains `PossiblySent` and a `Withheld` terminal: the provider may already have charged for the call. This is not proof of a complete response or of zero cost. This observation is process-local; this stage does not export a readable call record with attempts and terminal/sending facts. The G5-A requirement to expose possible billing in call evidence remains pending integration and an exported-record regression with [#2506](https://github.com/oceanbase/powercontext/pull/2506). Smaller, completely received responses still pass `before_release` before release.
A response buffer overflow discards the response and returns HTTP 400 with `response_buffer_limit_exceeded`. No provider content is released and the call is not retried; a reply that is already being forwarded under [early release](#streamed-replies) is the exception. The execution observation retains `PossiblySent` and a `Withheld` terminal: the provider may already have charged for the call. This is not proof of a complete response or of zero cost. This observation is process-local; this stage does not export a readable call record with attempts and terminal/sending facts. The G5-A requirement to expose possible billing in call evidence remains pending integration and an exported-record regression with [#2506](https://github.com/oceanbase/powercontext/pull/2506). Smaller, completely received responses still pass `before_release` before release.

Transparent Core/MCP forwarding retains the deployment body limit rather than consuming the model input allowance. `PC_GATEWAY_MAX_CONCURRENT` (default 64) applies independently to model calls and fallback calls, so an active fallback SSE connection cannot exhaust the model semaphore. The combined ceiling is therefore up to twice the configured value, excluding exempt health probes; this setting is not a process-wide concurrency ceiling. Model permits stay with the actual HTTP/1 connection owner through local response delivery and the end of related request work, including writes still buffered after body EOF/drop. Model responses declare `Connection: close`; normal connection completion establishes local completion, without proving client receipt. The original 180-second monotonic deadline covers intake, execution, and local delivery. Expiration ends the connection without an extra delivery/cleanup window; a response may be truncated and error JSON is best effort. Framework-observed disconnects stop local work with `request_cancelled`; unobserved network loss is bounded by the deadline. A delivery interruption preserves completed execution and model-send facts, including `ReleaseAuthorized` and `ResponseReceived`. Cancellation does not prove provider rollback or safe resend. The process-local `ExecutionSnapshot::local_delivery` reports model content delivery as `NotStarted`, `InProgress`, `Completed`, or `Interrupted(reason)`; rejection and lifecycle-error responses do not start model content delivery. It is independent of the execution terminal and does not retain response bytes or permits. Fallback permits remain attached to their response body until drop. Fallback retains authentication, keep-alive and streaming behavior without the model deadline or forced connection closure. Provider sends and HTTP Core RPCs use fresh HTTP/1 connections with idle pooling disabled; the UDS Core client retains its bounded idle pool. Gateway shutdown allows up to 25 seconds to drain and bounds process exit to 30 seconds from the first shutdown signal. `/healthz` is exempt from both semaphores. A fallback request with a known oversized Content-Length returns 413 before forwarding. Unknown-length overflow produces a body error: a prefix may already have reached Core, and the proxy returns 502 if forwarding fails. It is not successful truncation, and the gateway does not buffer an entire MCP stream to force a uniform error status.
Transparent Core/MCP forwarding retains the deployment body limit rather than consuming the model input allowance. `PC_GATEWAY_MAX_CONCURRENT` (default 64) applies independently to model calls and fallback calls, so an active fallback SSE connection cannot exhaust the model semaphore. The combined ceiling is therefore up to twice the configured value, excluding exempt health probes; this setting is not a process-wide concurrency ceiling. Model permits stay with the actual HTTP/1 connection owner through local response delivery and the end of related request work, including writes still buffered after body EOF/drop. Model responses declare `Connection: close`; normal connection completion establishes local completion, without proving client receipt. The original 180-second monotonic deadline covers intake, execution, and local delivery. Expiration ends the connection without an extra delivery/cleanup window; a response may be truncated and error JSON is best effort. Framework-observed disconnects stop local work with `request_cancelled`, except after a forwarded reply is complete (see [Streamed replies](#streamed-replies)); unobserved network loss is bounded by the deadline. A delivery interruption preserves completed execution and model-send facts, including `ReleaseAuthorized` and `ResponseReceived`. Cancellation does not prove provider rollback or safe resend. The process-local `ExecutionSnapshot::local_delivery` reports model content delivery as `NotStarted`, `InProgress`, `Completed`, or `Interrupted(reason)`; rejection and lifecycle-error responses do not start model content delivery. It is independent of the execution terminal and does not retain response bytes or permits. Fallback permits remain attached to their response body until drop. Fallback retains authentication, keep-alive and streaming behavior without the model deadline or forced connection closure. Provider sends and HTTP Core RPCs use fresh HTTP/1 connections with idle pooling disabled; the UDS Core client retains its bounded idle pool. Gateway shutdown allows up to 25 seconds to drain and bounds process exit to 30 seconds from the first shutdown signal. `/healthz` is exempt from both semaphores. A fallback request with a known oversized Content-Length returns 413 before forwarding. Unknown-length overflow produces a body error: a prefix may already have reached Core, and the proxy returns 502 if forwarding fails. It is not successful truncation, and the gateway does not buffer an entire MCP stream to force a uniform error status.

These are per-body and per-class concurrency limits. They do not measure retained bytes or establish a process RSS ceiling. Process-wide retained-byte accounting and output-capacity discovery belong to the remaining [G5-B work in #2464](https://github.com/oceanbase/powercontext/issues/2464).

Expand Down
Loading
Loading