feat(scxml): add <invoke> parsing and runtime support#575
Merged
Conversation
Parse SCXML <invoke> elements and wire them through the existing Python-level invoke infrastructure (IInvoke protocol, InvokeManager). Key changes: - New SCXMLInvoker handler (io/scxml/invoke.py) implementing IInvoke - Parser support for <invoke>, <content>, <param>, <finalize>, namelist - Processor wiring: InvokeDefinition → SCXMLInvoker → State(invoke=) - Engine hooks: handle_external_event for finalize/autoforward routing - Fix async processing loop early exit resolving caller_future - Fix finalize running even after invocation terminates (race condition) - 19 W3C invoke tests now passing (removed from xfail sets)
91445f5 to
41bd18b
Compare
… catching for transition content Implement two fixes for SCXML W3C tests 192 and 253: 1. Add #_<invokeid> send target support — the SCXML convention for parent-to-child event routing. Events are forwarded through InvokeManager.send_to_child() to the child handler's on_event(). Unreachable targets queue error.communication. 2. Wrap transition `on` content with on_error so errors are caught per-block (SCXML spec §5.12.1). Previously, errors in transition actions caused full microstep rollback; now the transition completes and error.execution is queued separately. During error.execution processing, on_error is disabled for transition content to prevent infinite loops in self-transition error handlers. Also includes: - Decouple SCXMLInvoker from processor (takes base_dir + register_child) - Add invoke_init callback for invoked child machines - Thread leak detection fixture and interruptible wait fixes - Unit tests for _send_to_invoke and SCXMLInvoker - Documentation updates for invoke, error handling, and release notes
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #575 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 33 33
Lines 4051 4116 +65
Branches 639 661 +22
=========================================
+ Hits 4051 4116 +65
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Invoke handlers run in background threads, outside the processing loop. Using the internal queue would either contaminate an unrelated macrostep or stall indefinitely. This matches done.invoke, which also uses the external queue for the same reason.
Add 19 tests covering uncovered lines in modified files: - EventDataWrapper edge cases (no args, __getattr__, name via trigger_data) - _send_to_parent namelist errors and param expr=None skip - _send_to_invoke param without expr skip - invoke_init idempotent behavior - SCXMLInvoker: on_event exception, non-string content, param location - Parser: <assign> child XML/text, <invoke> text content - InvokeManager: send_to_child not found / no on_event, null event - _stop_child_machine exception handling - BaseEngine.__del__ cancel_all exception - Async engine error in before callbacks Also fix _make_invoker to not hardcode /tmp, and document coverage report commands in AGENTS.md.
The `child.find("{http://www.w3.org/2005/07/scxml}scxml")` call was
unreachable because `strip_namespaces()` always runs before
`parse_invoke()`. Replaced with direct `child.find("scxml")`.
Also added a test for unknown child elements inside `<invoke>`.
|
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.



Summary
<invoke>elements and wire them through the existing Python-level invoke infrastructure (IInvokeprotocol,InvokeManager)SCXMLInvokerhandler (io/scxml/invoke.py) that resolves child state machines from<content>orsrc=, evaluates<param>andnamelist, handles autoforward and finalize<invoke>,<content>(inline SCXML),<param>,<finalize>,namelisthandle_external_event()onInvokeManagerfor finalize/autoforward routingcaller_future(prevents hang when SM terminates)