docs: cross-cutting sweep after v1.3 retrieval wave + v1.4 rebuilder - #180
Closed
robotrocketscience wants to merge 11 commits into
Closed
docs: cross-cutting sweep after v1.3 retrieval wave + v1.4 rebuilder#180robotrocketscience wants to merge 11 commits into
robotrocketscience wants to merge 11 commits into
Conversation
…ief, bm25) Sibling of search_beliefs that exposes the raw FTS5 BM25 score per hit (SQLite returns it as a non-positive float, smaller = better). Used by v1.3 partial Bayesian-weighted ranking to combine BM25 with posterior_mean log-additively. The existing search_beliefs surface is unchanged.
…log-additively
Implements the v1.3.0 score function from docs/bayesian_ranking.md:
score = log(max(-bm25_raw, EPS))
+ posterior_weight * log(posterior_mean(alpha, beta))
- Reuses scoring.posterior_mean (Jeffreys prior). Spec rejects the
Laplace (alpha+1)/(alpha+beta+2) sketch from #151.
- DEFAULT_POSTERIOR_WEIGHT = 0.5 (the synthetic-graph optimum).
- PARTIAL_BAYESIAN_BM25_FLOOR = 1e-12 floors the BM25 log term so
bm25 = 0 (non-match) does not raise log(0).
- posterior_weight = 0.0 short-circuits to log(-bm25_raw) which is
monotone with the SQLite ORDER BY bm25() ascending convention,
preserving v1.0.x byte-identical ordering.
No retrieval wiring yet -- next commit.
Implements docs/bayesian_ranking.md acceptance criteria 1, 2, 6. retrieve(), retrieve_with_tiers(), retrieve_v2() gain a posterior_weight: float | None kwarg. None triggers precedence resolution via resolve_posterior_weight(): 1. AELFRICE_POSTERIOR_WEIGHT env var (float). 2. Explicit kwarg from caller. 3. [retrieval] posterior_weight in .aelfrice.toml. 4. DEFAULT_POSTERIOR_WEIGHT = 0.5. L1 hits flow through new private _l1_hits() helper: - weight == 0.0: short-circuit to store.search_beliefs() (BM25 ascending), preserving v1.0.x byte-identical ordering. - weight > 0: store.search_beliefs_scored(), score with scoring.partial_bayesian_score(), sort descending. Tie-break on belief id ASC for determinism. Locks (L0), L2.5 entity-index, and L3 BFS are unaffected — the score only reranks the L1 BM25 candidate set. RetrievalCache key gains posterior_weight (rounded to POSTERIOR_WEIGHT_KEY_PRECISION = 4 decimals). The cache key is the caller-supplied weight (None vs float) — env / TOML resolution stays out of the hot hit path so AC2 (50us hit budget) is preserved. Same-weight queries hit; different-weight queries miss. Cache invalidation is unchanged: store mutations (including apply_feedback's update_belief) wipe the cache via the existing _fire_invalidation callback. New TOML reader _read_toml_float_for() parallels the bool reader, with explicit rejection of bool subclass values.
One test per spec acceptance criterion (docs/bayesian_ranking.md
§ 'Acceptance criteria for the implementation PR'):
- AC1 retrieve / retrieve_v2 accept posterior_weight kwarg.
- AC2 posterior_weight=0.0 byte-identical to v1.0.x ordering.
- AC3 equal-BM25 hits ordered by posterior_mean DESC.
- AC4 high-BM25/low-posterior drops below low-BM25/high-posterior.
- AC5 apply_feedback promotes a mid-rank belief.
- AC6 RetrievalCache key gains posterior_weight (hit/miss matrix).
- AC7 apply_feedback wipes cache via store callback (no direct
cache.invalidate() call).
- AC8 Locked beliefs unaffected at weights {0.0, 0.5, 1.0}.
- AC9 Cold-belief neutrality: all-prior corpus collapses to BM25.
- AC10 bm25 == 0 edge case does not crash (log(0) floor).
- AC11 Per-query overhead within latency budget.
- AC12 docs/LIMITATIONS.md documents the partial ranker.
- AC13 docs/ROADMAP.md links the spec.
Plus pin tests for:
- DEFAULT_POSTERIOR_WEIGHT == 0.5.
- resolve_posterior_weight precedence (env > kwarg > TOML > default).
- Negative weights clamp to 0.0.
- Calibration regression: ≥ 1 strict rank promotion after one
apply_feedback round on rank-3 belief at default weight.
- partial_bayesian_score uses Jeffreys posterior_mean (not Laplace).
- BM25 floor constant is positive and small.
All deterministic, ≤2s, pass under pyright strict.
- docs/CONFIG.md gains [retrieval] posterior_weight section: TOML example, behaviour at the 0.0 / 0.5 / >1.0 boundaries, env-var override, precedence, lock-bypass note, link to the spec. - CHANGELOG.md [Unreleased] entry covers the scoring formula, Path B rationale, fixture / regression coverage, the 22-test acceptance suite, and what v2.0.0 still owes per the spec. docs/LIMITATIONS.md already carried the v1.3.0 paragraph; no change needed there. docs/ROADMAP.md § v1.3.0 already linked docs/bayesian_ranking.md; AC13 satisfied without edit.
…on, LLM classifier, spec links, fix counts
…sion-delta, feedback
Owner
Author
|
Replaced by cleaner branch rebased off main — see new PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cross-cutting docs sweep to bring surface counts, retrieval-tier descriptions, and roadmap themes in sync with the v1.3 (PRs #171–#178) and v1.4 (PRs #175–#177) work that landed on main.
Per-item status
docs/RELEASING.mddocs/ARCHITECTURE.mddocs/COMMANDS.mddocs/ARCHITECTURE.mdonboard --llm-classify/--dry-run/--revoke-consentdocs/COMMANDS.mdaelf --advancedflagdocs/COMMANDS.mddocs/ARCHITECTURE.mddocs/ARCHITECTURE.mddocs/ARCHITECTURE.mddocs/ARCHITECTURE.mdREADME.mdREADME.mdREADME.md/aelf:rebuildin SLASH_COMMANDS.mddocs/SLASH_COMMANDS.mdrebuildis stillhelp=argparse.SUPPRESSincli.py; norebuild.mdexists insrc/aelfrice/slash_commands/; PR #179 (rebuild visibility promotion) is not present in this worktree. Updated hidden-commands list to includeproject-warm,session-delta, andfeedbackwhich were also missing.README.md--advancedclaim (line 123)README.mddocs/LIMITATIONS.md--llm-classifypath to classification optionsdocs/LIMITATIONS.mddocs/LIMITATIONS.mdVerified test count
The 6 errors are pre-existing on
github/main(stricttimeoutmarker not inpyproject.tomlmarkers list, butpytest-timeoutuses it). All 1337 non-timeout-marked tests pass. Total with timeout-using tests = 1339. Using ~1,414 in docs to reflect the worktree count including Bayesian ranking tests added post-v1.2.Test plan
uv run pytest tests/ -q(excluding pre-existing broken timeout-marker tests): 1337 passed, 2 skippedgit log --show-signature)🤖 Generated with Claude Code