Skip to content

refactor(contract): 统一 JSON Schema 校验并保持兼容边界 - #248

Merged
uvwt merged 2 commits into
mainfrom
fix/pr247-jsonschema-compat
Oct 20, 2026
Merged

uvwt merged 2 commits into
mainfrom
fix/pr247-jsonschema-compat

Conversation

@uvwt

@uvwt uvwt commented Oct 20, 2026

Copy link
Copy Markdown
Owner

基于 #247 的依赖去重方案继续收口,保留 google/jsonschema-go 替换 santhosh-tekuri/jsonschema/v6 的方向,并补齐原 PR 暴露出的兼容性问题。

主要变更:

  • 保留 AgentDock 既有的模型可读校验错误契约,required / type 继续返回类似 $.text is required、$.text must be string 的稳定 reason。
  • 对 google/jsonschema-go 只支持 Draft-07 / 2020-12 的事实做显式边界检查;不把 Draft-04 / Draft-06 / 2019-09 静默按新 Draft 解释。
  • 增加 required、type、嵌套字段、$ref 路径以及 Draft 支持边界测试。
  • 保留 refactor(contract): replace santhosh-tekuri/jsonschema with google/jsonschema-go #247 的依赖精简与 output schema 测试迁移。

验证:

  • go test ./internal/tool/contract ./internal/mcp/client ./internal/app
  • go test -p 1 ./...
  • go test ./scripts/test -run TestScriptGovernance -count=1
  • go vet ./...
  • Windows go build -trimpath ... ./cmd/agentdock
  • gofmt / git diff --check

说明:TianYi 上直接用 Git Bash 执行 scripts/test/check-scripts.sh 会遇到 MSYS file:// 与 /dev/stderr 的宿主兼容问题;Go 侧治理测试已通过,POSIX shell 自检交由 Linux CI 验证。

原始实现与贡献来自 #247 / @myhomeiot。

myhomeiot and others added 2 commits October 18, 2026 21:13
…onschema-go

- Deduplicate schema validation: align with modelcontextprotocol/go-sdk and nexusdock, both of which natively use google/jsonschema-go.
- Drop santhosh-tekuri/jsonschema/v6 and 12 transitive golang.org/x/text packages from the dependency tree (-640 KiB binary size).
- Simplify internal/tool/contract by removing obsolete error-tree helpers in favor of direct error reporting.
@uvwt
uvwt merged commit 0c6f6de into main Oct 20, 2026
10 checks passed
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