chaos

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package chaos provides fault injection for PromptArena resilience testing. It implements a hooks.ToolHook that intercepts tool execution and injects failures (errors, timeouts, latency) based on scenario chaos configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigFromContext

func ConfigFromContext(ctx context.Context) *config.ChaosConfig

ConfigFromContext retrieves chaos config from the context.

func WithConfig

func WithConfig(ctx context.Context, cfg *config.ChaosConfig) context.Context

WithConfig stores chaos config in the context.

Types

type Hook

type Hook struct{}

Hook implements hooks.ToolHook to inject failures into tool execution.

func NewHook

func NewHook() *Hook

NewHook creates a new chaos injection hook.

func (*Hook) AfterExecution

func (h *Hook) AfterExecution(_ context.Context, _ hooks.ToolRequest, _ hooks.ToolResponse) hooks.Decision

AfterExecution is a no-op — always allows.

func (*Hook) BeforeExecution

func (h *Hook) BeforeExecution(ctx context.Context, req hooks.ToolRequest) hooks.Decision

BeforeExecution checks chaos config and injects tool failures.

func (*Hook) Name

func (h *Hook) Name() string

Name returns the hook name.

Jump to

Keyboard shortcuts

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