denial

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package denial is the single client-error-envelope/v1 type for cost-bearing and entitlement denials. The schema lives in the workspace (kombify-Core/standards/client-error-envelope.v1.schema.json). Callers must not declare a parallel envelope; user_guidance is always an object.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidEnvelope = errors.New("denial: envelope is not client-error-envelope/v1")
	ErrGuidanceObject  = errors.New("denial: user_guidance must be an object")
)

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	ErrorCode        string         `json:"error_code"`
	ReasonCode       string         `json:"reason_code"`
	RequestID        string         `json:"request_id,omitempty"`
	Capability       string         `json:"capability,omitempty"`
	ProviderID       string         `json:"provider_id,omitempty"`
	RequiredFeatures []string       `json:"required_features,omitempty"`
	MissingFeatures  []string       `json:"missing_features,omitempty"`
	Retryable        bool           `json:"retryable"`
	UserGuidance     UserGuidance   `json:"user_guidance"`
	Remediation      string         `json:"remediation,omitempty"`
	SupportContext   map[string]any `json:"support_context,omitempty"`
}

Envelope is the machine-readable denial. Required fields match the workspace schema: error_code, reason_code, retryable, user_guidance.

func Parse

func Parse(data []byte) (Envelope, error)

Parse decodes a client-error-envelope/v1 document and fails closed when user_guidance is a string or any required field is missing.

func (*Envelope) Error

func (e *Envelope) Error() string

func (Envelope) MarshalJSON

func (e Envelope) MarshalJSON() ([]byte, error)

MarshalJSON always writes user_guidance as an object.

func (*Envelope) Validate

func (e *Envelope) Validate() error

Validate reports whether the envelope satisfies the required schema fields.

type UserGuidance

type UserGuidance struct {
	Title     string   `json:"title"`
	Body      string   `json:"body"`
	NextSteps []string `json:"next_steps"`
}

UserGuidance is the human-facing part of a denial. It is always a JSON object with title, body, and at least one next step.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL