florettest

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package florettest provides deterministic, consumer-facing test helpers for Floret integrations. It includes scripted model behavior, public tool and approval/effect contracts, terminal outcome contracts, and public-input-only Store fixture population. It is intended for test code, examples, and external conformance suites; production Floret packages never depend on it.

A contract that requires process death or storage fault injection reports a typed ContractPrerequisite and skips only that subtest when the consumer does not supply the corresponding fixture. The package never exposes SQLite tables, storage internals, or Floret internal packages.

Index

Constants

This section is empty.

Variables

View Source
var ErrGatewayScriptExhausted = errors.New("florettest: gateway script exhausted")

ErrGatewayScriptExhausted reports a request without a remaining Step.

Functions

func NewToolContractRegistry

func NewToolContractRegistry(t testing.TB, spec ToolContractSpec) *tools.Registry

NewToolContractRegistry builds the contract tool directly with tools.Define.

func RunBackendContract

func RunBackendContract(t *testing.T, source storage.Source)

RunBackendContract verifies the transactional, ownership, ordering, rollback, cancellation, and lifecycle semantics required from a storage Backend.

func RunToolContract

func RunToolContract(t *testing.T, factory ToolContractBuilder)

RunToolContract verifies the public behavioral baseline for a consumer tool constructor or wrapper.

Types

type ScriptedGateway

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

ScriptedGateway is a deterministic, concurrency-safe provider Gateway.

func NewScriptedGateway

func NewScriptedGateway(identity provider.Identity, capabilities provider.Capabilities, steps ...Step) *ScriptedGateway

NewScriptedGateway constructs a gateway with an explicit provider contract.

func (*ScriptedGateway) Capabilities

func (gateway *ScriptedGateway) Capabilities() provider.Capabilities

Capabilities returns the configured provider capability declaration.

func (*ScriptedGateway) Identity

func (gateway *ScriptedGateway) Identity() provider.Identity

Identity returns the configured provider identity.

func (*ScriptedGateway) Requests

func (gateway *ScriptedGateway) Requests() []provider.Request

Requests returns detached snapshots of all observed requests.

func (*ScriptedGateway) Stream

func (gateway *ScriptedGateway) Stream(ctx context.Context, request provider.Request) (<-chan provider.Event, error)

Stream consumes exactly one Step in request order.

func (*ScriptedGateway) WaitForRequests

func (gateway *ScriptedGateway) WaitForRequests(ctx context.Context, count int) error

WaitForRequests waits until count requests have entered Stream.

type Step

type Step struct {
	Events              []provider.Event
	ReturnError         error
	BlockUntil          <-chan struct{}
	WaitForCancellation bool
}

Step describes one Gateway.Stream call.

type ToolContractBuilder

type ToolContractBuilder func(testing.TB, ToolContractSpec) *tools.Registry

ToolContractBuilder adapts ToolContractSpec through consumer-owned tool construction code and returns the registry that exposes the resulting tool.

type ToolContractInvocation

type ToolContractInvocation struct {
	CallID        string
	Name          string
	RawArgs       string
	Value         string
	RunID         string
	ThreadID      string
	TurnID        string
	PromptScopeID string
	Step          int
	Labels        map[string]string
	HostContext   map[string]string
}

ToolContractInvocation is the product-neutral invocation shape exercised by RunToolContract. Factory implementations should preserve every identity and pass Value to the supplied callbacks without adding host policy.

type ToolContractSpec

type ToolContractSpec struct {
	Name      string
	Resources func(ToolContractInvocation) ([]tools.ResourceRef, error)
	Handler   func(context.Context, ToolContractInvocation) (tools.Result, error)
}

ToolContractSpec describes one tool using only public tools package inputs.

Jump to

Keyboard shortcuts

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