pub fn derive_availability(
catalogue: &AdvisorCatalogue,
inputs: &Inputs<'_>,
) -> Vec<AdvisorState>Expand description
Every advisor — declared ones in preference order, then linked peers by runtime — with its status. Pure over its inputs.
use majordomus_cli::reasoning::availability::*;
use majordomus_cli::reasoning::catalogue::{AdvisorCatalogue, References};
struct Nothing;
impl Presence for Nothing {
fn executable(&self, _: &str) -> bool { false }
fn variable(&self, _: &str) -> bool { false }
}
let c: AdvisorCatalogue = majordomus_cli::metadata::yaml::parse_into(
"version: 1\ncapabilities:\n - id: code_review\n description: x\nadvisors:\n - id: a\n title: A\n transport: cli\n adapter: a-cli\n executable: a\n capabilities: [code_review]\n",
).unwrap();
let refs = References::default();
let states = derive_availability(&c, &Inputs {
refs: &refs, presence: &Nothing, mode: ReasoningMode::Standard, disabled: &[],
history: &[], peers: &[], now: 0, cooldown: None,
});
assert_eq!(states[0].status, AdvisorStatus::Unavailable);
assert_eq!(states[0].reason, "executable_not_found");