feat(retrieval): seventh meta-belief consumer — adaptive posterior_temperature (#758) - #829
Conversation
There was a problem hiding this comment.
Sorry @robotrocketscience, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
PR-size soft capThis PR is over the advisory size threshold:
Bigger PRs collide with more open work, which under the parallel-session workflow tends to produce repeated This is advisory only — nothing is blocked. If the size is intentional (large refactor, module removal, generated code), apply the |
|
[claim:review:bagheera:2026-05-14T23:37:01Z] |
|
[claim:review:clarke:2026-05-14T23:37:44Z] |
|
[release:review:clarke:2026-05-14T23:37:49Z] |
|
[claim:review:oppenheimer:2026-05-14T23:38:50Z] |
|
[release:review:oppenheimer:2026-05-14T23:38:55Z] |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR implements the seventh meta-belief consumer ( ChangesPosterior Temperature Meta-Belief Integration
🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
9affa49 to
b066f0c
Compare
Review: rebased and readyPR by sister session, 4 commits all signed (G), CI green, BEHIND main was the only blocker. Rebase: clean — no conflicts. Main moved 7 commits via #821 (hot-path); this PR's only file overlap was Code-side verification:
Pre-push gates:
Verdict: ready-to-merge. Adding label, releasing claim. |
|
[release:review:bagheera:2026-05-14T23:41:26Z] |
|
merge-train: blocked branch is not fast-forward on The |
|
[claim:review:clarke:2026-05-14T23:43:36Z] |
Approve-equivalent — content correct; needs rebase (#828 landed in the gap)4 atomic signed commits, well-factored: surface ( Two-axis flag separation honored. Verification: CI green (pytest 3.12 + 3.13, all 20+ gates). Discretion grep on the full diff returns zero hits. Blocker: NOT-FF on current main Swapping |
|
[release:review:clarke:2026-05-14T23:44:55Z] |
|
[claim:conflict:prince:2026-05-14T23:50:27Z] |
b066f0c to
812a9df
Compare
|
[release:conflict:prince:2026-05-14T23:53:14Z] |
|
[claim:review:oppenheimer:2026-05-15T01:16:50Z] |
|
[claim:review:bagheera:2026-05-15T01:17:21Z] |
|
[release:review:bagheera:2026-05-15T01:17:26Z] |
812a9df to
af67607
Compare
Approve — rebased onto current main, ready-to-merge after CIPicked this up post-prince's rebase to Rebase result:
Code review (concur with clarke + bagheera): seventh meta-belief consumer follows the established #756 / #757 / #759 / #760 pattern — env-flag + predicate, idempotent install function, single-signal (SIGNAL_RELEVANCE), 30-day decay. Two-flag composition correct: this PR delivers evidence; #796's γ-rerank consumes it. Cold-start byte-identity preserved. Will add |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/aelfrice/retrieval.py`:
- Around line 396-398: The comment contains an ambiguous Unicode character "γ"
(e.g., in the phrase "γ-rerank" and references to
ENV_USE_GAMMA_POSTERIOR_TEMPERATURE); replace all occurrences of the glyph with
the ASCII word "gamma" (e.g., "gamma-rerank",
"ENV_USE_GAMMA_POSTERIOR_TEMPERATURE") in the comment block near the
sweeper/meta-belief explanation so lint (RUF003) and text searches work
reliably.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 26c9b469-4ade-4a60-a644-5abd9ad41172
📒 Files selected for processing (3)
CHANGELOG/v3.mdsrc/aelfrice/retrieval.pytests/test_posterior_temperature_meta.py
|
[release:review:oppenheimer:2026-05-15T01:24:19Z] |
|
merge-train: blocked branch is not fast-forward on The |
…-flag query for #758 Adds three new symbols to retrieval.py, co-located with the #796 gamma-rerank posterior-temperature constants: - ENV_META_BELIEF_POSTERIOR_TEMPERATURE ("AELFRICE_META_BELIEF_POSTERIOR_TEMPERATURE"): default-OFF feature flag for the adaptive-learning delivery path. Distinct from ENV_USE_GAMMA_POSTERIOR_TEMPERATURE (#796): the gamma flag gates whether the rerank uses T at all; the new flag gates whether the sweeper delivers relevance evidence to the meta-belief so T can learn. Two independent axes. - is_meta_belief_posterior_temperature_enabled(): mirrors is_meta_belief_expansion_gate_token_threshold_enabled exactly — checks ENV_META_BELIEF_POSTERIOR_TEMPERATURE against _ENV_TRUTHY plus "enabled". - install_posterior_temperature_meta_belief(store, *, now_ts) -> bool: idempotent install of META_POSTERIOR_TEMPERATURE_KEY. Relevance signal only (single-signal subscription is intentional: temperature changes the rerank distribution shape; the only natural feedback is whether the top-K was used). 30d posterior decay, static_default=0.5 which decodes to T=1.0 — byte-identical to the log-additive baseline. Returns True on first install, False if row already exists.
…ief_consumers (#758) Adds an is_meta_belief_posterior_temperature_enabled() guard block to get_active_meta_belief_consumers(), appending META_POSTERIOR_TEMPERATURE_KEY to the active list when AELFRICE_META_BELIEF_POSTERIOR_TEMPERATURE is truthy. The function's sorted() return preserves alphabetical determinism regardless of insertion order, so META_POSTERIOR_TEMPERATURE_KEY ("meta:retrieval. posterior_temperature") sorts correctly between the existing half-life and bm25f_anchor_weight keys. Updates the docstring's sweeper-coverage sentence to include #758 alongside #756, #757, and #760.
…consumer New test file tests/test_posterior_temperature_meta.py mirrors the #760 test file structure. Covers: - is_meta_belief_posterior_temperature_enabled: default-False, truthy tokens (1/true/yes/on/enabled), falsy tokens (0/false/no/off/disabled/""). - install_posterior_temperature_meta_belief: first call True / second call False (idempotent), row count stays at 1, signal_weights == {relevance: 1.0} only, half_life_seconds == 30d, static_default == 0.5. - Cold-start byte-identity: resolve_posterior_temperature_with_meta returns 1.0 exactly after fresh install (geometric mean of FLOOR=0.5 and CEIL=2.0). - Evidence responsiveness: 100 strong-positive events (evidence=1.0) push posterior mean toward 1.0 which decodes to T >= 1.0 (toward CEIL); 100 strong-negative events (evidence=0.0) push T <= 1.0 (toward FLOOR). Bounds [0.5, 2.0] are enforced in both directions. - Determinism (#605): same install + evidence sequence + now_ts yields identical read_meta_belief_value on two fresh stores. - get_active_meta_belief_consumers: key absent when flag off, present when on, sort order preserved when multiple flags are on.
Appends a changelog entry to CHANGELOG/v3.md under [Unreleased] for the Documents the two-axis state machine (gamma flag vs adaptive flag), relevance-only signal subscription rationale, cold-start byte-identity, and the 26 new tests.
af67607 to
d664fd7
Compare
|
merge-train: blocked 1 review thread(s) are unresolved on these files: src/aelfrice/retrieval.py. Resolve them on the PR (click 'Resolve conversation' on each) and re-add the label. The |
|
Resolving the RUF003 γ-glyph thread as wontfix-here: existing Re-adding |
|
merge-train: merged d664fd7 → |
|
[claim:review:clarke:2026-05-15T03:07:01Z] |
|
[release:review:clarke:2026-05-15T03:07:54Z] |
Closes #758. Sub-task D of umbrella #480 (adaptive meta-belief layer). Pattern reuse of the #756 / #757 / #759 / #760 family.
Scope
Wires the sweeper delivery path for
meta:retrieval.posterior_temperature. The decoder surface (resolve_posterior_temperature_with_meta, the [0.5, 2.0] guard band, the log-linear decode, thestatic_default = 0.5 → T = 1.0cold-start byte-identity) was already shipped by #796 / PR #807. What this PR adds is the learning loop: an env flag, a sweeper subscription, and an idempotent installer.Changes
ENV_META_BELIEF_POSTERIOR_TEMPERATURE = "AELFRICE_META_BELIEF_POSTERIOR_TEMPERATURE"— new env var, default-OFF, accepts1/true/yes/on/enabled.is_meta_belief_posterior_temperature_enabled() -> bool— mirrorsis_meta_belief_expansion_gate_token_threshold_enabled.install_posterior_temperature_meta_belief(store, *, now_ts) -> bool— idempotent. Relevance signal only (weight 1.0). 30-day posterior decay. Cold-start value 0.5.get_active_meta_belief_consumers()extended to includeMETA_POSTERIOR_TEMPERATURE_KEYwhen the new flag is on, so the Live close-the-loop relevance-signal infrastructure — #756 / #480 prereq #779 UPS sweeper delivers relevance evidence.tests/test_posterior_temperature_meta.py. Full suite green (4206 pass on pre-rebase HEAD; tests reverified post-rebase against current main with PR feat(retrieval): ζ bounded posterior-contribution rerank surface (#817, closes #800) #826 / ζ surface merged).resolve_posterior_temperature_with_metais not modified — it already reads the meta-belief wheneverstoreis supplied (locked behavior from #796). The new flag controls only whether the sweeper feeds evidence in.Two-axis flag state machine (intentional)
AELFRICE_USE_GAMMA_POSTERIOR_TEMPERATUREAELFRICE_META_BELIEF_POSTERIOR_TEMPERATURET = 1.0; no learningTunusedT, sweeper updates itBoth flags default-OFF until bench-corpus evidence clears the gate.
Decisions deferred to reviewer
1. Signal direction inversion vs issue-body spec
The issue body (#758 § Acceptance) specifies:
The shipped substrate semantics (this PR + the #796 decoder) deliver the opposite direction:
evidence = 1.0(high relevance, referenced) increments the Beta-Bernoulli posterior α → posterior value → 1.0 → log-linear decode →T → CEIL = 2.0(flatter / more exploration).evidence = 0.0(low relevance, not referenced) increments β → value → 0.0 →T → FLOOR = 0.5(sharper / more exploitation).Both directions are defensible bandit policies — issue body wants exploit-on-win, substrate gives explore-on-win — but they are not equivalent. The tests in this PR pin the substrate direction; they would fail if the decode were inverted. Default-OFF ships are safe either way (no production behavior change until both flags flip), but the direction must be ratified before the flip-default PR.
Three resolution paths if the issue-body direction is preferred:
T = exp(log_floor + v * (log_ceil - log_floor))toT = exp(log_ceil - v * (log_ceil - log_floor))inresolve_posterior_temperature_with_meta. Cold-start byte-identity atvalue = 0.5is preserved (stillT = 1.0). Modifies surface shipped under feat(retrieval): Boltzmann softmax rerank surface — precursor to #758 (operator path B) #796.1 - referencedinstead ofreferencedfor this specific consumer key. Sweeper-local; surface unchanged. Requires a per-consumer "invert" attribute or a custom write path.My recommendation is (c) — explore-on-win is the standard ε-decreasing posture and the substrate already happens to match it. But this is the reviewer's call.
2. Guard band [0.5, 2.0] vs issue-body [0.1, 10.0]
The issue body specifies
T ∈ [0.1, 10.0]. #796 ratified the shipped bounds at[POSTERIOR_TEMPERATURE_FLOOR, POSTERIOR_TEMPERATURE_CEIL] = [0.5, 2.0]because the cold-start byte-identity requirement pinsdecode(0.5) = 1.0, and[0.5, 2.0]has geometric mean exactly 1.0 with no float error. This PR does not change those bounds. If the wider[0.1, 10.0]band is actually wanted, the bounds change should land separately and choose astatic_defaultthat decodes to 1.0 under the new band (v = log(1.0) / (log(10.0) - log(0.1)) + log(0.1) / (log(10.0) - log(0.1)) = 0.5, sostatic_default = 0.5still works — the bound change is the simple part; the harder part is whether[0.5, 2.0]is in fact too narrow once adaptive learning is live).Bench gate
Per #758 the gate is
#437 A/B: meta-belief-driven vs hardcoded baseline, ≥+2pp recall-at-k. The labeled rerank-relevance corpus that this gate needs is currently the deliverable of #819, which is in-flight. Ship default-OFF; flip-default after #819's corpus exists and the A/B clears.Commits
feat(retrieval): install_posterior_temperature_meta_belief + adaptive-flag query for #758feat(retrieval): include posterior_temperature in get_active_meta_belief_consumers (#758)test(retrieval): coverage for #758 posterior_temperature meta-belief consumerdocs(changelog): note adaptive posterior_temperature consumer (#758)Rebased onto
github/main(ca0b09ce) post-#826 ζ-surface merge; CHANGELOG[Unreleased]### Addedconflict resolved by keeping both bullets.Summary by CodeRabbit
New Features
Documentation
Tests