feat(backend/api): admin LLM registry API with audit logging - #13611
feat(backend/api): admin LLM registry API with audit logging#13611ntindle wants to merge 4 commits into
Conversation
Part 7 of 9 of the LLM registry restack. Re-cut of #12467's admin API onto current dev layout (backend/api/features/admin/ + backend/data/llm_registry/), reworked per the restack design: - provider CRUD dropped (fixed seed rows; read-only list kept for UI); model CRUD, creator CRUD, disable-with-replacement + revert kept - every write claims source=LOCAL — the importer's admin-wins contract - AuditLog row per mutation (entity-typed actions, before/after snapshots; audit failure never fails the op) - new columns wired through requests/db/responses: visibility, minSubscriptionTier, fallbackModelSlug (validated), kind - unqualified "AgentNode" raw SQL fixed to {schema_prefix} helpers (the bug class majdyz flagged in the original review) - fixed a latent revert bug: migrate wrote provider-stripped node values but revert matched raw slugs, so reverts could never match - NEW: GET/PUT /api/admin/llm/routes (cell upsert with exists+enabled validation, HIDDEN allowed, capability warnings for e.g. non-reasoning models in thinking cells), GET /routes/warnings (recent LD-slug refusals from part 6), GET /catalog/export (catalog.json refresh via curl instead of prod DB access) Follow-ups noted: "reset to catalog" admin action (LOCAL is sticky); toggle-with-real-node-migration integration test needs graph fixtures. Co-authored-by: Bentlybro <Github@bentlybro.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/llm-registry-v2-copilot-routing #13611 +/- ##
=====================================================================
Coverage 76.01% 76.01%
=====================================================================
Files 2688 2688
Lines 204266 204266
Branches 19654 19653 -1
=====================================================================
+ Hits 155266 155278 +12
+ Misses 44657 44648 -9
+ Partials 4343 4340 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…istry-v2-admin-api
Bare-dict list responses generated untyped orval clients. Adds LlmModelsAdminListResponse et al., annotates the four GET list endpoints, and includes the source field on provider/creator responses (the admin UI shows source badges). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ints Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
After a post-build design review we pivoted from the DB-registry to catalog-as-code: one canonical, schema-validated catalog file is the source of truth (models + costs + copilot routing), updated by PR (catalog-only diffs may ride hotfix→master; the /review bot covers the lane), propagated by CD, with LaunchDarkly demoted to optional cohort experiments and git history as the audit log. Rationale: the admin machinery mostly bought instant-mutation and non-engineer authoring we don't need, and LD is too unreliable to be the load-bearing control layer. The retirement machinery (incl. the revert-matching fix found here) lives on as the CLI in #13625; the CRUD/audit/routing endpoints have no replacement by design — the PR is the write path, git is the audit. |
Why
Part 7 of 9 of the LLM registry restack (#13605→#13606→#13607→#13608→#13609→#13610→this). This is the front door that replaces the "hand-edit a JSON file and open a PR" model-management workflow: adding K3 becomes an authenticated admin call whose row is validated, audited, and propagated to every install.
What
Admin API at
/api/admin/llm(allSecurity(requires_admin_user)), re-cut from @Bentlybro's #12467:{slug:path}params), creator CRUD, usage counting, disable-with-replacement + revertsource=LOCALon every write — the importer's admin-wins contract from feat(backend): add idempotent LLM catalog importer and bundled catalog #13607AuditLogtable; entity-typed actions likeLLM_MODEL_DISABLED, before/after JSON; audit failure never fails the operation)visibility,min_subscription_tier,fallback_model_slug(existence-validated),kindGET/PUT /routes(routing-cell upsert; model must exist + be enabled, HIDDEN allowed; response carries capability warnings — e.g. non-reasoning model in a thinking cell);GET /routes/warnings(the feat(backend/copilot): resolve copilot models through the LLM registry #13610 refusal records — typo'd LD slugs surface here);GET /catalog/export(regenerate the bundled catalog.json with a curl)Fixes over the original branch
"AgentNode"raw SQL →{schema_prefix}helpers (the exact bug class flagged in the original feat(platform): Add LLM registry core - DB layer + in-memory cache #12359 review; breaks non-platformschemas otherwise)refresh_runtime_cachescopy replaced by the canonical one (single choke point for cache coherence)Verification
poetry run format+poetry run lintcleanKnown follow-ups (tickets, not scope): "reset to catalog" action (LOCAL is sticky by design); toggle-with-populated-graph integration test needs graph fixtures.
Checklist