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
@@ -3,6 +3,7 @@ package v071
import (
"context"
"errors"
"fmt"
"strings"
"time"
@@ -63,8 +64,14 @@ func (exporter *DocumentExporter) Export(ctx context.Context, item releaseworkfl
return nil, errors.New("invalid document release plan")
}
sourceContract, err := exporter.config.Contract.Contract(ctx, item)
if err != nil || sourceContract.WeKnoraVersion != releasebundle.WeKnoraVersionV071 ||
sourceContract.MigrationVersion != releasebundle.WeKnoraMigrationV071 || sourceContract.TenantID != exporter.config.TenantID ||
if err == nil && (sourceContract.WeKnoraVersion != releasebundle.WeKnoraVersionV071 ||
sourceContract.MigrationVersion != releasebundle.WeKnoraMigrationV071) {
// 单文档发布包是 0.7.1 契约:读到的库是别的版本时必须说清楚原因,
// 而不是和"租户/模型不对"共用一句泛化错误。
return nil, fmt.Errorf("single-document release supports only v0.7.1 (74): source library declares %s (%d), so its rows and index documents must go through the library-level publish path",
sourceContract.WeKnoraVersion, sourceContract.MigrationVersion)
}
if err != nil || sourceContract.TenantID != exporter.config.TenantID ||
sourceContract.KnowledgeBaseID != item.TestKnowledgeBaseID || sourceContract.RetrieverEngine != "elasticsearch_v8" ||
sourceContract.EmbeddingModel != exporter.config.EmbeddingModel || sourceContract.EmbeddingDimension != releasebundle.EmbeddingDimensionV071 {
return nil, errors.New("source WeKnora release contract mismatch")