feat: add protection lease concept for time-limited clone protection

Summary

Implement a protection lease concept for database clones, replacing infinite deletion protection with time-limited protection.

Requirements

  • Variable protection duration: Users can select from preset durations (1h, 12h, 1-7d, 14d, 30d, or "forever" if allowed)
  • Admin-configurable maximum: Admins can set protectionMaxDurationMinutes to cap the maximum duration users can select
  • UI dropdown filtering: Options are automatically filtered based on admin's max duration setting
  • CLI support: Add --protection-duration flag to clone create and clone update commands
  • API support: Add protectionDurationMinutes parameter to create/update clone endpoints
  • Webhook events: Add clone_protection_expiring and clone_protection_expired events for enterprise notifications
  • Background monitoring: Protection leases should be checked periodically

Configuration

cloning:
  protectionLeaseDurationMinutes: 1440    # Default protection (1 day)
  protectionMaxDurationMinutes: 10080     # Max allowed (7 days); 0 = no limit
  protectionExpiryWarningMinutes: 1440    # Warning 24h before expiry

Acceptance Criteria

  • Users can select protection duration from dropdown (UI)
  • Admins can limit max protection duration via config
  • CLI supports --protection-duration flag
  • API accepts protectionDurationMinutes parameter
  • Webhook events fire when protection is expiring/expired
  • Background job monitors and expires protection leases
  • Comprehensive tests cover all paths

Definition of Done

  • Protection lease configuration options (protectionLeaseDurationMinutes, protectionMaxDurationMinutes, protectionExpiryWarningMinutes) implemented and documented
  • UI dropdown shows preset durations filtered by admin's max duration setting
  • CLI clone create and clone update commands support --protection-duration flag
  • API protectionDurationMinutes parameter accepted in create/update clone endpoints
  • Webhook events (clone_protection_expiring, clone_protection_expired) fire correctly with test coverage
  • Background job monitors and expires protection leases on schedule
  • Comprehensive tests cover: creating with various durations, admin max enforcement, expiry, webhook events, CLI usage
  • Documentation updated with protection lease configuration examples and usage guide
Edited by Nikolay Samokhvalov