3 Commits

Author SHA1 Message Date
kjh2064 b07900d9aa feat(wbs): AEG-VS-01-05 Event/Job/Inbox - Part 4 Stage 1-2 (Hangfire + E2E Tests)
Part 4 Stage 1: Hangfire Job Scheduling
- DownstreamConsumerJob updated: Route IdentityCreated events
- Add IdentityCreatedConsumer, IdentityAuditConsumer, MfaReminderJob to DI
- BackgroundJob.Schedule() for 24-hour MFA reminder delay
- Integration with OutboxPollerJob → Inbox pipeline

Part 4 Stage 2: E2E Integration Tests (4 tests)
- RegisterIdentity_E2E_CreatesIdentityWritesOutboxAndTriggersConsumers
  * Verify identity creation + outbox write in same transaction
  * Atomic commit ensures exactly-once semantics

- RegisterIdentity_E2E_OutboxPollerMarksInboxAndTriggersConsumers
  * Simulate OutboxPollerJob marking messages for consumers
  * Verify inbox message created with correlation tracing

- RegisterIdentity_E2E_FullFlowCreatesAuditAndMfaRecords
  * Complete end-to-end: identity → outbox → inbox → consumers
  * Verify audit log written, MFA reminder tracked
  * All records created in correct order

- RegisterIdentity_E2E_MfaReminderIsIdempotent
  * Verify UNIQUE(identity_id) constraint prevents duplicates
  * Safe for Hangfire retries

- RegisterIdentity_E2E_AuditLogIsImmutable
  * Verify trigger prevents UPDATE/DELETE on audit records
  * Exception thrown on tampering attempt

Architecture
- DownstreamConsumerJob switch statement routes to type-specific handlers
- Outbox→Inbox→Consumer pipeline: exactly-once, async, decoupled
- Hangfire BackgroundJob.Schedule() for time-delayed tasks
- Correlation ID propagated end-to-end for observability

Status: 60% COMPLETE (event + endpoint + consumers + job scheduling + E2E tests)
Build:  0 errors, 0 warnings
Tests: 19 total (5 unit + 3 outbox integration + 4 E2E + 6 SQL integration + 1 misc)

Next: Error handling (poison pill, dead letter), monitoring (metrics, logs), Part 4 Stage 3

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-17 18:56:21 +09:00
kjh2064 c289a698c5 feat(wbs): AEG-VS-01-05 Event/Job/Inbox - Part 2-3 Complete (Outbox/Inbox + Consumers)
Part 2: Transaction + Outbox Integration
- RegisterIdentityEndpoint: DbConnection → DbTransaction → Outbox write
- RegisterIdentitySql: Accept NpgsqlConnection + NpgsqlTransaction (Dapper)
- Fixed schema references: identity.identity → public.identity
- Hash computation (SHA256) for Outbox payload integrity

Part 3: Consumer + Job Implementation
- IdentityCreatedConsumer: SignalR group 'identity-notifications'
- MfaReminderJob: Hangfire job, 24-hour reminder, idempotent via DB tracking
- IdentityAuditConsumer: Immutable append-only audit trail
- Migration 0043: identity_mfa_reminder + identity_audit_log tables

Testing
- Unit: IdentityCreated event serialization + immutability (4 tests)
- Integration: RegisterIdentityWithOutbox (3 tests: happy path, rollback, duplicate email)
- Updated existing tests: Transaction management (6 test methods)

Architecture
- Outbox/Inbox pattern ensures exactly-once delivery
- Consumers decouple from identity creation (async, independent retry)
- Audit trail immutable (trigger prevents updates/deletes)
- MFA reminder idempotent (tracked in DB)

Status: 40% COMPLETE (event + endpoint + 3 consumers)
Next: E2E tests + Hangfire job registration + Admin UI

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-17 18:41:10 +09:00
kjh2064 dc8f3466c9 WIP: AEG-VS-01-04 Part 2 - DI setup + Endpoint refactoring (token budget constraint)
- Added IdentityAccessModule.cs with DI registration
- Added KArtSell.Modules.IdentityAccess.csproj with FastEndpoints deps
- Added project files for UnitTests & IntegrationTests
- Updated Program.cs to register IdentityAccessModule
- Updated Host.csproj to reference IdentityAccess module
- Fixed Directory.Packages.props with Moq + MS.Extensions.DependencyInjection

ISSUES (to fix next session):
- FastEndpoints Send/SendAsync/SendOkAsync method resolution incomplete
- Response record initialization requires field values
- Need to refactor endpoints to match ModelOperations pattern exactly

WORKING:
- Domain layer (IdentityState, RoleAssignmentState) 
- SQL repositories (Dapper) 
- Unit tests (RegisterIdentity, RequestMfaSetup handlers) 
- Integration test structure ready 

Next: Simplify endpoints using 'Endpoint<Req,Resp>' pattern from GetApprovalQueue sample

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-17 17:50:25 +09:00