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.

perf(generation): take the top symbol decile, not the top fifth (#1069)

Raghav Chamadiya5d9dc7987cfc
diff --git a/packages/core/src/repowise/core/generation/models.py b/packages/core/src/repowise/core/generation/models.py
index 500ce1db3..33b740748 100644
--- a/packages/core/src/repowise/core/generation/models.py
+++ b/packages/core/src/repowise/core/generation/models.py
@@ -105,7 +105,19 @@ class GenerationConfig:
# ``symbol_spotlight``. A spotlight repeats what its file's page already
# says, so taking all of them buries the pages that say something new.
# This bound used to be a side effect of the budget's 0.15 share.
- top_symbol_percentile: float = 0.20
+ #
+ # Lowered 0.20 -> 0.10 on the evidence of a large monorepo: a 5.3k-file
+ # repo produced 4,996 spotlights inside a 14,027-page wiki. Doubling down
+ # on the strongest decile keeps the pages that say something new and drops
+ # the ones that restate their file's page. Small repos are unaffected in
+ # practice: the selector floors the bucket at one, so a repo with few
+ # public symbols still gets a spotlight.
+ top_symbol_percentile: float = 0.10
+ # NOTE: read by nothing today. File pages are deliberately not rationed
+ # (see selection/selector.py::select_pages -- the concept partition is a
+ # total cover of the production files). Kept because bounding the file
+ # bucket is a live question on very large repos, but bounding it is a
+ # design decision, not a default change.
file_page_top_percentile: float = 0.10
file_page_min_symbols: int = 1
skip_trivial_files: bool = True
diff --git a/packages/core/src/repowise/core/generation/selection/selector.py b/packages/core/src/repowise/core/generation/selection/selector.py
index c011f2c94..58c357613 100644
--- a/packages/core/src/repowise/core/generation/selection/selector.py
+++ b/packages/core/src/repowise/core/generation/selection/selector.py
@@ -286,7 +286,10 @@ def _build_symbol_candidates(
# slice by PageRank. This used to fall out of the coverage budget's 0.15
# share; with nothing costing tokens there is no budget to fall out of, so
# the percentile that always existed on the config now does the bounding.
- pct = getattr(inputs.config, "top_symbol_percentile", 0.20) or 0.0
+ # Fallback tracks GenerationConfig.top_symbol_percentile; a config object
+ # predating the field must not silently select a wider slice than the
+ # declared default.
+ pct = getattr(inputs.config, "top_symbol_percentile", 0.10) or 0.0
if pct <= 0:
return []
if pct >= 1.0:
diff --git a/tests/unit/generation/test_models.py b/tests/unit/generation/test_models.py
index a87c27026..a7c533f3d 100644
--- a/tests/unit/generation/test_models.py
+++ b/tests/unit/generation/test_models.py
@@ -152,7 +152,7 @@ def test_generation_config_defaults():
assert config.cache_enabled is True
assert config.staleness_threshold_days == 7
assert config.expiry_threshold_days == 30
- assert config.top_symbol_percentile == 0.20
+ assert config.top_symbol_percentile == 0.10
assert config.large_file_source_pct == 0.4
assert config.reasoning == "auto"
diff --git a/tests/unit/generation/test_selection_contract.py b/tests/unit/generation/test_selection_contract.py
index bcb3576aa..db7c5eaa8 100644
--- a/tests/unit/generation/test_selection_contract.py
+++ b/tests/unit/generation/test_selection_contract.py
@@ -193,6 +193,28 @@ def test_spotlights_are_bounded_by_the_percentile():
assert tenth.symbol_spotlights == half.symbol_spotlights[: len(tenth.symbol_spotlights)]
+def test_default_config_takes_the_top_symbol_decile():
+ """The stock default is the bound large repos actually get.
+
+ A 5.3k-file monorepo produced 4,996 spotlights inside a 14,027-page wiki at
+ the old 0.20. The bucket restates what each symbol's file page already says,
+ so the default keeps the strongest decile.
+ """
+ parsed, pagerank, betweenness, community = _build_synthetic_repo(100)
+ total_symbols = sum(len(p.symbols) for p in parsed)
+
+ sel = select_pages(_inputs(parsed, pagerank, betweenness, community, GenerationConfig()))
+
+ assert len(sel.symbol_spotlights) == int(total_symbols * 0.10)
+
+
+def test_small_repo_still_gets_a_spotlight_at_the_default():
+ """The floor of one keeps a tiny repo from losing the bucket entirely."""
+ parsed, pagerank, betweenness, community = _build_synthetic_repo(1)
+ sel = select_pages(_inputs(parsed, pagerank, betweenness, community, GenerationConfig()))
+ assert len(sel.symbol_spotlights) >= 1
+
+
def test_module_bucket_is_never_rationed():
"""The concept partition is total, so every group is emitted."""
parsed, pagerank, betweenness, community = _build_synthetic_repo(300)