fix: pass project_hint into retrieve and add path-signal ranking
Two changes that belong together:
1. builder.build_context() now passes project_hint into retrieve(),
so the project-aware boost actually fires for the retrieval pipeline
driven by /context/build. Before this, only direct /query callers
benefited from the registered-project boost.
2. retriever now applies two more ranking signals on every chunk:
- _query_match_boost: boosts chunks whose source/title/heading
echo high-signal query tokens (stop list filters out generic
words like "the", "project", "system")
- _path_signal_boost: down-weights archival noise (_archive,
_history, pre-cleanup, reviews) by 0.72 and up-weights current
high-signal docs (status, decision, requirements, charter,
system-map, error-budget, ...) by 1.18
Tests:
- test_context_builder_passes_project_hint_to_retrieval verifies
the wiring fix
- test_retrieve_downranks_archive_noise_and_prefers_high_signal_paths
verifies the new ranking helpers prefer current docs over archive
This addresses the cross-project competition and archive bleed
called out in current-state.md after the Wave 1 ingestion.
This commit is contained in:
@@ -41,6 +41,23 @@ def test_context_with_project_hint(tmp_data_dir, sample_markdown):
|
||||
assert pack.total_chars > 0
|
||||
|
||||
|
||||
def test_context_builder_passes_project_hint_to_retrieval(monkeypatch):
|
||||
init_db()
|
||||
init_project_state_schema()
|
||||
|
||||
calls = []
|
||||
|
||||
def fake_retrieve(query, top_k=None, filter_tags=None, project_hint=None):
|
||||
calls.append((query, project_hint))
|
||||
return []
|
||||
|
||||
monkeypatch.setattr("atocore.context.builder.retrieve", fake_retrieve)
|
||||
|
||||
build_context("architecture", project_hint="p05-interferometer", budget=300)
|
||||
|
||||
assert calls == [("architecture", "p05-interferometer")]
|
||||
|
||||
|
||||
def test_last_context_pack_stored(tmp_data_dir, sample_markdown):
|
||||
"""Test that last context pack is stored for debug."""
|
||||
init_db()
|
||||
|
||||
Reference in New Issue
Block a user