Skip to main content

VersionPlan

Struct VersionPlan 

Source
pub struct VersionPlan {
Show 17 fields pub policy: Policy, pub baseline: Baseline, pub declared_version: String, pub tool_version: String, pub writers_agree: bool, pub atoms: usize, pub fingerprint: String, pub implied: Impact, pub required: Impact, pub declared: Impact, pub required_version: String, pub status: Status, pub breaking: bool, pub changes: Vec<SurfaceChange>, pub commits: CommitEvidence, pub understated: bool, pub diagnostics: Vec<Diagnostic>,
}
Expand description

The whole answer: what moved, what that requires, and what the tree declares.

One value, and every surface renders it — the command line, /api/v1/release/analysis, the MCP tool, the Cockpit panel, the generated document and the CI gate. There is no second computation anywhere, which is the property that makes the number mean something.

use majordomus_cli::release::compat::{Status, VersionPlan};
let plan = VersionPlan {
    policy: Policy::for_version(Version::parse("0.5.0").unwrap()),
    baseline: Baseline {
        version: "0.5.0".into(), reference: "v0.5.0".into(), read_at: "3a032c1e".into(),
        commit: "3a032c1e".into(), recorded: true, atoms: 300, fingerprint: "sha256:a".into(),
    },
    declared_version: "0.5.0".into(),
    tool_version: "0.5.0".into(),
    writers_agree: true,
    atoms: 333,
    fingerprint: "sha256:b".into(),
    implied: Impact::Minor,
    required: Impact::Minor,
    declared: Impact::None,
    required_version: "0.6.0".into(),
    status: Status::Blocked,
    breaking: false,
    changes: Vec::new(),
    commits: CommitEvidence { commits: 24, implied: Impact::Patch, breaking: Vec::new() },
    understated: true,
    diagnostics: Vec::new(),
};
// The contract requires a minor and the version declares none: this tree may not land.
assert_eq!(plan.status, Status::Blocked);
assert!(plan.declared < plan.required);
assert!(plan.understated, "the commit subjects claim less than the contract did");

Fields§

§policy: Policy

The policy the verdict was reached under.

§baseline: Baseline

The release this was measured against.

§declared_version: String

The version the crate manifest declares — the one place it is authored.

§tool_version: String

The version bin/majordomus prints: what its projection, share/version.txt, states.

§writers_agree: bool

Whether that projection is current — states what the manifest declares. The name is kept from when the version had two writers; the manifest is the only one now.

§atoms: usize

How many public atoms this tree carries.

§fingerprint: String

The fingerprint of this tree’s surface.

§implied: Impact

What the surface movement amounts to on its own.

§required: Impact

What the policy requires of it.

§declared: Impact

What the two version numbers already represent.

§required_version: String

The smallest version this tree may declare.

§status: Status

Whether it does.

§breaking: bool

Whether anything a caller could hold is gone.

§changes: Vec<SurfaceChange>

Every movement of the contract, worst first.

§commits: CommitEvidence

What the commits said about themselves.

§understated: bool

Whether the commit subjects understate what the contract actually did.

§diagnostics: Vec<Diagnostic>

Anything incoherent about the release state, whatever the verdict.

Implementations§

Source§

impl VersionPlan

Source

pub fn measured_version(&self) -> Result<String, String>

The version the contract requires, when the analysis could measure one.

The analysis still returns a plan when a fact it rests on is untrustworthy — a version that is not three numbers (baseline-version-malformed, declared-version-malformed, then a guess), a baseline whose record and tag name different commits (tag-commit-mismatch), a version stated by hand (writers-disagree, version-stated-by-hand) — so a caller that takes required_version as the contract’s answer must ask this instead. It is sound exactly when release bump would write from it: any Severity::Error diagnostic (VersionPlan::has_errors) refuses, with every error’s message, one per line, as bump prints them.

assert_eq!(plan("0.6.0", Vec::new()).measured_version(), Ok("0.6.0".into()));
// no version line in the manifest: the analysis echoes "", which is no answer
assert!(plan("", Vec::new()).measured_version().is_err());
let guessed = Diagnostic { id: "baseline-version-malformed".into(),
    severity: Severity::Error, message: "the baseline is not three numbers".into() };
assert_eq!(plan("0.6.0", vec![guessed]).measured_version(),
    Err("the baseline is not three numbers".into()));
// any error refuses, not only a malformed version: the plan bump would not write from
let moved = Diagnostic { id: "tag-commit-mismatch".into(),
    severity: Severity::Error, message: "the tag moved".into() };
let stale = Diagnostic { id: "projection-stale".into(),
    severity: Severity::Warning, message: "run scripts/derive".into() };
assert_eq!(plan("0.6.0", vec![stale.clone()]).measured_version(), Ok("0.6.0".into()));
let unsound = plan("0.6.0", vec![moved.clone(), stale, moved]);
assert!(unsound.has_errors());
assert_eq!(unsound.measured_version(), Err("the tag moved\nthe tag moved".into()));
Source

pub fn counts(&self) -> (usize, usize, usize)

How many changes moved the contract in each direction.

let p = plan(vec![change(Direction::Added), change(Direction::Added), change(Direction::Removed)]);
assert_eq!(p.counts(), (2, 0, 1), "added, changed, removed");
Source

pub fn breaking_changes(&self) -> impl Iterator<Item = &SurfaceChange>

Everything that is breaking on its own.

assert_eq!(plan.breaking_changes().count(), 1, "only what is breaking on its own");
Source

pub fn has_errors(&self) -> bool

Whether anything makes the plan itself untrustworthy.

assert!(!plan.has_errors());
// A warning leaves the plan standing; only an error makes it untrustworthy.
plan.diagnostics.push(Diagnostic { id: "tag-without-record".into(),
    severity: Severity::Warning, message: "…".into() });
assert!(!plan.has_errors());
plan.diagnostics.push(Diagnostic { id: "writers-disagree".into(),
    severity: Severity::Error, message: "…".into() });
assert!(plan.has_errors());

Trait Implementations§

Source§

impl Clone for VersionPlan

Source§

fn clone(&self) -> VersionPlan

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 VersionPlan

Source§

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

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

impl<'de> Deserialize<'de> for VersionPlan

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 VersionPlan

Source§

impl JsonSchema for VersionPlan

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for VersionPlan

Source§

fn eq(&self, other: &VersionPlan) -> 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 VersionPlan

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 VersionPlan

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
§

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

§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

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

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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