Skip to content

feat(models): integrate governed model configuration - #3849

Open
JasonW404 wants to merge 1 commit into
split/context-capacity-foundationfrom
split/context-model-governance
Open

feat(models): integrate governed model configuration#3849
JasonW404 wants to merge 1 commit into
split/context-capacity-foundationfrom
split/context-model-governance

Conversation

@JasonW404

@JasonW404 JasonW404 commented Sep 3, 2026

Copy link
Copy Markdown
Member

概要

把容量与能力治理接入模型数据库、管理 API、服务层和模型配置界面,使治理基础真正成为可维护的产品能力。

新增能力

  • 模型 CRUD 支持上下文窗口、最大输出及其治理元数据。
  • Profile 模型自动使用受审查配置;自定义模型仅要求用户填写必要容量字段。
  • 前端模型新增/编辑流程提供一致的容量校验与 payload 适配。

对旧行为的调整

  • 去除资源页中孤立的容量覆盖组件,统一在模型设置流程维护。
  • 简化配置覆盖链,避免同一容量值在多个入口重复覆盖。
  • 旧数据仍可读取,新增字段保持可空并兼容滚动升级。

对 Nexent 的提升

减少用户配置项和错误覆盖来源,使运行时拿到一致、可解释的模型 profile,并为 Agent 输出空间保护提供单一事实来源。

规模与依赖

验证

  • 模型管理 API 94、数据库 32、服务 86、配置工具 33 个测试通过。
  • TypeScript type-check 通过。
  • Next.js 15.5.25 生产构建通过。
  • 本地在第一层 squash 结果上模拟本 PR 的 git merge --squash;最终结果提交 55600beb8,测试/构建通过且文件树与本分支一致。

合并说明

这是堆叠变更的第二层;评审时 GitHub 仅展示相对前置分支的本层差异。

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

  • Alert from antd uses message, not title. Using title here likely drops the suggestion banner headline entirely.
          title={

frontend/app/[locale]/models/components/model/ModelCapacityFields.tsx:570

  • Alert from antd uses message, not title. 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

  • Alert from antd uses the message prop, not title. With title the 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.

Comment on lines +106 to +110
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
Comment on lines 1012 to 1016
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", {
Comment on lines 1272 to 1276
<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";
Comment on lines 121 to +125
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.
@JasonW404
JasonW404 force-pushed the split/context-model-governance branch 3 times, most recently from ba1bd8a to d52f3fe Compare September 3, 2026 08:43
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.58763% with 118 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/apps/model_managment_app.py 59.74% 61 Missing and 1 partial ⚠️
backend/services/model_management_service.py 74.01% 40 Missing and 13 partials ⚠️
backend/database/model_management_db.py 85.00% 0 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@JasonW404
JasonW404 force-pushed the split/context-model-governance branch from d52f3fe to 5648221 Compare September 3, 2026 08:53
@JasonW404
JasonW404 force-pushed the split/context-model-governance branch from 5648221 to a377916 Compare September 3, 2026 09:10
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.

2 participants