Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
refactor(entry-points): give the execution-start candidacy rule one owner (#1533)
Swati Ahujad21066125f7e
diff --git a/packages/core/src/repowise/core/analysis/kg_curation.py b/packages/core/src/repowise/core/analysis/kg_curation.pyindex 33f4302da..d063ad1f6 100644--- a/packages/core/src/repowise/core/analysis/kg_curation.py+++ b/packages/core/src/repowise/core/analysis/kg_curation.py@@ -36,7 +36,7 @@ from repowise.core.generation.entry_points import (CONVENTIONAL_ENTRY_STEMS as _CONVENTIONAL_ENTRY_STEMS,)from repowise.core.generation.entry_points import (- is_glue_leaf,+ not_an_execution_start,rank_entry_points,)from repowise.core.generation.layers import (@@ -66,12 +66,6 @@ _FIXTURE_CAMEL_RES = _LANG_REGISTRY.camel_fixture_res_by_extension()# Test-project dir suffixes (.Tests/.Specs) — when present, the suite's# face must come from inside one._TEST_PROJECT_DIR_SUFFIXES: tuple[str, ...] = _LANG_REGISTRY.test_dir_suffixes()-# Config/markup/data + infra languages — a server.json or a Dockerfile-# describes or wires the system, it is never where execution starts, so it-# never belongs on the orientation entry-point list.-_NON_CODE_ENTRY_LANGUAGES: frozenset[str] = (- _LANG_REGISTRY.config_languages() | _LANG_REGISTRY.infra_languages()-)# Honest-degradation thresholds. Density = (imports + tested_by)# edges per dominant-language file — the same definition the validation@@ -873,13 +867,6 @@ def _curate_entry_points(except Exception: # pragma: no cover - defensivebetweenness = {}- def _not_an_execution_start(path: str, language: str) -> bool:- # Config/data files (server.json) describe the system and deep- # generic-glue leaves (a resolver's index.py) dispatch within it —- # neither is where a reader enters. Barrel demotion is handled- # separately (it mutates tags), so this covers only candidacy.- return language in _NON_CODE_ENTRY_LANGUAGES or is_glue_leaf(path)-candidates: list[tuple[str, float, float]] = []for node in kg.nodes:nid = node.get("id", "")@@ -902,7 +889,7 @@ def _curate_entry_points(new_tags.append("barrel")node["tags"] = new_tagscontinue- if _not_an_execution_start(path, language):+ if not_an_execution_start(path, language):continuecandidates.append((path, pagerank.get(path, 0.0), betweenness.get(path, 0.0)))@@ -919,7 +906,7 @@ def _curate_entry_points(pf = pf_by_path.get(path)if pf is not None and _is_barrel(pf):continue- if _not_an_execution_start(path, language):+ if not_an_execution_start(path, language):continuecandidates.append((path, pagerank.get(path, 0.0), betweenness.get(path, 0.0)))diff --git a/packages/core/src/repowise/core/generation/entry_points.py b/packages/core/src/repowise/core/generation/entry_points.pyindex f763c5e0f..931c46d8d 100644--- a/packages/core/src/repowise/core/generation/entry_points.py+++ b/packages/core/src/repowise/core/generation/entry_points.py@@ -42,6 +42,13 @@ SHALLOW_ENTRY_DEPTH = 1# no DB / graph / LLM dependency.CONVENTIONAL_ENTRY_STEMS: frozenset[str] = _LANG_REGISTRY.entry_filename_stems() - GLUE_STEMS+# Config/markup/data + infra languages — a server.json or a Dockerfile describes+# or wires the system, it is never where execution starts, so it never belongs+# on the orientation entry-point list.+NON_CODE_ENTRY_LANGUAGES: frozenset[str] = (+ _LANG_REGISTRY.config_languages() | _LANG_REGISTRY.infra_languages()+)+def entry_point_depth(path: str) -> int:"""Directory depth — 0 for a root file, 1 for one level deep, etc."""@@ -61,6 +68,24 @@ def is_glue_leaf(path: str) -> bool:)+def not_an_execution_start(path: str, language: str) -> bool:+ """True for a file that cannot be where a reader enters the system.++ Config/data files (``server.json``) describe the system and deep+ generic-glue leaves (a resolver's ``index.py``) dispatch within it —+ neither is an execution start.++ **Not the whole candidacy rule.** Callers apply their own further+ exclusions beside this one: the knowledge-graph curator drops adjacent+ layers, support paths and re-export barrels itself, and+ :func:`~repowise.core.generation.tour.score_entry_points` withholds its+ entry bonuses over a *wider* language set (it adds unnormalized aliases+ from older indexes). This owns only the two conditions above, so that+ the curator and the wiki surfaces answer them the same way.+ """+ return language in NON_CODE_ENTRY_LANGUAGES or is_glue_leaf(path)++def _name_bucket(path: str, conventional_stems: frozenset[str]) -> int:"""0 = conventional entry name, 1 = neutral, 2 = generic glue stem."""stem = PurePosixPath(path).stem.lower()@@ -144,7 +169,7 @@ def orientation_entry_points(repo_structure: Any, *, limit: int | None = None) -candidacy is the larger defect. ``repo_structure.entry_points`` carries``.github/workflows/main.yml``, ``README.md`` and test files, so somerepos lead with one whatever the order. The knowledge-graph curator drops- those (``kg_curation._not_an_execution_start``) and the wiki surfaces do+ those (:func:`not_an_execution_start`) and the wiki surfaces donot; sharing that rule is the follow-up. Same for the heuristic's ownfalse positives: ``app`` is a generic entry stem, so a React``src/components/App.tsx`` is published as an execution entry point, as isdiff --git a/tests/unit/generation/test_entry_points.py b/tests/unit/generation/test_entry_points.pyindex 1982ca238..82215f9cf 100644--- a/tests/unit/generation/test_entry_points.py+++ b/tests/unit/generation/test_entry_points.py@@ -7,6 +7,7 @@ from repowise.core.generation.entry_points import (entry_point_depth,entry_point_rank_key,is_glue_leaf,+ not_an_execution_start,rank_entry_points,)@@ -35,6 +36,33 @@ def test_is_glue_leaf_only_for_deep_generic_stems():assert not is_glue_leaf("a/b/c/d/main.py")+def test_not_an_execution_start_is_language_or_glue_leaf():+ # Config/data and infra languages describe or wire the system.+ assert not_an_execution_start("api/server.json", "json")+ assert not_an_execution_start("deploy/Dockerfile", "dockerfile")+ # Deep generic-glue leaves dispatch within it.+ assert not_an_execution_start("core/ingestion/resolvers/dotnet/index.py", "python")+ # A real code entry is neither, at any depth.+ assert not not_an_execution_start("src/main.py", "python")+ assert not not_an_execution_start("a/b/c/d/main.py", "python")+ # Only a *shallow* glue stem survives candidacy. A monorepo package barrel+ # is dropped here even though ``orientation_entry_points`` keeps it by+ # ranking it last — candidacy and ordering answer different questions.+ assert not not_an_execution_start("src/index.ts", "typescript")+ assert not_an_execution_start("packages/cli/src/index.ts", "typescript")+++def test_the_curator_calls_the_shared_rule_not_a_copy():+ # The curator's output is unchanged *by construction* only while it holds+ # this exact object; a re-inlined copy reopens the divergence the lift+ # closed. Scope, honestly: this pins the module binding, not the two call+ # sites. A copy that left the import in place still passes here — ruff's+ # unused-import rule is what catches that half.+ from repowise.core.analysis import kg_curation++ assert kg_curation.not_an_execution_start is not_an_execution_start++def test_glue_leaf_never_outranks_a_real_entry():# The .NET resolver index.py is highly central (high pagerank+betweenness)# but must rank below a shallow, conventionally-named main.py.