fakeprovider

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fakeprovider provides a deterministic scripted ReviewProvider for tests.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilContext reports an invocation made without a context.
	ErrNilContext = errors.New("fake provider: nil context")

	// ErrNilProvider reports an invocation on a nil Provider.
	ErrNilProvider = errors.New("fake provider: nil provider")
)

Functions

This section is empty.

Types

type CallSummary

type CallSummary struct {
	ProviderInstance      string
	Role                  domain.Role
	Purpose               ports.ProviderInvocationPurpose
	AttemptID             domain.AttemptID
	SourceInvocationID    string
	ExecutionInvocationID string
	CompleteStdinSHA256   string
	StdinByteLength       int
}

CallSummary is a redacted provider-call transcript entry. It deliberately excludes raw stdin, stdout, and scripted error messages.

type ErrorKind

type ErrorKind string

ErrorKind classifies a scripted provider error.

const (
	// ErrorKindFailure is an unspecified deterministic provider failure.
	ErrorKindFailure ErrorKind = "failure"
	// ErrorKindUnavailable is a deterministic provider-unavailable failure.
	ErrorKindUnavailable ErrorKind = "unavailable"
	// ErrorKindRejected is a deterministic provider-rejected failure.
	ErrorKindRejected ErrorKind = "rejected"
)

func (ErrorKind) Valid

func (kind ErrorKind) Valid() bool

Valid reports whether kind is a supported scripted error kind.

type ExpectedCall

type ExpectedCall struct {
	ProviderInstance      string
	Role                  domain.Role
	Purpose               ports.ProviderInvocationPurpose
	AttemptID             domain.AttemptID
	SourceInvocationID    string
	ExecutionInvocationID string
	Stdin                 []byte
	Result                Result
}

ExpectedCall describes one expected provider invocation in script order. New validates Stdin against the invocation contract, records only its integrity metadata, and does not retain the raw bytes.

type Provider

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

Provider implements ports.ReviewProvider by consuming a fixed ordered script.

func New

func New(script []ExpectedCall) (*Provider, error)

New constructs a deterministic provider from an ordered script. It validates every expected identity and defensively copies mutable fixtures.

func (*Provider) Invoke

func (provider *Provider) Invoke(ctx context.Context, invocation ports.ProviderInvocation) (ports.ProviderResult, error)

Invoke verifies and consumes exactly the next scripted call. A canceled context is returned before any script entry is consumed.

func (*Provider) Transcript

func (provider *Provider) Transcript() []CallSummary

Transcript returns caller-owned redacted summaries of calls consumed in invocation order.

type Result

type Result struct {
	Stdout []byte
	Error  *ScriptError
}

Result configures either stdout or a typed error for one expected call. Stdout and Error are mutually exclusive when Error is non-nil.

type ScriptError

type ScriptError struct {
	Kind    ErrorKind
	Message string
}

ScriptError is a typed, immutable-by-provider error returned by a scripted call.

func (*ScriptError) Error

func (err *ScriptError) Error() string

type UnexpectedCallError

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

UnexpectedCallError reports an extra, out-of-order, or mismatched call. Its summaries remain redacted and cannot mutate Provider state.

func (*UnexpectedCallError) Actual

func (err *UnexpectedCallError) Actual() CallSummary

Actual returns the redacted call that did not match the script.

func (*UnexpectedCallError) Error

func (err *UnexpectedCallError) Error() string

func (*UnexpectedCallError) Expected

func (err *UnexpectedCallError) Expected() (CallSummary, bool)

Expected returns the next scripted call that rejected Actual. It reports false for an extra call after the script was exhausted.

Jump to

Keyboard shortcuts

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