BudgetPolicy#
- class scikitplot.corpus.BudgetPolicy(max_iterations=4, max_retrieval_calls=8, max_subqueries=8, max_evidence_documents=64, max_graph_expansions=4, max_wall_time_seconds=30.0, max_context_tokens=None, max_model_tokens=None, token_counter=None, _iterations=0, _retrieval_calls=0, _subqueries=0, _graph_expansions=0, _started=None)[source]#
Deterministic, decrementing limits on an investigation.
- Parameters:
- max_iterationsint, optional
- max_retrieval_callsint, optional
- max_subqueriesint, optional
- max_evidence_documentsint, optional
- max_graph_expansionsint, optional
- max_wall_time_secondsfloat or None, optional
- max_context_tokensint or None, optional
- max_model_tokensint or None, optional
- token_countercallable or None, optional
str -> int. Corpus cannot know the consumer’s model, so token budgets are caller-supplied.
- Parameters:
max_iterations (int)
max_retrieval_calls (int)
max_subqueries (int)
max_evidence_documents (int)
max_graph_expansions (int)
max_wall_time_seconds (float | None)
max_context_tokens (int | None)
max_model_tokens (int | None)
_iterations (int)
_retrieval_calls (int)
_subqueries (int)
_graph_expansions (int)
_started (float | None)
Notes
Developer. The policy is the sole authority: a model may propose a next step, the policy decides whether it runs (ADR-R10-002). Every check is arithmetic on counters and clocks, never a model call, so termination is provable.
When
token_counterisNonethe two token budgets are reportedUNENFORCEABLErather than silently treated as unlimited. Guessing with a chunking tokenizer would give a budget wrong by an unknown, model-dependent factor – a budget that appears enforced and is not, which is the same silent-partial-evidence shape found elsewhere in this codebase.- check(*, evidence_count=0)[source]#
Return a record naming the exhausted budget, or
None.Notes
Checked before an action runs, so the loop never exceeds a budget and then reports it.
- Parameters:
evidence_count (int)
- Return type:
ErrorRecord | None