Skip to content

Add flow inheritance for subclasses#65

Merged
saturnflyer merged 5 commits intomainfrom
feature/flow-inheritance
Feb 24, 2026
Merged

Add flow inheritance for subclasses#65
saturnflyer merged 5 commits intomainfrom
feature/flow-inheritance

Conversation

@saturnflyer
Copy link
Member

Summary

  • Subclasses of Circulator classes now transparently inherit parent flows
  • Declaring flow on a subclass for an attribute already defined on a parent raises ArgumentError recommending Circulator.extension
  • Circulator.extension(ChildClass, :attribute) copies the parent flow, applies the extension, and stores it on the child class without affecting the parent
  • Early extensions (registered before the child class exists) are applied lazily via an inherited hook
  • Flow methods use dynamic transition lookup to ensure extensions work correctly on the very first call

Test plan

  • Subclass inherits parent flows transparently (action methods, available_flows, state predicates)
  • Redeclaring a parent's flow attribute raises ArgumentError with guidance
  • Subclass can declare flow for a different attribute without error
  • Late extension on subclass copies parent flow and applies changes
  • Extension can modify existing transitions without affecting parent
  • Early extension applied when subclass is defined
  • Early extension modifying existing transitions works on first call
  • Grandchild inheritance through intermediate class
  • Sibling subclasses with different extensions don't interfere
  • Standalone classes unaffected
  • Deep copy isolation (mutating child flow doesn't affect parent)
  • Full regression suite: 373 tests, 0 failures

🤖 Generated with Claude Code

Added: Flow#dup_for method for deep-copying flows to subclasses
Subclasses now transparently inherit parent flows without
needing to redeclare them. The class-level flows method walks
the ancestor chain, and instance-level flows aliases the child
model_key to the parent's flow data.

Changed: Subclasses of Circulator classes inherit parent flows
Version: major
Subclasses that try to declare a flow for the same attribute as
a parent class now get a clear error recommending Circulator.extension.

Added: Error on redeclaring inherited flow attributes in subclasses
Circulator.extension on a subclass now deep-copies the parent's
flow before merging, keeping parent and sibling flows isolated.

Added: Extension support for subclasses that inherit parent flows
Extensions registered before a subclass exists are now applied
lazily when the subclass's flows are first accessed. Flow methods
look up transitions dynamically so that early extensions that
modify existing transitions take effect on the first call.

Added: Lazy application of pending extensions via inherited hook
Changed: Flow methods use dynamic transition lookup for inherited flows
@saturnflyer saturnflyer force-pushed the feature/flow-inheritance branch from 506149c to 2ed2787 Compare February 24, 2026 15:37
@saturnflyer saturnflyer marked this pull request as ready for review February 24, 2026 15:38
@saturnflyer saturnflyer requested a review from a team as a code owner February 24, 2026 15:38
@saturnflyer saturnflyer merged commit a94a90a into main Feb 24, 2026
4 checks passed
@saturnflyer saturnflyer deleted the feature/flow-inheritance branch February 24, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant