Skip to content

Feat/split baker akka actors - #1943

Open
w8mr wants to merge 20 commits into
masterfrom
feat/split-baker-akka-actors
Open

Feat/split baker akka actors#1943
w8mr wants to merge 20 commits into
masterfrom
feat/split-baker-akka-actors

Conversation

@w8mr

@w8mr w8mr commented May 16, 2026

Copy link
Copy Markdown
Collaborator

Split akka-baker-actors into 7 modules:

  • Actors common
  • Actors protocol
  • Actors Recipe manager
  • Actors Delayed Transaction
  • Actors Process Index
  • Actors Process Instance
  • Actors orginal (integration)

w8mr and others added 20 commits May 11, 2026 14:00
- Migrated all 7 annotation files from Java to Kotlin
- Updated pom.xml with Kotlin build configuration
- Maintained full backward compatibility with Java consumers
- All annotations preserve runtime retention and proper targets
- Verified with full Maven build: all 21 modules compile successfully
- No breaking changes: existing Java, Scala, and Kotlin code works without modification
Create TestDataBuilders.kt to enable true unit testing by providing
helper functions that create Petri net objects without dependencies
on the full Recipe DSL pipeline.

Key features:
- Reuses RecipeCompiler helpers (interactionTransitionOf, createPlace, etc.)
- Supports creating EventDescriptor, EventTransition, InteractionTransition
- Enables testing individual functions without pipeline setup
- Made RecipeComponents and TransitionCollections internal for test access

All 82 existing tests still pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Converted all arc building and helper function tests to use TestDataBuilders
instead of the full Recipe DSL pipeline, achieving true unit testing.

Tests rewritten (11 total):
- buildInternalEventArcs - now creates transitions/events directly
- buildEventLimiterArcs - creates event transitions with firing limits
- buildEventPreconditionArcs (3 tests) - uses builder preconditions
- buildPreconditionErrors (4 tests) - uses builder transitions
- buildSensoryEventArcs - creates event transitions directly
- buildMultipleOutputFacilitatorArcs - creates shared ingredient transitions
- buildInteractionArcs - creates all components with builders
- buildMultipleOutputFacilitatorTransitions (2 tests) - no pipeline needed

Enhanced TestDataBuilders:
- Added outputEventIngredients parameter to simpleInteractionTransition
- Fixed InteractionFailureStrategy to use recipe.common.BlockInteraction()
- All builders now properly handle Scala interop

Benefits:
- Tests run faster (no Recipe DSL overhead)
- Tests are truly isolated (no pipeline dependencies)
- Clearer test intent (explicit test data creation)
- Easier to debug (minimal moving parts)

All 82 compiler tests still pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
#1940)

* Update the compiler to mostly use the kotlin data classes. Only the InteractionTransition and it's used clases are scala.
Next to all kotlin petrinet

* Removed interaction helper functio
Made originalName non-nullable in InteractionDescriptor
…dules

Split the monolithic baker-akka-actors module into 7 independent modules
following clean architecture and Single Responsibility Principle:

Modules created:
- baker-akka-actors-common: Shared utilities and serialization infrastructure
- baker-akka-actors-protocols: Message definitions and protobuf mappings
- baker-akka-actors-recipe-manager: Recipe storage actor + client wrapper
- baker-akka-actors-process-instance: Recipe instance execution
- baker-akka-actors-delayed-transition: Delayed transition handling
- baker-akka-actors-process-index: Process coordination
- baker-akka-actors: Integration module (aggregates all modules)

Post-split improvements:
- Created BakerActorNames utility for centralized actor name constants
- Moved ActorBasedRecipeManager to recipe-manager module for better cohesion
- Removed duplicate utility files (TimeoutUtil, AkkaSerializerProvider,
  BakerSerializable, SerializedDataProto, TypedProtobufSerializer) from
  integration module - kept only in common module

Benefits:
- Clear separation of concerns and module boundaries
- No circular dependencies
- Better testability and maintainability
- Backward compatible (no breaking changes)
- All 171 tests passing

Documentation: Added comprehensive ACTOR_MODULE_SPLIT_DOCUMENTATION.md
…attern

Split serialization logic from the monolithic BakerTypedProtobufSerializer
into module-specific serialization providers while maintaining backward
compatibility with persisted events.

Changes:
- Created ProcessInstanceSerialization (33 types) in process-instance module
- Created ProcessIndexSerialization (36 types) in process-index module
- Created RecipeManagerSerialization (8 types) in recipe-manager module
- Created DelayedTransitionSerialization (4 types) in delayed-transition module
- Refactored BakerTypedProtobufSerializer to act as proxy delegating to modules
- Maintained serializer ID 101 for backward compatibility with journal
- All 87 message types now distributed across modules by domain responsibility

Benefits:
- Better separation of concerns - each module owns its serialization logic
- Improved maintainability - changes to actor types stay within their modules
- Preserved backward compatibility - no breaking changes to persisted events
- Cleaner architecture following Single Responsibility Principle

All 565 tests passing.
Added comprehensive Phase 2 documentation covering:
- Serialization split architecture using proxy/delegation pattern
- Backward compatibility strategy (preserved serializer ID 101)
- Type distribution across 4 module-specific serialization providers
- Benefits of distributed serialization logic
- Updated build verification with 565 passing tests
- Serialization refactoring summary metrics
Moved 3 unit tests from integration module to their appropriate modules
to improve test organization and module cohesion.

Tests moved:
1. EncryptionPropertiesSpec → baker-interface
   - Pure property-based test for Encryption class
   - No Akka dependencies, just ScalaTest + ScalaCheck
   - Updated package from .akka.actor.serialization to .serialization

2. RecipeRuntimeSpec → baker-akka-actors-process-instance
   - Unit test for RecipeRuntime.createInteractionInput
   - Pure mockito-based test, no integration dependencies
   - Tests process instance runtime behavior

3. UtilSpec → baker-akka-actors-common
   - Unit test for Util.collectFuturesWithin
   - Refactored from AkkaTestBase to plain TestKit
   - Tests common utility function where it's defined

Changes:
- Added test dependencies (scalatest, scalacheck, mockito) to modules
- Added scalatest-maven-plugin to execute tests
- Integration module: 91 tests → 88 tests
- Total test count unchanged: 565 tests passing

Benefits:
- Better module isolation and test locality
- Tests live with the code they test
- Clearer module responsibilities
- Easier to run module-specific tests
Moved DelayedTransitionActorSpec (6 tests) to its appropriate module after
identifying and fixing the root cause of test failures.

Root cause analysis:
- DelayedTransitionActorProtocol messages extend BakerSerializable
- Test config had 'allow-java-serialization = off'
- In integration module: BakerTypedProtobufSerializer on classpath
- In delayed-transition module: No serializer → actor fails silently

Fix:
- Changed test config to 'allow-java-serialization = on'
- This is correct because the test verifies actor behavior, not serialization
- Serialization is tested separately in integration module

Changes:
- Added test dependencies to baker-akka-actors-delayed-transition
- Moved DelayedTransitionActorSpec with config fix
- Integration module: 88 tests → 82 tests
- Total test count unchanged: 565 tests passing

This pattern applies to other actor module tests:
- Tests using BakerSerializable messages need java-serialization enabled
- OR need the BakerTypedProtobufSerializer on test classpath
Extract complex business logic from integration tests into isolated unit tests
that can run without full actor infrastructure, persistence, or event sourcing.

New test files:
- ProcessInstanceUtilsSpec (10 tests): Tests ProcessInstance.getOutputEventName()
  and getWaitTimeInMillis() methods for delayed transitions and duration extraction
- EventInstanceValidationSpec (12 tests): Tests EventInstance.validate() method
  for event name matching, ingredient validation, and type checking

These isolated tests provide:
- Faster feedback during development
- Clearer test failures without actor lifecycle noise
- Better coverage of edge cases and error conditions
- Easier maintenance without integration test complexity

Test count: 565 -> 587 tests (+22 new isolated unit tests)
All 587 tests passing ✅
Base automatically changed from feat/split-baker-akka-runtime to release-6.0.0 May 18, 2026 10:55
Base automatically changed from release-6.0.0 to master June 25, 2026 10:52
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.

2 participants