✨ feat(user): magic-link expired-token cleanup loop (ADR-0028 Phase A consequence)
Periodically delete magic-link tokens past their expires_at — the rows accumulate without cleanup since the consume endpoint only marks them consumed but never removes them, and DeleteExpiredMagicLinkTokens (added in Phase A.3, PR #61) was never wired up. Mirrors the JWT secret cleanup pattern (ADR-0021). - pkg/user/magic_link_cleanup.go: MagicLinkCleanupRunner with StartCleanupLoop(ctx, interval) and an inner runOnce(ctx) for testability - pkg/user/magic_link_cleanup_test.go: unit tests cover happy path, error propagation, ctx-cancel termination, zero-interval no-op - pkg/server/server.go: start the loop right after the JWT cleanup loop - pkg/config/config.go: auth.magic_link.cleanup_interval (default 1h), env DLC_AUTH_MAGIC_LINK_CLEANUP_INTERVAL, getter GetMagicLinkCleanupInterval Mostly authored by Mistral Vibe in batch1-task-b worktree (parallel with batch1-task-a OIDC config). Mistral hit --max-price 1.50 right before the final commit step, Claude finished the ship via trainer takeover (Q-045 pattern, 2nd recurrence in two batches — to be addressed in Phase 1bis).
This commit is contained in:
@@ -764,6 +764,12 @@ func (s *Server) Run() error {
|
||||
s.userService.StartJWTSecretCleanupLoop(rootCtx, s.config.GetJWTSecretCleanupInterval())
|
||||
}
|
||||
|
||||
// Start the magic-link expired-token cleanup loop (ADR-0028 Phase A consequence).
|
||||
if mlRepo, ok := s.userRepo.(user.MagicLinkRepository); ok {
|
||||
runner := user.NewMagicLinkCleanupRunner(mlRepo)
|
||||
runner.StartCleanupLoop(rootCtx, s.config.GetMagicLinkCleanupInterval())
|
||||
}
|
||||
|
||||
// Wire the sampler hot-reload callback (ADR-0023 Phase 3, sub-phase 3.3).
|
||||
// telemetrySetup is non-nil only when telemetry was successfully initialized
|
||||
// at startup — hot-reloading telemetry-on is out of scope (see ADR-0023).
|
||||
|
||||
Reference in New Issue
Block a user