feat(models): integrate governed model configuration - #3849
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There are confirmed UI regressions (using unsupported Alert prop title) and an auth error-detail regression for TokenExpiredError that should be fixed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR integrates “model capacity governance” end-to-end across the DB schema, backend service/app layers, and the frontend model configuration flows, so capacity facts and provenance (catalog/provider/operator/legacy) are persisted consistently and can be audited/adopted via dedicated endpoints.
Changes:
- Backend: adds governed capacity/profile identity metadata fields, introduces transactional batch mutation writing, and adds capacity governance endpoints (health, catalog status, adoption preview/adopt, token-count probe).
- Frontend: extends model/config types and service mappers, updates add/edit dialogs to support capacity adoption + probing, and removes the legacy capacity coverage widget from the resource page.
- Tests: updates backend tests for the new transaction write path, new endpoints, and revised reserve policy behavior.
File summaries
| File | Description |
|---|---|
| test/backend/utils/test_config_utils.py | Updates reserve policy tests to match new “code default only” behavior. |
| test/backend/services/test_model_management_service.py | Adds coverage for profile resolution/governance persistence and mutation batching. |
| test/backend/database/test_model_managment_db.py | Adds tests for single-transaction apply_model_mutations. |
| test/backend/app/test_model_managment_app.py | Migrates to async HTTP client and adds tests for new governance endpoints/authorization. |
| frontend/types/modelConfig.ts | Adds types for governance metadata, adoption previews, health/catalog status. |
| frontend/services/modelService.ts | Adds API calls + mapping for governance metadata, health, adoption, and probing. |
| frontend/services/api.ts | Adds new capacity governance API endpoints. |
| frontend/lib/modelCapacityPayload.ts | Centralizes capacity payload building for add/edit flows. |
| frontend/app/[locale]/resource-manage/components/resources/ModelList.tsx | Removes the resource-page capacity coverage widget entry point. |
| frontend/app/[locale]/resource-manage/components/resources/ModelCapacityCoverageWidget.tsx | Deletes the legacy capacity coverage widget component. |
| frontend/app/[locale]/models/components/model/ModelEditDialog.tsx | Adds “review automatic update” + token-count probe actions and payload acceptance rules. |
| frontend/app/[locale]/models/components/model/ModelDeleteDialog.tsx | Improves React key stability for model rows. |
| frontend/app/[locale]/models/components/model/ModelCapacityFields.tsx | Displays field provenance + adds adoption/probe actions and revised validation/payload behavior. |
| frontend/app/[locale]/models/components/model/ModelAddDialog.tsx | Updates batch/single add flows to match new capacity governance + payload rules. |
| backend/utils/config_utils.py | Deprecates tenant soft-ratio override from runtime behavior. |
| backend/services/model_management_service.py | Adds governance merge/resolution flow, health/audit endpoints, and mutation batching. |
| backend/database/model_management_db.py | Introduces apply_model_mutations transactional writer. |
| backend/database/db_models.py | Adds new JSON/identity/provenance columns to model records (and monitoring evidence). |
| backend/apps/model_managment_app.py | Adds governance API routes and role-gated helpers for adoption/probing. |
Review details
Suppressed comments (3)
frontend/app/[locale]/models/components/model/ModelCapacityFields.tsx:490
Alertfromantdusesmessage, nottitle. Usingtitlehere likely drops the suggestion banner headline entirely.
title={
frontend/app/[locale]/models/components/model/ModelCapacityFields.tsx:570
Alertfromantdusesmessage, nottitle. As written, the validation error text may not render at all.
<Alert type="error" showIcon title={t(validationError)} />
frontend/app/[locale]/models/components/model/ModelAddDialog.tsx:1813
Alertfromantduses themessageprop, nottitle. Withtitlethe batch-default capacity hint header may not render.
<Alert
type="info"
showIcon
title={t("model.dialog.capacity.batchDefault.title")}
description={t("model.dialog.capacity.batchDefault.hint")}
/>
- Files reviewed: 19/19 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def _get_authenticated_user(authorization: Optional[str]) -> tuple[str, str]: | ||
| try: | ||
| return get_current_user_id(authorization) | ||
| except UnauthorizedError as exc: | ||
| raise HTTPException(status_code=HTTPStatus.UNAUTHORIZED, detail="Unauthorized") from exc |
| context_window_tokens: | ||
| payload.context_window_tokens ?? | ||
| (hasAny ? null : model.context_window_tokens), | ||
| max_input_tokens: | ||
| payload.max_input_tokens ?? | ||
| (hasAny ? null : model.max_input_tokens), | ||
| max_input_tokens: null, | ||
| max_output_tokens: |
| type="warning" | ||
| showIcon | ||
| message={t("model.dialog.capacity.legacyMaxTokensHint", { | ||
| title={t("model.dialog.capacity.legacyMaxTokensHint", { |
| <Alert | ||
| type="info" | ||
| showIcon | ||
| message={t("model.dialog.capacity.bulkApply.title")} | ||
| title={t("model.dialog.capacity.bulkApply.title")} | ||
| description={t("model.dialog.capacity.bulkApply.hint")} |
| displayName: string; | ||
| modelName: string; | ||
| modelFactory?: string | null; | ||
| modelType: "llm" | "vlm" | "vlm2" | "vlm3"; |
| def get_capacity_reserve_policy(self, tenant_id: str | None = None): | ||
| """Resolve W2 reserve policy from tenant config. | ||
| """Return the single automatic context action policy. | ||
|
|
||
| Missing `context.soft_limit_ratio` uses the code default. Invalid | ||
| configured values fail closed so production requests do not silently use | ||
| a different compaction envelope than operators configured. | ||
| The legacy tenant soft-ratio setting is accepted in storage for rolling | ||
| compatibility but intentionally does not alter runtime behavior. |
ba1bd8a to
d52f3fe
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
d52f3fe to
5648221
Compare
5648221 to
a377916
Compare
概要
把容量与能力治理接入模型数据库、管理 API、服务层和模型配置界面,使治理基础真正成为可维护的产品能力。
新增能力
对旧行为的调整
对 Nexent 的提升
减少用户配置项和错误覆盖来源,使运行时拿到一致、可解释的模型 profile,并为 Agent 输出空间保护提供单一事实来源。
规模与依赖
验证
git merge --squash;最终结果提交55600beb8,测试/构建通过且文件树与本分支一致。合并说明
这是堆叠变更的第二层;评审时 GitHub 仅展示相对前置分支的本层差异。