Skip to content

<feature>[ai] ZSTAC-84025: schema + SDK actions for inference template auto-match#3891

Open
zstack-robot-2 wants to merge 3 commits into5.5.22from
sync/ye.zou/feat/ZSTAC-84025-auto-match@@2
Open

<feature>[ai] ZSTAC-84025: schema + SDK actions for inference template auto-match#3891
zstack-robot-2 wants to merge 3 commits into5.5.22from
sync/ye.zou/feat/ZSTAC-84025-auto-match@@2

Conversation

@zstack-robot-2
Copy link
Copy Markdown
Collaborator

Scope (zstack core)

ZSTAC-84025 推理模板自动匹配 (Inference Template Auto-Match) for AIOS 5.5.22 — zstack core slice.

Changes (3 commits)

SHA What
552558629a V5.5.22__schema.sql — adds ModelVO.pipelineTag/manifestJson, ModelServiceRefVO.isDefault/createDate/lastOpDate
e088888775 SDK: new AutoMatchModelServiceByModelAction/Result, UpdateModelAction.defaultModelServiceUuid field
8ccf27b358 testlib ApiHelper.groovy regenerated with autoMatchModelServiceByModel DSL

Cross-repo dependencies

This MR is one of three:

  • zstack (this MR) — schema + SDK
  • premium ZSTAC-84025 — handler/matcher/interceptor/Case
  • aios ZSTAC-84025 — .gguf detection + YAML frontmatter parser + manifest passthrough

All three must land together; premium's runtime depends on schema added here.

Verification

  • ./runMavenProfile premium BUILD SUCCESS in PR docker (full clean install, 1h45m)
  • AutoMatchModelServiceCase 14 scenarios + perf PASS (288s)
  • Real-network ref distribution checked on .164/.159 — 33+25 refs, only 1 model has 2 refs → no upgrade dedupe needed
  • MariaDB single-CURRENT_TIMESTAMP constraint handled (createDate DEFAULT '0000-00-00 00:00:00')

Spec

sync from gitlab !9772

…erviceRefVO.isDefault/createDate/lastOpDate

Resolves: ZSTAC-84025

Change-Id: Ifbb68c9d475aa19762bb053e6545381a305dfe5b
…l.defaultModelServiceUuid

Resolves: ZSTAC-84025

Change-Id: I4046976b0c4437ba4c14069946b8075393f152ed
…Model DSL

Resolves: ZSTAC-84025

Change-Id: I0df26f7367a28da9c6c825dcddcb829db133374e
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

走查

该 PR 向数据库模式添加新列以支持管道标签和清单 JSON 元数据,同时为 ModelServiceRef 添加状态跟踪字段。在测试库中添加了新的 DSL 助手方法来支持自动匹配模型服务的操作。

改动

数据库 Schema 与测试支持

层 / 文件 总结
数据库 Schema
conf/db/upgrade/V5.5.22__schema.sql
向 ModelVO 添加 pipelineTag 和 manifestJson 列;向 ModelServiceRefVO 添加 isDefault、lastOpDate 和 createDate 列,具有相应的默认值和自动更新行为。
测试 DSL 方法
testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
新增 autoMatchModelServiceByModel 助手方法,用于构造、配置和执行 AutoMatchModelServiceByModelAction,支持 API 路径追踪。

代码审查工作量估计

🎯 2 (Simple) | ⏱️ ~12 分钟

🐰 新的列啊新的方,
Schema 添砖加瓦间,
时间戳记录每一刻,
测试方法来相伴,
模型服务更匹配!✨


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Title check ❌ Error 标题超过72字符的要求限制(81字符),不符合格式规范。 将标题缩短至72字符以内,例如:'[ai] ZSTAC-84025: schema + SDK for auto-match'
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed 拉取请求的描述与变更集密切相关,详细说明了所有三次提交的内容、跨仓库依赖关系和验证步骤。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/ye.zou/feat/ZSTAC-84025-auto-match@@2

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Microsoft Presidio Analyzer (2.2.362)
testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy

Microsoft Presidio Analyzer failed to scan this file


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@conf/db/upgrade/V5.5.22__schema.sql`:
- Line 17: 将 ALTER TABLE for `ModelServiceRefVO` 的 `createDate` 列默认值从
'0000-00-00 00:00:00' 改为 DEFAULT CURRENT_TIMESTAMP,并在修改列约束为 NOT NULL
之前为历史行回填合理时间:实现一个短小的存储过程/函数(例如
backfill_model_service_ref_create_date)在升级脚本中先查找并将所有旧值(NULL 或 '0000-00-00
00:00:00')更新为合适的时间戳(如 NOW() 或基于业务规则的时间),执行完回填后再运行 ALTER TABLE 修改列定义为 NOT NULL
DEFAULT CURRENT_TIMESTAMP,以确保在严格模式下升级不会失败并保留历史数据一致性。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: 457b51f9-3708-456c-b9b3-493701424bf5

📥 Commits

Reviewing files that changed from the base of the PR and between 18b0d53 and 8ccf27b.

⛔ Files ignored due to path filters (3)
  • sdk/src/main/java/org/zstack/sdk/AutoMatchModelServiceByModelAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/AutoMatchModelServiceByModelResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/UpdateModelAction.java is excluded by !sdk/**
📒 Files selected for processing (2)
  • conf/db/upgrade/V5.5.22__schema.sql
  • testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy

-- ZSTAC-84025: Add createDate/lastOpDate to ModelServiceRefVO so the auto-match Matcher can
-- pick the earliest isDefault=true row when DB has the rare 2+ defaults anomaly (Q5).
ALTER TABLE `zstack`.`ModelServiceRefVO` ADD COLUMN `lastOpDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE `zstack`.`ModelServiceRefVO` ADD COLUMN `createDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 只读校验:定位 zero-date 默认值及 NOT NULL 时间列定义
rg -n "ADD COLUMN `createDate`|ADD COLUMN `lastOpDate`|DEFAULT '0000-00-00 00:00:00'" conf/db/upgrade/V5.5.22__schema.sql

Repository: MatheMatrix/zstack

Length of output: 535


将第 17 行 createDate 的默认值改为 CURRENT_TIMESTAMP 并处理历史数据

第 17 行使用了 DEFAULT '0000-00-00 00:00:00',违反了 SQL 编码规范。根据要求应改为 DEFAULT CURRENT_TIMESTAMP,并由于列定义为 NOT NULL,必须使用存储过程或函数处理历史数据的回填,确保升级在严格模式下的兼容性。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@conf/db/upgrade/V5.5.22__schema.sql` at line 17, 将 ALTER TABLE for
`ModelServiceRefVO` 的 `createDate` 列默认值从 '0000-00-00 00:00:00' 改为 DEFAULT
CURRENT_TIMESTAMP,并在修改列约束为 NOT NULL 之前为历史行回填合理时间:实现一个短小的存储过程/函数(例如
backfill_model_service_ref_create_date)在升级脚本中先查找并将所有旧值(NULL 或 '0000-00-00
00:00:00')更新为合适的时间戳(如 NOW() 或基于业务规则的时间),执行完回填后再运行 ALTER TABLE 修改列定义为 NOT NULL
DEFAULT CURRENT_TIMESTAMP,以确保在严格模式下升级不会失败并保留历史数据一致性。

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