agentlooptest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package agentlooptest provides reusable conformance harnesses for the agentloop store contracts. An application implementing agentloop.StepStore / SessionStore against its own schema runs these from its own _test.go as an acceptance gate, so every implementation is held to the same behavioural guarantees the loop relies on.

It imports "testing" because it is consumed only from tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StepStoreContract

func StepStoreContract(t *testing.T, h StepStoreHarness)

StepStoreContract asserts the behavioural contract every agentloop.StepStore must satisfy.

func TestPgxStepStore_Contract(t *testing.T) {
    agentlooptest.StepStoreContract(t, agentlooptest.StepStoreHarness{
        NewStore:      func() agentloop.StepStore { return freshStore(t) },
        EnsureSession: func(id string) { seedSession(t, id) }, // FK prerequisite
    })
}

The load-bearing guarantee is LastN's chronological (oldest-first) order: the loop replays it straight into the LLM context, so a store that returns rows newest-first would silently corrupt multi-turn history.

Types

type StepStoreHarness

type StepStoreHarness struct {
	// NewStore returns a FRESH, empty StepStore on each call.
	NewStore func() agentloop.StepStore

	// EnsureSession is called once per session id before any step is
	// appended for it. Relational stores whose steps table has a
	// foreign key to a sessions table use it to create the prerequisite
	// session row; in-memory stores leave it nil. It receives the
	// session ids below.
	EnsureSession func(sessionID string)
}

StepStoreHarness configures the StepStoreContract for a particular implementation.

Jump to

Keyboard shortcuts

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