Skip to main content

RotationStateMachine

Struct RotationStateMachine 

Source
pub struct RotationStateMachine<S: PlatformSigner> { /* private fields */ }
Expand description

Drives the rotation procedure end-to-end.

One state machine corresponds to one platform deployment. Hold this behind an Arc<Mutex<_>> if multiple operators can drive it concurrently — the type itself is !Sync so the compiler enforces serialized access through the mutex.

Implementations§

Source§

impl<S: PlatformSigner> RotationStateMachine<S>

Source

pub fn new(current: S) -> Self

Build a fresh state machine seeded with the active key. Phase is RotationPhase::Active.

Source

pub async fn phase(&self) -> RotationPhase

Current phase.

Source

pub async fn last_event(&self) -> Option<RotationEvent>

Most recent rotation event published, if any.

Source

pub async fn begin_handover<N: PlatformSigner>( &self, next: &N, transition_window: Duration, ) -> Result<RotationEvent, RotationError>

Step 1 of the runbook (after the operator has generated the new KMS key out-of-band). Fetches both public keys, asks the current signer to sign the handover, returns the wire event.

Transitions the state machine from RotationPhase::Active to RotationPhase::Transitioning. Refuses to re-fire if a rotation is already in progress — emergency revocation is a distinct call path (see Self::emergency_revoke_current).

transition_window: how long both keys remain trusted. Default per RFC is 30 days (see DEFAULT_TRANSITION_DAYS).

Source

pub async fn retire_old(&self) -> Result<(), RotationError>

Step 2 of the runbook — operator calls this after the transition window has elapsed and the runbook’s manual aws kms disable-key step is complete. Brings the state machine back to RotationPhase::Active.

Note: the state machine does not switch its current signer (this type is generic and immutable). The expectation is that the registry process restarts with the new MOCKFORGE_PLATFORM_SIGNING_KMS_KEY_ID pointing at the new ARN. This method exists for in-memory state hygiene + audit completeness, and is the call site where the PlatformSigningKeyRetired audit event fires.

Source

pub async fn emergency_revoke_current(&self) -> Result<(), RotationError>

Emergency: revoke the current key without a successor. Used when the active key is believed compromised and no new key has been provisioned yet. After this returns, the registry refuses to publish anything signed by the old key.

This does NOT publish a rotation event — there’s no new key to hand over to. The runbook’s “Emergency revocation” section covers the operator-facing process (notify all hosted-mock owners, then run Self::begin_handover with a fresh key once it’s available).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more