fix(release): 以实例身份阻断绑定与发布跨实例
网页可能在实例 A 上列库并保存生产绑定,而文档发布执行器实际连实例 B。 克隆实例可以有相同知识库 ID、名称甚至租户,单靠 ID 无法证明写的是同一个 目标。现在绑定保存会冻结候选实例地址/租户,发布计划把身份冻结到每个项, 执行器在 Contract/Prepare/Activate/Restore/Compensate 前核对;不一致以 release_contract_mismatch 非重试失败关闭,不写目标。整库发布目标不变。 测试入库对象在上传前记录实际实例地址/租户;轮询、验收、移除先核对当前 连接,改绑实例或租户后旧对象不会被克隆实例接管。旧行没有身份时失败关闭。 「知识库绑定」保存要求对内/对外各选一个库,不再把显式未绑定回落到部署 默认 ID,避免换绑实例后带过去旧对象的默认库。 验证:隔离 PostgreSQL 覆盖绑定身份落库与发布计划冻结;v071 用同 ID/同租户 的 A/B 实例做正反例;四个测试 handler 的实例错配负例;前端 607 项通过。
This commit is contained in:
@@ -39,7 +39,7 @@ func TestLoadPublicationForUploadMapsVerifiedCandidate(t *testing.T) {
|
||||
|
||||
func TestMarkUploadingRejectsStalePublicationState(t *testing.T) {
|
||||
db := &recordingDB{commandTag: pgconn.NewCommandTag("UPDATE 0")}
|
||||
err := NewStore(db).MarkUploading(context.Background(), "publication-1", time.Date(2026, time.September, 4, 2, 0, 0, 0, time.UTC))
|
||||
err := NewStore(db).MarkUploading(context.Background(), "publication-1", "", 0, time.Date(2026, time.September, 4, 2, 0, 0, 0, time.UTC))
|
||||
if !errors.Is(err, ErrPublicationStateConflict) {
|
||||
t.Fatalf("MarkUploading() error = %v, want ErrPublicationStateConflict", err)
|
||||
}
|
||||
@@ -380,6 +380,8 @@ func (publicationValidationRow) Scan(dest ...any) error {
|
||||
*(dest[0].(*string)) = "publication-1"
|
||||
*(dest[1].(*string)) = "kb-1"
|
||||
*(dest[2].(*string)) = "knowledge-1"
|
||||
*(dest[3].(*string)) = ""
|
||||
*(dest[4].(*uint64)) = 0
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -547,13 +549,15 @@ func (row publicationPollRow) Scan(dest ...any) error {
|
||||
*(dest[0].(*string)) = "publication-1"
|
||||
*(dest[1].(*string)) = "kb-1"
|
||||
*(dest[2].(*string)) = "knowledge-1"
|
||||
*(dest[3].(*string)) = string(governance.ProcessingProcessing)
|
||||
*(dest[4].(*int)) = 2
|
||||
*(dest[5].(*string)) = "processing"
|
||||
*(dest[6].(**time.Time)) = &row.now
|
||||
*(dest[7].(**time.Time)) = &row.now
|
||||
*(dest[3].(*string)) = ""
|
||||
*(dest[4].(*uint64)) = 0
|
||||
*(dest[5].(*string)) = string(governance.ProcessingProcessing)
|
||||
*(dest[6].(*int)) = 2
|
||||
*(dest[7].(*string)) = "processing"
|
||||
*(dest[8].(**time.Time)) = &row.now
|
||||
*(dest[9].(**time.Time)) = &row.now
|
||||
*(dest[10].(**time.Time)) = &row.now
|
||||
*(dest[11].(**time.Time)) = &row.now
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -572,6 +576,8 @@ func (publicationUploadRow) Scan(dest ...any) error {
|
||||
"version-1",
|
||||
"kb-1",
|
||||
"",
|
||||
"", // test_instance_url
|
||||
uint64(0),
|
||||
string(governance.IngestPending),
|
||||
string(governance.ProcessingPending),
|
||||
"internal",
|
||||
@@ -589,6 +595,8 @@ func (publicationUploadRow) Scan(dest ...any) error {
|
||||
*target = value.(string)
|
||||
case *int64:
|
||||
*target = value.(int64)
|
||||
case *uint64:
|
||||
*target = value.(uint64)
|
||||
case *governance.Visibility:
|
||||
*target = governance.Visibility(value.(string))
|
||||
case nil:
|
||||
|
||||
Reference in New Issue
Block a user