@usine/durable/testing
Classes
Section titled “Classes”StubChildren
Section titled “StubChildren”The children the stub backend launched, in launch order.
Extends
Section titled “Extends”Context.ServiceClass
Properties
Section titled “Properties”Service
Section titled “Service”
readonlyService:object
The service’s operations: what yield* StubChildren returns.
readonlynext:Effect.Effect<StubChild>
Waits for the next child the parent launches.
StubStorage
Section titled “StubStorage”The durable storage behind stub runtimes: tasks and their sequence counters survive a runtime being closed and built again, as pi-durable storage survives an orchestrator restart.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StubStorage():
StubStorage
Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlytasks:Map<string&Brand<"AttemptId">,StubTask>
Interfaces
Section titled “Interfaces”DurableTestingOptions
Section titled “DurableTestingOptions”What the testing layer runs on.
Properties
Section titled “Properties”database
Section titled “database”
readonlydatabase:string
The SQLite file; build another layer on the same file to simulate an orchestrator restart.
parent
Section titled “parent”
readonlyparent: readonlyFauxResponseStep[]
The parent model’s answers, one per model request, in order.
StubChild
Section titled “StubChild”One child the stub backend launched; the test decides when and how it finishes.
Properties
Section titled “Properties”
readonlyblock: (message) =>Effect<void>
Finishes with a blocked report, which fails the Attempt unless the parent relays it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message |
string |
Returns
Section titled “Returns”Effect<void>
readonlyemit: (event) =>Effect<void>
Adds one event to the child’s stream.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
SessionStarted | TextOutput | ToolStarted | ToolFinished | PoolRateLimitsUpdated | SessionFinished | SessionIdle | SessionResumed | SessionTokensUpdated |
Returns
Section titled “Returns”Effect<void>
interrupted
Section titled “interrupted”
readonlyinterrupted:Effect<void>
Completes once the parent’s tool call interrupted the child (abort, cancel, or shutdown).
interventions
Section titled “interventions”
readonlyinterventions:Effect<readonly (Steer|Interrupt|OperatorMessage|Release)[]>
The operator actions delivered to this child so far.
readonlyreply: (message) =>Effect<void>
Finishes with message as the child’s report; under a Hold the report waits for the release.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message |
string |
Returns
Section titled “Returns”Effect<void>
request
Section titled “request”
readonlyrequest:ChildRequest
StubParentContext
Section titled “StubParentContext”What a scripted stub parent can do while execute runs it.
Properties
Section titled “Properties”
readonlyemit: (payload) =>Effect<void,InfraFailure|DefectFailure|AgentFailure|RunawayFailure|ChildSessionBudgetFailure>
Records one outbound envelope with the task’s next sequence.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
payload |
Started | SessionEvent | Final | Failed | Interrupted | InterventionApplied | InterventionRejected |
Returns
Section titled “Returns”Effect<void, InfraFailure | DefectFailure | AgentFailure | RunawayFailure | ChildSessionBudgetFailure>
reattached
Section titled “reattached”
readonlyreattached:boolean
Whether this execute call reattached a task a previous runtime started.
request
Section titled “request”
readonlyrequest:AttemptRequest
session
Section titled “session”
readonlysession:ParentSession
The parent session the stub reports events for.
Type Aliases
Section titled “Type Aliases”ParentStep
Section titled “ParentStep”ParentStep =
FauxResponseStep
One scripted answer of the parent’s model, or a function of the request that returns one.
StubParent
Section titled “StubParent”StubParent = (
context) =>Effect.Effect<string,AttemptFailure>
A stub parent’s work after Started; its result is the parent’s final message.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context |
StubParentContext |
Returns
Section titled “Returns”Effect.Effect<string, AttemptFailure>
Variables
Section titled “Variables”answer
Section titled “answer”
constanswer: (text) =>AssistantMessage
The parent gives its final answer.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
Returns
Section titled “Returns”AssistantMessage
completes
Section titled “completes”
constcompletes:StubParent
Completes at once with Completed: <task>.
delegate
Section titled “delegate”
constdelegate: (task) =>AssistantMessage
The parent delegates task to one child through the subagent tool.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
task |
string |
Returns
Section titled “Returns”AssistantMessage
fauxParent
Section titled “fauxParent”
constfauxParent: (steps) =>Pick<DurableHarnessOptions,"models"|"defaultModel">
pi-ai model access that answers the parent’s requests with steps, in order; it accepts every reasoning effort up to high.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
steps |
ReadonlyArray<ParentStep> |
Returns
Section titled “Returns”Pick<DurableHarnessOptions, "models" | "defaultModel">
constlayer: (options) =>Layer.Layer<AttemptRuntime|ChildBackend|DurableHarness|StubChildren,DurableHarnessError,never>
The durable Attempt runtime on a SQLite file with a scripted parent model and stub children, for driving whole Attempts in tests without a model or a harness binary.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
DurableTestingOptions |
Returns
Section titled “Returns”Layer.Layer<AttemptRuntime | ChildBackend | DurableHarness | StubChildren, DurableHarnessError, never>
PARENT_MODEL
Section titled “PARENT_MODEL”
constPARENT_MODEL:string&Brand
The parent model the testing layer serves; name it in RunSpec.parentModel or leave that empty.
stubAttemptRuntime
Section titled “stubAttemptRuntime”
conststubAttemptRuntime: (storage,parent?) =>Layer.Layer<AttemptRuntime,never,never>
An in-memory AttemptRuntime over storage, for executor and engine tests
that need no parent model. It records Started, the parent’s session events,
intervention receipts, and a Final without facts (the executor harvests
those) through the Attempt’s sink, numbering them per task so a reattached
execute continues the sequence. Only a completed parent leaves the live
state: interrupting execute (a stopped process) or a failing parent leaves
the task live until someone cancels it, so tests see whether the executor
stopped it. A completed task keeps its report, which a later execute
returns and finished reports until recordResult replaces it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
storage |
StubStorage |
parent? |
StubParent |
Returns
Section titled “Returns”Layer.Layer<AttemptRuntime, never, never>
stubChildBackendLayer
Section titled “stubChildBackendLayer”
conststubChildBackendLayer:Layer.Layer<ChildBackend|StubChildren>
A ChildBackend whose children run only as the test scripts them through StubChildren.
worksFor
Section titled “worksFor”
constworksFor: (millis) =>StubParent
Works for millis before completing.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
millis |
number |