pub struct IntentRecord {
pub id: String,
pub source: String,
pub title: String,
pub statement: String,
pub invariants: Vec<String>,
pub satisfaction: Vec<CriterionRecord>,
pub milestones: Vec<String>,
pub governance: Vec<String>,
pub non_goals: Vec<String>,
pub cancelled: bool,
pub superseded_by: String,
}Expand description
One intent as its file declares it: the statement that must become true, the invariants that must stay true, the milestones that realise it and the criteria that settle it. Nothing derived is stored here.
use majordomus_cli::intent::IntentRecord;
let r = IntentRecord::from_metadata(".ai/repo/project/intents/x.yaml", &serde_json::json!({
"id": "x", "title": "X", "statement": "It becomes true.", "milestones": ["m"],
"satisfaction": [{"id": "c", "criterion": "c", "evidence": "test", "ref": "t"}],
}));
assert_eq!(r.id, "x");
assert!(!r.cancelled);Fields§
§id: StringThe identity.
source: StringRepository-relative path of the file.
title: StringOne line.
statement: StringWhat must become true.
invariants: Vec<String>What must stay true.
satisfaction: Vec<CriterionRecord>The criteria.
milestones: Vec<String>Milestone ids.
governance: Vec<String>Governance references.
non_goals: Vec<String>What is deliberately not required.
cancelled: boolAbandoned.
superseded_by: StringThe replacement, when there is one.
Implementations§
Source§impl IntentRecord
impl IntentRecord
Sourcepub fn from_metadata(source: &str, meta: &Value) -> IntentRecord
pub fn from_metadata(source: &str, meta: &Value) -> IntentRecord
The record an object of kind intent carries. The schema has already refused a
malformed file by the time the index holds it, so this reads values, never guesses.
use majordomus_cli::intent::IntentRecord;
use serde_json::json;
let r = IntentRecord::from_metadata(
".ai/repo/project/intents/x.yaml",
&json!({"id": "x", "title": "X", "milestones": ["m"],
"satisfaction": [{"id": "c", "criterion": "c", "evidence": "test",
"ref": "test/cases/1_x.sh"}]}),
);
assert_eq!(r.milestones, ["m"]);
assert_eq!(r.satisfaction[0].reference, "test/cases/1_x.sh");Sourcepub fn all(index: &Index) -> Vec<IntentRecord>
pub fn all(index: &Index) -> Vec<IntentRecord>
Every intent record an index holds, in identity order, so nothing downstream depends on the order the files were read.
use majordomus_cli::index::Index;
use majordomus_cli::intent::IntentRecord;
let records = IntentRecord::all(index);
assert!(records.windows(2).all(|w| w[0].id <= w[1].id));Trait Implementations§
Source§impl Clone for IntentRecord
impl Clone for IntentRecord
Source§fn clone(&self) -> IntentRecord
fn clone(&self) -> IntentRecord
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 moreSource§impl Debug for IntentRecord
impl Debug for IntentRecord
Source§impl Default for IntentRecord
impl Default for IntentRecord
Source§fn default() -> IntentRecord
fn default() -> IntentRecord
Returns the “default value” for a type. Read more
impl Eq for IntentRecord
Source§impl PartialEq for IntentRecord
impl PartialEq for IntentRecord
Source§fn eq(&self, other: &IntentRecord) -> bool
fn eq(&self, other: &IntentRecord) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for IntentRecord
Auto Trait Implementations§
impl Freeze for IntentRecord
impl RefUnwindSafe for IntentRecord
impl Send for IntentRecord
impl Sync for IntentRecord
impl Unpin for IntentRecord
impl UnsafeUnpin for IntentRecord
impl UnwindSafe for IntentRecord
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> 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.