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: StringBLAKE3 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: StringReconciler kind that produced this reconcile.
workspace: StringWorkspace identifier (CR name + namespace, or operator-side state-name triple).
plan: PlanThe 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: DriftReportDrift classification report.
lifecycle: LifecycleStateFSM 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
magma-rubygems 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
impl Bundle
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub fn with_observation(
self,
observation: Observation,
) -> Result<Self, BundleError>
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.
Sourcepub fn observation(&self) -> Option<&Observation>
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.
Sourcepub 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>
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.
Sourcepub fn verify(&self) -> Result<(), BundleError>
pub fn verify(&self) -> Result<(), BundleError>
Verify the bundle’s stored bundle_id matches a freshly-
computed one. Use after deserialization to catch tampering.
Sourcepub fn change_count(&self) -> usize
pub fn change_count(&self) -> usize
Convenience: how many changes the bundle’s plan carried.
Sourcepub fn fully_succeeded(&self) -> bool
pub fn fully_succeeded(&self) -> bool
True iff the bundle reflects a successful end-to-end apply.
Sourcepub fn to_json(&self) -> Result<Value, BundleError>
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).
Sourcepub fn from_json_verified(value: Value) -> Result<Self, BundleError>
pub fn from_json_verified(value: Value) -> Result<Self, BundleError>
Deserialize + verify. The “import this bundle” path.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Bundle
impl<'de> Deserialize<'de> for Bundle
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Forget for Bundle
impl Freeze for Bundlewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
NonZero<i32>: Freeze,
Utc: Freeze,
PhantomData<Change>: Freeze,
PhantomData<AppliedChange>: Freeze,
PhantomData<FailedChange>: Freeze,
PhantomData<DriftEvent>: Freeze,
PhantomData<Transition>: Freeze,
PhantomData<Event>: Freeze,
impl Move for Bundle
impl RefUnwindSafe for Bundle
impl Send for Bundle
impl Sync for Bundle
impl Unpin for Bundle
impl UnsafeUnpin for Bundlewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
NonZeroI32Inner: UnsafeUnpin,
Utc: UnsafeUnpin,
PhantomData<Change>: UnsafeUnpin,
PhantomData<AppliedChange>: UnsafeUnpin,
PhantomData<FailedChange>: UnsafeUnpin,
PhantomData<DriftEvent>: UnsafeUnpin,
PhantomData<Transition>: UnsafeUnpin,
PhantomData<Event>: UnsafeUnpin,
impl UnwindSafe for Bundlewhere
RawVecInner: UnwindSafe,
NonZero<i32>: UnwindSafe,
Utc: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request