pub struct Explanation {
pub uri: String,
pub standing: Standing,
pub detail: String,
pub entry: Option<ContextEntry>,
pub excluded: Option<Excluded>,
pub deduplicated: Option<Deduplicated>,
pub budget: Budget,
}Expand description
Why one identifier is, or is not, in a compiled context.
standing says which of the five cases this is, and the three optional fields are the
evidence for it: at most one of entry, excluded and deduplicated is populated, and
which one is determined by the standing rather than independent of it. detail is the
same answer in words, so the value is legible without a reader matching them up.
budget is always present, including when the answer is unknown, and that is the
point of carrying it: the commonest reason to ask this question is an entry that did not
fit, and an explanation that said “excluded for budget” without the budget would need a
second call to act on.
use majordomus_cli::devcontext::{compile, explain, CompileInput, ExplainInput};
use majordomus_cli::devcontext::{Explanation, Standing};
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let compiled = compile(&ctx, CompileInput::default()).unwrap();
let selected = compiled.selected[0].uri.clone();
// something in the answer: the entry is the evidence, and the other two are empty
let e: Explanation =
explain(&ctx, ExplainInput { uri: selected.clone(), ..Default::default() }).unwrap();
assert_eq!(e.standing, Standing::Selected);
assert_eq!(e.entry.as_ref().unwrap().uri, selected);
assert!(e.excluded.is_none() && e.deduplicated.is_none());
assert!(!e.detail.is_empty(), "the standing always reads as a sentence too");
// something this repository does not hold: an answer, not an error — and the budget
// the judgement was made under is carried even here
let absent: Explanation = explain(
&ctx,
ExplainInput { uri: "majordomus://adr/9999".into(), ..Default::default() },
)
.unwrap();
assert_eq!(absent.standing, Standing::Unknown);
assert!(absent.entry.is_none());
assert_eq!(absent.budget.limit_tokens, compiled.budget.limit_tokens);Fields§
§uri: StringWhat was asked about.
standing: StandingWhere it stands.
detail: StringThe same, in words.
entry: Option<ContextEntry>The entry, when it is in the answer.
excluded: Option<Excluded>The exclusion, when it was reached and not given.
deduplicated: Option<Deduplicated>The collapse it was part of, when it was folded or dropped for another.
budget: BudgetThe budget the judgement was made under, so that “excluded for budget” can be acted on without a second call.
Trait Implementations§
Source§impl Clone for Explanation
impl Clone for Explanation
Source§fn clone(&self) -> Explanation
fn clone(&self) -> Explanation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Explanation
impl Debug for Explanation
Source§impl<'de> Deserialize<'de> for Explanation
impl<'de> Deserialize<'de> for Explanation
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>,
Source§impl JsonSchema for Explanation
impl JsonSchema for Explanation
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for Explanation
impl PartialEq for Explanation
Source§fn eq(&self, other: &Explanation) -> bool
fn eq(&self, other: &Explanation) -> bool
self and other values to be equal, and is used by ==.