Repository navigation
fix: mark compound states nested in parallel states as active - #652
Conversation
A compound state nested inside a parallel region was reported as inactive when reached through an attribute chain (e.g. `sm.door.shut`), even though it was present in the configuration. `sm.shut` (accessed directly) worked because it resolves to an `InstanceState` proxy, but `sm.door.shut` returned the raw class-level `State`, whose `is_active` is a stale attribute fixed to `False`. Root cause: `InstanceState.__init__` ran `_init_states()`, which set the raw child `State` objects directly on the proxy's `__dict__` (bypassing the delegating `__getattr__`) and mutated the shared raw children's `parent`. Now children are resolved lazily: `__getattr__` maps a declared child (or history) state to the machine's per-instance proxy via the new `Configuration.instance_state()`, so `is_active` is consistent regardless of access path. Fixes fgmacedo#651 Signed-off-by: Martin Bernstorff <martinbernstorff@gmail.com>
There was a problem hiding this comment.
Hi @MartinBernstorff, welcome! This is your first contribution here, and the minimal reproducer in #651 plus the PR with a test made this quick to verify. Thanks for the time you put into it.
Blocking: parent reached from a proxy regressed to the raw State (inline, with a one-line fix). The other comments are non-blocking.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #652 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 52 52
Lines 5648 5651 +3
Branches 887 888 +1
=========================================
+ Hits 5648 5651 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Review follow-up for fgmacedo#652: - resolve every State-valued attribute of an InstanceState to its per-instance proxy, so `parent` no longer returns the raw State - hand the instance_states mapping to the proxy at construction instead of reaching it through `machine._config` - pin proxy identity and cross-instance isolation in tests - unify assertion argument order (Sonar S3415) Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>
Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>
|



Fixes #651
I haven't dug into the code myself; I had an LLM write this, and glanced at the solution. Feel free to close.