Documentation
¶
Overview ¶
Package capability supplies host-neutral capability descriptors, exact-match scope narrowing and safe typed application failures. Hosts own identity, policy, approval and operation implementations. Catalog discovery grants no permission. Transport adapters must enforce current authority before effects.
Index ¶
- Constants
- func CheckNarrowing(name string, previous, next Scope) error
- type Catalog
- type Code
- type Descriptor
- type Effect
- type EffectState
- type Error
- type FailureDetail
- type Grant
- type GrantSet
- func (s GrantSet) Clone() GrantSet
- func (s GrantSet) MarshalJSON() ([]byte, error)
- func (s *GrantSet) UnmarshalJSON(data []byte) error
- func (s GrantSet) Validate() error
- func (s GrantSet) ValidateForRuntime(r RuntimeIdentity) error
- func (s GrantSet) ValidateRenewal(next GrantSet, owner RuntimeIdentity, now time.Time) error
- type GrantValidationError
- type RPCErrorData
- type RequestID
- type RuntimeIdentity
- type Scope
- type ScopeSchema
Constants ¶
const ( ReadonlyQuery = "readonly.query" ContextSource = "context.source" DurableAgentWake = "durable_agent.wake" ReflexSeed = "reflex.seed" MCPReach = "mcp.reach" StorageRead = "storage.read" StorageWrite = "storage.write" SecretsRead = "secrets.read" EgressRequest = "egress.request" EventsPublish = "events.publish" LogWrite = "log.write" )
const ContractVersion = 1
ContractVersion versions the explicit grant contract, independently of the subprocess protocol and each capability descriptor's schema version.
const HostRPCErrorCode = -32010
const MaxSafeInteger uint64 = 9007199254740991
MaxSafeInteger is the maximum generation representable exactly by Go and JS.
Variables ¶
This section is empty.
Functions ¶
func CheckNarrowing ¶
CheckNarrowing rejects an attempted widening by capability name. New empty dimensions carry no authority; positive new limits/identifiers are denied.
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog publishes a host-selected subset and private copies of extensions. Extensions cannot shadow a shared name, even when that name is unsupported.
func NewCatalog ¶
func NewCatalog(supported []string, extensions []Descriptor) (*Catalog, error)
type Code ¶
type Code string
Code is a stable application failure classification.
const ( InvalidRequest Code = "invalid_request" Unauthenticated Code = "unauthenticated" CapabilityDenied Code = "capability_denied" ScopeDenied Code = "scope_denied" UnsupportedCapability Code = "unsupported_capability" BudgetExceeded Code = "budget_exceeded" RateLimited Code = "rate_limited" Cancelled Code = "cancelled" DeadlineExceeded Code = "deadline_exceeded" UnknownOutcome Code = "unknown_outcome" InternalError Code = "internal_error" Conflict Code = "conflict" )
type Descriptor ¶
type Descriptor struct {
Name string `json:"name"`
SchemaVersion int `json:"schema_version"`
ScopeSchema ScopeSchema `json:"scope_schema"`
Description string `json:"description"`
EffectCeiling Effect `json:"effect_ceiling"`
Operations []string `json:"operations"`
Proposed bool `json:"proposed"`
}
Descriptor defines semantics; it does not grant authority or install a handler. Proposed marks reverse-service entries pending catalog ratification.
func SharedDescriptors ¶
func SharedDescriptors() []Descriptor
SharedDescriptors returns independent copies of the seed and proposed catalogs. Hosts opt into a supported subset; presence here is not permission.
func (Descriptor) ValidateScope ¶
func (d Descriptor) ValidateScope(version int, s Scope) error
ValidateScope rejects unknown versions, dimensions, effects and operations.
type EffectState ¶
type EffectState string
EffectState distinguishes authorization refusal from an ambiguous mutation.
const ( NotStarted EffectState = "not_started" NotCommitted EffectState = "not_committed" Committed EffectState = "committed" Unknown EffectState = "unknown" )
type Error ¶
type Error struct {
Code Code `json:"code"`
Capability string `json:"capability,omitempty"`
RequestID RequestID `json:"request_id,omitempty"`
EffectState EffectState `json:"effect_state"`
Detail FailureDetail `json:"detail,omitempty"`
}
Error contains only safe classification metadata. Adapters must not copy internal error messages, arguments or credentials into wire errors.
func (*Error) RPCData ¶
func (e *Error) RPCData() (RPCErrorData, error)
RPCData validates classification and the positive profile correlation ID. Adapters must copy the enclosing request ID; equality with that envelope is checked by the transport, which owns the envelope.
type FailureDetail ¶
type FailureDetail string
FailureDetail is a closed machine-readable refinement, never raw diagnostics.
const ( StaleBinding FailureDetail = "stale_binding" CallbackCycle FailureDetail = "callback_cycle" DepthExceeded FailureDetail = "depth_exceeded" ParentInvalid FailureDetail = "parent_invalid" ParentTerminal FailureDetail = "parent_terminal" )
type Grant ¶
type Grant struct {
GrantID string `json:"grant_id"`
Name string `json:"name"`
SchemaVersion uint32 `json:"schema_version"`
Scope json.RawMessage `json:"scope"`
HostInstance string `json:"host_instance"`
OwnerID string `json:"owner_id"`
OwnerGeneration uint64 `json:"owner_generation"`
Audience string `json:"audience"`
IssuedAt string `json:"issued_at"`
ExpiresAt string `json:"expires_at"`
PolicyRevision string `json:"policy_revision"`
}
Grant is discovery data, not proof of permission at execution time. The host normalizes Scope under its descriptor and enforces current policy separately. Identifiers and timestamps are preserved without normalization.
func (Grant) MarshalJSON ¶
func (*Grant) UnmarshalJSON ¶
type GrantSet ¶
type GrantSet []Grant
GrantSet encodes nil and empty sets as [], and refuses null on decode.
func (GrantSet) MarshalJSON ¶
func (*GrantSet) UnmarshalJSON ¶
func (GrantSet) ValidateForRuntime ¶
func (s GrantSet) ValidateForRuntime(r RuntimeIdentity) error
ValidateForRuntime checks the single canonical tuple, including an empty set.
func (GrantSet) ValidateRenewal ¶
ValidateRenewal checks an unchanged, still-live authority set. Timestamps are the only mutable fields. It does not authenticate a host or approve policy; the host must revalidate both before sending and after receiving an ack. Scope bytes and grant order are retained exactly, including host extensions.
type GrantValidationError ¶
type GrantValidationError struct{ Field, Reason string }
GrantValidationError classifies a structural failure without including the rejected value, which may contain sensitive scope or identity data.
func (*GrantValidationError) Error ¶
func (e *GrantValidationError) Error() string
type RPCErrorData ¶
type RPCErrorData struct {
Contract string `json:"contract"`
Code Code `json:"code"`
RequestID RequestID `json:"request_id"`
EffectState EffectState `json:"effect_state"`
Retryable bool `json:"retryable"`
Detail FailureDetail `json:"detail,omitempty"`
}
RPCErrorData is the protocol-2 host application error payload. All errors prohibit automatic retry, including unknown outcomes and idempotent hints.
type RequestID ¶
type RequestID uint64
RequestID is a positive JavaScript-safe integer for host-rpc/1 correlation. It is distinct from the broader ID vocabulary in base JSON-RPC. Zero denotes an internal error without RPC correlation and cannot appear on the wire.
func (RequestID) MarshalJSON ¶
func (*RequestID) UnmarshalJSON ¶
type RuntimeIdentity ¶
type RuntimeIdentity struct {
HostInstance string `json:"host_instance"`
OwnerID string `json:"owner_id"`
OwnerGeneration uint64 `json:"owner_generation"`
}
RuntimeIdentity is the host-issued incarnation tuple. It is distinct from a manifest's server.runtime execution engine and from a verified caller identity.
func (RuntimeIdentity) MarshalJSON ¶
func (r RuntimeIdentity) MarshalJSON() ([]byte, error)
func (*RuntimeIdentity) UnmarshalJSON ¶
func (r *RuntimeIdentity) UnmarshalJSON(data []byte) error
func (RuntimeIdentity) Validate ¶
func (r RuntimeIdentity) Validate() error
type Scope ¶
type Scope struct {
Allowlists map[string][]string `json:"allowlists"`
Limits map[string]int64 `json:"limits"`
}
Scope is a normalized authority envelope, not a wire grant. Each allowlist contains exact identifiers, never patterns. A missing/empty list or missing/ zero budget conveys no authority. Limits are nonnegative ceilings, in units defined by the descriptor. Hosts must encode related identifiers (such as server/tool pairs) in one dimension rather than creating a Cartesian product.
func Intersect ¶
Intersect computes requested ∩ supported ∩ approved ∩ policy. All inputs must already use the same descriptor version; missing constraints deny. The result owns its maps and slices and never aliases an input.
type ScopeSchema ¶
ScopeSchema closes the vocabulary of exact-match dimensions and numeric ceilings. All named dimensions/limits must be present, including explicit empty lists/zero limits for denial. Units are documented in package docs.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
hosttest
Package hosttest runs behavioral capability conformance through a host's actual admission, dispatcher, lifecycle and non-plugin bridge adapters.
|
Package hosttest runs behavioral capability conformance through a host's actual admission, dispatcher, lifecycle and non-plugin bridge adapters. |