Skip to main content

LifecycleEvent

Struct LifecycleEvent 

Source
pub struct LifecycleEvent {
    pub event_id: String,
    pub ctx_id: CtxId,
    pub event_type: LifecycleEventType,
    pub occurred_at: DateTime<Utc>,
    pub actor: AgentDid,
    pub reason: Option<String>,
    pub signature: Option<Signature>,
}
Expand description

A lifecycle event (RFC-ACDP-0013 §4) — one entry of registry_state.lifecycle_events.

CLOSED schema (acdp-lifecycle-event.schema.json, additionalProperties: false): exactly the seven specified members; an unknown member changes the signed preimage and is rejected at parse time. Lifecycle events are registry state, outside the body: never an input to the producer’s content_hash (RFC-ACDP-0001 §5.7) and never stored inside a body (§4.1).

Event ordering is array position in lifecycle_events (the registry-accepted order); occurred_at never participates in the retraction-state derivation (§4.1, §7.1).

Fields§

§event_id: String

UUID (RFC 9562 canonical lowercase form) minted by the actor. MUST be unique within the context’s lifecycle_events array.

§ctx_id: CtxId

The affected context. MUST equal the ctx_id of the context whose registry state carries the event — binding a signed event to exactly one context so it cannot be replayed against another.

§event_type: LifecycleEventType

The event kind (open vocabulary, §7.3).

§occurred_at: DateTime<Utc>

When the actor performed the action: canonical millisecond-precision RFC 3339 UTC (RFC-ACDP-0001 §5.3). The strict serde on this field rejects any non-canonical byte form (which the schema pattern forbids) so a parsed event always re-serializes byte-identically — a signed member must never be silently normalized.

§actor: AgentDid

The DID of the party performing the action: body.agent_id for producer-initiated events; the registry’s DID (capabilities.registry_did) for registry-initiated events.

§reason: Option<String>

Optional human-readable explanation (≤ 1024 chars). Informational only; MUST NOT drive automated decisions (§4).

§signature: Option<Signature>

Signature over the event hash (RFC-ACDP-0013 §5). REQUIRED on producer-initiated events; SHOULD be present on registry-initiated events.

Implementations§

Source§

impl LifecycleEvent

Source

pub fn new( event_id: impl Into<String>, ctx_id: CtxId, event_type: LifecycleEventType, occurred_at: DateTime<Utc>, actor: AgentDid, reason: Option<String>, ) -> Result<Self, AcdpError>

Construct a validated, unsigned event (occurred_at is millisecond-truncated per RFC-ACDP-0001 §5.3). Producer-initiated events MUST subsequently be signed via Self::sign_with; registry-initiated events SHOULD be.

Source

pub fn sign_with( self, key: impl Into<AcdpSigningKey>, key_id: impl Into<String>, ) -> Result<Self, AcdpError>

Sign this event per RFC-ACDP-0013 §5 (the RFC-ACDP-0010 §5 construction): JCS of the event minus signature, SHA-256, and a signature over the ASCII bytes of the full "sha256:<hex>" string. key_id’s DID portion MUST equal actor — the signing key need not be the key that signed the original body (§5: producers rotate keys), but it must belong to the actor’s DID.

Source

pub fn from_value(value: &Value) -> Result<Self, AcdpError>

Parse an event from raw wire JSON, enforcing the closed schema plus the §4 semantic invariants (Self::validate). The canonical occurred_at byte form is enforced by the field’s strict serde. An event failing this parse is malformed registry state — structurally non-conformant per §7.3.

Source

pub fn validate(&self) -> Result<(), AcdpError>

The §4 semantic invariants not already enforced by serde: canonical-UUID event_id, well-formed ctx_id and actor, reason length.

Source

pub fn preimage_hash_of_value(value: &Value) -> Result<ContentHash, AcdpError>

Compute the event’s preimage hash from the RAW wire JSON (the value minus signature, JCS-canonicalized as received).

Verifiers MUST hash the event exactly as received rather than re-serializing a parsed struct — the same raw-JSON rule as crate::receipt::RegistryReceipt::preimage_hash_of_value.

Source

pub fn preimage_hash(&self) -> Result<ContentHash, AcdpError>

Compute the event’s preimage hash from the struct. Used at signing time; verifiers should prefer Self::preimage_hash_of_value over the raw wire JSON. (For events parsed through this type’s strict serde the two agree — every field round-trips byte-identically.)

Source

pub fn actor_bound_signature(&self) -> Result<&Signature, AcdpError>

RFC-ACDP-0013 §5 actor binding: the DID portion of signature.key_id MUST equal actor. Returns the signature for further verification; a missing signature is an error (call sites that tolerate unsigned registry events check Self::is_signed first).

Source

pub fn is_signed(&self) -> bool

True when the event carries a signature.

Source

pub fn verify_signature_with_key( &self, actor_pub_ed25519: Option<&[u8; 32]>, actor_pub_p256_sec1: Option<&[u8]>, ) -> Result<(), AcdpError>

Verify the event signature against a known actor public key (pure — no DID resolution). Checks the §5 actor binding, then verifies over the ASCII bytes of the recomputed event hash. Resolver-backed verification lives in acdp_verify::verify_lifecycle_event.

Source

pub fn verify_signature_against_hash( &self, hash: &ContentHash, actor_pub_ed25519: Option<&[u8; 32]>, actor_pub_p256_sec1: Option<&[u8]>, ) -> Result<(), AcdpError>

Like Self::verify_signature_with_key but over an already-computed preimage hash — pair with Self::preimage_hash_of_value for raw-JSON verification.

Trait Implementations§

Source§

impl Clone for LifecycleEvent

Source§

fn clone(&self) -> LifecycleEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LifecycleEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for LifecycleEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for LifecycleEvent

Source§

fn eq(&self, other: &LifecycleEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for LifecycleEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for LifecycleEvent

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.