Skip to content

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

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

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

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 !9745

…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 Apr 27, 2026

概览

该拉取请求向 ModelVOModelServiceRefVO 表添加新列以支持推理模板自动匹配功能,包括管道标签、清单JSON数据及默认标记。同时在测试库中引入新的 API 辅助方法,用于自动匹配模型服务。

更改

集群 / 文件 摘要
数据库架构迁移
conf/db/upgrade/V5.5.22__schema.sql
ModelVO 表添加 pipelineTagmanifestJson 列;向 ModelServiceRefVO 表添加 isDefaultcreateDatelastOpDate 时间戳列,支持基于默认标记和时间顺序的模板引用选择。
测试框架扩展
testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
新增 autoMatchModelServiceByModel() API 辅助方法,用于创建和执行 AutoMatchModelServiceByModelAction 操作,包含会话ID传递、API路径跟踪及错误处理逻辑。

预估代码审查工作量

🎯 2 (简单) | ⏱️ ~10 分钟

🐰 新列添入数据库里,
模板自动来相配,
测试助手展身手,
架构锦上又添花。
迁移升级齐完美!


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 Pull request title exceeds 72 character limit (81 characters) and is otherwise properly formatted. Reduce title length to 72 characters or less while maintaining the required [scope]: format.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description comprehensively covers the pull request scope, changes, dependencies, verification, and references, directly relating to the changeset.
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

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 the current code and only fix it if needed.

Inline comments:
In `@conf/db/upgrade/V5.5.22__schema.sql`:
- Around line 5-6: The upgrade script uses raw ALTER TABLE ... ADD COLUMN for
ModelServiceRefVO.`isDefault` (and the other two ADD COLUMNs at the same file)
which can fail if the column already exists; change these raw ALTERs to the same
safe pattern used elsewhere in this file (use the ADD_COLUMN wrapper function or
an existence check via information_schema) so the script is idempotent — update
the statements that add isDefault (and the other two direct ADD COLUMN lines) to
call the ADD_COLUMN helper or surround them with a conditional existence check
before ALTER TABLE.
🪄 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: f82ecf34-a85f-4358-b16f-ef10bf4145b4

📥 Commits

Reviewing files that changed from the base of the PR and between ce7b222 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

Comment on lines +5 to +6
ALTER TABLE `zstack`.`ModelServiceRefVO` ADD COLUMN `isDefault` TINYINT(1) NOT NULL DEFAULT 0;

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

升级脚本加列方式不一致,存在重复执行失败风险。

Line 5、Line 16、Line 17 直接使用 ALTER TABLE ... ADD COLUMN,而同文件 Line 2/12 使用了 ADD_COLUMN 封装。若目标环境已存在这些列,直接 ALTER 会中断升级。建议统一改为带存在性检查的方式(如 ADD_COLUMNinformation_schema 判存)。

As per coding guidelines: "Upgrading scene has been carefully handled".

Also applies to: 16-17

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@conf/db/upgrade/V5.5.22__schema.sql` around lines 5 - 6, The upgrade script
uses raw ALTER TABLE ... ADD COLUMN for ModelServiceRefVO.`isDefault` (and the
other two ADD COLUMNs at the same file) which can fail if the column already
exists; change these raw ALTERs to the same safe pattern used elsewhere in this
file (use the ADD_COLUMN wrapper function or an existence check via
information_schema) so the script is idempotent — update the statements that add
isDefault (and the other two direct ADD COLUMN lines) to call the ADD_COLUMN
helper or surround them with a conditional existence check before ALTER TABLE.

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