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

Function NormalizeEnvelope

internal/network/validate.go:84–101  ·  view source on GitHub ↗

NormalizeEnvelope trims identifier fields, validates the envelope, and returns a safe cloned copy for downstream use.

(env Envelope, opts ValidateOptions)

Source from the content-addressed store, hash-verified

82// NormalizeEnvelope trims identifier fields, validates the envelope, and
83// returns a safe cloned copy for downstream use.
84func NormalizeEnvelope(env Envelope, opts ValidateOptions) (Envelope, error) {
85 opts = opts.withDefaults()
86
87 normalized := normalizeEnvelopeCopy(env)
88 if err := validateEnvelopeHeader(normalized); err != nil {
89 return Envelope{}, err
90 }
91 if err := validateEnvelopeParticipants(normalized); err != nil {
92 return Envelope{}, err
93 }
94 if err := validateEnvelopeReferences(normalized); err != nil {
95 return Envelope{}, err
96 }
97 if err := validateEnvelopeBodyAndFreshness(normalized, opts); err != nil {
98 return Envelope{}, err
99 }
100 return normalized, nil
101}
102
103// ValidateEnvelope validates one envelope without returning a normalized copy.
104func ValidateEnvelope(env Envelope, opts ValidateOptions) error {

Calls 6

normalizeEnvelopeCopyFunction · 0.85
validateEnvelopeHeaderFunction · 0.85
withDefaultsMethod · 0.45