Add semantic configuration resume evidence
This commit is contained in:
32
internal/manifest/semantic_fingerprint.go
Normal file
32
internal/manifest/semantic_fingerprint.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package manifest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var lowercaseSHA256Pattern = regexp.MustCompile(`^[0-9a-f]{64}$`)
|
||||
|
||||
// SemanticConfigFingerprint identifies the versioned, result-affecting
|
||||
// configuration observed by one pipeline stage.
|
||||
type SemanticConfigFingerprint struct {
|
||||
Version int `json:"version"`
|
||||
Digest string `json:"digest"`
|
||||
}
|
||||
|
||||
// Validate checks the durable fingerprint contract.
|
||||
func (f SemanticConfigFingerprint) Validate() error {
|
||||
if f.Version <= 0 {
|
||||
return fmt.Errorf("version must be positive")
|
||||
}
|
||||
if !lowercaseSHA256Pattern.MatchString(f.Digest) {
|
||||
return fmt.Errorf("digest must be a lowercase SHA-256 value")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Equal reports whether two valid fingerprint records identify the same
|
||||
// semantic configuration contract and payload.
|
||||
func (f SemanticConfigFingerprint) Equal(other SemanticConfigFingerprint) bool {
|
||||
return f.Version == other.Version && f.Digest == other.Digest
|
||||
}
|
||||
Reference in New Issue
Block a user