Skip to content

Commit e85287c

Browse files
committed
fix(diffctx): hub dampening + noise filter fixes — 98→64 failures
1 parent f2e6f9e commit e85287c

5 files changed

Lines changed: 17 additions & 16 deletions

File tree

src/treemapper/diffctx/filtering.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
_PROXIMITY_FLOOR_MAX = 0.01
1414
_PROXIMITY_HALF_DECAY = 50
1515
_DEFINITION_PROXIMITY_HALF_DECAY = 5
16-
_HUB_REVERSE_THRESHOLD = 3
16+
_HUB_REVERSE_THRESHOLD = 2
1717
_MAX_CONTEXT_FRAGMENTS_PER_FILE = 10
18-
_LOW_RELEVANCE_THRESHOLD = 0.005
18+
_LOW_RELEVANCE_THRESHOLD = 0.02
1919
_SIZE_PENALTY_BASE_TOKENS = 100
2020
_SIZE_PENALTY_EXPONENT = 0.5
2121

@@ -96,10 +96,10 @@ def _find_hub_noise_paths(
9696

9797
noise_counts: dict[Path, int] = {}
9898
for deps in reverse_deps.values():
99-
if len(deps) > _HUB_REVERSE_THRESHOLD:
99+
if len(deps) >= _HUB_REVERSE_THRESHOLD:
100100
for dep in deps:
101101
noise_counts[dep] = noise_counts.get(dep, 0) + 1
102-
return {p for p, count in noise_counts.items() if count >= 3 and p not in direct_edge_paths}
102+
return {p for p, count in noise_counts.items() if count >= 1 and p not in direct_edge_paths}
103103

104104

105105
def _find_config_generic_code_files(

src/treemapper/diffctx/graph.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def build_graph(fragments: list[Fragment], repo_root: Path | None = None) -> Gra
8484
_SUPPRESSION_EXEMPT = frozenset({"semantic", "structural", "test_edge"})
8585

8686

87+
_HUB_OUT_DEGREE_THRESHOLD = 3
88+
89+
8790
def _apply_hub_suppression(
8891
edges: dict[tuple[FragmentId, FragmentId], float],
8992
edge_categories: dict[tuple[FragmentId, FragmentId], str],
@@ -110,4 +113,14 @@ def _apply_hub_suppression(
110113
weight = weight / max(1.0, math.log(1 + deg))
111114
suppressed[(src, dst)] = weight
112115

116+
sem_out_degree: dict[FragmentId, int] = {}
117+
for (src, _dst), cat in edge_categories.items():
118+
if cat == "semantic":
119+
sem_out_degree[src] = sem_out_degree.get(src, 0) + 1
120+
121+
for src, dst in list(suppressed.keys()):
122+
out_deg = sem_out_degree.get(src, 0)
123+
if out_deg >= _HUB_OUT_DEGREE_THRESHOLD and edge_categories.get((src, dst)) == "semantic":
124+
suppressed[(src, dst)] = suppressed[(src, dst)] / math.sqrt(out_deg)
125+
113126
return suppressed

tests/cases/diff/julia_003_project_toml.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,3 @@ oracle:
275275
- no_global_3
276276
- no_global_4
277277
- no_global_5
278-
xfail:
279-
category: null
280-
reason: TOML fragmentation — version bump line not included in selected [deps] fragment
281-
issue: null

tests/cases/diff/regression_003_large_config_fragmentation.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,3 @@ oracle:
158158
allowed: []
159159
forbidden:
160160
- no_global_0
161-
xfail:
162-
category: null
163-
reason: package.json fragmentation — config files need better merge strategy
164-
issue: null

tests/cases/diff/regression_007_migration_enum_tracing.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,3 @@ oracle:
342342
- no_global_13
343343
- no_global_14
344344
- no_global_15
345-
xfail:
346-
category: null
347-
reason: Enum fragment truncated under budget pressure — QUARTER value missing
348-
issue: null

0 commit comments

Comments
 (0)