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 }