feat: add command domain invariants

This commit is contained in:
2026-08-31 08:09:28 +00:00
parent e23737de0d
commit 49627a9f5a
14 changed files with 869 additions and 1 deletions
+27
View File
@@ -0,0 +1,27 @@
package domain
import "crypto/sha256"
type RequestHash [sha256.Size]byte
func HashImmutableRequest(canonical []byte) RequestHash { return sha256.Sum256(canonical) }
type ReplayDecision uint8
const (
ReplayNew ReplayDecision = iota
ReplayExact
ReplayConflict
)
// ClassifyReplay compares a canonical immutable request against durable state.
// A nil stored hash means no mutation with this request UUID exists.
func ClassifyReplay(stored *RequestHash, incoming RequestHash) ReplayDecision {
if stored == nil {
return ReplayNew
}
if *stored == incoming {
return ReplayExact
}
return ReplayConflict
}