waygraph / Instruction
Interface: Instruction<In, Out, Observed>
Defined in: src/engine/block/block.ts:26
The four-phase pipeline every Block runs. Most Blocks only need act + a one-line resolve - add observe only once a Block genuinely branches, add verify only once you want to confirm the reached state, not just classify it.
Type Parameters
In
In extends Checkpoint<string>
Out
Out extends Checkpoint<string>
Observed
Observed = void
Properties
precondition?
Defined in: src/engine/block/block.ts:45
Optional. Runs once, right before act starts - confirms the page is still in the state this Block is about to assume, before touching it. verify only ever confirms what a Block ITSELF just did; nothing previously checked whether the page is STILL there by the time the NEXT Block starts (a redirect, a popup, a session timeout between two Blocks - the gap verify alone can't see, since it only ever runs right after the PREVIOUS Block's own resolve, not right before THIS one's act). A function form picks different checks per incoming In, same as verify does per resolved Out.
Example
precondition: [Trait.visible("#checkout-form")]stubAfter?
optionalstubAfter?:StubLifecycleFn<Out>
Defined in: src/engine/block/block.ts:72
After the step lands; written by Block.stub((ctx) => ...).
stubBefore?
optionalstubBefore?:StubLifecycleFn<Out>
Defined in: src/engine/block/block.ts:70
The demo's narration before the step, written by Block.stubBefore((ctx) => ...) where a flow uses the Block (stubs chained there add up). Not something to set in a Block's definition: Blocks carry no narration.
stubOnError?
optionalstubOnError?:StubLifecycleFn<Out>
Defined in: src/engine/block/block.ts:74
When the step fails, before the failure panel; written by Block.stubOnError((ctx) => ...).
verify?
Defined in: src/engine/block/block.ts:65
Optional. Runs once, only after resolve has already decided Out - confirms or fails loud, can never redirect what was decided. A function form picks different checks per branch (a failed login shouldn't be checked against "reached the dashboard"); see Block.withVerify and Block.modVerify for changing this from outside the Block's own file.
Methods
act()
act(
page,input,mem):Promise<void>
Defined in: src/engine/block/block.ts:32
Drives the browser only, this tab only. Never touches context - see observe for that.
Parameters
page
Page
input
In
mem
Returns
Promise<void>
observe()?
optionalobserve(page,mem):Promise<Observed>
Defined in: src/engine/block/block.ts:51
Optional. Gathers evidence for resolve to classify, runs assertions, writes memory - the only phase allowed to look at the DOM before a decision is made, or open a second tab via page.context().
Parameters
page
Page
mem
Returns
Promise<Observed>
resolve()
resolve(
observed):Out|Promise<Out>
Defined in: src/engine/block/block.ts:57
Mandatory, pure. Its only parameter is the evidence observe handed it - no page, no mem in scope, not by convention but because they're missing from the signature. Reproducible from observed alone.
Parameters
observed
Observed
Returns
Out | Promise<Out>