feat(engine): add on_enter node-entry hook#37
Merged
Conversation
The engine's per-node record was only available at run end (the trace). A live consumer that wants to show which node is executing *right now* — and the path the caller has taken so far — had no signal until the call was over. Add `FlowEffects::on_enter(node, kind)`, called once as the engine reaches each node, before that node's own effects run. It fires for every visited node, including `hours` (which runs no other effect) and a node re-entered by a goto; a menu's internal retries do not re-fire it. Default no-op, so existing impls are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hj93UCb3RKjF6mBwzhsp9f
wavekat-eason
commented
Jul 21, 2026
wavekat-eason
commented
Jul 21, 2026
wavekat-eason
marked this pull request as ready for review
July 21, 2026 10:14
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
FlowEffects::on_enter(node, kind), called once as the engineenters each node in
run_node, before that node's own effects run.Default no-op, so it's backward-compatible — existing
FlowEffectsimpls compile and behave unchanged.
Why
A consumer (wavekat-voice's live call-screening UI) needs to light up
the current node on the flow graph as a call moves through it. The
existing effect calls (
speak,collect_digit,record_message, …)can't drive that on their own: node kinds repeat (multiple greetings /
menus), so an effect can't name which node is active, and an
effect-less node like
hoursfires no effect at all and would beskipped on the map.
on_entercarries the node's id and kind atthe one moment that unambiguously identifies it — arrival.
It fires for every visited node, including
hours, and exactly onceper entry (a node re-entered by a menu retry loop fires again on each
real re-entry, not on internal retries).
Changes
FlowEffects::on_enter(&mut self, node: &NodeId, kind: &'static str)with a default no-op.
run_nodecallsfx.on_enter(id, kind)right after resolving thenode's kind.
MockEffectsrecords entries; new teston_enter_reports_each_node_as_the_engine_reaches_itpins entryorder across the open/closed paths and the menu-retry case.
Release
The downstream consumer pins
wavekat-flow = "0.0.5"behind a local[patch.crates-io]for iteration. Publish 0.0.5 to crates.io afterthis merges, so the consumer can drop the patch and resolve the pin
from the registry.
36 tests pass.