feat(library): 发布写入支持 WeKnora 0.9.0 schema 134
build / build (push) Successful in 1m54s

整库发布写入路径原先按 0.7.1 的固定表集合工作:0.9.0 没有 wiki_log_entries,
Current/清理/编目/整实例指纹都会在不存在表上失败,跨版本闸门也因快照丢掉
SchemaVersion 而失效(未知版本被当作 74)。

改为在装配时解析目标 profile,表集合与清理顺序按解析结果;快照复制与范围改写
带上 SchemaVersion/Profile;跨版本发布显式拒绝并同时点名两个版本。单文档发布包
仍只支持 0.7.1,但改为明确拒绝并说明原因。

本机隔离验证:真实 0.9.0 schema 源库→导出→封存→写入干净 134 目标→逐表核对→
写前镜像回滚;74→134 拒绝与 134 缺表不报错两个负例通过。make verify 17 项全绿。
This commit is contained in:
姚章浩
2026-11-16 20:42:23 +08:00
parent 10568943af
commit fba2713b4e
21 changed files with 630 additions and 56 deletions
+24
View File
@@ -165,3 +165,27 @@ func TestValidateRejectsUndeclaredOrDriftedMapping(t *testing.T) {
})
}
}
// 单文档发布包只支持 0.7.1 契约。0.9.0(134)的包必须被**明确拒绝并说明原因**:
// 静默按 74 处理会让 0.9.0 的表集合/索引文档走错写入路径,而泛化错误又让人分不清
// "版本不支持"和"字段写错"。
func TestSealRejectsNonV071SchemaContractExplicitly(t *testing.T) {
manifest := validManifest()
manifest.Contract.WeKnoraVersion = "v0.9.0"
manifest.Contract.MigrationVersion = 134
_, err := Seal(manifest)
if err == nil {
t.Fatal("0.9.0 release bundle must be refused")
}
for _, want := range []string{"v0.9.0", "134", "74", "library-level publish"} {
if !strings.Contains(err.Error(), want) {
t.Fatalf("rejection message must name %q, got %v", want, err)
}
}
// 只改版本号、不改 WeKnora 版本同样必须拒绝:两者必须成对出现。
manifest = validManifest()
manifest.Contract.MigrationVersion = 134
if _, err := Seal(manifest); err == nil {
t.Fatal("schema version 134 with a v0.7.1 label must be refused")
}
}