Repository navigation
refactor(module): 消费 pub.ihub.module:ihub-module-core 替代自有双实现模型 - #6
Merged
Merged
Conversation
- 删除 agents 自有 ModuleDescriptor/ModuleCapability/McpToolDefinition(3 个 record),改用 pub.ihub.module:ihub-module-core 0.3.1(modules 发布,加了 @JsonIgnoreProperties 容错) - ModuleService/ModuleTools import 变更:pub.ihub.module.core.* 替代自有包 - m.status() 从 String 变 enum → ModuleTools 用 .name() 序列化为 JSON 字符串 - 0.3.1 的容错反序列化(忽略 /required 等模型外字段)是本次依赖切换的前提(见 modules #377) - 消除双实现:两仓模型统一,未来 schema 演进只改 module-core 一处
There was a problem hiding this comment.
Pull request overview
该 PR 通过直接依赖 pub.ihub.module:ihub-module-core:0.3.1 来统一 agents 与 modules 两仓的 ModuleDescriptor / McpToolDefinition 等模型,消除 agents 侧自维护的重复实现,并修复解析真实 descriptor(含未知字段如 $schema)时的兼容性问题。
Changes:
- 删除
mcp-server内自有的ModuleDescriptor(及内嵌ModuleCapability/McpToolDefinition)实现,改为消费ihub-module-core的模型。 ModuleService/ModuleTools替换为pub.ihub.module.core.*的类型引用,并调整模块工具列表返回类型。mcp-server增加ihub-module-core:0.3.1依赖;status输出由String迁移到 enum 后显式序列化为字符串。
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| mcp-server/src/main/java/pub/ihub/agent/mcp/tools/ModuleTools.java | 切换到 module-core 的 ModuleDescriptor/McpToolDefinition,并调整 status 输出与工具列表类型。 |
| mcp-server/src/main/java/pub/ihub/agent/mcp/module/ModuleService.java | 使用 module-core 的 ModuleDescriptor 反序列化并返回 module-core 的工具定义列表。 |
| mcp-server/src/main/java/pub/ihub/agent/mcp/module/ModuleDescriptor.java | 删除 agents 自有重复模型实现(由 module-core 替代)。 |
| mcp-server/build.gradle.kts | 添加 ihub-module-core:0.3.1 依赖以消费统一模型。 |
Suppressed comments (1)
mcp-server/src/main/java/pub/ihub/agent/mcp/tools/ModuleTools.java:91
- Same as above:
.name()can change the externally visiblestatusstring (and bypass any@JsonValue/toString()mapping) and can NPE ifstatusis null. Prefer passing the enum through to JSON serialization.
map.put("status", m.status().name());
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| detail.put("version", m.version()); | ||
| detail.put("domain", m.domain()); | ||
| detail.put("status", m.status()); | ||
| detail.put("status", m.status().name()); |
Comment on lines
+81
to
84
| public List<pub.ihub.module.core.McpToolDefinition> listTools(String moduleId) { | ||
| return findById(moduleId) | ||
| .map(m -> m.mcpTools() != null ? m.mcpTools() : List.<ModuleDescriptor.McpToolDefinition>of()) | ||
| .map(m -> m.mcpTools() != null ? m.mcpTools() : List.<pub.ihub.module.core.McpToolDefinition>of()) | ||
| .orElse(List.of()); |
| implementation(libs.spring.boot.starter.web) | ||
| implementation(libs.spring.ai.starter.mcp.server) | ||
| implementation(libs.ihub.migrate.analyzer) | ||
| implementation("pub.ihub.module:ihub-module-core:0.3.1") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更概要
审计缺口 #7:消除 agents 与 modules 的 ModuleDescriptor 双实现,两仓模型统一。
背景
agents mcp-server 自带
ModuleDescriptor/ModuleCapability/McpToolDefinition三个 record,与 modules
ihub-module-core:0.3.0模型结构相同但代码独立——schema 漏进同一处则两仓都得改、且 agents 侧没有 @JsonIgnoreProperties,解析真实 iam descriptor(含
$schema)会炸。前置合并(已完成)
@JsonIgnoreProperties(ignoreUnknown = true)+ 契约测试,发 0.3.1(已上 Central)变更
mcp-server/.../module/ModuleDescriptor.java(含内部 ModuleCapability/McpToolDefinition)mcp-server/build.gradle.kts:加implementation("pub.ihub.module:ihub-module-core:0.3.1")ModuleService:import 改为pub.ihub.module.core.ModuleDescriptorModuleTools:importModuleDescriptor/McpToolDefinition(均为 module-core top-level record);m.status()从 String→enum →.name()序列化为 JSON 字符串验证
./gradlew build✓(本地 JDK 25,0.3.1 从 Central 解析)契约保障
ModuleDescriptorContractTest(解析真实 iam descriptor + 未来未知字段容错)——agents 不需要单独加测试,consumption 隐式受此契约保护