Expand description
The consultation policy: given what is uncertain and how much it matters, whether independent review is worth having, how much, and from which available advisors.
Pure over its inputs, like models.route: the same assessment against the same
availability gets the same plan, and every advisor that was not selected says why.
It names capabilities and never an advisor: a repository’s preference (“ask this one
first”) is the catalogue’s declaration order, which reaches this function only as the
order of the states it is handed.
The budget is the number of advisors, by materiality and mode:
| mode | trivial | low | material | high | critical |
|---|---|---|---|---|---|
| ci | 0 | 0 | 0 | 0 | 0 |
| fast | 0 | 0 | 0 | 1 | 1 |
| standard | 0 | 0 | 1 | 2 | 2 |
| offline | 0 | 0 | 1 | 2 | 2 |
| strict | 0 | 0 | 1 | 2 | 3 |
High confidence in the local conclusion lowers it by one. Selection is greedy and explainable: each next advisor is the one covering the most requested capabilities not yet covered, then one from a source not yet asked (independence: two answers from one vendor are one opinion twice), then declaration order. Zero selected is a plan, not a failure: the plan then carries the structured local review a session performs instead.
What the policy never does is count. There is no quorum, no threshold of agreeing
advisors, no majority: how advice becomes a decision is the conclusion’s business,
and a conclusion is refused while a disagreement it covers is unresolved (see
super::store).
§Example
High uncertainty under standard allows two advisors. Of three, one is rate limited
and is excluded with its reason; the other two are selected in preference order.
use majordomus_cli::reasoning::availability::{AdvisorState, ModeResolution, ReasoningMode};
use majordomus_cli::reasoning::policy::{plan, Materiality, PlanOutcome, PlanRequest};
fn advisor(id: &str, adapter: &str, status: &str) -> AdvisorState {
serde_json::from_value(serde_json::json!({
"id": id, "title": id, "transport": "api", "adapter": adapter,
"capabilities": ["independent_reasoning"], "status": status,
"reason": "present", "probe": "",
}))
.unwrap()
}
let states = [
advisor("first", "x-api", "available"),
advisor("limited", "y-api", "rate_limited"),
advisor("second", "z-cli", "available"),
];
let mode = ModeResolution { mode: ReasoningMode::Standard, source: "default".into() };
let request = PlanRequest { materiality: Materiality::High, ..Default::default() };
let p = plan(&request, &mode, &states);
assert_eq!(p.outcome, PlanOutcome::Consult);
let selected: Vec<&str> = p.selected.iter().map(|s| s.advisor.as_str()).collect();
assert_eq!(selected, ["first", "second"]);
assert_eq!(p.excluded[0].advisor, "limited");
assert!(p.excluded[0].reason.starts_with("rate_limited"));Structs§
- Excluded
Advisor - One advisor left out of the plan, its standing when the plan was made, and why: its status, a capability it does not offer, or a budget already spent.
- Plan
Request - What the policy is asked about: the materiality and confidence of one uncertainty, the advisory capabilities review needs, and any standing conclusion on the subject.
- Review
Plan - The plan: the decision with its reasons attached. It carries what it answered (mode, materiality, confidence, capabilities), the budget, the outcome with one sentence of why, every advisor selected or excluded, and the local review when one is due.
- Selected
Advisor - One selected advisor, the requested capabilities it covers, and why the greedy selection chose it at its position.
Enums§
- Materiality
- How much the uncertain decision could matter. Ordered from
trivialtocritical: with the mode it sets the review budget, and frommaterialup a decision taken alone carries the structured local review. - Plan
Outcome - What the plan decided: consult the selected advisors, decide on local evidence, or reuse a standing conclusion. Deciding locally is an ordinary outcome, not a failure.
- Reasoning
Confidence - How sure the primary executor is of its current hypothesis.
highlowers the review budget by one; the other levels leave it as the mode and materiality set it.
Constants§
- DEFAULT_
CAPABILITY - The capability review defaults to.
- LOCAL_
REVIEW - The adversarial self-review a session performs when it must decide alone.
Functions§
- budget
- The budget of a mode and materiality, before confidence: how many advisors a plan may select, as the table in the module header states it.
- materiality_
word - The word that names a materiality, the same one its JSON form carries: what a plan’s reason sentence prints.
- plan
- Make the plan for one request under one mode, over the advisors’ states in preference
order. Pure: the same inputs give the same plan, and every advisor not selected is in
excludedwith its reason.