capabilitycontract

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxSchemaDepth      = 32
	MaxSchemaNodes      = 4096
	MaxSchemaProperties = 1024
	MaxSchemaEnumValues = 1024
	MaxSchemaBranches   = 64
)
View Source
const SchemaVersion = "redevplugin.host_capability_contract.v1"

Variables

View Source
var (
	ErrInvalidContract  = errors.New("host capability contract is invalid")
	ErrIdentityMismatch = errors.New("host capability contract identity mismatch")
)

Functions

func DetailSchemaSHA256

func DetailSchemaSHA256(schema map[string]any) (string, error)

func GenerateTypeScript

func GenerateTypeScript(contract Contract) ([]byte, error)

func SchemaSHA256

func SchemaSHA256(schema map[string]any) (string, error)

func Validate

func Validate(contract Contract) error

func ValidatePin

func ValidatePin(pin Pin) error

func ValidateValue

func ValidateValue(schema map[string]any, value any) error

Types

type BusinessError

type BusinessError struct {
	Code          string         `json:"code"`
	Message       string         `json:"message"`
	DetailsSchema map[string]any `json:"details_schema,omitempty"`
}

type CancelPolicy

type CancelPolicy struct {
	Cancelable        bool   `json:"cancelable"`
	DisableBehavior   string `json:"disable_behavior"`
	UninstallBehavior string `json:"uninstall_behavior"`
	AckTimeoutMS      int    `json:"ack_timeout_ms,omitempty"`
}

type Confirmation

type Confirmation struct {
	Mode              string   `json:"mode"`
	PreflightMethod   string   `json:"preflight_method,omitempty"`
	RequestHashFields []string `json:"request_hash_fields,omitempty"`
	PlanHashRequired  bool     `json:"plan_hash_required,omitempty"`
}

type Contract

type Contract struct {
	SchemaVersion     string          `json:"schema_version"`
	ContractID        string          `json:"contract_id"`
	ContractVersion   string          `json:"contract_version"`
	PublisherID       string          `json:"publisher_id"`
	CapabilityID      string          `json:"capability_id"`
	CapabilityVersion string          `json:"capability_version"`
	ClientName        string          `json:"client_name"`
	Methods           []Method        `json:"methods"`
	Errors            []BusinessError `json:"errors,omitempty"`
}

type KnownContract added in v1.0.0

type KnownContract struct {
	Contract Contract
	Pin      Pin
	// contains filtered or unexported fields
}

func NewKnownContract added in v1.0.0

func NewKnownContract(contract Contract) (KnownContract, error)

NewKnownContract validates a Host-owned contract and binds its local registry identity to the canonical contract bytes shipped with the Host.

func NewKnownContractFromArtifact added in v1.1.3

func NewKnownContractFromArtifact(raw []byte) (KnownContract, error)

NewKnownContractFromArtifact validates a published contract artifact while retaining the digest of its exact immutable bytes as the registry pin.

type Method

type Method struct {
	Name                string         `json:"name"`
	ClientMethod        string         `json:"client_method"`
	Effect              string         `json:"effect"`
	Execution           string         `json:"execution"`
	PreflightOnly       bool           `json:"preflight_only,omitempty"`
	RequiredPermissions []string       `json:"required_permissions,omitempty"`
	TargetFields        []string       `json:"target_fields"`
	TargetSchema        map[string]any `json:"target_schema"`
	RequestTypeName     string         `json:"request_type_name"`
	ResponseTypeName    string         `json:"response_type_name"`
	RequestSchema       map[string]any `json:"request_schema"`
	ResponseSchema      map[string]any `json:"response_schema"`
	EventTypeName       string         `json:"event_type_name,omitempty"`
	EventSchema         map[string]any `json:"event_schema,omitempty"`
	Confirmation        *Confirmation  `json:"confirmation,omitempty"`
	CancelPolicy        *CancelPolicy  `json:"cancel_policy,omitempty"`
	Quota               Quota          `json:"quota"`
}

type Pin

type Pin struct {
	PublisherID     string `json:"publisher_id"`
	ContractID      string `json:"contract_id"`
	ContractVersion string `json:"contract_version"`
	ArtifactSHA256  string `json:"artifact_sha256"`
}

type Quota

type Quota struct {
	MaxConcurrent  int   `json:"max_concurrent,omitempty"`
	MaxDurationMS  int   `json:"max_duration_ms,omitempty"`
	MaxStreamBytes int64 `json:"max_stream_bytes,omitempty"`
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Add

func (r *Registry) Add(contract KnownContract) error

func (*Registry) Require

func (r *Registry) Require(pin Pin) (KnownContract, error)

Jump to

Keyboard shortcuts

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