#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Id(pub String);
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct FindingId(pub String);
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct DocPath(pub String);
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Date(pub String);
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Rev(pub String);
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Kind {
Decision,
Axiom,
Invariant,
Architecture,
Current,
Roadmap,
Milestone,
Evidence,
ReviewLog,
Evolution,
Handoff,
Explainer,
Index,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Lifecycle {
Draft,
Current,
Superseded,
Historical,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Authority {
Normative,
Axiomatic,
Descriptive,
Prospective,
Evidence,
Historical,
Operational,
Explanatory,
Navigational,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Status {
Open,
Proposed,
Accepted,
Superseded,
Deprecated,
Rejected,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Impl {
Absent,
Scaffold,
Partial,
Implemented,
Verified,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Door {
Reversible,
OneWay,
}
#[derive(Clone, Debug)]
pub enum Facet {
Decision(DecisionFacet),
Axiom,
Canon {
implementation: Option<Impl>,
code_revision: Option<Rev>,
},
Current {
implementation: Impl,
code_revision: Rev,
source_revision: Option<Rev>,
},
Plan {
implementation: Impl,
code_revision: Rev,
},
Evidence {
measured: Option<(Impl, Rev)>,
source_revision: Option<Rev>,
},
Narrative,
}
#[derive(Clone, Debug)]
pub struct DecisionFacet {
pub status: Status,
pub date: Date,
pub implementation: Option<Impl>,
pub fork: Option<Fork>,
pub realized_by: Vec<Id>,
}
#[derive(Clone, Debug)]
pub struct Fork {
pub lean: String,
pub decide_when: String,
pub door: Door,
}
impl Facet {
pub fn code_revision(&self) -> Option<&Rev> {
match self {
Facet::Current { code_revision, .. } | Facet::Plan { code_revision, .. } => {
Some(code_revision)
}
Facet::Canon { code_revision, .. } => code_revision.as_ref(),
Facet::Evidence { measured, .. } => measured.as_ref().map(|(_, rev)| rev),
_ => None,
}
}
}
#[derive(Clone, Debug, Default)]
pub struct Edges {
pub depends_on: Vec<Id>,
pub supersedes: Vec<Id>,
pub related: Vec<Id>,
pub supports: Vec<Id>,
pub driven_by: Vec<FindingId>,
}
#[derive(Clone, Debug, Default)]
pub struct Body {
pub bare_mentions: Vec<Id>,
pub findings: Vec<Finding>,
pub section_refs: Vec<String>,
pub links: Vec<String>,
pub link_refs: Vec<Id>,
}
#[derive(Clone, Debug)]
pub struct Finding {
pub id: FindingId,
pub status: String,
}
#[derive(Clone, Debug)]
pub struct Record {
pub id: Option<Id>,
pub path: DocPath,
pub kind: Kind,
pub lifecycle: Lifecycle,
pub authority: Authority,
pub last_reviewed: Date,
pub aka: Vec<Id>,
pub edges: Edges,
pub facet: Facet,
pub body: Body,
}
impl Record {
pub fn minimal(
id: Option<Id>,
path: DocPath,
kind: Kind,
lifecycle: Lifecycle,
authority: Authority,
facet: Facet,
) -> Self {
Record {
id,
path,
kind,
lifecycle,
authority,
last_reviewed: Date(String::new()),
aka: Vec::new(),
edges: Edges::default(),
facet,
body: Body::default(),
}
}
}