{"modulePath":"github.com/meigma/codemode","version":"v0.2.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package execution\n\nPackage execution runs one restricted, bounded Starlark program at a time.\n\nEngine is compiled from the fixed language surface merged with process-neutral capability bindings. Each Execute call receives a request-specific NativeCall and converts only main's final value.\n\n## Constants\n\n```go\nconst MaxAgentErrorBytes = 256\n```\nMaxAgentErrorBytes is the maximum UTF-8 size of an approved agent-visible capability-failure suffix, including a trailing ASCII ellipsis when truncated.\n\n## Variables\n\n```go\nvar (\n\t// ErrInvalidProgram classifies invalid source, entrypoint behavior, or loading-phase native calls.\n\tErrInvalidProgram = errors.New(\"invalid program\")\n\n\t// ErrInvalidArguments classifies native arguments rejected before the native port.\n\tErrInvalidArguments = errors.New(\"invalid capability arguments\")\n\n\t// ErrPermissionDenied classifies a recognized authorization denial.\n\tErrPermissionDenied = errors.New(\"permission denied\")\n\n\t// ErrPolicyFailure classifies an authorization evaluation error or panic.\n\tErrPolicyFailure = errors.New(\"authorization policy failure\")\n\n\t// ErrResourceLimit classifies source, step, native-call, depth, or value-size exhaustion.\n\tErrResourceLimit = errors.New(\"resource limit exceeded\")\n\n\t// ErrCapabilityFailure classifies a native handler or handler-result failure.\n\tErrCapabilityFailure = errors.New(\"capability failed\")\n\n\t// ErrInternal classifies an unexpected runtime or contract failure.\n\tErrInternal = errors.New(\"internal failure\")\n)\n```\n\n## Functions\n\n```go\nfunc SafeDetail(err error) (string, bool)\n```\nSafeDetail reports the approved suffix attached to err, if any.\n\nExtraction follows the error chain with [errors.As](/errors#As).\n\n```go\nfunc WithSafeDetail(cause error, detail string) error\n```\nWithSafeDetail attaches detail to cause without changing cause.Error.\n\nEmpty detail returns cause unchanged. Callers must pass only model-derived suffixes or sanitized explicitly handler-authored detail; host-derived text must not be attached.\n\n## Types\n\n```go\ntype CapabilityBinding struct {\n\t// ID is the stable capability identity passed to NativeCall.\n\tID string\n\n\t// Name is the dotted Starlark path used to assemble the frozen namespace.\n\tName string\n\n\t// Input is the private compiled input schema used to bind keyword arguments.\n\tInput binding.InputSchema\n}\n```\nCapabilityBinding is one process-neutral capability exposed to the interpreter.\n\n```go\ntype Engine struct {\n\t// contains filtered or unexported fields\n}\n```\nEngine owns the frozen language surface and capability namespace shared by fresh execution threads.\n\n```go\nfunc New(bindings []CapabilityBinding) (*Engine, error)\n```\nNew compiles one immutable execution engine from the fixed language surface and capability bindings.\n\n```go\nfunc (engine *Engine) Execute(\n\tsource string,\n\tnativeCall NativeCall,\n\tlimits Limits,\n) (any, error)\n```\nExecute runs source in a fresh restricted interpreter and converts only main's final value.\n\n```go\ntype Limits struct {\n\t// MaxSourceBytes bounds the submitted Starlark source length.\n\tMaxSourceBytes int\n\n\t// MaxExecutionSteps bounds abstract Starlark interpreter work.\n\tMaxExecutionSteps uint64\n\n\t// MaxNativeCalls bounds attempted capability invocations.\n\tMaxNativeCalls uint64\n\n\t// MaxValueDepth bounds recursive crossing-value conversion.\n\tMaxValueDepth int\n\n\t// MaxValueBytes supplies the byte-derived materialization bound.\n\tMaxValueBytes int\n}\n```\nLimits contains the prevalidated positive budgets for one execution.\n\n```go\ntype NativeCall func(id string, arguments map[string]any) (any, error)\n```\nNativeCall invokes one capability with a fresh canonical argument map.\n\nIt returns one normalized process-neutral value or a classified error.\n\n","path":"github.com/meigma/codemode/internal/execution","name":"execution","synopsis":"Package execution runs one restricted, bounded Starlark program at a time.","isRedistributable":true}
