# Action Nodes

## What a strong action node looks like

The platform built-in `database.fast-forward` is available as a sandbox action
when the environment definition declares at least one database. Choose a
declared database key in its `database` input. Its typed result fields become
Workflow variables, so later nodes can use values such as
`$var.offset_days`. See the Sandbox v2 guide's Data Fast-forward topic for the
database declaration and shift behavior.

The Workflow-local `sandbox.reset` built-in restores the active Run-owned
Sandbox v2 copy from its exact pinned snapshot and version, then continues at
the next authored node after the replacement copy is ready and the existing
persona has been freshly authenticated. Anonymous Runs stay anonymous. Add an
explicit Navigate after reset before taking another checkpoint. Reset does not
replay earlier setup, seed, or called-Workflow steps, and it is not a manual
sandbox CLI command. In a test with several page states, reset the copy before
the setup actions for the next state. See the Sandbox v2 guide's
`seeds-and-actions` topic for the full authoring behavior.

Action nodes are the workhorse of a flow — and they are also the unit the
cache stores and replays. Sizing them well is what makes a flow both fast
(cacheable sooner) and durable (resistant to benign UI churn). Five things
separate a strong action node from a weak one.

### 1. It reads as one coherent step

A good node has a title you could read aloud as a single instruction to a
teammate: "Create a ticket", "Fill out the subscription form", "Click Start
to open the run-config modal". The title names a goal — and, where it helps,
the purpose of the step — not raw mechanics.

A node is usually broader than a single click, but not always: a lone action
that genuinely stands on its own in the flow is a fine node ("Click Start to
open the modal"). The extremes to avoid are a purely mechanical title with no
intent ("Click the button") and a node stuffed with several unrelated
outcomes ("Create a ticket, assign it, comment, and upload"). When in doubt,
err toward clearer, more discrete steps over one overloaded node.

### 2. It has roughly 3–8 playbook steps

Each playbook step is one atomic intent executed in one tool call, bounded
by stable page states. Fuse actions coupled through ephemeral UI state — an
opener and a target that exists only while its menu is open — into that
call. Split unrelated intents and every stable intermediate. A healthy node
lands around 3–8 steps:

```text
click → fill_form → click            (good — open, fill, submit)
click → click → fill_form → click    (good)
27 clicks                            (bad — that's several outcomes)
```

"Meaningful" is the operative word. Incidental events collapse into the
nearest step (a focus-click before a fill is part of the fill), and a whole
form-fill is ONE fill_form step, not one step per field. If a single outcome
would need more than ~8 steps, that's the signal to split it into sequential
action nodes ("Fill customer details" → "Fill billing details" → "Review &
submit") rather than grow one megastep.

This ~3–8 is the STEP count inside one action node — not a cap on how many
NODES a flow has. A flow is as long as its coherent journey needs (see Best
Practices on flow scope).

Interaction recipes are property-scoped, reusable interaction mechanics.
A recipe invocation appears as one `call` step for its whole transaction,
not as separate steps for the browser actions inside it.

### 3. It has a clear assertion boundary

A strong node ends at a checkpoint you can assert on: a modal disappeared,
the URL changed, a row appeared, a toast fired. Put that check inline on the
node (see the Assertions section) so the node's success is observable and the
run gets a real progress marker at each step. State the behavior promised
by the requirement, not DOM attributes, SVG details, or an arbitrary
measurement threshold discovered during exploration. Keep observation
mechanics in executable code and chosen interaction inputs in the action.

Inline assertions verify the END STATE after the action. They can be relative
or temporal ("the row count dropped by 2"), but only if the baseline was
captured upstream — write `current row count = $var.captured_row_count - 2`,
never "the count dropped by 2". The reason: an action may replay from cache
while its assertion is judged live by the agent, which does NOT have the
action's execution context. A self-contained assertion (absolute values, or
values bound to captured variables) survives that split; one that silently
assumes "before" state does not.

### 4. It is not conditional

Avoid baking branching into an action node — "if the location isn't New York,
set it to New York", "if patient X isn't in the table, create patient X". A
conditional in a node usually means the data wasn't staged properly, and it
caches poorly (the cached path and the live path diverge).

Prefer, in order:

- Seed the precondition so the branch never exists ("patient X always
  present" → seed patient X). See Seed Workflows.
- If the action is idempotent — the same sequence reaches the desired state
  regardless of where it started (re-selecting "New York" works whether or
  not it was already set) — just run the sequence unconditionally. No branch
  needed.
- If the branch is genuine, use a formal CONDITION node (deterministic when
  the check is a `$var` / identity comparison; agentic otherwise), which keeps
  the branch explicit and cacheable per path.

If a conditional truly must live inside a node, set `alwaysUseAgent: true` on
it so the branch is reasoned about live every run and never mis-cached.

### 5. Its prose is short

The description is what a tester would say out loud — two to four plain
sentences: what to click, what should happen, what state to leave behind.
Playbook targets name controls by their visible text ("'Create copy' menu
item", "QA Policy row checkbox"). Exact strings belong in the
assertions only when they are required by the spec, not merely locator
details. The readable condition must remain about the product behavior.

- Good: "Search for QA Carrier, tick the QA Policy A and QA Policy B row
  checkboxes, and click the 'Create policies' toolbar icon. Review the
  preview, then click 'Cancel'. Leave both rows selected."
- Bad: a paragraph that restates hover/retry mechanics, quotes request
  URLs and response bodies, or narrates a bug with its ticket id
  and repro steps.

Do not restate the same mechanics in every node ("hover the row so its
controls appear — they render only while hovered — then click …"); say it
once in a short phrase or leave it to the agent. Known failures go in a
warn-severity assertion that cites the ticket id in one clause, with the
ticket attached to the flow (status event / comment), never as an essay
inside the node. If a description needs more than four sentences, the node
is doing more than one thing — split it (point 1).

## Why this matters

The node is the atomic cache unit. The smaller and more reliable each node is,
the sooner the flow caches and the faster it replays. But because the node is
also the unit of specificity, the more a node pins to incidental detail (exact
button text, a precise field order), the more a benign change breaks it.
Nailing the altitude — coherent goal, ~3–8 meaningful steps, a clean assertion
boundary, no hidden branches, short prose — is what buys both speed and
reliability at once.
