Skip to main content

Bundle

Struct Bundle 

Source
pub struct Bundle {
    pub bundle_id: String,
    pub built_at: DateTime<Utc>,
    pub kind: String,
    pub workspace: String,
    pub plan: Plan,
    pub outcome: Option<Outcome>,
    pub drift: DriftReport,
    pub lifecycle: LifecycleState,
    pub audit: Vec<Event>,
    pub gem_tree_attestation: Option<String>,
    pub observation: Option<Observation>,
}
Expand description

Compliance-ready bundle. Carries every typed artifact a single reconcile produces, plus a BLAKE3 bundle_id over the canonical projection. Round-trips through serde + verifies via Bundle::verify.

Fields§

§bundle_id: String

BLAKE3 hash over the canonical projection (every field except bundle_id itself + built_at).

§built_at: DateTime<Utc>

When the bundle was built (NOT in the hash so two bundles over the same reconcile data hash equally).

§kind: String

Reconciler kind that produced this reconcile.

§workspace: String

Workspace identifier (CR name + namespace, or operator-side state-name triple).

§plan: Plan

The typed Plan.

§outcome: Option<Outcome>

The Outcome of applying the Plan (may be a no-op outcome if the plan never applied — e.g. HeldForApproval).

§drift: DriftReport

Drift classification report.

§lifecycle: LifecycleState

FSM lifecycle snapshot at bundle-build time.

§audit: Vec<Event>

Audit events (typically the magma-stream chain for this reconcile). May be empty if no stream was wired.

§gem_tree_attestation: Option<String>

BLAKE3 attestation of the materialized magma-rubygems gem tree this reconcile ran against. None means the reconcile ran outside a magma-rubygems-materialized closure (e.g. legacy bundle install workspace). Once per theory/MAGMA-RUBYGEMS.md M5 lands, every Pangea-side reconcile populates this — operators can verify the gem closure end-to-end alongside plan + drift + lifecycle.

§observation: Option<Observation>

How much of this reconcile’s before side was real, observed fact — the plan-time refresh’s own trustworthiness.

Why a receipt needs this. A refresh in which every ReadResource failed leaves state untouched, so the plan is all-NoOp and the bundle looks exactly like a reconcile in which reality genuinely matched. A compliance artifact that cannot tell “we checked and it was fine” from “we could not check” is not evidence of anything.

Covered by bundle_id — unlike the plan’s own copy, which is deliberately outside PlanId (see magma_types::Plan::observation). A PlanId addresses a change set and must stay stable under transient RPC weather; a bundle id attests to what actually happened, so the record that a pass was blind must not be strippable without breaking verification.

None means “not recorded”, never “clean” — an honest absence rather than a default that flatters. Populated by whoever assembled the reconcile (the pangea-operator reconcile loop is the intended writer; nothing inside magma builds a bundle from a refreshed plan today).

Implementations§

Source§

impl Bundle

Source

pub fn new( kind: impl Into<String>, workspace: impl Into<String>, plan: Plan, outcome: Option<Outcome>, drift: DriftReport, lifecycle: LifecycleState, audit: Vec<Event>, ) -> Result<Self, BundleError>

Construct a Bundle. Computes bundle_id from the canonical projection of every field except bundle_id + built_at.

Source

pub fn new_with_gem_tree( kind: impl Into<String>, workspace: impl Into<String>, plan: Plan, outcome: Option<Outcome>, drift: DriftReport, lifecycle: LifecycleState, audit: Vec<Event>, gem_tree_attestation: Option<String>, ) -> Result<Self, BundleError>

Like new, but also records a magma-rubygems gem tree attestation alongside the reconcile artifacts. Once magma-rubygems M5 lands, every Pangea-side reconcile constructs the bundle via this path; legacy bundle-install workspaces still go through new and set the field to None.

Source

pub fn with_observation( self, observation: Observation, ) -> Result<Self, BundleError>

Record how much of this reconcile’s before side was real, observed fact, re-deriving bundle_id to cover it.

Re-deriving is the point, not a side effect: a receipt from which the “this pass was blind” record can be stripped without breaking verification is not a receipt. Attaching an observation therefore mints a new id, and a tampered-with one fails Bundle::verify exactly like any other field.

Source

pub fn observation(&self) -> Option<&Observation>

The honest answer to “how much of this bundle is real?”.

None means the assembler never recorded one — an absence, never a clean bill of health. Callers deciding whether a bundle is evidence of convergence must treat None and Some(_)-with-blind-coverage the same way.

Source

pub fn derive_id( kind: &str, workspace: &str, plan: &Plan, outcome: &Option<Outcome>, drift: &DriftReport, lifecycle: &LifecycleState, audit: &[Event], gem_tree_attestation: Option<&str>, observation: Option<&Observation>, ) -> Result<String, BundleError>

Re-derive bundle_id from the canonical projection. The optional gem_tree_attestation is included in the projection so identical reconciles against different gem closures hash to different bundle_ids (catches gem-closure drift).

observation is included the same way, and for the sharper reason: two reconciles with an identical plan, outcome, drift and lifecycle are NOT the same event when one of them read reality and the other could not. It is added to the projection only when present, so every bundle stored before this field existed still verifies byte-for-byte — an upgrade must not manufacture tamper alarms.

Source

pub fn verify(&self) -> Result<(), BundleError>

Verify the bundle’s stored bundle_id matches a freshly- computed one. Use after deserialization to catch tampering.

Source

pub fn plan_id(&self) -> &PlanId

The plan_id the bundle is keyed at (convenience accessor).

Source

pub fn change_count(&self) -> usize

Convenience: how many changes the bundle’s plan carried.

Source

pub fn fully_succeeded(&self) -> bool

True iff the bundle reflects a successful end-to-end apply.

Source

pub fn to_json(&self) -> Result<Value, BundleError>

Serialize to a single JSON value. Suitable for storage in any blob store (S3, Postgres jsonb, K8s ConfigMap).

Source

pub fn from_json_verified(value: Value) -> Result<Self, BundleError>

Deserialize + verify. The “import this bundle” path.

Trait Implementations§

Source§

impl Clone for Bundle

Source§

fn clone(&self) -> Self

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 Bundle

Source§

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

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

impl<'de> Deserialize<'de> for Bundle

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 Serialize for Bundle

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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