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 ¶
- func CloneHash(src map[string]value.Value) map[string]value.Value
- func CloneKwargs(kwargs map[string]value.Value) map[string]value.Value
- 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 CloneKwargs ¶
CloneKwargs returns a deep copy of the keyword-arguments map suitable for handing to host callbacks without exposing script-side aliases.
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) and cyclic structures anywhere inside val. Capability boundaries call it so host code never receives a script-side callable it cannot safely invoke.
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.