Documentation
¶
Overview ¶
Package capabilitycontract centralizes the helper utilities shared by the carved vibes/capability/* subpackages. The helpers operate on vibes/value.Value so they stay free of runtime-AST imports and can be reused by every capability adapter without forcing each one to take a hard dependency on the vibes package.
Index ¶
- Constants
- func CloneDataOnlyValue(label string, val value.Value) (value.Value, error)
- func CloneHash(src map[string]value.Value) map[string]value.Value
- func CloneHashValue(label string, val value.Value) (map[string]value.Value, error)
- func CloneKwargs(kwargs map[string]value.Value) map[string]value.Value
- func CloneKwargsDataOnly(method string, kwargs map[string]value.Value) (map[string]value.Value, error)
- func CloneMethodResult(method string, result value.Value) (value.Value, error)
- func DeepCloneValue(val value.Value) value.Value
- func EnsureBlock(block value.Value, name string) error
- func IsNilImplementation(impl any) bool
- func NameArg(method, label string, val value.Value) (string, error)
- func ValidateAnyReturn(method string) func(result value.Value) error
- func ValidateDataOnlyValue(label string, val value.Value) error
- func ValidateHashValue(label string, val value.Value) error
- func ValidateKwargsDataOnly(method string, kwargs map[string]value.Value) error
Constants ¶
const MaxDataOnlyTraversalDepth = capabilitydata.MaxDepth
MaxDataOnlyTraversalDepth bounds recursive capability payload validation and cloning so deeply nested acyclic values cannot exhaust the host stack.
Variables ¶
This section is empty.
Functions ¶
func CloneDataOnlyValue ¶ added in v0.60.0
CloneDataOnlyValue validates and deep-copies val in one graph walk.
func CloneHash ¶
CloneHash returns a deep copy of the provided string-keyed map. An empty input returns an empty (non-nil) map to preserve historical behavior of the in-package helper this replaced.
func CloneHashValue ¶ added in v0.60.0
CloneHashValue checks that val is a hash or object, validates that it contains only data values, and returns an isolated copy of its entries.
func CloneKwargs ¶
CloneKwargs returns a deep copy of the keyword-arguments map suitable for handing to host callbacks without exposing script-side aliases.
func CloneKwargsDataOnly ¶ added in v0.60.0
func CloneKwargsDataOnly(method string, kwargs map[string]value.Value) (map[string]value.Value, error)
CloneKwargsDataOnly validates and deep-copies keyword arguments in one pass so host callbacks receive isolated data-only values.
func CloneMethodResult ¶
CloneMethodResult validates and deep-copies a host-returned Value so the host's mutable state is not aliased into the script heap.
func DeepCloneValue ¶
DeepCloneValue recursively copies arrays, hashes, and objects so the host receives a fully isolated snapshot of script-supplied data. Scalar kinds and runtime-only kinds are returned unchanged.
func EnsureBlock ¶
EnsureBlock returns a "%s requires a block" error when block is not a block Value. The name argument is the script-facing method name.
func IsNilImplementation ¶
IsNilImplementation reports whether impl is a nil interface or a typed-nil pointer / channel / func / map / slice. Capability constructors use it to reject zero-value implementations that would later panic with a nil-pointer dereference at call time.
func NameArg ¶
NameArg validates that val is a non-empty string or symbol and returns its textual form. Used by capability adapters to interpret leading "name" arguments such as the collection passed to db.find.
func ValidateAnyReturn ¶
ValidateAnyReturn returns the post-call return validator used in CapabilityMethodContract.ValidateReturn entries for methods that allow any data-only return value.
func ValidateDataOnlyValue ¶
ValidateDataOnlyValue rejects callable payloads (functions, blocks, builtins, classes, instances), runtime-only payloads (shape values), and cyclic structures anywhere inside val. Capability boundaries call it so host code never receives a script-side callable it cannot safely invoke or an opaque runtime payload that is not plain data.
func ValidateHashValue ¶
ValidateHashValue checks that val is a hash (or object) and data-only. The error string format matches the original validateCapabilityHashValue wrapper so capability tests that grep on it continue to pass.
Types ¶
This section is empty.