|
| 1 | +name: region-builder |
| 2 | +group: core |
| 3 | +description: The RegionBuilder provides a fluent API for constructing state machines with support for features, middleware, event handlers, and hierarchical state management |
| 4 | + |
| 5 | +features: |
| 6 | + - name: state-configuration |
| 7 | + description: Core state definition and configuration functionality |
| 8 | + specs: |
| 9 | + - acceptanceCriteria: A builder can define states using setStates with variadic parameters |
| 10 | + intent: Provides convenient bulk state definition through variadic syntax, simplifying initial state machine configuration |
| 11 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/SetStatesTest.php |
| 12 | + |
| 13 | + - acceptanceCriteria: A builder can add individual states using addState |
| 14 | + intent: Enables incremental state definition for dynamic or conditional state machine construction |
| 15 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/AddStateTest.php |
| 16 | + |
| 17 | + - acceptanceCriteria: A builder can mark a state as initial using markInitial |
| 18 | + intent: Explicitly designates the starting state, overriding the default first-state convention |
| 19 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/MarkInitialTest.php |
| 20 | + |
| 21 | + - acceptanceCriteria: A builder can mark a state as final using markFinal |
| 22 | + intent: Explicitly designates the terminal state, overriding the default last-state convention |
| 23 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/MarkFinalTest.php |
| 24 | + |
| 25 | + - acceptanceCriteria: Built region uses first state as initial when none is marked |
| 26 | + intent: Provides sensible default behavior, reducing boilerplate for simple state machines |
| 27 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/DefaultInitialStateTest.php |
| 28 | + |
| 29 | + - acceptanceCriteria: Built region uses last state as final when none is marked |
| 30 | + intent: Provides sensible default terminal state, reducing configuration for linear workflows |
| 31 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/DefaultFinalStateTest.php |
| 32 | + |
| 33 | + - name: feature-registration |
| 34 | + description: Feature system integration and registration |
| 35 | + specs: |
| 36 | + - acceptanceCriteria: A builder can register features using enableFeatures |
| 37 | + intent: Activates modular functionality extensions, enabling features to configure the DI container and middleware chains |
| 38 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/EnableFeaturesTest.php |
| 39 | + |
| 40 | + - acceptanceCriteria: enableFeatures accepts multiple features as variadic parameters |
| 41 | + intent: Simplifies multi-feature registration through variadic syntax, reducing method call overhead |
| 42 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/EnableMultipleFeaturesTest.php |
| 43 | + |
| 44 | + - acceptanceCriteria: Features are invoked with the builder's ChainMail instance |
| 45 | + intent: Provides features with DI container access, allowing service registration and middleware configuration during setup |
| 46 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/FeatureInvocationTest.php |
| 47 | + |
| 48 | + - acceptanceCriteria: Features registered via enableFeatures are available in built region |
| 49 | + intent: Ensures feature-provided services and middleware are accessible in the constructed region, completing feature integration |
| 50 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/FeatureAvailabilityTest.php |
| 51 | + |
| 52 | + - name: event-handler-registration |
| 53 | + description: Registering lifecycle callbacks and action handlers |
| 54 | + specs: |
| 55 | + - acceptanceCriteria: A builder can register action handlers using onAction |
| 56 | + intent: Registers state-specific event handlers, enabling custom business logic execution when events occur in particular states |
| 57 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/OnActionRegistrationTest.php |
| 58 | + |
| 59 | + - acceptanceCriteria: A builder can register enter handlers using onEnter |
| 60 | + intent: Registers state entry callbacks, enabling initialization and setup logic when transitioning into states |
| 61 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/OnEnterRegistrationTest.php |
| 62 | + |
| 63 | + - acceptanceCriteria: A builder can register exit handlers using onExit |
| 64 | + intent: Registers state exit callbacks, enabling cleanup and teardown logic when transitioning out of states |
| 65 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/OnExitRegistrationTest.php |
| 66 | + |
| 67 | + - acceptanceCriteria: Event handlers are executed through the build chain |
| 68 | + intent: Ensures handlers integrate with middleware chain, allowing handler behavior to be modified by features and middleware |
| 69 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/EventHandlerChainIntegrationTest.php |
| 70 | + |
| 71 | + - acceptanceCriteria: Multiple handlers can be registered for the same state and event type |
| 72 | + intent: Supports composition of multiple handlers, enabling modular and reusable event handling logic |
| 73 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/MultipleHandlersSameStateTest.php |
| 74 | + |
| 75 | + - name: metadata-management |
| 76 | + description: Region and state metadata configuration |
| 77 | + specs: |
| 78 | + - acceptanceCriteria: A builder can set metadata using setMetaData with array or ArrayAccess |
| 79 | + intent: Attaches arbitrary metadata to regions or states, enabling data-driven configuration and runtime introspection |
| 80 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/SetMetaDataTest.php |
| 81 | + |
| 82 | + - acceptanceCriteria: setMetaData requires a MetaType parameter to categorize metadata |
| 83 | + intent: Organizes metadata by type, preventing namespace collisions and enabling type-specific metadata handling |
| 84 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/MetaTypeRequiredTest.php |
| 85 | + |
| 86 | + - acceptanceCriteria: setMetaData supports optional flags parameter for configuration |
| 87 | + intent: Provides fine-grained control over metadata behavior through configuration flags |
| 88 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/MetaDataFlagsTest.php |
| 89 | + |
| 90 | + - acceptanceCriteria: setMetaData supports optional predicate for conditional metadata |
| 91 | + intent: Enables dynamic metadata attachment based on runtime conditions, supporting context-aware configuration |
| 92 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/ConditionalMetaDataTest.php |
| 93 | + |
| 94 | + - name: build-steps |
| 95 | + description: Custom build middleware and step management |
| 96 | + specs: |
| 97 | + - acceptanceCriteria: A builder can add custom build steps using addBuildStep with BuildStep interface |
| 98 | + intent: Enables extensible build pipeline through custom middleware, allowing features to modify construction process |
| 99 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/AddBuildStepTest.php |
| 100 | + |
| 101 | + - acceptanceCriteria: Build steps are executed in order during the build process |
| 102 | + intent: Ensures predictable build pipeline execution, supporting ordered construction transformations |
| 103 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/BuildStepExecutionTest.php |
| 104 | + |
| 105 | + - acceptanceCriteria: Build step callbacks receive builder, next, and first parameters |
| 106 | + intent: Provides middleware pattern for build steps, enabling composition and restart capabilities during construction |
| 107 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/BuildStepCallbacksTest.php |
| 108 | + |
| 109 | + - acceptanceCriteria: Build steps can modify the region during construction |
| 110 | + intent: Allows dynamic region customization during build phase, supporting conditional and computed configurations |
| 111 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/BuildStepModificationTest.php |
| 112 | + |
| 113 | + - name: connection-management |
| 114 | + description: Hierarchical and parallel region connections |
| 115 | + specs: |
| 116 | + - acceptanceCriteria: A builder can connect to remote regions using connect method |
| 117 | + intent: Establishes hierarchical or parallel region relationships, enabling composite state machine structures |
| 118 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/ConnectRegionTest.php |
| 119 | + |
| 120 | + - acceptanceCriteria: connect accepts optional flags parameter for connection configuration |
| 121 | + intent: Provides fine-grained control over connection behavior through configuration flags |
| 122 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/ConnectionFlagsTest.php |
| 123 | + |
| 124 | + - acceptanceCriteria: connect accepts optional predicate for conditional connections |
| 125 | + intent: Enables dynamic region connections based on runtime conditions, supporting context-aware hierarchies |
| 126 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/ConnectionPredicateTest.php |
| 127 | + |
| 128 | + - acceptanceCriteria: Connections are registered with the ConnectedRegions chain during build |
| 129 | + intent: Ensures connections integrate with middleware chain, allowing connection behavior to be extended by features |
| 130 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/ConnectionRegistrationTest.php |
| 131 | + |
| 132 | + - name: builder-lifecycle |
| 133 | + description: Builder instantiation, cloning, and region construction |
| 134 | + specs: |
| 135 | + - acceptanceCriteria: A builder can be instantiated with default ChainMail instance |
| 136 | + intent: Provides zero-configuration construction, simplifying basic state machine creation |
| 137 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/DefaultConstructorTest.php |
| 138 | + |
| 139 | + - acceptanceCriteria: A builder can be instantiated with custom ChainMail instance |
| 140 | + intent: Enables pre-configured DI containers, supporting shared service registration across builders |
| 141 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/CustomChainMailConstructorTest.php |
| 142 | + |
| 143 | + - acceptanceCriteria: newInstance creates a new builder sharing the same ChainMail configuration |
| 144 | + intent: Facilitates builder cloning for creating related state machines with shared services and middleware |
| 145 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/NewInstanceTest.php |
| 146 | + |
| 147 | + - acceptanceCriteria: build creates a Region instance from builder configuration |
| 148 | + intent: Constructs the final state machine, executing build pipeline and instantiating the runtime region |
| 149 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/BuildTest.php |
| 150 | + |
| 151 | + - acceptanceCriteria: build accepts optional Mesh or iterable for feature arguments |
| 152 | + intent: Provides dynamic feature configuration during build, enabling parameterized feature initialization |
| 153 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/BuildWithFeatureArgsTest.php |
| 154 | + |
| 155 | + - acceptanceCriteria: build accepts optional skipMiddlewares flag to bypass EnhanceRegionBuilder chain |
| 156 | + intent: Allows bypassing middleware for performance or testing, providing direct region construction |
| 157 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/SkipMiddlewaresTest.php |
| 158 | + |
| 159 | + - name: chainmail-integration |
| 160 | + description: Dependency injection container integration |
| 161 | + specs: |
| 162 | + - acceptanceCriteria: Builder exposes ChainMail instance through public property with asymmetric visibility |
| 163 | + intent: Provides direct access to the DI container through a publicly readable property while preventing external modification, enabling advanced service registration and middleware configuration outside the builder's fluent API |
| 164 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/ChainMailAccessTest.php |
| 165 | + |
| 166 | + - acceptanceCriteria: ChainMail is booted automatically when building region |
| 167 | + intent: Ensures all registered DI services and middleware are fully initialized before region construction begins, guaranteeing complete dependency resolution and proper middleware chain setup |
| 168 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/ChainMailBootTest.php |
| 169 | + |
| 170 | + - acceptanceCriteria: Builder constructor registers default service providers in ChainMail |
| 171 | + intent: Establishes comprehensive core infrastructure by automatically registering essential chains and services (EnhanceRegionBuilder, DispatchAction, validation chains, connection chains, state management chains, and Events), providing a complete operational foundation for basic state machine functionality |
| 172 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/DefaultServicesTest.php |
| 173 | + |
| 174 | + - acceptanceCriteria: Builder integrates with EnhanceRegionBuilder chain for middleware processing |
| 175 | + intent: Enables features and middleware to intercept and transform the builder before region construction through the EnhanceRegionBuilder chain, supporting advanced customization, validation, and dynamic configuration modifications |
| 176 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/EnhanceBuilderIntegrationTest.php |
| 177 | + |
| 178 | + - name: validation |
| 179 | + description: Configuration validation and error handling |
| 180 | + specs: |
| 181 | + - acceptanceCriteria: Builder throws RuntimeException when building with empty states array |
| 182 | + intent: Prevents construction of invalid state machines by enforcing that every region must have at least one defined state, catching configuration errors early with clear error messages |
| 183 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/EmptyStatesValidationTest.php |
| 184 | + |
| 185 | + - acceptanceCriteria: Builder validates configuration in assertValidConfig during build |
| 186 | + intent: Ensures configuration consistency and correctness through a centralized validation checkpoint executed during build, catching structural and logical configuration errors before region instantiation |
| 187 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/ConfigValidationTest.php |
| 188 | + |
| 189 | + - name: fluent-api |
| 190 | + description: Method chaining and fluent interface pattern |
| 191 | + specs: |
| 192 | + - acceptanceCriteria: All configuration methods return self for method chaining |
| 193 | + intent: Implements the fluent interface pattern by returning self from all configuration methods, enabling readable and expressive state machine construction through continuous method chaining |
| 194 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/FluentInterfaceTest.php |
| 195 | + |
| 196 | + - acceptanceCriteria: Builder methods can be chained in any logical order |
| 197 | + intent: Provides maximum flexibility in builder configuration by allowing order-independent method chaining, enabling developers to organize code logically without artificial ordering constraints while maintaining correct final state |
| 198 | + test: vendor/bin/phpunit tests/PHPUnit/Unit/Core/RegionBuilder/MethodChainingOrderTest.php |
0 commit comments