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 ¶
- Variables
- func PublicToolContractFactory(t testing.TB, spec ToolContractSpec) *tools.Registry
- func RunApprovalEffectContract(t *testing.T)
- func RunModelGatewayContract(t *testing.T, factory ModelGatewayFactory)
- func RunTerminalOutcomeContract(t *testing.T, options TerminalOutcomeContractOptions)
- func RunToolContract(t *testing.T, factory ToolContractFactory)
- func ScriptedModelGatewayFactory(_ testing.TB, steps []ModelStep) runtime.ModelGateway
- type ContractPrerequisite
- type ContractPrerequisiteError
- type ModelGatewayFactory
- type ModelStep
- type ScriptedModelGateway
- type StoreFixtureInput
- type StoreFixtureResult
- type StoreFixtureTurn
- type TerminalOutcomeContractOptions
- type TerminalOutcomeFixture
- type ToolContractFactory
- type ToolContractInvocation
- type ToolContractSpec
Constants ¶
This section is empty.
Variables ¶
var ErrModelScriptExhausted = errors.New("florettest: model gateway script exhausted")
ErrModelScriptExhausted reports a ModelGateway request for which no scripted step remains.
Functions ¶
func PublicToolContractFactory ¶
func PublicToolContractFactory(t testing.TB, spec ToolContractSpec) *tools.Registry
PublicToolContractFactory builds the contract tool directly with tools.Define.
func RunApprovalEffectContract ¶
RunApprovalEffectContract exercises Floret's public durable approval and effect-authority lifecycle. It deliberately uses no host UI or product authorization policy; those remain consumer responsibilities.
func RunModelGatewayContract ¶
func RunModelGatewayContract(t *testing.T, factory ModelGatewayFactory)
RunModelGatewayContract runs the consumer-visible baseline expected from a ModelGateway and its host adapter.
func RunTerminalOutcomeContract ¶
func RunTerminalOutcomeContract(t *testing.T, options TerminalOutcomeContractOptions)
RunTerminalOutcomeContract verifies consumer-visible terminal outcomes.
func RunToolContract ¶
func RunToolContract(t *testing.T, factory ToolContractFactory)
RunToolContract verifies the public behavioral baseline for a consumer tool constructor or wrapper.
func ScriptedModelGatewayFactory ¶
func ScriptedModelGatewayFactory(_ testing.TB, steps []ModelStep) runtime.ModelGateway
ScriptedModelGatewayFactory is the default in-process contract factory.
Types ¶
type ContractPrerequisite ¶
type ContractPrerequisite string
ContractPrerequisite identifies a black-box condition that cannot be manufactured through Floret's current public test inputs alone.
const ( // ContractPrerequisiteInterruptedTurn requires a process/storage fixture // containing an admitted turn whose lease was interrupted. ContractPrerequisiteInterruptedTurn ContractPrerequisite = "interrupted_turn_fixture" // ContractPrerequisiteProjectionFailure requires a public Store // implementation or fault injector that can fail terminal projection reads. ContractPrerequisiteProjectionFailure ContractPrerequisite = "projection_failure_fixture" )
type ContractPrerequisiteError ¶
type ContractPrerequisiteError struct {
Prerequisite ContractPrerequisite
Reason string
}
ContractPrerequisiteError explains why a contract subtest cannot run.
func (*ContractPrerequisiteError) Error ¶
func (e *ContractPrerequisiteError) Error() string
type ModelGatewayFactory ¶
type ModelGatewayFactory func(testing.TB, []ModelStep) runtime.ModelGateway
ModelGatewayFactory creates a gateway that implements the supplied steps. Adapter authors can translate the same steps into a fake wire transport and use RunModelGatewayContract against their production ModelGateway adapter.
type ModelStep ¶
type ModelStep struct {
Events []runtime.ModelEvent
ReturnError error
BlockUntil <-chan struct{}
WaitForCancellation bool
}
ModelStep describes one StreamModel call. ReturnError takes precedence over all other fields. WaitForCancellation keeps the stream open until the request context is canceled. BlockUntil keeps it open until release or cancellation.
type ScriptedModelGateway ¶
type ScriptedModelGateway struct {
// contains filtered or unexported fields
}
ScriptedModelGateway is a deterministic, concurrency-safe ModelGateway. Each request consumes exactly one ModelStep in declaration order.
func NewScriptedModelGateway ¶
func NewScriptedModelGateway(steps ...ModelStep) *ScriptedModelGateway
NewScriptedModelGateway constructs a gateway from an ordered script.
func (*ScriptedModelGateway) Requests ¶
func (g *ScriptedModelGateway) Requests() []runtime.ModelRequest
Requests returns stable snapshots of all requests observed so far.
func (*ScriptedModelGateway) StreamModel ¶
func (g *ScriptedModelGateway) StreamModel(ctx context.Context, request runtime.ModelRequest) (<-chan runtime.ModelEvent, error)
StreamModel implements runtime.ModelGateway.
func (*ScriptedModelGateway) WaitForRequests ¶
func (g *ScriptedModelGateway) WaitForRequests(ctx context.Context, count int) error
WaitForRequests waits until at least count requests have entered StreamModel.
type StoreFixtureInput ¶
type StoreFixtureInput struct {
ThreadID runtime.ThreadID
CreateIntentID runtime.CreateIntentID
Turns []StoreFixtureTurn
}
StoreFixtureInput describes a public-API-only Store fixture. PopulateStoreFixture requires a fresh, unconfigured Store and never exposes its backend tables or internal storage handles.
type StoreFixtureResult ¶
type StoreFixtureResult struct {
Thread runtime.ThreadSummary
Turns []runtime.TurnResult
}
StoreFixtureResult reports only public durable creation and turn outcomes.
func PopulateStoreFixture ¶
func PopulateStoreFixture(ctx context.Context, store *runtime.Store, input StoreFixtureInput) (StoreFixtureResult, error)
PopulateStoreFixture creates a thread and runs scripted turns exclusively through runtime's public capability binders and ModelGateway contract.
type StoreFixtureTurn ¶
type StoreFixtureTurn struct {
Request runtime.RunTurnRequest
ModelSteps []ModelStep
}
StoreFixtureTurn contains only public inputs for one durable turn.
type TerminalOutcomeContractOptions ¶
type TerminalOutcomeContractOptions struct {
Interrupted TerminalOutcomeFixture
}
TerminalOutcomeContractOptions supplies only the failure fixtures that cannot currently be constructed with public in-process Store inputs.
type TerminalOutcomeFixture ¶
type TerminalOutcomeFixture func(testing.TB) (runtime.TurnResult, error)
TerminalOutcomeFixture runs a consumer-supplied black-box fixture and returns the public terminal result and error observed by its host.
type ToolContractFactory ¶
type ToolContractFactory func(testing.TB, ToolContractSpec) *tools.Registry
ToolContractFactory 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.