feat(release): 发布目标知识库可选(源库 → 目标库映射)
- 迁移 000044:production_kb_bindings + release_item_executions.target_knowledge_base_id - 系统设置新增「生产知识库绑定(对内/对外)」:从生产 WeKnora 实际列表选库, 保存时真校验(不存在拒收;生产端不可达只提示并如实回报),仅管理员可改 - 执行计划按绑定解析目标库并冻结进 release_item_executions;空目标直接拒收; 已发布过的条目保留原目标(重试/回滚回到同一处) - DocumentBundle.RemapKnowledgeBase:knowledges/chunks/knowledge_tags/wiki_pages/ wiki_folders 的 knowledge_base_id 与 ES 文档字段改写为目标库,重算表/文档摘要并重新封装 - 契约比对改为「声明的映射对」(KnowledgeBaseMapping),其余字段继续 fail-closed - 契约检查器 / 目标身份 / 验证器全部走映射后的目标库;对象通道无需改写 - Compose 拆分:数据面接线 compose.release-sim.yaml + 两道门禁 compose.release-gates.yaml - 测试:RemapKnowledgeBase 全通道/无操作/fail-closed、映射契约、绑定接口、RBAC、真实 PG 集成
This commit is contained in:
@@ -37,14 +37,18 @@ var (
|
||||
)
|
||||
|
||||
type PlanItem struct {
|
||||
ReleaseExecutionID string `json:"release_execution_id"`
|
||||
PublicationID string `json:"publication_id"`
|
||||
Action string `json:"action"`
|
||||
SourceItemVersionID string `json:"source_item_version_id"`
|
||||
SourceRevision string `json:"source_revision"`
|
||||
ParseRevision string `json:"parse_revision"`
|
||||
ReleaseRevision string `json:"release_revision"`
|
||||
TestKnowledgeBaseID string `json:"test_knowledge_base_id"`
|
||||
ReleaseExecutionID string `json:"release_execution_id"`
|
||||
PublicationID string `json:"publication_id"`
|
||||
Action string `json:"action"`
|
||||
SourceItemVersionID string `json:"source_item_version_id"`
|
||||
SourceRevision string `json:"source_revision"`
|
||||
ParseRevision string `json:"parse_revision"`
|
||||
ReleaseRevision string `json:"release_revision"`
|
||||
TestKnowledgeBaseID string `json:"test_knowledge_base_id"`
|
||||
// TargetKnowledgeBaseID is the 源库 → 目标库 mapping resolved when the
|
||||
// execution started (see production_kb_bindings). It equals the tested base
|
||||
// when the scope is unbound, which is the historical same-id semantics.
|
||||
TargetKnowledgeBaseID string `json:"target_knowledge_base_id"`
|
||||
KnowledgeID string `json:"knowledge_id"`
|
||||
DecidedVisibility governance.Visibility `json:"decided_visibility"`
|
||||
PreviousProductionRevision string `json:"previous_production_revision"`
|
||||
@@ -56,6 +60,16 @@ type ItemResult struct {
|
||||
ProductionRevision string
|
||||
}
|
||||
|
||||
// TargetBase is the knowledge base this item is written to: the resolved
|
||||
// 源库 → 目标库 mapping when the release carries one, otherwise the tested base
|
||||
// itself (the historical same-id semantics).
|
||||
func (item PlanItem) TargetBase() string {
|
||||
if trimmed := strings.TrimSpace(item.TargetKnowledgeBaseID); trimmed != "" {
|
||||
return trimmed
|
||||
}
|
||||
return item.TestKnowledgeBaseID
|
||||
}
|
||||
|
||||
type StartExecutionRequest struct {
|
||||
ExecutionID string
|
||||
JobID string
|
||||
|
||||
@@ -43,6 +43,15 @@ func NewSidecarPublisher(exporter BundleExporter, target SidecarTarget) (*Sideca
|
||||
return &SidecarPublisher{exporter: exporter, target: target}, nil
|
||||
}
|
||||
|
||||
// releaseItemMapping declares which production base this item must land in: the
|
||||
// tested base it came from, and the 源库 → 目标库 target the execution resolved.
|
||||
func releaseItemMapping(item PlanItem) releasebundle.KnowledgeBaseMapping {
|
||||
return releasebundle.KnowledgeBaseMapping{
|
||||
SourceKnowledgeBaseID: item.TestKnowledgeBaseID,
|
||||
TargetKnowledgeBaseID: item.TargetKnowledgeBaseID,
|
||||
}
|
||||
}
|
||||
|
||||
func (publisher *SidecarPublisher) Publish(ctx context.Context, item PlanItem) (ItemResult, error) {
|
||||
bundle, err := publisher.exporter.Export(ctx, item)
|
||||
if err != nil {
|
||||
@@ -62,7 +71,7 @@ func (publisher *SidecarPublisher) Publish(ctx context.Context, item PlanItem) (
|
||||
if err != nil {
|
||||
return ItemResult{}, newSidecarError(ErrorCodeTargetUnavailable, true, err)
|
||||
}
|
||||
if err := releasebundle.Validate(manifest, targetContract); err != nil {
|
||||
if err := releasebundle.Validate(manifest, targetContract, releaseItemMapping(item)); err != nil {
|
||||
return ItemResult{}, newSidecarError(ErrorCodeContractMismatch, false, err)
|
||||
}
|
||||
change, err := publisher.target.Prepare(ctx, item, bundle)
|
||||
@@ -121,7 +130,7 @@ func (publisher *SidecarPublisher) Delete(ctx context.Context, item PlanItem) (I
|
||||
if err != nil {
|
||||
return ItemResult{}, newSidecarError(ErrorCodeTargetUnavailable, true, err)
|
||||
}
|
||||
if err := releasebundle.Validate(manifest, targetContract); err != nil {
|
||||
if err := releasebundle.Validate(manifest, targetContract, releaseItemMapping(item)); err != nil {
|
||||
return ItemResult{}, newSidecarError(ErrorCodeContractMismatch, false, err)
|
||||
}
|
||||
change, err := publisher.target.Prepare(ctx, item, bundle)
|
||||
|
||||
Reference in New Issue
Block a user