Skip to content

feat: introduce VerificationService orchestration layer#8

Open
Maatify wants to merge 3 commits intomainfrom
feat/verification-service-12403240662160590175
Open

feat: introduce VerificationService orchestration layer#8
Maatify wants to merge 3 commits intomainfrom
feat/verification-service-12403240662160590175

Conversation

@Maatify
Copy link
Owner

@Maatify Maatify commented Mar 16, 2026

Introduces a new lightweight orchestration layer, VerificationService, to provide a clean workflow API around the verification engine.

Architecture Check & Compliance:

  1. Verification Engine Only: Yes, the module remains a verification engine.
  2. No Delivery Mechanism: Yes, the service only coordinates generator/validator. It does not send SMS or emails.
  3. No Domain Logic: The service cleanly acts as an API proxy.
  4. No Framework Dependencies: The service purely implements an interface and uses standard constructor dependency injection.

Key Changes:

  • src/Application/Verification/VerificationServiceInterface.php: Defines the workflow API.
  • src/Application/Verification/VerificationService.php: Implements orchestration using existing VerificationCodeGeneratorInterface and VerificationCodeValidatorInterface.
  • tests/Unit/Application/Verification/VerificationServiceTest.php: Adds unit testing for orchestration behavior matching specification requirements.

CI (composer analyse and composer test) passes correctly.


PR created automatically by Jules for task 12403240662160590175 started by @Maatify

- Created VerificationServiceInterface and VerificationService in `src/Application/Verification/`.
- Implemented lightweight orchestration methods `startVerification`, `verifyCode`, and `resendVerification`.
- Strictly enforced separation of concerns by delegating core logic to existing generator and validator components.
- Avoided framework or delivery mechanisms as per architectural constraints.
- Added comprehensive unit tests in `tests/Unit/Application/Verification/VerificationServiceTest.php`.
- Ensured code passes max level PHPStan analysis and all PHPUnit tests.

Co-authored-by: Maatify <130119162+Maatify@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules bot and others added 2 commits March 16, 2026 03:13
- Required `maatify/exceptions` via Composer.
- Created `VerificationErrorCodeEnum` for specific verification error codes.
- Created `VerificationException` base class extending `MaatifyException`.
- Added specific child exceptions for invalid codes, expired codes, attempt limits, generation blocks, and internal errors.
- Updated `VerificationService` to catch domain exceptions/results and throw the correct application exception.
- Updated unit tests to assert proper exception throwing instead of evaluating scalar booleans.
- The domain and infrastructure layers remain unchanged.

Co-authored-by: Maatify <130119162+Maatify@users.noreply.github.com>
- Introduced `VerificationFailureEnum` (`INVALID_CODE`, `EXPIRED`, `ATTEMPTS_EXCEEDED`).
- Updated `VerificationResult` DTO to securely encapsulate failure codes using the new enum.
- Refactored `VerificationCodeValidator` to assign proper failure enum codes upon validation failures based on remaining attempts and current active status.
- Added `VerificationGenerationRateLimitedException` in the domain layer to isolate generation-blocking errors cleanly.
- Updated `VerificationCodeGenerator` to throw `VerificationGenerationRateLimitedException` on max window or cooldown breaches.
- Re-architected `VerificationService` exception mapping layer to utilize robust `match ($result->failureCode)` structures, eliminating all unsafe `str_contains()` logic.
- Updated unit and integration test assertions and mocks to match the structured validation DTO return types and generator exceptions.

Co-authored-by: Maatify <130119162+Maatify@users.noreply.github.com>
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