mock

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mock provides a deterministic in-memory agent bridge for tests and for running agent-bearing models in CI without an LLM.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

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

Bridge answers agent decisions from a static routing table. It records every invocation so a test can assert on what the graph asked.

func New

func New(opts ...Option) *Bridge

New builds a mock bridge.

func (*Bridge) Calls

func (b *Bridge) Calls() []agent.Request

Calls returns every request the bridge received, in order.

func (*Bridge) Invoke

func (b *Bridge) Invoke(ctx context.Context, req agent.Request) (agent.Response, error)

Invoke implements agent.Bridge.

func (*Bridge) Reset

func (b *Bridge) Reset()

Reset clears the recorded calls.

type Option

type Option func(*Bridge)

Option configures a Bridge.

func WithAnswer

func WithAnswer(decision string, value any) Option

WithAnswer routes a decision (by ID or name) to a fixed value.

func WithFallback

func WithFallback(fn func(agent.Request) (agent.Response, error)) Option

WithFallback answers any decision no other rule matched.

func WithHandler

func WithHandler(match func(agent.Request) bool, fn func(agent.Request) (agent.Response, error)) Option

WithHandler registers a predicate-driven handler, consulted in registration order after the fixed answers.

func WithLatency

func WithLatency(d time.Duration) Option

WithLatency makes every invocation take at least d, so failure-policy tests can drive the engine's latency budget without a real network.

Jump to

Keyboard shortcuts

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