# PR #3184 — delete 6 dead advanced_search_system files + 17 test files

Components deleted in PR #3184 (see that PR for the full pre-deletion code —
this file only summarises what was novel).

All six were unreachable from `search_system_factory.py` and had zero
production imports at deletion; each was orphaned experimental work.
Multi-round subagent novelty audit confirmed every file before deletion.

---

## Component: `AdaptiveQueryGenerator`

- File deleted: `src/local_deep_research/advanced_search_system/query_generation/adaptive_query_generator.py` (405 LOC at deletion).
- Reachability: no producers or consumers outside the module.
- Closest reachable successors: `SmartQueryStrategy` (`src/local_deep_research/advanced_search_system/strategies/smart_query_strategy.py`) for LLM-driven query synthesis, and `EnhancedEvidenceBasedStrategy` (`evidence_based_strategy_v2.py`) for pattern learning.

### Useful ideas from the pre-deletion version

- **Hand-curated query-template library with hardcoded success rates** — a small registry of query shapes (entity+property+location, event+temporal+statistic, name+comparison) seeded at 0.6–0.7 success and updated from usage. Superseded by v2's `QueryPattern` dataclass doing the same thing, though less granular.
- **LLM-synonym semantic-expansion cache** — for each constraint value, fetched 3 alternative phrasings once and built `(term OR syn1 OR syn2)` queries from them. Not actively exercised anywhere today; v2 has a "semantic_expansion" pattern name but uses static templates.
- **Constraint-tuple success tracking** — counted which *combinations* of constraint types led to successful candidate discoveries (not just individual constraints) and sorted by frequency. This combination-ordering heuristic is absent in successors.
- **Type-specific single-constraint fallback templates** — hardcoded fallback queries for each constraint type (e.g. `'"{value}" names list'` for `NAME_PATTERN`, `'"{value}" incidents accidents'` for `EVENT`) guaranteeing query generation even when multi-constraint templates fail. Successors regenerate via LLM, losing the guaranteed-coverage floor.
- **4-tier on-demand fallback escalation** — simplify → broaden (AND → OR) → decompose to single constraints → LLM-generated alternatives. `SmartQueryStrategy._generate_query_variations` generates variants up front instead, which is cheaper but less reactive.

### Why deletion was safe

v2 and `SmartQueryStrategy` reimplement the most important pieces (pattern learning, semantic expansion concept) at coarser granularity. Type-specific hardcoded templates are replaced by general LLM synthesis — flexible but loses guaranteed-minimal-coverage.

### Recovery path

If the semantic-expansion cache or combination-tuple learning proves valuable in benchmarks, add it as an optional flag on `EnhancedEvidenceBasedStrategy` and wire it into `_update_patterns()`.

---

## Component: `DiversityManager`

- File deleted: `src/local_deep_research/advanced_search_system/source_management/diversity_manager.py` (613 LOC at deletion).
- Reachability: zero references across `src/` and `tests/`.
- Closest reachable successor: `EnhancedEvidenceBasedStrategy._calculate_source_diversity` (`evidence_based_strategy_v2.py` ~lines 887-909). The successor does a fraction of what the deleted file did.

### Useful ideas from the pre-deletion version

This was the richest file in the PR by far — nine distinct ideas worth flagging:

- **Multi-dimensional source profiling** — per-source record of URL, domain, type, credibility, specialties, temporal coverage, geographic focus, unified in one profile object. Successor tracks only name + usage stats.
- **Structured `DiversityMetrics` dataclass** — separate scores for type, temporal, geographic, credibility distribution plus a specialty-coverage breakdown. Successor collapses everything into one entropy aggregate.
- **Credibility scoring with domain heuristics** — source-type base scores (academic 0.9 / government 0.85 / news 0.7 / wiki 0.75 / blog 0.5 / forum 0.4 / social 0.3) adjusted by domain signals (HTTPS, presence of citations, author info). No equivalent today.
- **LLM-driven source-type detection** — content-excerpt prompt to classify ambiguous sources instead of pattern-matching URLs. No equivalent today.
- **Temporal and geographic extraction from content** — regex + content analysis to derive year range and geographic focus. No equivalent today.
- **Diversity gap identification + actionable recommendations** — explicitly detected missing types / regions / time ranges and generated search modifiers to fill them. No recommendation engine anywhere today.
- **Source-effectiveness feedback loop** — boosted credibility on constraint satisfaction; tracked per-source evidence quality and timestamps. Successor tracks count + success rate only.
- **Constraint-aware source selection** — preferred specialised sources per constraint type (academic for properties, IMDB for statistics, Wikipedia for locations). Successor uses generic least-used-first.
- **Diversity-preserving selection** — refused to add an Nth source of one type if another type was underrepresented. Score-ranking alone doesn't do this.

### Why deletion was safe

Orphaned experimental system. No caller invoked any of `select_diverse_sources`, `recommend_additional_sources`, `calculate_diversity_metrics`, or `track_source_effectiveness`. Production strategies use the simpler entropy-based balancing in v2 plus category-based candidate diversity in `DiversityExplorer`.

### Recovery path

If source-profile coherence or credibility heuristics become necessary, reintroduce the `type_priorities` mapping and credibility-enhancement logic as composable helpers on `EnhancedEvidenceBasedStrategy`, not as a standalone manager.

---

## Component: `CrossConstraintManager`

- File deleted: `src/local_deep_research/advanced_search_system/search_optimization/cross_constraint_manager.py` (624 LOC at deletion).
- Reachability: zero references anywhere.
- Closest reachable successor: `EnhancedEvidenceBasedStrategy._analyze_constraint_relationships` (`evidence_based_strategy_v2.py` ~lines 836-850). Does far less.

### Useful ideas from the pre-deletion version

- **Typed constraint relationships** — pairwise `ConstraintRelationship` classified as `complementary / dependent / exclusive` via LLM with a strength score in `[0, 1]`. Successor only tracks untyped adjacency lists.
- **Three-layer constraint clustering** — type-based → relationship-graph-connected-component → LLM-driven semantic clustering, with a cluster-coherence score (weighted average relationship strength × cluster size). No equivalent today.
- **Progressive multi-constraint query generation** — built a family of queries ramping up constraint count (top-2, then top-3, …) rather than generating one combined query. Not replicated in successors.
- **Pairwise cross-validation queries** — dedicated per-pair queries of the form "does candidate satisfy constraint A *and* constraint B together?" Absent today.
- **Cross-constraint candidate validation** — joint-confidence scoring that explicitly boosted complementary constraint pairs. Successors do per-constraint evidence gathering without joint coupling.

### Why deletion was safe

Pure search-optimization layer that was never wired into the factory. The core multi-constraint mechanics (pairing, combined searches, evidence aggregation) are now inline methods on `EnhancedEvidenceBasedStrategy` and the former `ImprovedEvidenceBasedStrategy`; the relationship-typing + clustering-coherence content is genuinely lost, but with no benchmark data it's not clear it was paying for itself.

### Recovery path

If relationship typing becomes load-bearing, rebuild as a mixin on `EnhancedEvidenceBasedStrategy` reusing the `ConstraintRelationship` / `ConstraintCluster` dataclass shapes from the pre-deletion file. Don't restore the 624-LOC parallel manager.

---

## Component: `IntelligentConstraintRelaxer`

- File deleted: `src/local_deep_research/advanced_search_system/constraint_checking/intelligent_constraint_relaxer.py` (501 LOC at deletion).
- Reachability: not imported anywhere.
- Closest reachable successors: `ConstrainedSearchStrategy._rank_constraints_by_restrictiveness` and `ParallelConstrainedStrategy._create_relaxed_combinations`.

### Useful ideas from the pre-deletion version

- **Explicit constraint-type priority hierarchy** — hardcoded priority map (`NAME_PATTERN=10, STATISTIC=3, COMPARISON=1`, etc.) distinguishing "essential, never relax" from "safe to drop first." Successors use a generic restrictiveness score based on length/presence-of-numbers; no semantic-importance knowledge.
- **Progressive relaxation with `min_constraints=2` floor** — generated relaxations in priority order (drop 1 low-priority, then 2, then 3) while preserving enough structure for the query to mean something. Successors skip to binary phases (strict → relaxed → individual).
- **Type-specific semantic variations** — four dedicated relaxers (STATISTIC / COMPARISON / TEMPORAL / PROPERTY) producing semantically-aware alternatives: ±10% / ±20% / ±50% tolerance bands for statistics, term mappings like "times more" → "significantly more" for comparisons, year → decade → year-range for temporal. Successors strip constraints to bare values, losing these mappings.
- **Rejection-impact analysis** — `analyze_relaxation_impact` labelled each relaxation as high/low-impact with a user-facing warning ("High-priority constraints removed. Results may be less accurate."). No equivalent tracing today.

### Why deletion was safe

Ranking by restrictiveness and phased-search fallback together cover the "coarse" relaxation shape without the specialised class. The per-type semantic variations are less sophisticated now, but the codebase prioritises breadth over depth of relaxation.

### Recovery path

Put the constraint-type-to-priority map on `Constraint.is_critical()` (in `base_constraint.py`) as a lookup table. If the per-type variation logic matters later, port the four `_relax_*_constraint` method bodies into a helper used by `ConstrainedSearchStrategy` — don't restore the file.

---

## Component: `BrowseCompAnswerDecoder`

- File deleted: `src/local_deep_research/advanced_search_system/answer_decoding/browsecomp_answer_decoder.py` (422 LOC at deletion).
- Reachability: exported in `answer_decoding/__init__.py` at deletion but never instantiated anywhere in production code.
- Closest reachable successor: dataset-level decryption helpers in `src/local_deep_research/benchmarks/datasets/utils.py` and `browsecomp.py` (XOR + hardcoded-key fallback only).

### Useful ideas from the pre-deletion version

- **Multi-scheme encoding detection pipeline** — attempted base64, hex, URL-encoding, ROT13, and Caesar in one pattern-driven sweep. Successor only handles XOR+base64, which is sufficient for current BrowseComp datasets but not obviously future-proof.
- **Caesar cipher scored by an English-frequency heuristic** — ranked shifts 1–25 using letter-frequency scoring (top-10 letters +2, top-20 +1) plus common-word bonuses, returning only shifts above threshold. More general than the hardcoded-key lookup in the successor.
- **Plaintext-vs-encoded heuristics** — short-answer detection, English-indicator word presence, year/money/name/percentage regex, character-diversity floor. Useful for avoiding false decoding of legitimate plaintext answers; no equivalent today.
- **Character-distribution answer validation** — ≥80% printable, no control characters, ≥30% letters, <50% punctuation. Successor's range check (ASCII 32–126 only) is much looser.
- **`analyze_answer_encoding` diagnostic mode** — returned a full per-scheme breakdown of matches, decodings, and validity. Debug tool, not production-critical.

### Why deletion was safe

The decoder was only a hypothetical extension layer; real BrowseComp decryption happens at dataset load time with XOR+password-derived keys. No benchmark runner or strategy depended on it.

### Recovery path

If a dataset arrives using Caesar, ROT13, or multi-scheme encoding, lift the `_decode_caesar` / `_english_score` functions and the plaintext heuristics from the pre-deletion file into `benchmarks/datasets/utils.py`. Don't restore the whole decoder module.

---

## Component: `EvidenceRequirements` (and its helpers)

- File deleted: `src/local_deep_research/advanced_search_system/evidence/requirements.py` (122 LOC at deletion).
- Reachability: exported in `evidence/__init__.py` but never imported or instantiated anywhere.
- Closest reachable successor: `EvidenceEvaluator` (`evidence/evaluator.py`) + `base_evidence.py`.

### Useful ideas from the pre-deletion version

- **Per-constraint-type confidence floors** — distinct minimum-confidence thresholds per constraint type: `STATISTIC=0.8, EVENT=0.7, PROPERTY=0.6, NAME_PATTERN=0.5`. Current code uses a single global threshold (typically 0.85 or factory-default 0.95) for all types, losing this nuance.
- **Per-constraint preferred/acceptable source guidance** — hand-curated source-type preferences per constraint (e.g. `NAME_PATTERN` → etymology / linguistic_analysis; `STATISTIC` → government databases). Never made it into retrieval or evaluation.

### Why deletion was safe

Never called. `EvidenceEvaluator` uses `EvidenceType.base_confidence` in `base_evidence.py` and per-match score adjustments, bypassing constraint-typed requirements entirely.

### Recovery path

If constraint-aware confidence floors prove useful, add a `constraint_type` kwarg to `EvidenceEvaluator.extract_evidence` and apply the per-type threshold there. Don't restore a standalone class.
