Skip to content
Merged
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
10 changes: 8 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ providers/transport → `deep-dive-providers.md`; reload/restart →
`wire/` protocol codecs, `routing/` + `accounts/` +
`catalog/` + `quota/` + `health/` selection, `model_router.rs` affinity,
`identity.rs` + `web_session.rs` + `user_budget.rs` + `instance_budget.rs` +
`model_policy.rs` + `personal_upstream.rs` on-prem user access, `providers/` transport,
`model_policy.rs` + `routing_policy.rs` + `personal_upstream.rs` on-prem user access, `providers/` transport,
`runtime_lifecycle/` generations + `reload.rs` +
`task_supervisor.rs` + `security_events.rs`, `operations/` local lifecycle, `db/` +
`rust/assets/db/migrations/` v1–v68 immutable.
`rust/assets/db/migrations/` v1–v69 immutable.
- Reusable policy crates: `rust/crates/eggpool-model-routing/` (neutral validation/compilation only; selector execution and affinity cache stay in `rust/src/`), `rust/crates/eggpool-client-config/` (portable Codex/OpenCode projection, profiles, `epc1` tokens, V1/V2 renderers, TOML/JSONC-preserving mutation; EggPool `Config`/catalog/DB/key/endpoint/CLI/file IO stays in `rust/src/operations/integrations.rs`), `rust/crates/eggpool-provider-profile/` (secret-free sans-I/O provider-profile contract plus the canonical bundled asset at `assets/_provider_profiles.toml`; `rust/src/provider_profile.rs` is the only EggPool reader), `rust/crates/eggpool-wire/` (neutral sans-I/O wire kernel; execution stays in `rust/src/`), `rust/crates/eggpool-connect/` (narrow `eggpool-connect` binary: plan/install/verify/backups/restore/remove with byte-exact backups, atomic writes, automatic rollback; no Axum/SQLite/Eggress, no proxy/agent/daemon).
- Tooling only (never a runtime fallback): repo-root `pyproject.toml`, `scripts/`, `tests/tooling/`. `scripts/qualification_sbc.py` is the sole physical-SBC runner (loopback-only, aggregate-only, non-CI). Native tests live in `rust/tests/` (serial; there is no `coordinator_c012`; streaming files are `coordinator.rs`, `execution.rs`, `terminal.rs`, `timeout.rs`, `types.rs`, `diagnostics.rs`).
- Config resolution: `--config` > `$EGGPOOL_CONFIG` > `~/.config/eggpool/config.toml` > `./config.toml`. Provider/upstream keys come from environment/`.env`, never committed; the server key lives under `[server]` (`api_key` via `eggpool newkey`, or `api_key_env`). Examples: `rust/config.example.toml`, `rust/config.local.example.toml`, `rust/config.sbc.example.toml`.
Expand Down Expand Up @@ -91,6 +91,12 @@ dir, then `serve` (it daemonizes), curl, `stop`.

## Conventions agents miss

- Operator routing policy lives in SQLite (v69), not configuration: a stored
row overrides, absence inherits the config baseline and then the upstream
fact, and an unreadable snapshot fails closed. `models.expose_mode` stays
parseable but inert; the stored mode drives discovery. Do not add rank,
window, or capacity columns without their milestone.

- `rust/src/config_reload_policy.rs::classify_transition` is the only
reload-vs-restart authority. Mutation paths classify before atomic replace;
server `rehash` reclassifies before publication. Mixed changes are wholly
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@ All notable changes to EggPool are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- **Operator routing policy.** Migration v69 adds a durable policy overlay for
the discovery exposure mode, per-provider-model enablement, and model
metadata overrides, with a revision-triggered immutable request snapshot.
Disables are enforced in eligibility, separate mode advertises
provider-qualified ids, and `/routing/policy` provides audited admin
controls. Reverting an override deletes the row and restores the inherited
value. An installation with no policy rows behaves exactly as before.

### Fixed

- **Routing policy now holds on every request path and in separate-mode
discovery.** Separate mode advertised no real provider-model pairs because
the discovery projection read the catalog's pair tuple in the wrong order;
the admin datalists were swapped the same way. The compact endpoint and the
selector's internal dispatch never captured the request snapshot, so a
configured disable did not apply to remote compaction and an unreadable
policy store did not fail them closed. The routing-policy metadata table now
shows the stored input-token override, the effective upstream limit, and its
source tag, and reports a row the catalog does not know as orphaned.

## [0.8.3] - 2026-10-30

### Changed
Expand Down
3 changes: 3 additions & 0 deletions architecture/deep-dive-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ tuning (`refresh_interval_s`, `expose_mode`, `startup_refresh`, `stale_after_s`,
`allow_stale_catalog`, `ping_retain_days`, `collapse_models`,
`catalog_withdrawal_policy`). `RoutingConfig` holds `strategy`, `near_tie_epsilon`,
`local_quota_mode`, `fairness_mode`, `fairness_epsilon`, and `fairness_scope`.
`models.expose_mode` stays in `ModelsConfig` for configuration compatibility but
has no runtime consumer; discovery projection is operator policy owned by
`rust/src/routing_policy.rs`.

`ModelRouterConfig` declares one virtual model: `selector_model`, `default_model`,
`routes: BTreeMap<String, ModelRouteConfig>`, `sticky`, `affinity_ttl_s`,
Expand Down
44 changes: 44 additions & 0 deletions architecture/deep-dive-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,50 @@ hit and selector repair use the same request snapshot. A policy denial returns
403 before the concrete provider attempt, while provider eligibility,
health, quota, and fairness remain owned by this routing module.

## Operator routing policy

An operator policy overlay sits beside configuration, not inside it.
`rust/src/routing_policy.rs` owns a process-wide `RoutingPolicyService`, and
`rust/src/db/routing_policy.rs` owns the durable rows introduced by migration
v69. A policy row is an explicit override; absence means inherit the
configuration baseline and then the upstream catalog fact, so reverting is a
row delete rather than a sentinel value.

Precedence is policy row, then configuration, then the upstream catalog entry.
The overlay currently carries the exposure mode, per-provider-model
enablement, and metadata overrides. It deliberately has no rank, window, or
capacity column: those arrive in later milestones.

Every mutating table carries insert, update, and delete triggers that advance a
singleton revision. Admission calls `RoutingPolicyService::snapshot()`, which
performs one indexed revision read and returns a cached immutable snapshot when
it matches; otherwise it rebuilds the snapshot in one transaction. The request
carries that snapshot as `RoutingRequestFacts::routing_policy`, so selection
reads policy without I/O and an edit can never change decisions already made.
Admission resolves the snapshot once per request and shares that `Arc` with the
selector's internal dispatch and the concrete routing facts, so a virtual-model
request cannot observe two different policies; the compact and embeddings
surfaces capture it on the same terms. An unreadable store fails every
inference surface closed with the typed `RoutingPolicyUnavailable` outcome
instead of silently ignoring a configured disable.

`candidate_for_account` checks an explicit provider-model disable immediately
after the credentials and provider gates, before health, quarantine, catalog,
and freshness work, and reports `model_disabled_for_provider`. Discovery
projects the same snapshot: consolidated mode lists canonical ids, separate
mode lists one `model/provider` id per enabled provider-model pair and keeps
virtual aliases unqualified. `models.expose_mode` remains parseable and
classified live, but it has no runtime effect; the stored mode decides.

The admin surface is `/routing/policy` with admin-scoped, CSRF-protected
`/admin/routing/*` mutations. Each committed mutation writes exactly one
`routing_policy_audit` row in the same transaction. Only a refused mutation, or
a revert of a row that does not exist, writes nothing; saving an unchanged
value is an ordinary committed mutation, so it is audited and advances the
revision. The metadata table shows every stored field beside the effective
upstream value and the source tag that value came from, and reports a row the
catalog does not know as `orphaned` rather than inventing a fact.

## Eligibility gates

`eligibility.rs::build_eligible_candidates` is the read-only gate. `EligibilityPolicy::from_config`
Expand Down
11 changes: 7 additions & 4 deletions architecture/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ managed-user at `/login`, `/logout`, `/account`, `/account/landing`,
`/account/tokens/revoke`, `/usage`, `/api/user-budget`; dashboard pages at
`/`, `/accounts`, `/models`, `/models/{*model_id}`, `/latency`, `/events`,
`/timeseries`, `/bandwidth`, `/pings`, `/reliability`, `/routing`,
`/traces`, `/runtime`, `/cache`, `/users`, `/profiles`, `/admin/audit`,
`/api/admin/audit/export`;
`/routing/policy`, `/traces`, `/runtime`, `/cache`, `/users`, `/profiles`,
`/admin/audit`, `/api/admin/audit/export`;
admin actions at `/admin/users/create`, `/admin/users/state`,
`/admin/users/password`, `/admin/users/token`, `/admin/users/revoke-tokens`,
`/admin/users/profile`, `/admin/users/override`,
Expand All @@ -174,7 +174,10 @@ admin actions at `/admin/users/create`, `/admin/users/state`,
`/admin/budget/instance`, `/admin/budget/instance/remove`,
`/admin/profiles/create`, `/admin/profiles/default`,
`/admin/profiles/update`, `/admin/profiles/delete`, `/admin/profiles/rule`,
`/admin/profiles/rule/remove`, `/admin/profiles/prefer`; statics at
`/admin/profiles/rule/remove`, `/admin/profiles/prefer`,
`/admin/routing/mode`, `/admin/routing/model-policy`,
`/admin/routing/model-policy/remove`, `/admin/routing/metadata`,
`/admin/routing/metadata/remove`; statics at
`/static/dashboard.css`, `/static/dashboard.js`, `/static/chart.js`,
`/static/favicon.svg`, `/static/theme.css`. The per-surface behavior of each
family is owned by its deep dive, not by this index.
Expand Down Expand Up @@ -359,7 +362,7 @@ is the only persistence boundary. `db/` owns only the `backup_to` snapshot
primitive; backup orchestration lives in `operations/backup.rs` and crash
repair in `runtime_lifecycle/recovery.rs` plus coordinator reconciliation.
Migrations (`rust/assets/db/migrations/`,
currently v1–v68 with `checksums.json`) are embedded and immutable; commit or
currently v1–v69 with `checksums.json`) are embedded and immutable; commit or
ownership ambiguity fails closed; startup reconciliation repairs only covered
states. Repositories accept no unbounded diagnostic content and never store
credentials, prompts, raw bodies, or cache keys.
Expand Down
5 changes: 4 additions & 1 deletion docs/live-config-rehash.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ candidate builder already constructs as generation-owned objects:
``collapse_models``, ``refresh_interval_s``, ``stale_after_s``,
``allow_stale_catalog``. Startup-only fields
(``startup_refresh``, ``ping_retain_days``,
``catalog_withdrawal_policy``) remain ``RESTART_REQUIRED``.
``catalog_withdrawal_policy``) remain ``RESTART_REQUIRED``. The
``expose_mode`` key remains parseable and live-classified but has no
runtime effect: discovery mode is operator routing policy stored in
SQLite and applied through the per-request policy snapshot.
`security.persist_redacted_error_detail` remains parseable for configuration
compatibility but has no runtime effect. Its existing reload classification is
unchanged and does not imply an active persistence control.
Expand Down
Loading
Loading