Step 1: Add state machine transitions for `maintenance` state
## Summary Add `enter_maintenance` and `exit_maintenance` events to the `Namespaces::Stateful` state machine. The `maintenance: 6` state value already exists but has no transitions defined. This is the foundation — all other steps depend on this. > **POC approach:** This will be part of a single POC MR (does not need to merge to master). Maintenance mode will be toggled via Rails console — no Rake task or admin UI needed for the POC. ## Dependencies - **None** — this is the first step - **Blocks**: Step 2 (#591689 — middleware), Step 3 (#591690 — error page), Step 4 (#591691 — GraphQL enforcement) ## Context Parent issue: https://gitlab.com/gitlab-org/gitlab/-/issues/590009 The state machine is defined in `app/models/concerns/namespaces/stateful.rb`. The existing pattern for transitions (e.g., `schedule_deletion`, `cancel_deletion`) should be followed. ## Tasks - [ ] Add `enter_maintenance` event with transitions from `ancestor_inherited` and `archived` to `maintenance` - [ ] Add `exit_maintenance` event with transition from `maintenance` back to previous state (use state preservation pattern from `cancel_deletion` / `StatePreservation` module) - [ ] Add `maintenance` to `FORBIDDEN_ANCESTOR_STATES` in `app/models/concerns/namespaces/stateful/transition_validation.rb` to prevent child namespaces from independently changing state while parent is in maintenance - [ ] Add `maintenance_reason` field to `state_metadata` jsonb (e.g., `"organization_transfer"`) for future extensibility - [ ] Add specs for all new transitions, including edge cases (e.g., transitioning from archived, ancestor validation) - [ ] Verify `effective_state` in `StateQuerying` correctly resolves `maintenance` for child namespaces via ancestor traversal ## Key Files - `app/models/concerns/namespaces/stateful.rb` - `app/models/concerns/namespaces/stateful/transition_validation.rb` - `app/models/concerns/namespaces/stateful/state_preservation.rb` - `app/models/concerns/namespaces/stateful/transition_callbacks.rb` - `app/models/namespace/detail.rb` (state_metadata) ## Effort Estimate Small (1-2 days)
task