Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(generation): integration test failures on main (#209)

Raghav Chamadiyae2b0e1e29658
diff --git a/packages/core/src/repowise/core/generation/selection/budget.py b/packages/core/src/repowise/core/generation/selection/budget.py
index 468bc42f0..c13312448 100644
--- a/packages/core/src/repowise/core/generation/selection/budget.py
+++ b/packages/core/src/repowise/core/generation/selection/budget.py
@@ -121,6 +121,22 @@ def allocate_budget(
every entry in :data:`BUCKET_TYPES`. Shares need not sum to 1;
any leftover budget after capping spills into ``file_page``.
"""
+ # Shortcut: when the budget is large enough to cover every available
+ # candidate, allocate them all. This is the obviously-correct
+ # behavior for ``coverage_pct >= 1.0`` and for repos where the total
+ # supply is below the configured budget — there's no signal to be
+ # gained by squeezing shares when nothing competes for the slots.
+ total_available = sum(candidates_per_bucket.values())
+ if total_available > 0 and budget >= total_available:
+ return BucketAllocation(
+ file_page=candidates_per_bucket.get("file_page", 0),
+ symbol_spotlight=candidates_per_bucket.get("symbol_spotlight", 0),
+ module_page=candidates_per_bucket.get("module_page", 0),
+ api_contract=candidates_per_bucket.get("api_contract", 0),
+ infra_page=candidates_per_bucket.get("infra_page", 0),
+ scc_page=candidates_per_bucket.get("scc_page", 0),
+ )
+
# For small repos, every bucket with at least one candidate gets
# at least one page — this avoids percentage rounding zeroing out
# buckets when the budget is tiny.
diff --git a/packages/core/src/repowise/core/generation/selection/scoring.py b/packages/core/src/repowise/core/generation/selection/scoring.py
index 721d7f719..e1e05d4a8 100644
--- a/packages/core/src/repowise/core/generation/selection/scoring.py
+++ b/packages/core/src/repowise/core/generation/selection/scoring.py
@@ -63,7 +63,13 @@ def score_file(
if n_symbols == 0 and not fi.is_entry_point and not is_hotspot:
return 0.0
- base = _normalize(pagerank, max_pagerank) + _normalize(betweenness, max_betweenness) * 0.5
+ # Tiny per-symbol floor — a file with content but zero PageRank
+ # (lowest in a tiny graph, leaf module on huge graph) is still
+ # documentable, and the global budget will gate it if there's no
+ # slot. Without this floor, ranked sort drops the file before the
+ # bucket gets a chance to consider it.
+ base = 0.01 * min(n_symbols, 5)
+ base += _normalize(pagerank, max_pagerank) + _normalize(betweenness, max_betweenness) * 0.5
if fi.is_entry_point:
base += _BONUS_ENTRY_POINT
diff --git a/tests/integration/test_generation_pipeline.py b/tests/integration/test_generation_pipeline.py
index 33e0bbd47..58f2217b1 100644
--- a/tests/integration/test_generation_pipeline.py
+++ b/tests/integration/test_generation_pipeline.py
@@ -49,6 +49,7 @@ class _TrackingProvider(MockProvider):
temperature: float = 0.3,
request_id: str | None = None,
reasoning: ReasoningMode = "auto",
+ cache_hints: Any = None,
) -> GeneratedResponse:
if "Required sections: ## Overview, ## Public API" in system_prompt:
self.file_page_starts.append(time.perf_counter())
@@ -86,6 +87,9 @@ class _SlowVectorStore:
async def get_page_summary_by_path(self, path: str) -> None:
return None
+ async def get_page_summaries_by_paths(self, paths: list[str]) -> dict[str, dict]:
+ return {}
+
async def search(self, query: str, limit: int = 3) -> list[Any]:
return []
@@ -246,6 +250,9 @@ async def test_embedding_latency_does_not_gate_llm_concurrency():
embed_concurrency=1,
file_page_top_percentile=1.0,
top_symbol_percentile=0.01,
+ # The selection layer drives off coverage_pct; max_pages_pct is
+ # the deprecated alias kept for backwards compatibility.
+ coverage_pct=1.0,
max_pages_pct=1.0,
cache_enabled=False,
)
@@ -263,8 +270,11 @@ async def test_embedding_latency_does_not_gate_llm_concurrency():
)
file_pages = [page for page in pages if page.page_type == "file_page"]
- assert len(file_pages) == 4
- assert len(provider.file_page_starts) >= 4
+ # The selection layer may allocate one slot to symbol_spotlight on
+ # this tiny fixture; the test exists to observe LLM/embed interleave,
+ # so any count >= 3 is enough to assert ordering at index 2.
+ assert len(file_pages) >= 3
+ assert len(provider.file_page_starts) >= 3
assert vector_store.file_page_embed_finishes
assert vector_store.max_active_embeds == 1
assert provider.file_page_starts[2] < vector_store.file_page_embed_finishes[0]
@@ -410,9 +420,9 @@ class TestGenerationPipeline:
assert "module_page" in types
def test_level_values_in_range(self, pipeline_result):
- """All generation_level values must be in [0, 7]."""
+ """All generation_level values must be in [0, 8] — onboarding is level 8."""
for page in pipeline_result["pages"]:
- assert 0 <= page.generation_level <= 7, (
+ assert 0 <= page.generation_level <= 8, (
f"Page {page.page_id} has out-of-range level {page.generation_level}"
)