proctest

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package proctest is the integration harness for the shipped base procedures: a real application over temp filesystem stores — real registry, real template values, real embedded procedure entries — with a scripted LLM. Procedure behavior is tested here, at the composition layer that owns the wiring, so no test fakes an application contract; internal/engine tests stay generic over synthetic specs.

Per-procedure suites live in this directory as package proctest_test, one file per procedure, mirroring internal/baseprocedures/entries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBase

func DefaultBase() time.Time

DefaultBase anchors generated timestamps near the real clock: entries spread backwards from here, so recency windows (heat exp-14d, by(date)) see a live graph. Capture it once per fixture — every generating call must share one base or IDs drift across a second boundary.

func HubID

func HubID(base time.Time) string

HubID returns the generated hub plan's entry ID for a base — the anchor for chain-expansion worst-case walks.

func LoadEntry

func LoadEntry(t *testing.T, graphDir, id string) *model.Entry

LoadEntry parses a written entry back from the world's graph dir.

func MustTopics

func MustTopics(labels ...string) []model.TopicPath

MustTopics parses topic labels into the typed paths a fixture entry carries; fixtures are static, so a bad label is a programming error.

func RealisticGraph

func RealisticGraph(base time.Time, shape GraphShape) []*model.Entry

RealisticGraph generates the fixture entries for a shape, timestamped backwards from base. Every reference resolves inside the generated set, so the graph loads warning-clean and the health framing lane stays quiet — measured serves reflect content, not fixture damage.

func RequireStatus

func RequireStatus(t *testing.T, serve *sdd.WorkflowServe, status string)

RequireStatus fails unless the serve carries the status.

func RequireStep

func RequireStep(t *testing.T, serve *sdd.WorkflowServe, step string)

RequireStep fails unless the serve sits at the step.

func WriteEntry

func WriteEntry(t *testing.T, graphDir string, e *model.Entry)

WriteEntry writes one fixture entry into the graph dir at its ID-derived path, rendered by the production serializer exactly as the write handler persists it — usable before NewWorld and mid-test (reads snapshot per call, so later reads see it).

func WriteRawEntry

func WriteRawEntry(t *testing.T, graphDir, id, content string)

WriteRawEntry writes entry content verbatim for shapes the Entry struct does not model.

func WriteWIPMarkers

func WriteWIPMarkers(t *testing.T, graphDir string, base time.Time, shape GraphShape)

WriteWIPMarkers writes the shape's WIP marker files into the graph's wip/ directory, each pointing at the base's generated hub entry.

Types

type GraphShape

type GraphShape struct {
	// Entries is the general population: gaps, pending directives, plans, and
	// dones spread over the last weeks, so recency- and heat-ranked lanes
	// have real material.
	Entries int
	// Facts enroll in the retrieval index (the shell's factIndex lane).
	Facts int
	// Principles are facts under principles/interactive — the shell's
	// as-bodies framing lane, which renders full bodies.
	Principles int
	// Actors and RolesPerActor populate the participants lane.
	Actors        int
	RolesPerActor int
	// Focuses with InvolvementsPerFocus targets populate the focus lane.
	Focuses              int
	InvolvementsPerFocus int
	// Aspirations and GuidingDirectives populate their framing lanes.
	Aspirations       int
	GuidingDirectives int
	// WIPMarkers are marker files under wip/ (groom's sweep, catch-up's lane).
	WIPMarkers int
	// HubFanOut entries all reference one hub plan — the chain-expansion
	// worst case for entryChains (engage, implementation, evaluate).
	HubFanOut int
	// TopicLabels is the number of distinct topic labels spread across the
	// population (capture's topicLabels lane).
	TopicLabels int
}

GraphShape sizes the generated realistic graph — one knob per surface that scales an automatic serve (the audit inventory on d-tac-rzi). The door test's old fixture was blind exactly because it populated none of these.

func DefaultShape

func DefaultShape() GraphShape

DefaultShape approximates the SDD repository's own graph where scale matters to a serve: lane populations at their real order of magnitude.

type GuideFinding

type GuideFinding struct {
	Reasoning string `json:"reasoning"`
	Axis      string `json:"axis"`
	Quote     string `json:"quote"`
	Repair    string `json:"repair"`
	Severity  string `json:"severity"`
}

GuideFinding is a scripted writing-guide finding, marshaled in the shape the real guide parser expects.

type LLMScript

type LLMScript struct {
	PreflightFindings []PreflightFinding
	GuideFindings     []GuideFinding
	Summary           string
	// contains filtered or unexported fields
}

LLMScript scripts the runtime's LLM runner per purpose and counts calls, so "the guide ran once" is asserted on real runner invocations instead of a faked op. Fields may be changed between calls; a nil findings slice scripts a clean pass.

func (*LLMScript) Calls

func (s *LLMScript) Calls(purpose llm.Purpose) int

Calls returns how often the runner ran for the purpose.

func (*LLMScript) Run

func (s *LLMScript) Run(_ context.Context, request llm.Request) (llm.Result, error)

type Option

type Option func(*config)

Option configures NewWorld.

func WithBranchDir

func WithBranchDir(branch, dir string) Option

WithBranchDir registers an additional branch backed by its own graph dir — for procedures that route reads and writes by branch state (implementation's work branches). The default branch main stays on the world's GraphDir.

func WithEntries

func WithEntries(entries ...*model.Entry) Option

WithEntries writes fixture entries before the stores open.

func WithGraphDir

func WithGraphDir(dir string) Option

WithGraphDir uses an existing graph dir instead of a fresh temp dir — e.g. to reopen the same stores as an earlier world (restart scenarios).

func WithParticipant

func WithParticipant(name string) Option

WithParticipant sets the resolved participant (default Christopher).

type PreflightFinding

type PreflightFinding struct {
	Severity    string `json:"severity"`
	Category    string `json:"category"`
	Observation string `json:"observation"`
}

PreflightFinding is a scripted pre-flight finding, marshaled in the shape the real pre-flight parser expects.

type Session

type Session struct {
	World *World
	WF    *sdd.WorkflowSession
	ID    sdd.SessionID
}

Session wraps one workflow session on the world.

func (*Session) Answer

func (s *Session) Answer(t *testing.T, instance, chooser, choice string, fields map[string]any, userWords string) *sdd.WorkflowServe

Answer answers the pending chooser.

func (*Session) AnswerErr

func (s *Session) AnswerErr(t *testing.T, instance, chooser, choice string, fields map[string]any, userWords string) (*sdd.WorkflowServe, error)

AnswerErr is Answer for tests asserting the failure.

func (*Session) LogRead

func (s *Session) LogRead(t *testing.T, tool string, full, summary []string)

LogRead records a read into the session ledger, as the host's read tools do.

func (*Session) Report

func (s *Session) Report(t *testing.T, instance string, fields map[string]any) *sdd.WorkflowServe

Report sends state fields to the instance's current step.

func (*Session) ReportErr

func (s *Session) ReportErr(t *testing.T, instance string, fields map[string]any) (*sdd.WorkflowServe, error)

ReportErr is Report for tests asserting the failure.

func (*Session) Stage

func (s *Session) Stage(t *testing.T, filename string, content []byte) string

Stage places bytes in the session's staged scratch and returns the handle.

func (*Session) Start

func (s *Session) Start(t *testing.T, canonical string, params map[string]any) *sdd.WorkflowServe

Start starts a procedure instance; params may seed declared params and state.

func (*Session) StartChild

func (s *Session) StartChild(t *testing.T, canonical string, params map[string]any, parent string) *sdd.WorkflowServe

StartChild starts a procedure under a spawning parent, so a dispatch seed recorded on the parent's answered junction applies to the new instance.

func (*Session) StartErr

func (s *Session) StartErr(t *testing.T, canonical string, params map[string]any) (*sdd.WorkflowServe, error)

StartErr is Start for tests asserting the failure.

type World

type World struct {
	App      *sdd.Application
	Identity sdd.RequestIdentity
	GraphDir string
	LLM      *LLMScript
}

World is one project: a real application over temp stores with a scripted LLM. GraphDir is the on-disk graph — real writes land there.

func NewRealisticWorld

func NewRealisticWorld(t *testing.T, shape GraphShape) (*World, string)

NewRealisticWorld builds a world over a generated realistic graph and returns it with the hub entry's ID.

func NewWorld

func NewWorld(t *testing.T, opts ...Option) *World

NewWorld builds the world: fixture entries written, filesystem stores over temp dirs, real project runtime, real application.

func (*World) Open

func (w *World) Open(t *testing.T, connID string) *Session

Open opens a fresh workflow session under the connection id.

func (*World) Resume

func (w *World) Resume(t *testing.T, sessionID sdd.SessionID, connID string) (*Session, sdd.WorkflowResumeResult)

Resume re-attaches to a session from another connection (takeover), as a re-attached or restarted client would.

Jump to

Keyboard shortcuts

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