solvi.strategist¶
The strategist: the functions and checks of a catalog assembled into a flow per request (Flow, PlanError).
Strategist: given the questions and init_state, picks functions AND checks from the catalog and assembles the flow.
Targets for each question
• it has a rule → the rule's arguments;
• an answer head is fitted → the facts selected during fitting;
• otherwise → the uses hint; otherwise everything computable from init_state (marked "flow not narrowed").
Then it walks back through signatures down to what init_state provides; the question's required parts (requires) are always added.
Checks: besides those the targets need, the strategist takes every catalog check whose inputs are all already in the flow and
that touches at least one COMPUTED (non-input) fact — a check on computed facts. Nothing else from the catalog is executed.
Typed facts: the flow records the type of each fact it uses (flow.types: a producer's return type, or for a given fact the
type its typed readers expect); producer / consumer types were already checked when the parts were registered.
Decisions with a model: decision parts that read the same facts with the same model, when the model can answer several
questions in one forward pass, are grouped (flow.batches); the executor scores each group in one pass.
Binary ¶
OrderModel ¶
P(hard check fails | cheap facts), one online model per hard check.
ProducerPolicy ¶
Chooses the order of a fact's alternative producers per input and learns from outcomes.
Alternatives whose predicted agreement with the reference (the last declared producer, normally the most trusted) is at
least quality are tried first, cheapest expected cost first (cost ÷ P(accepted)); the rest follow in the same order.
With probability explore the remaining producers also run after the accepted one, as a shadow: their outputs are never
used, only compared, which gives agreement labels for producers the policy would otherwise stop trying.
computable ¶
All facts computable from init_state (closure over signatures).
given_facts ¶
The facts the catalog reads but no part produces — what init_state has to provide: arguments of parts and rules,
and the questions' uses hints. (A rule that reads a question's name reads a given fact: answers are not facts.)
scalar_row ¶
Cheap features from a dict of facts: numbers, booleans and short strings as they are; a long string gives its length; a list / tuple / dict gives its length. Anything else is left out.