执行时真实时钟与持久授权回读(撤销/过期即停并保留预备份)、写集合写前落盘、 租约与 attempt 身份、恢复队列与原发送身份分离、成功收尾必须释放维护后再登记终态。
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package governance
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func LibraryQueueRequest(handoff bool, jobID, scope, snapshotID, releaseType string) (string, string, []byte, error) {
|
||||
payload := map[string]string{"library_job_id": jobID, "scope": scope, "target_snapshot_id": snapshotID}
|
||||
queueID := QueueJobIDFor(jobID)
|
||||
queueType := releaseType
|
||||
if handoff {
|
||||
payload["next_type"] = releaseType
|
||||
queueID = LibraryHandoffQueueJobID(jobID)
|
||||
queueType = "library.snapshot.handoff"
|
||||
}
|
||||
raw, err := json.Marshal(payload)
|
||||
return queueID, queueType, raw, err
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package governance
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
// The recovery request has its own queue identity and stable operation. It
|
||||
// borrows the original window's fence, never its immutable sending identity.
|
||||
func LibraryRecoveryQueueID(windowJob string) string {
|
||||
sum := sha256.Sum256([]byte(windowJob))
|
||||
return "lrec-" + hex.EncodeToString(sum[:14])
|
||||
}
|
||||
|
||||
func LibraryRecoveryDigest(scope, queue, window, operation, target, source, backup, plan string) (string, error) {
|
||||
return LibraryRequestDigest(scope, LibraryJobRecover, map[string]any{
|
||||
"recovery_queue": queue, "window_job": window, "original_operation": operation,
|
||||
"target_id": target, "source_snapshot": source, "backup_snapshot": backup, "writeset_digest": plan,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package governance
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// SourceIdentity binds an immutable capture to its configured origin, not to a
|
||||
// target or a page of mixed version history. It does not modify snapshot hashes.
|
||||
type LibrarySourceIdentity struct {
|
||||
Project string `json:"project"`
|
||||
App string `json:"app"`
|
||||
Scope string `json:"scope"`
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
KnowledgeBaseID string `json:"knowledge_base_id"`
|
||||
}
|
||||
|
||||
func (s LibrarySourceIdentity) ID() (string, error) {
|
||||
if s.Project == "" || s.App == "" || (s.Scope != "internal" && s.Scope != "external") || s.TenantID == 0 || s.KnowledgeBaseID == "" {
|
||||
return "", errors.New("source project/app/scope/tenant/knowledge base binding incomplete")
|
||||
}
|
||||
raw, err := json.Marshal(s)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
sum := sha256.Sum256(raw)
|
||||
return hex.EncodeToString(sum[:]), nil
|
||||
}
|
||||
Reference in New Issue
Block a user