Files
nixos/.gitignore
JakeHillion 35ce22b6b3
commit-validation / validate-single-commit (pull_request) Successful in 3s
buildbot/nix-eval Build done. (1040 warnings)
buildbot/nix-build Build done.
buildbot/nix-effects Build done.
llm-proxy: add etcd-coordinated sidecar for upstream LLM access
Introduces a per-host Rust sidecar that arbitrates upstream LLM access
through an etcd-backed scheduler. Two QoS tiers are exposed:
`/v1/immediate/chat/completions` always forwards immediately and only
takes a fleet-wide marker once it hits its first 429, blocking batch
work during its retry loop. `/v1/batch/{nice}/chat/completions` enters
a priority queue ordered by signed niceness and yields whenever any
immediate marker exists. On 429 each task holds its slot, sleeps with
jittered exponential backoff (5 s -> 5 min), and retries; if etcd is
unreachable the sidecar bypasses the scheduler and forwards directly.

The sidecar abstracts the upstream provider entirely: callers send a
logical model name (e.g. `moonshotai/kimi-k2.6`, `zai/glm-5.1`) and the
sidecar looks it up in a fleet-wide model index that maps each name to
exactly one provider, rewrites the body to the upstream's name, and
attaches the matching API key. Two providers are preconfigured today,
Canopy Wave (`moonshotai/kimi-k2.6`, `minimax/minimax-m2.5`) and Ollama
Cloud (`zai/glm-5.1`, `deepseek/deepseek-v4-pro`); each owns its own
etcd queue prefix.

A new Rust workspace (`Cargo.toml`, `crates/llm-proxy/`,
`rust-toolchain.toml`) is added at the repo root, packaged via
`pkgs/llm-proxy.nix` with the standard nixpkgs Rust builder.
`programs.rustfmt` is added to treefmt.

`modules/services/llm-proxy/` provides the systemd unit (DynamicUser,
LoadCredential for both provider keys, hardening, ETCD_ENDPOINTS) and
renders the TOML config through `pkgs.formats.toml`.

`async-coder`, `personal-agent`, `openwebui` and the home-manager
`opencode` profile are repointed at `127.0.0.1:9100` with the logical
model names; their per-consumer Canopy Wave and Ollama Cloud secrets
are removed in favour of the single sidecar credentials. The devbox
profile enables the sidecar so the four devbox hosts running
`opencode` get a local instance.

Test plan:
- CI
2026-05-10 12:29:41 +01:00

5 lines
36 B
Plaintext

result
.DS_Store
/.direnv/
/target/