Skip to main content

Module select

Module select 

Source
Expand description

Which of a graded check’s applies to ask, to hand over free, to judge blindly as a placebo, or to leave for later: the lesson selection policy. It replaces attention.rs, which stays one release as the Attention sub-policy.

Policies (policy, the first that applies): BORG_SELECT=fixed the fixed rule; BORG_STOP_ASK_CAP=N the fixed rule asking only the first N 3s (evaluation only); BORG_STOP_ATTENTION=on attention.rs’s learned cut (evaluation only); otherwise the learned policy (Learned, select/policy.rs), the default since its pre-registered checks passed under Rules v2 (docs/evidence.md#lesson-selection: P4 had failed its first run and the rerun under the v1 design).

The fixed rule (conscience.rs graded_without, no cap) asks every 3 and 2 and the 1s up to conscience::CAP when a check has a 3, else hands over the 2s and 1s free, up to CAP; a lesson the session already had delivered (Ctx::had) may still be asked but never takes a free slot, which its delivery would drop as given before. It also draws up to PLACEBO_SLOTS of the applies it delivers neither way for the placebo arm (draw_placebo): judged blindly where a free delivery would be, never shown, so what not delivering is worth gets labels at no cost to quality. Those are the labels the learned policy cannot get from the fixed rule’s history, which asks and hands over by grade alone.

The learned policy (select/policy.rs choose, policy v2) leaves the fixed rule only on evidence from a fitted value model, and on live checks runs a randomised test of how many of the fixed rule’s delivered lessons to ask rather than hand over (nothing withheld), both under a conservative gate rationed by the collective’s tolerance (alpha); cold start (no fit, or a gate that may risk nothing yet) is exactly the fixed rule, and so is a store the monitor reverted (select/summary.rs REVERTED). It draws its placebos among the applies it leaves for later, as the fixed rule does. The evaluation switches decide exactly as the hook did before this module (0.5.0’s attention.rs graded) and draw no placebo.

What it reads. Only Ctx: the summary the hook loaded once (select/summary.rs load, beside the lessons file), and for the Attention sub-policy the outcomes beside the lessons file (outcome.rs path_beside), never the routed collective’s: an evaluation that points BORG_CONSCIENCE at its own store reads that store’s outcomes, not the engineer’s.

Deterministic: a decision depends on the applies, the policy, the summary and the check id (check_id, seed), all logged.

Modules§

policy
The learned policy’s core: a Bayesian model of what each route of a graded apply is worth, fitted from the outcome log, and the decision it drives at one check. Pure: no file, no clock, no environment (an engineer’s budget comes in as an argument).
replay
borg debug select [--replay] [--rebuild] [--dir DIR | --file FILE] [--json] [--eval RUNS_DIR --qrels FILE]: the selection policy’s state and its pre-registered checks, replayed from the outcome log (0 tokens). Reports, never applies.
summary
What a hook needs to decide, folded from the outcome log once and cached, so no check parses the whole log: every graded apply with its route and what became of it, the delivery tallies, the pool’s yield and latency, the gate’s ledger, the monitor, the checks whose learned decision fell back to the fixed rule, the randomised question-count test’s checks, and the fit (select/policy.rs).

Structs§

Ctx
The check a decision is made for.
Log
What a decision logs: the graded record’s policy and fit, and the #borg-select line.
Routed
A graded check’s decision: what to ask (in the order to ask it), to hand over free (in the order to deliver it), and to judge as placebo; per apply (aligned with the applies) its probability of being asked (p) and of being handed over free (pf) under the policy in force; and what to log.
Unit
One graded apply as the policy sees it, aligned with the check’s applies.

Enums§

Policy
The policy in force for a graded check (module doc).
Route
What happens to one graded apply at its check.

Constants§

ARMS
The arms a graded apply can be delivered by (Route::arm). Protocol: the length and order of every per-arm array (select/policy.rs monitor, select/replay.rs).
CHECK_HEX
Hex digits of a check id. Protocol: the length of the @<check> tags hook.rs already writes (append_p_of), 48 bits, so two checks of one store collide with negligible chance.
PLACEBO_SLOTS
Placebo slots per check: of the applies a check delivers neither way, at most this many are judged blindly (Routed::placebo). Guard: bounds the judge’s extra work per check.
REVERTED_SOURCE
Log::source of a learned check on a store the monitor reverted (select/summary.rs REVERTED). Protocol: logged as the graded record’s source, which borg debug select P1 reads back as the revert the hook saw (select/replay.rs).

Functions§

alpha
The learned policy’s α for the store that holds lessons: the collective’s risk (risk_of), policy::ALPHA unless it sets one. What the hook reads into Ctx::alpha at the check; a replay reads the record’s instead (alpha_of).
alpha_of
The tolerance a graded record’s check was decided under, from its logged alpha (logged_alpha): policy::ALPHA when none is logged, as on every record from before risk.
budget_of
The engineer’s budget for the collective whose store holds lessons: its budget in collectives.json (collective.rs Entry::budget: pool tokens per session, a positive number), None when unset (the default) or the config does not load.
check_id
A graded check’s id: CHECK_HEX hex digits of blake3 over its session, channel (stop, live), start (epoch ms) and process id. Not a count of the session’s checks: a stop and a live check of one session can run at once and would count the same lines. Computed once per check and logged, never recomputed.
graded_under
A graded check’s decision under policy (the hook passes the policy in force, policy, through hook.rs decide): replaces 0.5.0’s attention.rs graded. Fixed and Cap decide by the fixed rule (conscience.rs graded_without with ctx.had, Cap with its cap), whose propensities are its choice (attention.rs fixed_p); Attention on a check with a 3 by the learned cut on the outcomes beside ctx.lessons, with the explore mixture’s propensities, and by the fixed rule otherwise; Learned on every check by select/policy.rs choose (the fixed rule at cold start or while the store is reverted), with its exact propensities (learned). Fixed and Learned draw placebos among the applies they deliver neither way (draw_placebo); the asked and free lists never depend on that draw, so the fixed rule’s decision is the same with or without it (P0).
logged_alpha
Log::alpha of a check decided under the tolerance alpha: None at policy::ALPHA. What the hook logs and alpha_of reads back, from one definition so the two never part.
nofree
The applies the session already had (Ctx::had), each once, in the applies’ order: what the graded record logs as nofree (outcome.rs), all a replay needs of had to decide as the hook did.
policy
The policy this process runs under, from the environment (module doc).
pool_tokens
The pool budget in tokens for a check of session under the policy in force (policy, pool_tokens_under).
pool_tokens_under
pool_tokens under policy, never the environment’s: whole.rs TOKENS unless the pool is the learned policy’s (pool_active); then the budget its fit chooses (select/policy.rs pool_tokens), never past the baseline without the harness’s stop budget for the model call (limit_ms) and the latency evidence to fit in it. Fixed for a session between fits, so its prompt prefix stays stable. What a replay calls for the policy it replays.
precedence
policy over its three switches: select (BORG_SELECT), cap (BORG_STOP_ASK_CAP as conscience.rs ask_cap reads it) and attention (BORG_STOP_ATTENTION=on). fixed wins over both evaluation switches, the cap over attention, both over learned; any other BORG_SELECT, or none, is the default, the learned policy: its pre-registered checks passed under Rules v2 (docs/evidence.md#lesson-selection, run v2 2026-10-29), and BORG_SELECT=fixed is the way back. Whatever evaluates the learned policy (select/replay.rs, the monitoring of what it would do) names Policy::Learned and never reads this.
risk_of
The engineer’s tolerance for learning in the collective whose store holds lessons: its risk in collectives.json (collective.rs Entry::risk: the share of the fixed rule’s value the randomised question-count test may risk, 0 to 1, 0 turning it off), None when unset (the default, under which the policy uses policy::ALPHA), not a number in range, or the config does not load.
seed
The seed of a check’s draws: the first 8 bytes of blake3 over its session, channel and id, so a replay of the logged check draws the same, and a stop and a live check of one session never share draws.
shown_tokens
The pool tokens of a check whose model call was shown shown (hook.rs Call::order): whole.rs cost summed over them, saturating. What the graded record logs (outcome.rs tokens) and the decision values (Ctx::tokens), from one definition so the two never part.
units
The units of applied, in its order.