Skip to main content

PinnedRef

Struct PinnedRef 

Source
pub struct PinnedRef {
    pub name: String,
    pub component_type: ComponentType,
    pub version: Version,
    pub digest: ManifestDigest,
    pub resolved_from: Option<VersionReq>,
}
Expand description

An exact, digest-verified component pin. version and digest are both mandatory (non-Option) — a pin always carries both.

Fields§

§name: String§component_type: ComponentType§version: Version§digest: ManifestDigest§resolved_from: Option<VersionReq>

The semver range this pin was RESOLVED FROM, when it was resolved from one. Same type as ComponentRef::Range’s range field, because a resolution records the same kind of thing the range declared.

§Why a pin keeps the range it resolved (D-10)

Cargo’s model, adopted deliberately because that logic is proven and will pass the same security reviews. Cargo keeps TWO artifacts: Cargo.toml holds the range (author intent — what enables reuse and upgrade), Cargo.lock holds the resolution (the exact version plus its checksum). Pinning never destroys the range.

Before this field, ComponentRef was strictly either/or, so pinning DISCARDED the declared range — losing the one fact the dev-to-prod case turns on. A target environment could not distinguish “dev declared ^1.2 and resolved 1.3.0” from “dev declared =1.2.0”. In the first case prod’s already-deployed 1.2.0 still satisfies ^1.2, so it is silently kept — the wrong reference, with nothing in the package able to say so.

§What None means — decided, not left implicit (D-10)

None means “no declared range is recorded on this pin”. It is NOT distinguishable from “this package was packed before this field existed”: the additive serde attributes below make an old pin deserialize to exactly the value a direct pin produces. The crate ACCEPTS that ambiguity rather than carrying a schema-version discriminator — pmcp-package is 0.x, and the standing position for the package tree is to break freely rather than ship compatibility shims.

Two obligations follow, and both are load-bearing:

  • Consumer side. Anything building skew reporting on this field — Phase 123’s dev-to-prod import check is the named one — MUST treat None as “cannot report” and NEVER as “no skew”. Reading an absent fact as a positive claim is precisely the failure this field exists to prevent.
  • Producer side. A producer that resolved a range MUST record it. A None written by a range-resolving producer is indistinguishable from an old package, and destroys the signal for every consumer downstream.

§Compatibility — both halves, because only stating one under-scopes the next change

  • Serde/wire: ADDITIVE. #[serde(default)] means pin JSON written before this field existed still deserializes (yielding None), and skip_serializing_if means nothing new is emitted for a None. No checked-in fixture byte and no pinned digest constant moves — measured, not assumed: all four tests/golden_fixtures/canonical/*.json files and all five pinned constants in tests/digest_stability.rs are byte-identical across this addition, and their tests pass unedited. skip_serializing_if is load-bearing here, not cosmetic: without it every pin would emit "resolved_from": null, and both workflow.canonical.json and EXPECTED_WORKFLOW_DIGEST would move.

    A Some(range) DOES change the canonical bytes and therefore the manifest digest — see recording_the_range_a_pin_resolved_changes_the_manifest_digest in tests/digest_stability.rs. The field participates in package identity; it is not cosmetic metadata that could be stripped or forged without changing what the package IS.

  • Rust source: BREAKING. PinnedRef had four public fields before this, all non-Option, all set by struct literal — a fifth field breaks every literal in the language, everywhere. The MEASURED inventory is EIGHT construction sites (grep -rn 'PinnedRef {' --include="*.rs" crates cargo-pmcp returns nine hits; the ninth is this struct’s own pub struct PinnedRef { definition, which is not a construction site):

    • crates/pmcp-package/src/reference.rs — 4 (all inside #[cfg(test)] mod tests)
    • crates/pmcp-package/src/oci/unpack.rs — 2 (both in a #[cfg(test)] fixture helper)
    • crates/pmcp-package/src/package/workflow.rs — 1 (#[cfg(test)] helper)
    • crates/pmcp-team-servers/src/team/identity.rs — 1 (#[cfg(test)] helper)

    A reader who takes “additive” at face value will under-scope the next field addition exactly as this one would have been.

Trait Implementations§

Source§

impl Clone for PinnedRef

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 PinnedRef

Source§

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

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

impl<'de> Deserialize<'de> for PinnedRef

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 Eq for PinnedRef

Source§

impl PartialEq for PinnedRef

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for PinnedRef

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 PinnedRef

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

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.