pub struct CompilerPolicy {
pub schema: u64,
pub graph: String,
pub tiers: Vec<TierRule>,
pub edges: Vec<EdgeRule>,
pub selectors: Vec<SelectorRule>,
pub default_budget_tokens: u64,
pub default_max_depth: usize,
pub default_floor: f64,
pub bytes_per_token: u64,
}Expand description
The compiler’s own rules, so that a caller reads the decision instead of inferring it from an answer.
This is the answer to “why did I get that”, asked once rather than reverse-engineered
from every context. It is a projection of the tables and constants this module is built
from — Tier::ORDER, select::EDGES, Selector::ALL and the four defaults
— and holds no numbers of its own, so the published rules and the code that applies them
cannot drift apart.
The defaults are here because they are what a request gets when it says nothing, and a caller tuning a request needs to know what it is tuning away from.
use majordomus_cli::devcontext::{policy, CompilerPolicy, Selector, Tier};
use majordomus_cli::devcontext::{BYTES_PER_TOKEN, DEFAULT_BUDGET_TOKENS};
use majordomus_cli::devcontext::{DEFAULT_FLOOR, DEFAULT_MAX_DEPTH};
use majordomus_cli::graph;
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let rules: CompilerPolicy = policy(&ctx).unwrap();
// it names the graph it reads relations from, rather than leaving it to be guessed
assert_eq!(rules.schema, 1);
assert_eq!(rules.graph, graph::COMPOSED);
// the three tables are complete
assert_eq!(rules.tiers.len(), Tier::ORDER.len());
assert_eq!(rules.selectors.len(), Selector::ALL.len());
assert!(!rules.edges.is_empty());
// and the published defaults are the constants a silent request actually gets
assert_eq!(rules.default_budget_tokens, DEFAULT_BUDGET_TOKENS);
assert_eq!(rules.default_max_depth, DEFAULT_MAX_DEPTH);
assert_eq!(rules.default_floor, DEFAULT_FLOOR);
assert_eq!(rules.bytes_per_token, BYTES_PER_TOKEN);Fields§
§schema: u64The format of this answer.
graph: StringThe graph the relations are read from.
tiers: Vec<TierRule>The tiers, in the order the budget spends in.
edges: Vec<EdgeRule>Every edge kind the composed graph has, followed or refused.
selectors: Vec<SelectorRule>The selectors, and which of them infer.
default_budget_tokens: u64The default ceiling in estimated tokens.
default_max_depth: usizeThe default depth limit.
default_floor: f64The default relevance floor.
bytes_per_token: u64Bytes per estimated token.
Trait Implementations§
Source§impl Clone for CompilerPolicy
impl Clone for CompilerPolicy
Source§fn clone(&self) -> CompilerPolicy
fn clone(&self) -> CompilerPolicy
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 CompilerPolicy
impl Debug for CompilerPolicy
Source§impl<'de> Deserialize<'de> for CompilerPolicy
impl<'de> Deserialize<'de> for CompilerPolicy
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 CompilerPolicy
impl JsonSchema for CompilerPolicy
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 CompilerPolicy
impl PartialEq for CompilerPolicy
Source§fn eq(&self, other: &CompilerPolicy) -> bool
fn eq(&self, other: &CompilerPolicy) -> bool
self and other values to be equal, and is used by ==.