Skip to main content

Module ope

Module ope 

Source
Expand description

borg debug ope: off-policy estimates of the usefulness belief’s hand-set weights, from the outcome log alone. Reports, never applies: no constant changes.

What is estimated. The per-ask change rate under a candidate policy: of the lessons a check asks, the share the drone then changed its work on. The candidates differ from the policy in force in one weight of the belief (memory.rs Weights), the others held.

Which records count. The weights reach a logged propensity on one path only: the Thompson slot draw over a pool (conscience.rs budget_pool/widen_pool and propensity, the bm25 and the non-graded paths), whose asked records carry the pool (outcome.rs pool, base, scoped). On the default graded path p comes from the model’s grades (0 or 1) or the learned cut (attention.rs), both free of these weights: a candidate’s p equals the logged p there, so those records say nothing about the weights. The weights do order the shortlist the model grades, but nothing there is randomised or logged. So a decision is an asked record with p and a pool; the rest is skipped and counted (Skipped): no p, p = 0, no pool, no result yet, and graded records.

Leak-free replay. For each decision the beliefs come from memory.rs derive over the outcomes before its ms (sorted once, stably), under the candidate’s weights, then the same propensity the live path ran, on the logged pool with score = base × (0.5 + the candidate’s mean) and the decision’s session. A lesson’s counts depend only on the records that name it, so evaluate derives over those records alone (an index per lesson), which keeps a run linear in the log. The logged pool is held fixed: other weights could move a lesson across the LOW/BLOCK bars or change the widen path’s forced picks, which the replay does not model. “Before its ms” is what the live draw saw only when every record arrived by its ms: a team record arrives a sync round after its ms, so the draw may not have seen it. A decision whose replay under the current weights misses its logged p (by more than AGREE) was drawn from other records than the replay’s, and its weights would be biased: it is counted (Report::drifted) and left out of every estimate.

The estimate. Self-normalised inverse propensity scoring over the asked lessons, w = p under the candidate / logged p, reward 1 when the session’s result after the ask is a change; the effective sample size (Σw)²/Σw²; a 95% interval from a bootstrap over whole sessions (a session’s rewards are not independent), seeded, so a run is deterministic.

Structs§

Decision
One logged Thompson check: its asked record’s index in the log, ms and session, the asked lessons with their logged p and reward, and the pool (id, base, scoped).
Estimate
One estimate of a policy’s per-ask change rate.
Knob
One hand-set weight: its name, current value, the outcome kinds it weighs (its evidence), and how a candidate sets it.
Pick
A knob’s best candidate (the highest estimate; ties go to the current value) and whether its CI lower bound clears the current value’s estimate. Never applied.
Report
Row
One candidate value of one knob.
Skipped
What decisions left out, and why. no_p, zero_p and pending count asked lessons; no_pool and graded count records.

Constants§

AGREE
Method: how far a replayed p may lie from the logged one and still count as the same draw: the logged p is rounded (outcome.rs round_p), and the draw’s estimate is Monte Carlo (conscience::P_DRAWS).
CURRENT
The policy in force.
KNOBS
The three hand-set weights: the veto’s (VETOED_W), a regret’s (REGRET) and a green test run’s (TESTED_W).
RESAMPLES
Method: the resamples behind a CI: precision, not a knob (as conscience::P_DRAWS).

Functions§

decisions
The logged Thompson checks of outcomes, in log order, and what was skipped. A lesson’s reward is 1 when the strongest result of its session at or after the ask is a change, else 0: a correction or a veto after the ask means asking did not help. A placebo’s result (outcome.rs PLACEBO: judged where a free delivery would be, never shown) is no result about the lesson, and an unclear verdict (UNCLEAR), a remaining consequence (REMAINS) and a point that never came up (NOT_ARISEN) have no rank: none rewards anything.
evaluate
Evaluates every knob’s grid on outcomes (decisions, replay, snips).
grid
Candidates around a weight: half, itself, double. Derived from the current value, never hand-picked; one knob moves at a time, the others stay current.
main
borg debug ope [--dir DIR | --file OUTCOMES.jsonl] [--json]: the store of the collective DIR routes to (the working directory by default), or one outcomes file alone.
render
The report as text: counts, the agreement of the replay with the log, the reward, the grid, then a table per knob with its best candidate.
replay
Each pooled lesson’s chance of a slot under cand, as of the decision: beliefs from memory::derive over the records of log before d.ms (the cut is made here: nothing at or after the decision reaches it) with the candidate weights, then conscience::propensity on the logged pool with s = base × (0.5 + mean) and the decision’s session.
snips
Self-normalised IPS over units (w = p_cand / p_logged, reward, session): Σwr/Σw; None when Σw = 0. ESS = (Σw)²/Σw². CI: the 2.5th and 97.5th percentiles of RESAMPLES bootstrap resamples of whole sessions (the session’s rewards are not independent), drawn with memory::Rng from seed: deterministic.