capabilitydata

package
v0.70.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package capabilitydata bounds and isolates data graphs crossing host capabilities.

Index

Constants

View Source
const MaxDepth = 256

MaxDepth is the existing capability payload nesting limit.

Variables

This section is empty.

Functions

func WithBudget

func WithBudget(ctx context.Context, budget *Budget) context.Context

WithBudget transports a budget only between runtime and first-party adapters. The receiver must unpack it before passing the context to host code.

Types

type Budget

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

Budget accounts for cumulative work and allocations across independent snapshots in one operation. Callers must use it sequentially and release their external reservation after the operation. Nil hooks retain the standalone hard limits.

func ExecutionBudget

func ExecutionBudget(exec Execution) *Budget

ExecutionBudget uses the runtime's private provider when available, preserving the existing public execution interfaces for direct embedders.

func NewBudget

func NewBudget(ctx context.Context, chargeSteps, reserve func(int) error) *Budget

NewBudget creates a bounded operation with optional interpreter step and memory hooks. Each charged step represents 64 units of graph or byte work.

func UnpackBudget

func UnpackBudget(ctx context.Context) (context.Context, *Budget)

UnpackBudget returns the exact original context and operation budget. Ordinary callers receive a standalone budget; no state is stored on their context.

func (*Budget) Refresh

func (b *Budget) Refresh() error

Refresh starts the next snapshot against current live roots.

func (*Budget) Reserve

func (b *Budget) Reserve(bytes int) error

Reserve checks allocation size before it is passed to make or a constructor.

func (*Budget) ReserveMap

func (b *Budget) ReserveMap(count int) error

ReserveMap checks space for a cloned string-keyed map before allocation.

func (*Budget) SetSnapshotRefresh

func (b *Budget) SetSnapshotRefresh(refresh func() error)

SetSnapshotRefresh installs the runtime hook that refreshes live memory after a host call or script callback changes the operation's reachable roots.

func (*Budget) Work

func (b *Budget) Work(units int) error

Work charges work before a traversal, hash, copy, or allocation performs it.

type Cloner

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

Cloner preserves shared children across every root of one immutable input graph. Create a new Cloner after invoking host code or yielding a snapshot; reuse its Budget to retain cumulative limits without retaining stale clones.

func NewCloner

func NewCloner(budget *Budget, options Options) *Cloner

NewCloner starts an independent identity memo using the operation's budget.

func (*Cloner) Clone

func (c *Cloner) Clone(label string, source value.Value) (value.Value, error)

Clone validates and isolates one root, preserving aliases to earlier roots.

func (*Cloner) CloneWithOptions

func (c *Cloner) CloneWithOptions(label string, source value.Value, options Options) (value.Value, error)

CloneWithOptions applies a root's existing containment policy. Tag-free data shares its clone across policies; tagged ancestors receive separate views.

func (*Cloner) Hash

func (c *Cloner) Hash(label string, source value.Value) (map[string]value.Value, error)

Hash clones a hash or object using the request memo and returns its entries.

func (*Cloner) Kwargs

func (c *Cloner) Kwargs(method string, source map[string]value.Value) (map[string]value.Value, error)

Kwargs isolates keyword values with the same memo as positional roots.

func (*Cloner) KwargsWithOptions

func (c *Cloner) KwargsWithOptions(method string, source map[string]value.Value, options Options) (map[string]value.Value, error)

KwargsWithOptions applies a keyword group's policy with the request's memo.

type Execution

type Execution interface {
	Context() context.Context
	Step() error
}

Execution is the optional host execution context needed for budget fallback.

type Options

type Options struct {
	AllowRuntimeValues bool
	PreserveObjectTags bool
}

Options preserves the distinct contracts of validated option parsers and runtime containment copies. The default rejects runtime values and strips tags.

type Validator

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

Validator checks a complete argument graph without copying its containers. Depth errors precede callable errors, which precede cycle errors.

func NewValidator

func NewValidator(budget *Budget) *Validator

NewValidator starts a validation memo sharing the operation's budget.

func (*Validator) Kwargs

func (v *Validator) Kwargs(method string, kwargs map[string]value.Value) error

Kwargs validates every keyword using one memo and cumulative budget.

func (*Validator) Validate

func (v *Validator) Validate(label string, source value.Value) error

Validate rejects runtime values, cycles, and excessive graph depth or work.

Jump to

Keyboard shortcuts

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