high priority low complexity backend pending backend specialist Tier 10

Acceptance Criteria

ProxyRegistrationSucceeded event carries the new activity ID and attributed peer mentor ID
ProxyRegistrationDuplicateDetected event carries the full conflict reference (conflicting activity ID, date, peer mentor ID)
ProxyRegistrationFailed event carries a typed error code and a human-readable message suitable for display
No additional Supabase queries are triggered by the BLoC after receiving any of the three event types
All three event types are sealed/union typed — exhaustive switch in the BLoC causes a compile-time error if a variant is unhandled
Events are emitted exactly once per registration attempt — no double emissions
BLoC state transitions driven by these events produce the correct UI states (success screen, conflict review, error snackbar)

Technical Requirements

frameworks
Flutter
BLoC
data models
ProxyRegistrationSucceeded
ProxyRegistrationDuplicateDetected
ProxyRegistrationFailed
ProxyRegistrationResult
performance requirements
Event emission is synchronous after the service result is resolved — no additional async operations in the emission layer
security requirements
Error messages in ProxyRegistrationFailed must not leak internal Supabase error details or stack traces to the UI
ui components
Conflict review dialog/sheet (receives conflict payload from ProxyRegistrationDuplicateDetected)
Success confirmation screen (receives activity ID from ProxyRegistrationSucceeded)
Error snackbar/toast (receives message from ProxyRegistrationFailed)

Execution Context

Execution Tier
Tier 10

Tier 10 - 11 tasks

Can start after Tier 9 completes

Dependencies (10)
epic-proxy-activity-registration-core-services-task-001 component Cross-Epic Component proxy-registration-service depends on proxy-duplicate-detection-service
epic-proxy-activity-registration-core-services-task-002 component Cross-Epic Component proxy-registration-service depends on proxy-duplicate-detection-service
epic-proxy-activity-registration-core-services-task-003 component Cross-Epic Component proxy-registration-service depends on proxy-duplicate-detection-service
epic-proxy-activity-registration-core-services-task-008 component Cross-Epic Component proxy-registration-service depends on proxy-duplicate-detection-service
epic-proxy-activity-registration-core-services-task-004 component Cross-Epic Component proxy-registration-service depends on activity-attribution-service
epic-proxy-activity-registration-core-services-task-005 component Cross-Epic Component proxy-registration-service depends on activity-attribution-service
epic-proxy-activity-registration-core-services-task-006 component Cross-Epic Component proxy-registration-service depends on activity-attribution-service
epic-proxy-activity-registration-core-services-task-007 component Cross-Epic Component proxy-registration-service depends on activity-attribution-service
epic-proxy-activity-registration-core-services-task-009 component Cross-Epic Component proxy-registration-service depends on activity-attribution-service
epic-proxy-activity-registration-core-services-task-010 component Cross-Epic Component proxy-registration-service depends on activity-attribution-service
Dependents (18)
epic-proxy-activity-registration-ui-task-001 component Cross-Epic Component bulk-participant-list depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-002 component Cross-Epic Component bulk-participant-list depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-003 component Cross-Epic Component bulk-participant-list depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-004 component Cross-Epic Component duplicate-warning-dialog depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-005 component Cross-Epic Component duplicate-warning-dialog depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-006 component Cross-Epic Component duplicate-warning-dialog depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-007 component Cross-Epic Component proxy-peer-mentor-selector depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-008 component Cross-Epic Component proxy-peer-mentor-selector depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-009 component Cross-Epic Component proxy-peer-mentor-selector depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-010 component Cross-Epic Component proxy-activity-form depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-011 component Cross-Epic Component proxy-activity-form depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-012 component Cross-Epic Component proxy-registration-screen depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-013 component Cross-Epic Component proxy-registration-screen depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-014 component Cross-Epic Component proxy-registration-screen depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-015 component Cross-Epic Component bulk-registration-screen depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-016 component Cross-Epic Component bulk-registration-screen depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-017 component Cross-Epic Component bulk-registration-screen depends on proxy-registration-service
epic-proxy-activity-registration-ui-task-018 component Cross-Epic Component proxy-registration-bloc depends on proxy-registration-service

Implementation Notes

Define ProxyRegistrationEvent as a sealed class hierarchy (Dart 3 sealed or freezed). The service should return a ProxyRegistrationResult (also sealed), and the BLoC translates the result into the corresponding event using a switch expression. Keep the emission logic as a thin translation layer — no business logic should live here. This separation means the service is independently testable without a BLoC, and the BLoC is testable with a mocked service.

Use the bloc_test package's emitsInOrder matcher to assert exact event sequences. Ensure error messages are localized and do not contain raw Supabase error strings — define a ProxyRegistrationErrorCode enum with values like duplicateConflict, networkFailure, authorizationDenied, unknown, and map error codes to user-facing strings in the UI layer.

Testing Requirements

Write BLoC unit tests using flutter_test and bloc_test package. Test scenarios: (1) service returns success → BLoC emits ProxyRegistrationSucceeded with correct activity ID; (2) service returns duplicate conflict → BLoC emits ProxyRegistrationDuplicateDetected with full conflict reference; (3) service returns error → BLoC emits ProxyRegistrationFailed with typed error code; (4) no event is emitted twice for a single registration call; (5) BLoC state after each event matches expected UI state variant. Confirm compile-time exhaustiveness by ensuring the sealed event hierarchy has no unhandled cases in the BLoC switch.

Component
Proxy Registration Service
service medium
Epic Risks (3)
high impact low prob integration

If the Supabase batch RPC partial-inserts some records before encountering an error and does not roll back cleanly, the bulk service may report failure while orphaned records exist in the database, corrupting reporting data.

Mitigation & Contingency

Mitigation: Wrap the bulk insert in an explicit Supabase transaction via the RPC function. Write an integration test that simulates a mid-batch constraint violation and asserts zero records were written.

Contingency: If a partial-write incident occurs, the registered_by audit field allows identification and deletion of the orphaned records. Implement a coordinator-facing bulk submission status screen to surface any such anomalies.

medium impact medium prob scope

When a bulk submission of 15 participants has 4 duplicates, the aggregated conflict summary may be too complex for coordinators to process quickly, leading to blanket override decisions that defeat the purpose of duplicate detection.

Mitigation & Contingency

Mitigation: Design the conflict result type to support per-participant override flags, so the UI can present a clear list of conflicting participants with individual cancel/override toggles rather than a single global decision.

Contingency: If coordinator usability testing reveals the conflict review screen is too complex, simplify to a 'skip all conflicts and submit the rest' mode as an immediate fallback while a more granular UI is designed.

high impact low prob security

If the coordinator role check inside proxy-registration-service is inconsistent with the route-level guard, a regression in the guard could allow peer mentors to call the service directly via deep links, submitting records with incorrect attribution.

Mitigation & Contingency

Mitigation: Enforce role authorization at both the route guard level (coordinator-role-guard) and inside each service method independently. Write a security test that calls the service directly with a peer mentor session token and asserts rejection.

Contingency: If a bypass is discovered, immediately enable the server-side RLS policy as the final enforcement layer and audit any records written during the exposure window using the registered_by field.