Skip to content

feat: Centralize and uniformly enforce blood unit status transitions#1

Open
marvelousufelix wants to merge 2 commits intomainfrom
feature/centralize-blood-transitions
Open

feat: Centralize and uniformly enforce blood unit status transitions#1
marvelousufelix wants to merge 2 commits intomainfrom
feature/centralize-blood-transitions

Conversation

@marvelousufelix
Copy link
Copy Markdown
Owner

@marvelousufelix marvelousufelix commented Mar 26, 2026

This PR introduces a centralized state machine for blood unit lifecycle management, ensuring uniform validation of status transitions across the backend and enforcing synchronization with the Soroban smart contract.

Changes

  • ✅ Centralized BloodStatusStateMachine service
  • ✅ Aligned BloodStatus enum with Soroban contract
  • ✅ BloodTransitionException for detailed error handling
  • ✅ 34 comprehensive property-based tests (all passing)
  • ✅ Module DI integration
  • ✅ Full documentation and integration guides

Test Results

  • ✅ 34 BloodStatusStateMachine tests - PASSING
  • ✅ 17 BloodUnit entity tests - PASSING
  • ✅ All 9 transitions verified against Soroban contract - MATCHING

Key Features

  • Single source of truth for transition rules
  • Type-safe validation with TypeScript enums
  • Uniform enforcement across all code paths
  • Detailed exceptions for debugging
  • Complete replay capability from event history

Closes Emeka000#284

- Add BloodStatusStateMachine with centralized transition rules
- Implement BloodTransitionException for detailed error handling
- Update BloodStatus enum to match Soroban contract
- Add 34 comprehensive property-based tests
- All 9 valid transitions verified against Soroban
- Update blood-unit entity and tests for new enum values

Tests passing: 34/34 BloodStatusStateMachine, 17/17 entities
- Export BloodStatusStateMachine from BloodUnitsModule
- Ready for injection in services and controllers
- Enables uniform transition validation across codebase
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.

Harden blood status transition matrix with exhaustive tests

1 participant