fake

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fake is a scriptable harness.Adapter for pipeline and worker tests (harness-adapters.md §Fake adapter): scripted progress, usage and results, a scripted repair turn, and ways to simulate a rate limit or a run that only ends when it's stopped.

Index

Constants

View Source
const Name = "fake"

Name is the fake harness's default name.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// HarnessName is Name() (default "fake").
	HarnessName string
	Script      Script
	// contains filtered or unexported fields
}

Adapter is the fake harness. It records what it was given; safe for concurrent use.

func (*Adapter) Capabilities

func (a *Adapter) Capabilities() v1alpha1.AdapterCapabilities

Capabilities implements harness.Adapter.

func (*Adapter) Name

func (a *Adapter) Name() string

Name implements harness.Adapter.

func (*Adapter) Prepare

func (a *Adapter) Prepare(_ context.Context, ws harness.Workspace, _ v1alpha1.Task) error

Prepare implements harness.Adapter.

func (*Adapter) Prepared

func (a *Adapter) Prepared() []harness.Workspace

Prepared returns the workspaces Prepare was given.

func (*Adapter) Problems

func (a *Adapter) Problems() [][]string

Problems returns the problems each Repair was given.

func (*Adapter) Prompts

func (a *Adapter) Prompts() []string

Prompts returns the prompts Run was given.

func (*Adapter) Repair

func (a *Adapter) Repair(ctx context.Context, ws harness.Workspace, problems []string, sink harness.EventSink) (harness.Raw, error)

Repair implements harness.Adapter.

func (*Adapter) Run

Run implements harness.Adapter.

type Script

type Script struct {
	Turn
	// PrepareErr is returned by Prepare.
	PrepareErr error
	// Repairs are the successive Repair turns; a Repair beyond them writes nothing.
	Repairs []Turn
}

Script is the whole fake run: the Run turn and the repair turns, in order.

type Turn

type Turn struct {
	// Events and Usage are reported to the sink in order (Usage after Events).
	Events []harness.ProgressEvent
	Usage  []harness.UsageDelta
	// Result, when non-nil, is written to the workspace's $FACTORY_RESULT file.
	Result []byte
	// Output is returned as Raw.Result (the harness's structured output).
	Output []byte
	// Transcript lines are returned as Raw.Transcript.
	Transcript []string
	// Err is returned after the turn.
	Err error
	// RateLimitAfter > 0 reports RateLimited(RateLimitUntil) after that many events and
	// then waits for ctx to end.
	RateLimitAfter int
	RateLimitUntil time.Time
	// Block waits for ctx to end after the events (a run only a limit stops).
	Block bool
	// Do runs before the events, with the workspace and the prompt ("" for a repair); an
	// error ends the turn with it.
	Do func(ctx context.Context, ws harness.Workspace, prompt string) error
}

Turn is one scripted Run or Repair.

Jump to

Keyboard shortcuts

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