~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
test: add 53 high-value tests for EvidenceRequirements (#2576)
LearningCircuit006f3ffdef66
diff --git a/tests/advanced_search_system/candidates/__init__.py b/tests/advanced_search_system/candidates/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/tests/advanced_search_system/candidates/test_base_candidate_high_value.py b/tests/advanced_search_system/candidates/test_base_candidate_high_value.pynew file mode 100644index 0000000000..a6d9015944--- /dev/null+++ b/tests/advanced_search_system/candidates/test_base_candidate_high_value.py@@ -0,0 +1,262 @@+"""+High-value tests for the Candidate dataclass and its methods.++Tests cover:+- Candidate dataclass construction and defaults+- add_evidence() behavior+- calculate_score() with various constraint/evidence combinations+- get_unverified_constraints() filtering+- get_weak_evidence() filtering with thresholds+"""++import pytest++from local_deep_research.advanced_search_system.candidates.base_candidate import (+ Candidate,+)+from local_deep_research.advanced_search_system.constraints.base_constraint import (+ Constraint,+ ConstraintType,+)+from local_deep_research.advanced_search_system.evidence.base_evidence import (+ Evidence,+ EvidenceType,+)+++# ---------------------------------------------------------------------------+# Helpers+# ---------------------------------------------------------------------------+++def _make_constraint(cid: str, weight: float = 1.0) -> Constraint:+ return Constraint(+ id=cid,+ type=ConstraintType.PROPERTY,+ description=f"constraint {cid}",+ value=f"value-{cid}",+ weight=weight,+ )+++def _make_evidence(confidence: float = 0.8) -> Evidence:+ return Evidence(+ claim="test claim",+ type=EvidenceType.DIRECT_STATEMENT,+ source="test source",+ confidence=confidence,+ )+++# ---------------------------------------------------------------------------+# 1. Candidate dataclass construction+# ---------------------------------------------------------------------------+++class TestCandidateDataclass:+ def test_required_name_field(self):+ c = Candidate(name="answer-1")+ assert c.name == "answer-1"++ def test_default_evidence_is_empty_dict(self):+ c = Candidate(name="a")+ assert c.evidence == {}+ assert isinstance(c.evidence, dict)++ def test_default_score_is_zero(self):+ c = Candidate(name="a")+ assert c.score == 0.0++ def test_default_metadata_is_empty_dict(self):+ c = Candidate(name="a")+ assert c.metadata == {}+ assert isinstance(c.metadata, dict)++ def test_distinct_default_dicts_per_instance(self):+ c1 = Candidate(name="a")+ c2 = Candidate(name="b")+ c1.evidence["x"] = _make_evidence()+ assert "x" not in c2.evidence+++# ---------------------------------------------------------------------------+# 2. add_evidence()+# ---------------------------------------------------------------------------+++class TestAddEvidence:+ def test_adds_evidence_keyed_by_constraint_id(self):+ c = Candidate(name="a")+ ev = _make_evidence(0.9)+ c.add_evidence("c1", ev)+ assert "c1" in c.evidence+ assert c.evidence["c1"] is ev++ def test_overwrites_existing_evidence(self):+ c = Candidate(name="a")+ ev1 = _make_evidence(0.5)+ ev2 = _make_evidence(0.9)+ c.add_evidence("c1", ev1)+ c.add_evidence("c1", ev2)+ assert c.evidence["c1"] is ev2++ def test_multiple_constraint_ids(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.3))+ c.add_evidence("c2", _make_evidence(0.7))+ assert len(c.evidence) == 2+++# ---------------------------------------------------------------------------+# 3. calculate_score()+# ---------------------------------------------------------------------------+++class TestCalculateScore:+ def test_empty_constraints_returns_zero(self):+ c = Candidate(name="a")+ assert c.calculate_score([]) == 0.0++ def test_single_constraint_full_confidence(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(1.0))+ con = _make_constraint("c1", weight=1.0)+ score = c.calculate_score([con])+ assert score == pytest.approx(1.0)++ def test_weighted_average_two_constraints(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.8))+ c.add_evidence("c2", _make_evidence(0.6))+ cons = [_make_constraint("c1", 1.0), _make_constraint("c2", 1.0)]+ score = c.calculate_score(cons)+ # (0.8*1 + 0.6*1) / (1+1) = 0.7+ assert score == pytest.approx(0.7)++ def test_missing_evidence_counts_as_zero(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(1.0))+ cons = [_make_constraint("c1", 1.0), _make_constraint("c2", 1.0)]+ score = c.calculate_score(cons)+ # (1.0*1 + 0) / 2 = 0.5+ assert score == pytest.approx(0.5)++ def test_all_evidence_present(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.9))+ c.add_evidence("c2", _make_evidence(0.7))+ c.add_evidence("c3", _make_evidence(0.5))+ cons = [+ _make_constraint("c1", 1.0),+ _make_constraint("c2", 1.0),+ _make_constraint("c3", 1.0),+ ]+ score = c.calculate_score(cons)+ assert score == pytest.approx((0.9 + 0.7 + 0.5) / 3.0)++ def test_different_weights(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(1.0))+ c.add_evidence("c2", _make_evidence(0.5))+ cons = [_make_constraint("c1", 3.0), _make_constraint("c2", 1.0)]+ score = c.calculate_score(cons)+ # (1.0*3 + 0.5*1) / (3+1) = 3.5/4 = 0.875+ assert score == pytest.approx(0.875)++ def test_zero_total_weight_returns_zero(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.9))+ cons = [_make_constraint("c1", 0.0)]+ score = c.calculate_score(cons)+ assert score == pytest.approx(0.0)++ def test_score_is_stored_on_instance(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.6))+ cons = [_make_constraint("c1", 1.0)]+ result = c.calculate_score(cons)+ assert c.score == result+++# ---------------------------------------------------------------------------+# 4. get_unverified_constraints()+# ---------------------------------------------------------------------------+++class TestGetUnverifiedConstraints:+ def test_all_unverified(self):+ c = Candidate(name="a")+ cons = [_make_constraint("c1"), _make_constraint("c2")]+ unverified = c.get_unverified_constraints(cons)+ assert len(unverified) == 2++ def test_all_verified(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence())+ c.add_evidence("c2", _make_evidence())+ cons = [_make_constraint("c1"), _make_constraint("c2")]+ unverified = c.get_unverified_constraints(cons)+ assert unverified == []++ def test_mixed_verified_and_unverified(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence())+ cons = [+ _make_constraint("c1"),+ _make_constraint("c2"),+ _make_constraint("c3"),+ ]+ unverified = c.get_unverified_constraints(cons)+ ids = [u.id for u in unverified]+ assert ids == ["c2", "c3"]++ def test_empty_constraints_list(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence())+ assert c.get_unverified_constraints([]) == []+++# ---------------------------------------------------------------------------+# 5. get_weak_evidence()+# ---------------------------------------------------------------------------+++class TestGetWeakEvidence:+ def test_all_strong(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.9))+ c.add_evidence("c2", _make_evidence(0.8))+ assert c.get_weak_evidence() == []++ def test_all_weak(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.1))+ c.add_evidence("c2", _make_evidence(0.3))+ weak = c.get_weak_evidence()+ assert set(weak) == {"c1", "c2"}++ def test_mixed_strong_and_weak(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.9))+ c.add_evidence("c2", _make_evidence(0.2))+ weak = c.get_weak_evidence()+ assert weak == ["c2"]++ def test_default_threshold_is_half(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.5))+ c.add_evidence("c2", _make_evidence(0.49))+ weak = c.get_weak_evidence()+ # 0.5 is NOT < 0.5, so only 0.49 is weak+ assert weak == ["c2"]++ def test_custom_threshold(self):+ c = Candidate(name="a")+ c.add_evidence("c1", _make_evidence(0.7))+ c.add_evidence("c2", _make_evidence(0.9))+ weak = c.get_weak_evidence(threshold=0.8)+ assert weak == ["c1"]++ def test_empty_evidence(self):+ c = Candidate(name="a")+ assert c.get_weak_evidence() == []diff --git a/tests/advanced_search_system/evidence/test_base_evidence_high_value.py b/tests/advanced_search_system/evidence/test_base_evidence_high_value.pynew file mode 100644index 0000000000..27ea1322f4--- /dev/null+++ b/tests/advanced_search_system/evidence/test_base_evidence_high_value.py@@ -0,0 +1,202 @@+"""+High-value pure logic tests for base_evidence module.++Tests EvidenceType enum values, base_confidence property,+and Evidence dataclass behavior including defaults and __post_init__.+"""++import pytest+from datetime import datetime++from local_deep_research.advanced_search_system.evidence.base_evidence import (+ Evidence,+ EvidenceType,+)+++# ---------------------------------------------------------------------------+# EvidenceType enum: membership and value strings+# ---------------------------------------------------------------------------+++class TestEvidenceTypeEnum:+ """Tests for EvidenceType enum values."""++ def test_direct_statement_value(self):+ assert EvidenceType.DIRECT_STATEMENT.value == "direct_statement"++ def test_official_record_value(self):+ assert EvidenceType.OFFICIAL_RECORD.value == "official_record"++ def test_research_finding_value(self):+ assert EvidenceType.RESEARCH_FINDING.value == "research_finding"++ def test_news_report_value(self):+ assert EvidenceType.NEWS_REPORT.value == "news_report"++ def test_statistical_data_value(self):+ assert EvidenceType.STATISTICAL_DATA.value == "statistical_data"++ def test_inference_value(self):+ assert EvidenceType.INFERENCE.value == "inference"++ def test_correlation_value(self):+ assert EvidenceType.CORRELATION.value == "correlation"++ def test_speculation_value(self):+ assert EvidenceType.SPECULATION.value == "speculation"++ def test_enum_has_exactly_eight_members(self):+ assert len(EvidenceType) == 8+++# ---------------------------------------------------------------------------+# EvidenceType.base_confidence property+# ---------------------------------------------------------------------------+++class TestEvidenceTypeBaseConfidence:+ """Tests for the base_confidence property on each enum member."""++ @pytest.mark.parametrize(+ "evidence_type, expected_confidence",+ [+ (EvidenceType.DIRECT_STATEMENT, 0.95),+ (EvidenceType.OFFICIAL_RECORD, 0.90),+ (EvidenceType.RESEARCH_FINDING, 0.85),+ (EvidenceType.STATISTICAL_DATA, 0.85),+ (EvidenceType.NEWS_REPORT, 0.75),+ (EvidenceType.INFERENCE, 0.50),+ (EvidenceType.CORRELATION, 0.30),+ (EvidenceType.SPECULATION, 0.10),+ ],+ ids=[+ "direct_statement",+ "official_record",+ "research_finding",+ "statistical_data",+ "news_report",+ "inference",+ "correlation",+ "speculation",+ ],+ )+ def test_base_confidence(self, evidence_type, expected_confidence):+ assert evidence_type.base_confidence == expected_confidence++ def test_highest_confidence_is_direct_statement(self):+ highest = max(EvidenceType, key=lambda t: t.base_confidence)+ assert highest is EvidenceType.DIRECT_STATEMENT++ def test_lowest_confidence_is_speculation(self):+ lowest = min(EvidenceType, key=lambda t: t.base_confidence)+ assert lowest is EvidenceType.SPECULATION+++# ---------------------------------------------------------------------------+# Evidence dataclass: construction, defaults, __post_init__+# ---------------------------------------------------------------------------+++class TestEvidenceDataclass:+ """Tests for the Evidence dataclass."""++ def test_required_fields_only(self):+ ev = Evidence(+ claim="The sky is blue",+ type=EvidenceType.DIRECT_STATEMENT,+ source="observation",+ )+ assert ev.claim == "The sky is blue"+ assert ev.type is EvidenceType.DIRECT_STATEMENT+ assert ev.source == "observation"++ def test_default_confidence_auto_set_from_type(self):+ """When confidence is left at default 0.0, __post_init__ sets it."""+ ev = Evidence(+ claim="claim",+ type=EvidenceType.OFFICIAL_RECORD,+ source="src",+ )+ assert ev.confidence == 0.90++ def test_explicit_confidence_preserved(self):+ """When confidence is explicitly provided (non-zero), it is kept."""+ ev = Evidence(+ claim="claim",+ type=EvidenceType.DIRECT_STATEMENT,+ source="src",+ confidence=0.42,+ )+ assert ev.confidence == 0.42++ def test_default_reasoning_is_none(self):+ ev = Evidence(claim="c", type=EvidenceType.INFERENCE, source="s")+ assert ev.reasoning is None++ def test_default_raw_text_is_none(self):+ ev = Evidence(claim="c", type=EvidenceType.INFERENCE, source="s")+ assert ev.raw_text is None++ def test_default_metadata_is_empty_dict(self):+ ev = Evidence(claim="c", type=EvidenceType.INFERENCE, source="s")+ assert ev.metadata == {}+ assert isinstance(ev.metadata, dict)++ def test_metadata_default_is_not_shared_across_instances(self):+ """Each instance should get its own dict, not a shared mutable default."""+ ev1 = Evidence(claim="c1", type=EvidenceType.INFERENCE, source="s")+ ev2 = Evidence(claim="c2", type=EvidenceType.INFERENCE, source="s")+ ev1.metadata["key"] = "value"+ assert "key" not in ev2.metadata++ def test_timestamp_auto_generated(self):+ ev = Evidence(claim="c", type=EvidenceType.INFERENCE, source="s")+ assert isinstance(ev.timestamp, str)+ # Should be a valid ISO-format timestamp+ parsed = datetime.fromisoformat(ev.timestamp)+ assert isinstance(parsed, datetime)++ def test_timestamp_is_recent(self):+ before = datetime.utcnow()+ ev = Evidence(claim="c", type=EvidenceType.INFERENCE, source="s")+ parsed = datetime.fromisoformat(ev.timestamp.replace("+00:00", ""))+ # Timestamp should be within a few seconds of now+ delta = abs((parsed - before).total_seconds())+ assert delta < 5++ def test_all_fields_set_explicitly(self):+ ev = Evidence(+ claim="test claim",+ type=EvidenceType.SPECULATION,+ source="test source",+ confidence=0.77,+ reasoning="some reasoning",+ raw_text="raw text here",+ metadata={"key": "val"},+ )+ assert ev.claim == "test claim"+ assert ev.type is EvidenceType.SPECULATION+ assert ev.source == "test source"+ assert ev.confidence == 0.77+ assert ev.reasoning == "some reasoning"+ assert ev.raw_text == "raw text here"+ assert ev.metadata == {"key": "val"}++ def test_post_init_each_type_sets_correct_confidence(self):+ """Verify __post_init__ sets the right confidence for every type."""+ for et in EvidenceType:+ ev = Evidence(claim="c", type=et, source="s")+ assert ev.confidence == et.base_confidence, (+ f"Expected {et.base_confidence} for {et.name}, got {ev.confidence}"+ )++ def test_confidence_zero_triggers_auto_set(self):+ """Explicitly passing confidence=0.0 should still trigger auto-set."""+ ev = Evidence(+ claim="c",+ type=EvidenceType.RESEARCH_FINDING,+ source="s",+ confidence=0.0,+ )+ assert ev.confidence == 0.85diff --git a/tests/advanced_search_system/evidence/test_evaluator_high_value.py b/tests/advanced_search_system/evidence/test_evaluator_high_value.pynew file mode 100644index 0000000000..b89198f47f--- /dev/null+++ b/tests/advanced_search_system/evidence/test_evaluator_high_value.py@@ -0,0 +1,234 @@+"""+High-value pure logic tests for EvidenceEvaluator.++Tests cover:+- source_reliability dict entries+- _parse_evidence_response() parsing logic+- _parse_evidence_type() mapping and defaults+- _assess_match_quality() scoring+"""++import pytest+from unittest.mock import MagicMock++from local_deep_research.advanced_search_system.evidence.evaluator import (+ EvidenceEvaluator,+)+from local_deep_research.advanced_search_system.evidence.base_evidence import (+ Evidence,+ EvidenceType,+)+from local_deep_research.advanced_search_system.constraints.base_constraint import (+ Constraint,+ ConstraintType,+)+++def evaluator():+ """Create an EvidenceEvaluator bypassing __init__."""+ obj = EvidenceEvaluator.__new__(EvidenceEvaluator)+ obj.model = MagicMock()+ obj.source_reliability = {+ "official": 1.0,+ "research": 0.95,+ "news": 0.8,+ "community": 0.6,+ "inference": 0.5,+ "speculation": 0.3,+ }+ return obj+++# ---------------------------------------------------------------------------+# source_reliability dict tests+# ---------------------------------------------------------------------------+++class TestSourceReliability:+ """Verify all 6 source_reliability entries."""++ def test_official_reliability(self, evaluator):+ assert evaluator.source_reliability["official"] == 1.0++ def test_research_reliability(self, evaluator):+ assert evaluator.source_reliability["research"] == 0.95++ def test_news_reliability(self, evaluator):+ assert evaluator.source_reliability["news"] == 0.8++ def test_community_reliability(self, evaluator):+ assert evaluator.source_reliability["community"] == 0.6++ def test_inference_reliability(self, evaluator):+ assert evaluator.source_reliability["inference"] == 0.5++ def test_speculation_reliability(self, evaluator):+ assert evaluator.source_reliability["speculation"] == 0.3+++# ---------------------------------------------------------------------------+# _parse_evidence_response() tests+# ---------------------------------------------------------------------------+++class TestParseEvidenceResponse:+ """Test key-value parsing from LLM output."""++ def test_basic_parsing(self, evaluator):+ content = (+ "CLAIM: The lake was formed by glaciers\n"+ "TYPE: direct_statement\n"+ "SOURCE: Wikipedia\n"+ "CONFIDENCE: 0.9\n"+ "REASONING: Clear geological evidence\n"+ "QUOTE: formed during the last ice age"+ )+ result = evaluator._parse_evidence_response(content)+ assert result["claim"] == "The lake was formed by glaciers"+ assert result["type"] == "direct_statement"+ assert result["source"] == "Wikipedia"+ assert result["confidence"] == "0.9"+ assert result["reasoning"] == "Clear geological evidence"+ assert result["quote"] == "formed during the last ice age"++ def test_confidence_regex_extracts_float(self, evaluator):+ content = "CONFIDENCE: approximately 0.85 based on evidence"+ result = evaluator._parse_evidence_response(content)+ assert result["confidence"] == "0.85"++ def test_confidence_integer_extraction(self, evaluator):+ content = "CONFIDENCE: 1"+ result = evaluator._parse_evidence_response(content)+ assert result["confidence"] == "1"++ def test_unknown_keys_ignored(self, evaluator):+ content = (+ "CLAIM: some claim\n"+ "EXTRA_FIELD: should be ignored\n"+ "NOTES: also ignored"+ )+ result = evaluator._parse_evidence_response(content)+ assert "claim" in result+ assert "extra_field" not in result+ assert "notes" not in result++ def test_missing_keys_return_empty_dict(self, evaluator):+ content = "No structured content here at all"+ result = evaluator._parse_evidence_response(content)+ assert isinstance(result, dict)+ assert len(result) == 0++ def test_value_with_colons(self, evaluator):+ """Values containing colons should be preserved after the first split."""+ content = "CLAIM: URL is https://example.com:8080/path"+ result = evaluator._parse_evidence_response(content)+ assert result["claim"] == "URL is https://example.com:8080/path"++ def test_leading_trailing_whitespace_stripped(self, evaluator):+ content = " CLAIM: lots of spaces \n TYPE: inference "+ result = evaluator._parse_evidence_response(content)+ assert result["claim"] == "lots of spaces"+ assert result["type"] == "inference"++ def test_case_insensitive_keys(self, evaluator):+ content = "Claim: mixed case key\nTYPE: speculation"+ result = evaluator._parse_evidence_response(content)+ assert result["claim"] == "mixed case key"+ assert result["type"] == "speculation"+++# ---------------------------------------------------------------------------+# _parse_evidence_type() tests+# ---------------------------------------------------------------------------+++class TestParseEvidenceType:+ """Test evidence type string-to-enum mapping."""++ @pytest.mark.parametrize(+ "type_str,expected",+ [+ ("direct_statement", EvidenceType.DIRECT_STATEMENT),+ ("official_record", EvidenceType.OFFICIAL_RECORD),+ ("research_finding", EvidenceType.RESEARCH_FINDING),+ ("news_report", EvidenceType.NEWS_REPORT),+ ("statistical_data", EvidenceType.STATISTICAL_DATA),+ ("inference", EvidenceType.INFERENCE),+ ("correlation", EvidenceType.CORRELATION),+ ("speculation", EvidenceType.SPECULATION),+ ],+ )+ def test_all_valid_types(self, evaluator, type_str, expected):+ assert evaluator._parse_evidence_type(type_str) == expected++ def test_case_insensitivity(self, evaluator):+ assert (+ evaluator._parse_evidence_type("DIRECT_STATEMENT")+ == EvidenceType.DIRECT_STATEMENT+ )+ assert (+ evaluator._parse_evidence_type("News_Report")+ == EvidenceType.NEWS_REPORT+ )++ def test_unknown_type_defaults_to_speculation(self, evaluator):+ assert (+ evaluator._parse_evidence_type("made_up_type")+ == EvidenceType.SPECULATION+ )++ def test_empty_string_defaults_to_speculation(self, evaluator):+ assert evaluator._parse_evidence_type("") == EvidenceType.SPECULATION+++# ---------------------------------------------------------------------------+# _assess_match_quality() tests+# ---------------------------------------------------------------------------+++class TestAssessMatchQuality:+ """Test match quality scoring between evidence and constraints."""++ def _make_evidence(self, claim: str) -> Evidence:+ return Evidence(+ claim=claim,+ type=EvidenceType.DIRECT_STATEMENT,+ source="test",+ confidence=0.9,+ )++ def _make_constraint(self, value: str) -> Constraint:+ return Constraint(+ id="c1",+ type=ConstraintType.PROPERTY,+ description="test constraint",+ value=value,+ )++ def test_exact_value_match_returns_1(self, evaluator):+ evidence = self._make_evidence("The lake was formed during ice age")+ constraint = self._make_constraint("formed during ice age")+ assert evaluator._assess_match_quality(evidence, constraint) == 1.0++ def test_partial_word_match_returns_0_8(self, evaluator):+ evidence = self._make_evidence("The trail has glacial features")+ constraint = self._make_constraint("glacial ice formations")+ # "glacial" appears in evidence claim+ assert evaluator._assess_match_quality(evidence, constraint) == 0.8++ def test_no_match_returns_0_6(self, evaluator):+ evidence = self._make_evidence("The river flows south")+ constraint = self._make_constraint("volcanic eruption")+ assert evaluator._assess_match_quality(evidence, constraint) == 0.6++ def test_case_insensitive_exact_match(self, evaluator):+ evidence = self._make_evidence("Contains BODY PART in name")+ constraint = self._make_constraint("body part")+ assert evaluator._assess_match_quality(evidence, constraint) == 1.0++ def test_case_insensitive_partial_match(self, evaluator):+ evidence = self._make_evidence("Located near MOUNTAINS")+ constraint = self._make_constraint("rocky mountains area")+ # "mountains" word matches+ assert evaluator._assess_match_quality(evidence, constraint) == 0.8diff --git a/tests/advanced_search_system/evidence/test_requirements_high_value.py b/tests/advanced_search_system/evidence/test_requirements_high_value.pynew file mode 100644index 0000000000..117287821d--- /dev/null+++ b/tests/advanced_search_system/evidence/test_requirements_high_value.py@@ -0,0 +1,187 @@+"""+High-value tests for EvidenceRequirements - pure logic, no mocking needed.++Tests get_requirements() and get_minimum_confidence() static methods+across all ConstraintType values and edge cases.+"""++import pytest++from local_deep_research.advanced_search_system.constraints.base_constraint import (+ ConstraintType,+)+from local_deep_research.advanced_search_system.evidence.requirements import (+ EvidenceRequirements,+)++REQUIRED_KEYS = {"preferred", "acceptable", "sources"}+ALL_CONSTRAINT_TYPES = list(ConstraintType)+++# ---------------------------------------------------------------------------+# get_requirements: structural tests for all 8 constraint types+# ---------------------------------------------------------------------------+++class TestGetRequirementsStructure:+ """Every ConstraintType should return a dict with the correct keys and non-empty lists."""++ @pytest.mark.parametrize("ctype", ALL_CONSTRAINT_TYPES)+ def test_returns_dict_with_required_keys(self, ctype: ConstraintType):+ result = EvidenceRequirements.get_requirements(ctype)+ assert isinstance(result, dict)+ assert set(result.keys()) == REQUIRED_KEYS++ @pytest.mark.parametrize("ctype", ALL_CONSTRAINT_TYPES)+ def test_preferred_is_non_empty_list(self, ctype: ConstraintType):+ result = EvidenceRequirements.get_requirements(ctype)+ assert isinstance(result["preferred"], list)+ assert len(result["preferred"]) > 0++ @pytest.mark.parametrize("ctype", ALL_CONSTRAINT_TYPES)+ def test_acceptable_is_non_empty_list(self, ctype: ConstraintType):+ result = EvidenceRequirements.get_requirements(ctype)+ assert isinstance(result["acceptable"], list)+ assert len(result["acceptable"]) > 0++ @pytest.mark.parametrize("ctype", ALL_CONSTRAINT_TYPES)+ def test_sources_is_non_empty_list(self, ctype: ConstraintType):+ result = EvidenceRequirements.get_requirements(ctype)+ assert isinstance(result["sources"], list)+ assert len(result["sources"]) > 0+++# ---------------------------------------------------------------------------+# get_requirements: specific preferred evidence per type+# ---------------------------------------------------------------------------+++class TestGetRequirementsPreferred:+ """Verify the expected preferred evidence types for key constraint types."""++ def test_property_has_direct_statement_preferred(self):+ result = EvidenceRequirements.get_requirements(ConstraintType.PROPERTY)+ assert "direct_statement" in result["preferred"]++ def test_property_has_official_record_preferred(self):+ result = EvidenceRequirements.get_requirements(ConstraintType.PROPERTY)+ assert "official_record" in result["preferred"]++ def test_name_pattern_has_linguistic_analysis_preferred(self):+ result = EvidenceRequirements.get_requirements(+ ConstraintType.NAME_PATTERN+ )+ assert "linguistic_analysis" in result["preferred"]++ def test_event_has_news_report_preferred(self):+ result = EvidenceRequirements.get_requirements(ConstraintType.EVENT)+ assert "news_report" in result["preferred"]++ def test_statistic_has_statistical_data_preferred(self):+ result = EvidenceRequirements.get_requirements(ConstraintType.STATISTIC)+ assert "statistical_data" in result["preferred"]++ def test_temporal_has_official_record_preferred(self):+ result = EvidenceRequirements.get_requirements(ConstraintType.TEMPORAL)+ assert "official_record" in result["preferred"]++ def test_location_has_geographical_data_preferred(self):+ result = EvidenceRequirements.get_requirements(ConstraintType.LOCATION)+ assert "geographical_data" in result["preferred"]++ def test_comparison_has_statistical_comparison_preferred(self):+ result = EvidenceRequirements.get_requirements(+ ConstraintType.COMPARISON+ )+ assert "statistical_comparison" in result["preferred"]++ def test_existence_has_direct_statement_preferred(self):+ result = EvidenceRequirements.get_requirements(ConstraintType.EXISTENCE)+ assert "direct_statement" in result["preferred"]+++# ---------------------------------------------------------------------------+# get_requirements: default / unknown type fallback+# ---------------------------------------------------------------------------+++class TestGetRequirementsDefault:+ """An unrecognized constraint type should fall back to a safe default."""++ def test_unknown_type_returns_dict_with_required_keys(self):+ fake_type = "not_a_real_type"+ result = EvidenceRequirements.get_requirements(fake_type)+ assert set(result.keys()) == REQUIRED_KEYS++ def test_unknown_type_preferred_is_direct_statement(self):+ fake_type = "not_a_real_type"+ result = EvidenceRequirements.get_requirements(fake_type)+ assert result["preferred"] == ["direct_statement"]++ def test_unknown_type_acceptable_is_inference(self):+ fake_type = "not_a_real_type"+ result = EvidenceRequirements.get_requirements(fake_type)+ assert result["acceptable"] == ["inference"]++ def test_unknown_type_sources_is_general(self):+ fake_type = "not_a_real_type"+ result = EvidenceRequirements.get_requirements(fake_type)+ assert result["sources"] == ["general sources"]+++# ---------------------------------------------------------------------------+# get_minimum_confidence: explicit thresholds+# ---------------------------------------------------------------------------+++class TestGetMinimumConfidence:+ """Verify the explicit confidence thresholds for mapped types."""++ def test_statistic_confidence_is_0_8(self):+ assert (+ EvidenceRequirements.get_minimum_confidence(+ ConstraintType.STATISTIC+ )+ == 0.8+ )++ def test_event_confidence_is_0_7(self):+ assert (+ EvidenceRequirements.get_minimum_confidence(ConstraintType.EVENT)+ == 0.7+ )++ def test_property_confidence_is_0_6(self):+ assert (+ EvidenceRequirements.get_minimum_confidence(ConstraintType.PROPERTY)+ == 0.6+ )++ def test_name_pattern_confidence_is_0_5(self):+ assert (+ EvidenceRequirements.get_minimum_confidence(+ ConstraintType.NAME_PATTERN+ )+ == 0.5+ )+++# ---------------------------------------------------------------------------+# get_minimum_confidence: default threshold for unmapped types+# ---------------------------------------------------------------------------+++class TestGetMinimumConfidenceDefault:+ """Types not in the explicit threshold map should return the default 0.6."""++ @pytest.mark.parametrize(+ "ctype",+ [+ ConstraintType.TEMPORAL,+ ConstraintType.LOCATION,+ ConstraintType.COMPARISON,+ ConstraintType.EXISTENCE,+ ],+ )+ def test_unmapped_type_returns_default_0_6(self, ctype: ConstraintType):+ assert EvidenceRequirements.get_minimum_confidence(ctype) == 0.6