MCPcopy Create free account
hub / github.com/compozy/agh / Validate

Method Validate

internal/memory/contract/types.go:43–80  ·  view source on GitHub ↗

Validate reports whether the parsed memory header is complete and valid.

()

Source from the content-addressed store, hash-verified

41
42// Validate reports whether the parsed memory header is complete and valid.
43func (h *Header) Validate() error {
44 h.Normalize()
45 if h.Name == "" {
46 return fmt.Errorf("memory name is required")
47 }
48 if err := h.Type.Validate(); err != nil {
49 return err
50 }
51 if h.Scope != "" {
52 if err := h.Scope.Validate(); err != nil {
53 return err
54 }
55 }
56 if h.Scope == ScopeAgent {
57 if h.AgentName == "" {
58 return fmt.Errorf("agent name is required for agent-scoped memory")
59 }
60 if h.AgentTier == "" {
61 return fmt.Errorf("agent tier is required for agent-scoped memory")
62 }
63 if err := h.AgentTier.Validate(); err != nil {
64 return err
65 }
66 } else {
67 if h.AgentName != "" {
68 return fmt.Errorf("agent name requires agent scope")
69 }
70 if h.AgentTier != "" {
71 return fmt.Errorf("agent tier requires agent scope")
72 }
73 }
74 if h.Provenance != nil {
75 if err := h.Provenance.Validate(); err != nil {
76 return err
77 }
78 }
79 return nil
80}
81
82// Provenance records how a curated memory entry was created or superseded.
83type Provenance struct {

Callers 7

writeRawMethod · 0.95
ParseHeaderFunction · 0.95
scanMethod · 0.95
TestHeaderSerializationFunction · 0.95
renderMemoryDocumentFunction · 0.95

Calls 2

NormalizeMethod · 0.95
ValidateMethod · 0.65

Tested by 1

TestHeaderSerializationFunction · 0.76