invocation

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package invocation preserves execution evidence at a complete model-call boundary. A failed invocation may have consumed resources or produced external work; only FailureNotExecuted proves absence of work. No classification authorizes retry. Compositions own their complete outcome independently of nested causes.

Example
package main

import (
	"errors"
	"fmt"

	"github.com/Tangerg/scope/core/invocation"
)

func main() {
	admission := &invocation.Failure{
		Kind:  invocation.FailureNotExecuted,
		Cause: errors.New("unsupported model option"),
	}
	completedWork := &invocation.Failure{
		Kind:  invocation.FailureFailed,
		Cause: fmt.Errorf("follow-up request: %w", admission),
	}
	fmt.Println(invocation.ClassifyFailure(admission))
	fmt.Println(invocation.ClassifyFailure(completedWork))
	fmt.Println(errors.Is(completedWork, admission))
}
Output:
not_executed
failed
true

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrInvalidFailure = errors.New("invocation: invalid call failure")

Functions

This section is empty.

Types

type Failure

type Failure struct {
	Kind  FailureKind
	Cause error
}

Failure owns evidence for the complete current Call or Stream invocation. Cause remains inspectable through errors.Is and errors.As, but failures inside it belong to nested invocations and cannot override Kind. A composition that already executed work must establish its own boundary, including Unknown when it cannot establish the complete outcome. No kind authorizes a retry.

func (*Failure) Error

func (f *Failure) Error() string

func (*Failure) Unwrap

func (f *Failure) Unwrap() error

func (*Failure) Validate

func (f *Failure) Validate() error

type FailureKind

type FailureKind string
const (
	FailureNone        FailureKind = ""
	FailureUnknown     FailureKind = "unknown"
	FailureFailed      FailureKind = "failed"
	FailureNotExecuted FailureKind = "not_executed"
)

None classifies a nil error and is never the Kind of a Failure. Failed establishes an unsuccessful invocation, not absence of side effects or token use. Only NotExecuted proves no provider work ran in this invocation.

func ClassifyFailure

func ClassifyFailure(err error) FailureKind

ClassifyFailure is the execution-evidence boundary; errors.Is and errors.As inspect diagnostics, not the outcome of a composite invocation. Transparent wrapping preserves one boundary. Joined independent boundaries require an enclosing owner to classify the whole call, otherwise its outcome is unknown. Nil has no failure; an ordinary or invalid error establishes only Unknown.

func (FailureKind) Valid

func (f FailureKind) Valid() bool

Jump to

Keyboard shortcuts

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