Files
leleka/desktop-core/POOL.md
T
Pavlo Ratushnyi 4013e0c9bd
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
Import tracked Strata Next source snapshot
2026-10-05 18:15:08 +02:00

82 lines
4.9 KiB
Markdown

# Experimental pool gateway
Implemented in STRA-56. One loopback Responses endpoint can queue requests and
forward them to several already running local workers or loopback SSH tunnels.
This does **not** install runtimes, create tunnels, load models or integrate a
pool editor into the desktop UI yet. Production serving is Rust, without Python.
## Run
Copy `examples/pool.json` to a private location and replace all model IDs,
endpoints, capabilities and memory budgets with verified values. The included
three endpoints and 1 GiB allocations are examples, not a tested model recipe.
Supply credentials through the named environment variables (minimum 16 bytes).
Use a separate gateway token; upstream credentials are never forwarded from a
client header. An upstream token reference may be null for a trusted unauthenticated
loopback worker. Never commit real configurations or credentials.
```sh
cargo build --locked --manifest-path desktop-core/Cargo.toml
desktop-core/target/debug/strata-desktop gateway /absolute/private/pool.json
```
Configure the harness base URL as `http://127.0.0.1:18765/v1`, its bearer token as
the gateway token, and its model as a deployment ID or an explicitly configured
alias such as `coding-pool`. The gateway exposes authenticated `/v1/models`,
`/v1/responses` and `/pool/status`. Exact deployment IDs never substitute models.
An alias explicitly permits any of its members; choose equivalent models or
accept the heterogeneous selection policy intentionally. Backend model IDs are
sent upstream and retained in responses; `x-strata-deployment` identifies routing.
## Admission and streams
- Default example queue: 8 waiting requests; gateway maximum: 64. Request bodies
are limited to 2 MiB, buffered non-stream responses to 8 MiB, terminal SSE
inspection to 1 MiB per line/event. Streaming content is relayed unchanged.
- Requests wait on the same HTTP connection; this is not a durable 202 job API.
Align harness timeouts with queue plus inference time. Full queue returns 429
with Retry-After; expired queue returns 504. Accepted work does not survive a
gateway restart.
- Oldest eligible request gets a free slot; unrelated blocked requests do not
block other workers. Per-worker and shared resource-group admission is atomic.
Group budgets are incremental memory AFTER resident weights and safety reserve;
request_bytes must upper-bound allocations for the worker's allowed context.
The backend must enforce those limits. Aliases to one GPU must share a group.
- Capability filters cover Responses, tools, reasoning, structured output,
image/audio/file input. These are explicit administrator declarations, not
automatic quality or compatibility validation. Native backend validation remains.
- A lease lasts through response completion, not merely HTTP headers. Waiting
cancellation removes the queue entry. Stream cancellation/timeout or missing
terminal event quarantines that deployment: cancellation alone cannot prove
the upstream worker stopped computing. Other deployments continue.
- Recovery is intentionally manual in this preview: verify the upstream worker
is idle and healthy before restarting the gateway. Automatic verified recovery
and upstream cancellation acknowledgement belong to managed lifecycle work.
- No inference request is retried. Per-request SSE bytes/tool-call arguments are
preserved. An interrupted stream ends as a transport error, never a fabricated
successful response. Never infer model quality from successful transport tests.
- previous_response_id routes to its known original worker. Ownership is bounded
to the latest 4096 response IDs in gateway memory; unknown/evicted IDs return
409. Worker state must still exist. Durable ownership, conversation resources,
background mode and transparent migration are not supported. Input must contain
full history when starting a new independent session.
## Security and deployment boundary
Bind and upstream addresses must be literal loopback IPs. Remote links go through
an independently managed SSH tunnel. Redirects and ambient HTTP proxies are
disabled. Credentials come from environment references, raw payloads are not
logged. This version assumes configured workers are ready at startup and their
slots are exclusively managed by this gateway; attaching a busy shared worker is
not supported. Existing user test sessions must not be attached automatically.
## Evidence
`cargo test --locked --manifest-path desktop-core/Cargo.toml` exercises a real
loopback HTTP gateway with three synthetic workers: concurrent execution,
fourth-request queuing, routing/affinity, saturation/timeout, authentication,
capability rejection, fragmented SSE byte equality and disconnect isolation.
Pool tests additionally cover FIFO eligibility, shared memory budgets and 100
dispatch/cancel races. These are functional tests, not real-model benchmarks.
The real local + two SSH harness run and desktop integration remain open.