pub fn bind(
intents: &Intents,
plan: &Plan,
gaps: &[GapRecord],
critiques: &[CritiqueRecord],
policy: &IntentPolicy,
request: BindingRequest,
) -> IntentBindingExpand description
What request is bound to. One derivation: every link is judged by the preflight, and
this adds only what a task needs beside it — an intent given by name, a declared
exemption, ambiguity, the scope note and the two pins.
The order of judgement is fixed, so the same request always meets the same first refusal: an exemption is judged alone (and refuses to stand beside named work); then an issue, an intent, or paths, in that precedence, choose the issues; then the preflight judges them.
use majordomus_cli::intent::Intents;
use majordomus_cli::intent_binding::{bind, BindingCause, BindingRequest, BindingStanding};
use majordomus_cli::plan::Plan;
use majordomus_cli::policy::{ExemptionClass, IntentPolicy};
let intents = Intents { intents: vec![], findings: vec![] };
let policy = IntentPolicy {
exemptions: vec![ExemptionClass { id: "emergency".into(), description: String::new() }],
..Default::default()
};
let ask = |exemption: &str, because: Option<&str>| {
bind(&intents, &plan, &[], &[], &policy, BindingRequest {
exemption: Some(exemption.into()),
because: because.map(str::to_string),
..Default::default()
})
};
// a declared class with a reason is the only exemption there is
assert_eq!(ask("emergency", Some("master is red")).standing, BindingStanding::Exempt);
assert_eq!(ask("emergency", None).refusals[0].cause, BindingCause::ExemptionWithoutReason);
assert_eq!(ask("whim", Some("because")).refusals[0].cause, BindingCause::UnknownExemption);