pub enum BenchmarkPrecondition {
PlanHoldsAnIssue,
}Expand description
What a repository must hold before a conditional benchmark requirement applies to it. Typed, like a waiver’s reason, so that the condition is a reviewable statement on the descriptor and never a provider quietly returning nothing.
use majordomus_cli::capability::BenchmarkPrecondition;
let p: BenchmarkPrecondition = serde_json::from_str(r#""plan_holds_an_issue""#).unwrap();
assert_eq!(p, BenchmarkPrecondition::PlanHoldsAnIssue);Variants§
PlanHoldsAnIssue
The plan holds at least one issue. A command whose every honest case is a refusal chosen from an issue’s own status has no such refusal in a plan with no issue: the only answer there is a lookup miss, which times an error path and is not the operation.
Implementations§
Source§impl BenchmarkPrecondition
impl BenchmarkPrecondition
Sourcepub fn holds(self, index: &Index) -> bool
pub fn holds(self, index: &Index) -> bool
Does the repository this index describes hold what the precondition names?
It is answered from the index, so the same capability can be a requirement in one repository and inapplicable in another without any provider returning nothing.
use majordomus_cli::capability::BenchmarkPrecondition;
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let p = BenchmarkPrecondition::PlanHoldsAnIssue;
// a repository whose plan holds nothing: the requirement does not apply here
assert!(!p.holds(&repo.index().unwrap()));
// declare where issues live, as `majordomus init` does, and put one issue in the plan
let sources = repo.root().join(".ai/repo/knowledge/sources.yaml");
let mut text = std::fs::read_to_string(&sources).unwrap();
text.push_str(" - id: issue\n kind: issue\n discovery: vcs\n pathspec: ':(glob).ai/repo/project/issues/*.yaml'\n required: false\n");
std::fs::write(&sources, text).unwrap();
let issues = repo.root().join(".ai/repo/project/issues");
std::fs::create_dir_all(&issues).unwrap();
std::fs::write(
issues.join("I0001.yaml"),
"id: I0001\nmilestone: M000\ntitle: A first issue\nslug: a-first-issue\n\
priority: p1\nprofile: implementation\nobjective: \"Do the first thing.\"\n\
scope:\n - lib\nacceptance_criteria:\n - It is done\nvalidation:\n - \"true\"\n\
evidence_required:\n - proof\n",
)
.unwrap();
// the same precondition now holds, answered from the index alone
assert!(p.holds(&repo.index().unwrap()));Trait Implementations§
Source§impl Clone for BenchmarkPrecondition
impl Clone for BenchmarkPrecondition
Source§fn clone(&self) -> BenchmarkPrecondition
fn clone(&self) -> BenchmarkPrecondition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for BenchmarkPrecondition
Source§impl Debug for BenchmarkPrecondition
impl Debug for BenchmarkPrecondition
Source§impl<'de> Deserialize<'de> for BenchmarkPrecondition
impl<'de> Deserialize<'de> for BenchmarkPrecondition
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for BenchmarkPrecondition
Source§impl JsonSchema for BenchmarkPrecondition
impl JsonSchema for BenchmarkPrecondition
Source§fn schema_id() -> Cow<'static, str>
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
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
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 moreSource§impl Ord for BenchmarkPrecondition
impl Ord for BenchmarkPrecondition
Source§fn cmp(&self, other: &BenchmarkPrecondition) -> Ordering
fn cmp(&self, other: &BenchmarkPrecondition) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for BenchmarkPrecondition
impl PartialEq for BenchmarkPrecondition
Source§fn eq(&self, other: &BenchmarkPrecondition) -> bool
fn eq(&self, other: &BenchmarkPrecondition) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for BenchmarkPrecondition
impl PartialOrd for BenchmarkPrecondition
Source§impl Serialize for BenchmarkPrecondition
impl Serialize for BenchmarkPrecondition
impl StructuralPartialEq for BenchmarkPrecondition
Auto Trait Implementations§
impl Freeze for BenchmarkPrecondition
impl RefUnwindSafe for BenchmarkPrecondition
impl Send for BenchmarkPrecondition
impl Sync for BenchmarkPrecondition
impl Unpin for BenchmarkPrecondition
impl UnsafeUnpin for BenchmarkPrecondition
impl UnwindSafe for BenchmarkPrecondition
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
Mutably borrows from an owned value. Read more
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.