Skip to content

Enforce routing policy on every dispatch and fix separate-mode discovery - #12

Merged
dbowm91 merged 4 commits into
mainfrom
feat/routing-policy-enforcement-correction
Nov 30, 2026
Merged

dbowm91 merged 4 commits into
mainfrom
feat/routing-policy-enforcement-correction

Conversation

@dbowm91

@dbowm91 dbowm91 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

What this changes

M001 added the operator routing policy store, but an independent audit at 69247df7 found the policy did not actually hold everywhere. This is the corrective pass, Milestone 4 of the routing policy and capacity subsystem.

Fixed

  • Separate-mode discovery was empty. The projection destructured the catalog pair as (provider_id, model_id) while the producer emits (model_id, provider_id), so every real pair was dropped and only virtual aliases survived. The admin datalists were swapped the same way.
  • Compact ignored policy. /v1/responses/compact never captured the snapshot, so a configured disable did not apply and an unreadable store did not fail closed.
  • The selector dispatch ignored policy. The internal selector call built routing facts with no snapshot and could dispatch to a disabled pin.
  • The metadata page omitted a stored field. input_tokens was accepted and stored but never rendered, and no override showed what it departed from.
  • Documentation overstated the audit rule. The deep dive claimed a repeated save writes no audit row; every committed save is audited and advances the revision.

Enforcement now

One immutable snapshot per request, resolved once during admission and shared by the selector dispatch and the concrete routing facts on chat, streaming, compact, and embeddings. Policy absence still inherits; an unreadable store fails every surface closed with RoutingPolicyUnavailable (503). No schema change, no new configuration key, no wire change.

Evidence

  • Full matrix: fmt, strict clippy, no-default check and clippy, both serial workspace suites (194 test result: lines, zero failures), locked release build.
  • Focused: routing_policy 12, routing_domain 16, routing_fail_closed 6, catalog_refresh 7, on_prem_admin_ui 15, gateway_audit 2, routing_policy_enforcement 5, embeddings_api 4 (+1 ignored live qualification).
  • Each guard was shown failing on a deliberate perturbation: the pair swap, the compact capture removal, the selector revert, and a RoutingPolicyService reference under rust/src/routing/.
  • End-to-end with the release binary and an isolated home: consolidated demo-model, audited mode change, separate demo-model/demo, audited disable to [] with chat 503, stop/start still [] and 503, re-enable restores the pair.
  • Tooling suite 270 passed, 1 skipped; release docs validator pass.

Plan records

  • Corrective plan: plans/implementation/routing-policy-capacity/004-policy-enforcement-and-projection-correction.md
  • Closure: plans/closure/routing-policy-capacity/004-status.md (Status: closed)
  • The M001 closure now points at the corrective; the roadmap status table and the registry are updated.

Notes for review

  • No migration, configuration key, wire codec, or CLI change.
  • The selector pin refusal and the facts-level policy are deliberately redundant; together they refuse before any provider call.
  • Timing is local: warm revision read 1.5 us, GET /v1/models p50 0.4 ms over 200 loopback requests. The correction adds a snapshot read only to compact.

CI Test added 4 commits November 30, 2026 20:03
- Add migration v69 with a revision-triggered policy store for the discovery
  exposure mode, per-provider-model enablement, and metadata overrides.
- Carry an immutable policy snapshot into each request through routing facts;
  an unreadable store fails the request closed instead of ignoring a disable.
- Exclude disabled provider-model pairs in eligibility and project either
  consolidated or provider-qualified discovery ids.
- Add the /routing/policy admin page and audited /admin/routing mutations with
  revert-by-delete; keep models.expose_mode parseable but inert.
- Update the migration, route, module, and schema censuses, the runtime
  manifests, the architecture docs, and the changelog.
- Verified with fmt, strict clippy, no-default check and clippy, both serial
  suites, the locked release build, release docs, and the tooling suite.
- Add the M001 closure record with the requirement-to-evidence matrix, the
  invariant, failure, migration, and security reviews, and four low findings.
- Mark the milestone conditionally closed: end-to-end discovery, process
  restart, and revision-read timing remain named evidence gaps.
- Update the roadmap milestone table and the registry subsystem and
  recently-closed rows to cite the closure and implementation 7f961dc.
- Read the catalog pair as (model_id, provider_id) in the discovery
  projection and the admin datalists, so separate mode advertises the
  provider-qualified ids the catalog holds instead of only virtual aliases.
- Resolve one policy snapshot per request on chat, streaming, compact, and
  embeddings; share that Arc with the selector dispatch and the concrete
  routing facts, and refuse a selector pin the snapshot disables.
- Show the stored input-token override, the effective upstream limit, and
  its source tag on the metadata page; report a row the catalog does not
  know as orphaned.
- Correct the deep-dive sentence that claimed a repeated save writes no
  audit row, and record the two-guard enforcement and one-snapshot rule.
- Add the acceptance evidence M001 claimed but did not execute: trigger
  matrix, failed-audit rollback, same-Arc identity, typed failure mapping,
  secret-free Debug, concurrent readers, candidate reason code, admin
  refusals for every mutation class, and a selection-boundary tooling guard.
- Close routing policy and capacity Milestone 4 with the discovery,
  restart, and revision-read evidence M001 named as gaps.
- Verified with fmt, strict clippy, no-default check and clippy, both serial
  suites, the focused routing targets, the locked release build, release
  docs, the tooling suite, and an isolated-home end-to-end run.
- Sort the imports and drop the redundant parentheses in the selection
  boundary test so it satisfies ruff format --check and ruff check, the
  two check-job steps the first CI run failed on.
- Verified with ruff format --check, ruff check, pyright, and the full
  tooling suite (270 passed, 1 skipped).
@dbowm91
dbowm91 merged commit 3ac4f8b into main Nov 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant