~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
fix(scheduler): correct over-reach relative import + delete stale tests for removed modules (#3537)
LearningCircuita8664539a13c
diff --git a/src/local_deep_research/scheduler/background.py b/src/local_deep_research/scheduler/background.pyindex 2017993350..c3fb08b8f9 100644--- a/src/local_deep_research/scheduler/background.py+++ b/src/local_deep_research/scheduler/background.py@@ -829,7 +829,7 @@ class BackgroundJobScheduler:# Set search context so rate limiting works in both# download_pdfs and extract_text paths- from ...utilities.thread_context import (+ from ..utilities.thread_context import (set_search_context,)diff --git a/tests/advanced_search_system/answer_decoding/test_browsecomp_decoder_high_value.py b/tests/advanced_search_system/answer_decoding/test_browsecomp_decoder_high_value.pydeleted file mode 100644index 8b2890860d..0000000000--- a/tests/advanced_search_system/answer_decoding/test_browsecomp_decoder_high_value.py+++ /dev/null@@ -1,219 +0,0 @@-"""High-value tests for BrowseCompAnswerDecoder internal scoring/validation methods."""--import pytest--from local_deep_research.advanced_search_system.answer_decoding.browsecomp_answer_decoder import (- BrowseCompAnswerDecoder,-)---def decoder():- return BrowseCompAnswerDecoder()---# --- _caesar_shift tests ------class TestCaesarShift:- def test_shift_zero(self, decoder):- assert decoder._caesar_shift("abc", 0) == "abc"-- def test_shift_one_lowercase(self, decoder):- assert decoder._caesar_shift("abc", 1) == "bcd"-- def test_shift_one_uppercase(self, decoder):- assert decoder._caesar_shift("ABC", 1) == "BCD"-- def test_wraparound_lowercase(self, decoder):- assert decoder._caesar_shift("xyz", 3) == "abc"-- def test_wraparound_uppercase(self, decoder):- assert decoder._caesar_shift("XYZ", 3) == "ABC"-- def test_non_alpha_passthrough(self, decoder):- assert decoder._caesar_shift("a1!b", 1) == "b1!c"-- def test_shift_25(self, decoder):- assert decoder._caesar_shift("b", 25) == "a"-- def test_shift_13_rot13(self, decoder):- assert decoder._caesar_shift("hello", 13) == "uryyb"-- def test_mixed_case_and_symbols(self, decoder):- assert decoder._caesar_shift("Hello, World!", 5) == "Mjqqt, Btwqi!"-- def test_empty_string(self, decoder):- assert decoder._caesar_shift("", 10) == ""---# --- _english_score tests ------class TestEnglishScore:- def test_empty_text(self, decoder):- assert decoder._english_score("") == 0.0-- def test_no_letters(self, decoder):- assert decoder._english_score("12345!@#") == 0.0-- def test_common_letters_high_score(self, decoder):- score = decoder._english_score("the rain in spain")- assert score > 0.5-- def test_uncommon_letters_lower_score(self, decoder):- score_common = decoder._english_score("the")- score_uncommon = decoder._english_score("zqx")- assert score_common > score_uncommon-- def test_common_word_bonus(self, decoder):- score_with_words = decoder._english_score("the cat is in the hat")- score_without = decoder._english_score("blrk mnop qrst")- assert score_with_words >= score_without-- def test_single_letter(self, decoder):- score = decoder._english_score("e")- assert score > 0.0-- def test_score_capped_at_one(self, decoder):- score = decoder._english_score(- "the and of to a in is it you that the and of to"- )- assert score <= 1.0---# --- validate_decoded_answer tests ------class TestValidateDecodedAnswer:- def test_empty_string_invalid(self, decoder):- assert decoder.validate_decoded_answer("") is False-- def test_none_invalid(self, decoder):- assert decoder.validate_decoded_answer(None) is False-- def test_whitespace_only_invalid(self, decoder):- assert decoder.validate_decoded_answer(" ") is False-- def test_length_one_valid(self, decoder):- # Single alpha character: length ok, 100% printable, 100% alpha, 0% punct- assert decoder.validate_decoded_answer("A") is True-- def test_length_1000_valid(self, decoder):- text = "Hello world " * 83 + "Hello wo" # 1000 chars- text = text[:1000]- assert len(text.strip()) <= 1000- assert decoder.validate_decoded_answer(text) is True-- def test_length_1001_invalid(self, decoder):- text = "a" * 1001- assert decoder.validate_decoded_answer(text) is False-- def test_low_printable_ratio_invalid(self, decoder):- # Mostly non-printable (control chars with ord > 31 won't trigger ctrl check,- # but let's use non-printable surrogates - actually just use many non-printable)- text = "ab" + "\x00" * 10 # has control chars- assert decoder.validate_decoded_answer(text) is False-- def test_control_characters_invalid(self, decoder):- text = "Hello\x01World"- assert decoder.validate_decoded_answer(text) is False-- def test_tab_newline_allowed(self, decoder):- text = "Hello\tWorld\nFoo Bar"- assert decoder.validate_decoded_answer(text) is True-- def test_low_alpha_ratio_invalid(self, decoder):- text = "1234567890!@#$%^&*()"- assert decoder.validate_decoded_answer(text) is False-- def test_high_punctuation_ratio_invalid(self, decoder):- text = "a!@#$%^&*()!@#$%^&*()"- assert decoder.validate_decoded_answer(text) is False-- def test_normal_text_valid(self, decoder):- assert decoder.validate_decoded_answer("Mount Everest") is True---# --- is_likely_direct_answer tests ------class TestIsLikelyDirectAnswer:- def test_short_answer_plaintext(self, decoder):- assert decoder.is_likely_direct_answer("Yes") is True-- def test_three_char_plaintext(self, decoder):- assert decoder.is_likely_direct_answer("No!") is True-- def test_english_indicator_the(self, decoder):- assert decoder.is_likely_direct_answer("the company") is True-- def test_english_indicator_corporation(self, decoder):- assert decoder.is_likely_direct_answer("Acme Corporation") is True-- def test_multi_word_plaintext(self, decoder):- assert decoder.is_likely_direct_answer("John Smith") is True-- def test_year_pattern(self, decoder):- assert decoder.is_likely_direct_answer("2024") is True-- def test_money_pattern(self, decoder):- assert decoder.is_likely_direct_answer("$500") is True-- def test_name_format_pattern(self, decoder):- assert decoder.is_likely_direct_answer("John Smith") is True-- def test_low_char_diversity_not_plaintext(self, decoder):- # Repetitive characters: needs >= 4 chars, no English indicators,- # no spaces, no common patterns, and diversity < 0.3- # "xzxzxzxzxzxzxzxz" -> diversity = 2/16 = 0.125 < 0.3- # No English indicators match (no "the", "and", "a", etc. as substrings -- # but "a" matches as substring! Use chars that avoid all indicators)- result = decoder.is_likely_direct_answer("qxqxqxqxqxqxqxqx")- assert result is False-- def test_encoded_base64_pattern(self, decoder):- # Looks like base64: long string of alphanumeric + /+= chars- result = decoder.is_likely_direct_answer("Y00Qhep12345")- assert result is False-- def test_percentage_pattern(self, decoder):- assert decoder.is_likely_direct_answer("75%") is True---# --- analyze_answer_encoding tests ------class TestAnalyzeAnswerEncoding:- def test_returns_dict_with_required_keys(self, decoder):- result = decoder.analyze_answer_encoding("Hello")- assert "original" in result- assert "length" in result- assert "likely_plaintext" in result- assert "pattern_matches" in result- assert "attempted_decodings" in result-- def test_plaintext_analysis(self, decoder):- result = decoder.analyze_answer_encoding("Mount Everest")- assert result["likely_plaintext"] is True- assert result["original"] == "Mount Everest"- assert result["length"] == 13-- def test_encoded_pattern_matches(self, decoder):- # Hex-like string- result = decoder.analyze_answer_encoding("48656c6c6f")- matches = result["pattern_matches"]- types = [m["type"] for m in matches]- assert "hex" in types-- def test_attempted_decodings_all_schemes(self, decoder):- result = decoder.analyze_answer_encoding("SGVsbG8=")- assert "base64" in result["attempted_decodings"]- assert "rot13" in result["attempted_decodings"]- assert "caesar_cipher" in result["attempted_decodings"]-- def test_base64_decoded_valid(self, decoder):- result = decoder.analyze_answer_encoding("SGVsbG8=")- b64 = result["attempted_decodings"]["base64"]- assert b64["decoded"] == "Hello"- assert b64["valid"] is Truediff --git a/tests/advanced_search_system/answer_decoding/test_caesar_decode_pure_logic.py b/tests/advanced_search_system/answer_decoding/test_caesar_decode_pure_logic.pydeleted file mode 100644index 2a1a723abb..0000000000--- a/tests/advanced_search_system/answer_decoding/test_caesar_decode_pure_logic.py+++ /dev/null@@ -1,82 +0,0 @@-"""-Pure-logic tests for BrowseCompAnswerDecoder._decode_caesar.--Tests the full Caesar cipher decoding pipeline: trying shifts 1-25,-scoring each with _english_score, and returning the best result-only if score > 0.3 — no LLM or search calls.-"""--from local_deep_research.advanced_search_system.answer_decoding.browsecomp_answer_decoder import (- BrowseCompAnswerDecoder,-)---class TestDecodeCaesar:- """Verify Caesar cipher decoding with English scoring."""-- def setup_method(self):- self.decoder = BrowseCompAnswerDecoder()-- def test_rot13_returns_some_result(self):- """ROT13-encoded text produces a non-None result (score > 0.3)."""- import codecs-- original = "the cat sat on the mat"- encoded = codecs.encode(original, "rot13")- result = self.decoder._decode_caesar(encoded)- # The heuristic scorer may not pick the correct shift, but should- # find at least one shift scoring > 0.3- assert result is not None-- def test_shift_one(self):- """Shift-1 encoded common English text is decoded."""- # "hello" shifted by 1 = "ifmmp"- result = self.decoder._decode_caesar("ifmmp")- # With shift 25 (reverse of shift 1), should get "hello"- # But it might find a better scoring shift- assert result is not None or result is None # May not score > 0.3-- def test_nonsense_returns_none(self):- """Purely random non-English text may return None."""- result = self.decoder._decode_caesar("xyzxyzxyz")- # No shift will produce English-like text from this- # Result depends on scoring threshold- # This documents the behavior- assert result is None or isinstance(result, str)-- def test_empty_string(self):- """Empty string returns None (score 0.0 < 0.3)."""- result = self.decoder._decode_caesar("")- assert result is None-- def test_numbers_and_punctuation_preserved(self):- """Non-alpha characters are preserved through all shifts."""- result = self.decoder._decode_caesar("123!@#")- # All shifts produce "123!@#" which has english_score 0.0- assert result is None-- def test_mixed_case_preserved(self):- """Case is preserved during decoding."""- import codecs-- original = "The Quick Brown Fox"- encoded = codecs.encode(original, "rot13")- result = self.decoder._decode_caesar(encoded)- if result:- # Original has mixed case, decoded should preserve case pattern- assert result[0].isupper()-- def test_returns_best_scoring_shift(self):- """Returns the shift with highest English score among all 25 shifts."""- # Verify that _decode_caesar returns the shift with the highest score- # by checking the score of the returned result is maximal- text = "ifmmp" # "hello" shifted by 1- result = self.decoder._decode_caesar(text)- if result is not None:- result_score = self.decoder._english_score(result)- # Verify no other shift scores higher- for shift in range(1, 26):- shifted = self.decoder._caesar_shift(text, shift)- assert (- self.decoder._english_score(shifted) <= result_score + 1e-9- )diff --git a/tests/advanced_search_system/answer_decoding/test_decode_pipeline_long_paths.py b/tests/advanced_search_system/answer_decoding/test_decode_pipeline_long_paths.pydeleted file mode 100644index 4b98ce0638..0000000000--- a/tests/advanced_search_system/answer_decoding/test_decode_pipeline_long_paths.py+++ /dev/null@@ -1,230 +0,0 @@-"""-Pure-logic tests for BrowseCompAnswerDecoder pipeline paths.--Tests decode_answer full loop (scheme fallback chain),-validate_decoded_answer boundaries, and is_likely_direct_answer boundaries-— all pure logic, no LLM or search calls.-"""--import base64--from local_deep_research.advanced_search_system.answer_decoding.browsecomp_answer_decoder import (- BrowseCompAnswerDecoder,-)---class TestDecodeAnswerFullLoop:- """Verify decode_answer end-to-end: scheme fallback, short-circuit, exceptions."""-- def setup_method(self):- self.decoder = BrowseCompAnswerDecoder()-- def test_plaintext_short_circuits(self):- """Plaintext answer is returned without decoding, scheme is None."""- result, scheme = self.decoder.decode_answer("John Smith")- assert result == "John Smith"- assert scheme is None-- def test_empty_input_returns_as_is(self):- """Empty string returns as-is with None scheme."""- result, scheme = self.decoder.decode_answer("")- assert result == ""- assert scheme is None-- def test_whitespace_only_returns_as_is(self):- """Whitespace-only input returns as-is."""- result, scheme = self.decoder.decode_answer(" ")- assert result == " "- assert scheme is None-- def test_base64_encoded_decoded_successfully(self):- """Base64-encoded answer is decoded and validated."""- # Encode a reasonable answer- original = "Albert Einstein"- encoded = base64.b64encode(original.encode()).decode()- # This may or may not decode depending on is_likely_direct_answer- result, scheme = self.decoder.decode_answer(encoded)- # If it decoded, scheme should be "base64"- # If it was treated as plaintext, scheme is None- assert result is not None-- def test_all_schemes_fail_returns_original(self):- """When no scheme can decode, returns original with None."""- # A string that looks encoded but isn't valid for any scheme- gibberish = "ZZZZZZZZZZZZZZZZ"- result, scheme = self.decoder.decode_answer(gibberish)- # Should return original since no decoding produces valid text- assert result == gibberish or scheme is not None-- def test_hex_encoded_answer(self):- """Hex-encoded answer is decoded."""- original = "Hello World Test"- encoded = original.encode().hex()- result, scheme = self.decoder.decode_answer(encoded)- # The hex string matches encoded patterns, so decoding is attempted- assert result is not None---class TestValidateDecodedAnswer:- """Verify validate_decoded_answer boundary conditions."""-- def setup_method(self):- self.decoder = BrowseCompAnswerDecoder()-- def test_empty_string_invalid(self):- """Empty string is not valid."""- assert self.decoder.validate_decoded_answer("") is False-- def test_none_invalid(self):- """None is not valid."""- assert self.decoder.validate_decoded_answer(None) is False-- def test_whitespace_only_invalid(self):- """Whitespace-only string is invalid."""- assert self.decoder.validate_decoded_answer(" ") is False-- def test_single_char_valid(self):- """Single alphabetic character is valid (length >= 1)."""- assert self.decoder.validate_decoded_answer("A") is True-- def test_exactly_1000_chars_valid(self):- """Exactly 1000 characters is valid (at boundary)."""- text = "A" * 1000- assert self.decoder.validate_decoded_answer(text) is True-- def test_1001_chars_invalid(self):- """1001 characters exceeds the 1000-char limit."""- text = "A" * 1001- assert self.decoder.validate_decoded_answer(text) is False-- def test_exactly_30_percent_alpha(self):- """Text with exactly 30% alphabetic characters passes."""- # 30 letters + 70 digits = 100 chars, 30% alpha- text = "a" * 30 + "1" * 70- assert self.decoder.validate_decoded_answer(text) is True-- def test_below_30_percent_alpha(self):- """Text with 29% alphabetic characters fails."""- # 29 letters + 71 digits = 100 chars, 29% alpha- text = "a" * 29 + "1" * 71- assert self.decoder.validate_decoded_answer(text) is False-- def test_exactly_50_percent_punct(self):- """Text with exactly 50% punctuation passes (not > 50%)."""- # 50 letters + 50 punctuation = 100 chars- text = "a" * 50 + "!" * 50- assert self.decoder.validate_decoded_answer(text) is True-- def test_above_50_percent_punct(self):- """Text with 51% punctuation fails."""- # 49 letters + 51 punctuation = 100 chars- text = "a" * 49 + "!" * 51- assert self.decoder.validate_decoded_answer(text) is False-- def test_80_percent_printable_boundary(self):- """Text with exactly 80% printable passes."""- # 80 printable + 20 non-printable (control chars that aren't \t\n\r)- # Actually control chars < 32 (not in \t\n\r) would fail the control char check first- # Use chars > 127 that aren't printable- printable_part = "a" * 80- # Use characters that are printable (>= 32) to avoid control char check- # The 80% check is: printable_count / len(decoded) >= 0.8- text = printable_part + chr(0x7F) * 20 # DEL is not printable- # DEL (127) is not a control char < 32 but is not printable- result = self.decoder.validate_decoded_answer(text)- # 80/100 = 0.8 which satisfies >= 0.8 but alpha = 80% passes too- assert result is True-- def test_control_characters_invalid(self):- """Text with control characters (< 32, not \\t\\n\\r) is invalid."""- text = "Hello" + chr(1) + "World"- assert self.decoder.validate_decoded_answer(text) is False-- def test_tab_newline_carriage_return_allowed(self):- """Tabs, newlines, and carriage returns are not rejected."""- text = "Hello\tWorld\nTest\rLine"- assert self.decoder.validate_decoded_answer(text) is True-- def test_all_checks_pass_cumulatively(self):- """A normal sentence passes all validation checks."""- text = "The answer is Albert Einstein, born in 1879."- assert self.decoder.validate_decoded_answer(text) is True---class TestIsLikelyDirectAnswer:- """Verify is_likely_direct_answer boundary conditions and pattern matching."""-- def setup_method(self):- self.decoder = BrowseCompAnswerDecoder()-- def test_very_short_answer_is_direct(self):- """Answers shorter than 4 characters are always direct."""- assert self.decoder.is_likely_direct_answer("Hi") is True- assert self.decoder.is_likely_direct_answer("AB") is True-- def test_exactly_3_chars_is_direct(self):- """3-char answer is direct (< 4)."""- assert self.decoder.is_likely_direct_answer("abc") is True-- def test_exactly_4_chars_not_auto_direct(self):- """4-char answer is NOT auto-direct (>= 4), checked by other heuristics."""- # "ABCD" has no spaces, no English words, no common patterns- # char_diversity = 4/4 = 1.0 (>= 0.3)- # Not matching encoded patterns -> returns True (not encoded)- result = self.decoder.is_likely_direct_answer("ABCD")- assert isinstance(result, bool)-- def test_english_word_detected(self):- """Answer containing an English indicator word is direct."""- assert self.decoder.is_likely_direct_answer("the company") is True-- def test_multi_word_is_direct(self):- """Multi-word answer with spaces is direct."""- assert self.decoder.is_likely_direct_answer("John Doe") is True-- def test_year_pattern_is_direct(self):- """4-digit year is direct."""- assert self.decoder.is_likely_direct_answer("2024") is True-- def test_money_pattern_is_direct(self):- """Dollar amount is direct."""- assert self.decoder.is_likely_direct_answer("$500") is True-- def test_name_pattern_is_direct(self):- """First Last name format is direct."""- assert self.decoder.is_likely_direct_answer("John Smith") is True-- def test_percentage_is_direct(self):- """Percentage format is direct."""- assert self.decoder.is_likely_direct_answer("85%") is True-- def test_low_diversity_not_direct(self):- """Repetitive characters (low diversity < 0.3) returns False."""- # Use 'x' to avoid matching English indicators (which include "a")- # "xxxxxxxxxxxx" has diversity 1/12 = 0.08 < 0.3- assert self.decoder.is_likely_direct_answer("xxxxxxxxxxxx") is False-- def test_diversity_exactly_03(self):- """Diversity of exactly 0.3 is NOT below threshold (< 0.3 check)."""- # Need 10 chars with 3 unique, avoiding English indicator substrings- # "xxxyyyzzzz" has 3 unique / 10 = 0.3- text = "xxxyyyzzzz"- assert len(set(text)) / len(text) == 0.3- # diversity is not < 0.3, so won't return False at that check- # Falls through to encoded pattern check (matches ^[A-Za-z0-9]{8,}$)- result = self.decoder.is_likely_direct_answer(text)- assert isinstance(result, bool)-- def test_encoded_pattern_detected(self):- """Base64-looking string is flagged as potentially encoded."""- # Matches r"^[A-Za-z0-9]{8,}$" encoded pattern- # Avoid letters that form English indicator substrings (e.g. "a", "in", "or")- encoded_looking = "XYZWVUTSRQPL"- result = self.decoder.is_likely_direct_answer(encoded_looking)- # Should be False because it matches an encoded pattern- assert result is False-- def test_english_indicator_plus_encoded_chars(self):- """English indicator word overrides encoded pattern detection."""- # Contains "the" -> returns True immediately- assert self.decoder.is_likely_direct_answer("the ABCDEFgh") is Truediff --git a/tests/advanced_search_system/test_constraint_relaxer.py b/tests/advanced_search_system/test_constraint_relaxer.pydeleted file mode 100644index c7a4c8de75..0000000000--- a/tests/advanced_search_system/test_constraint_relaxer.py+++ /dev/null@@ -1,202 +0,0 @@-"""-Tests for the intelligent constraint relaxer.--Tests cover:-- Constraint priority handling-- Progressive relaxation strategies-- Constraint type inference-"""--from unittest.mock import Mock---class TestIntelligentConstraintRelaxer:- """Tests for the IntelligentConstraintRelaxer class."""-- def test_relaxer_constraint_priorities(self):- """Verify constraint type priorities are correctly defined."""- from local_deep_research.advanced_search_system.constraint_checking.intelligent_constraint_relaxer import (- IntelligentConstraintRelaxer,- )-- relaxer = IntelligentConstraintRelaxer()-- # High priority constraints should never be relaxed first- assert (- relaxer.constraint_priorities["NAME_PATTERN"]- > relaxer.constraint_priorities["STATISTIC"]- )- assert (- relaxer.constraint_priorities["EXISTENCE"]- > relaxer.constraint_priorities["COMPARISON"]- )- assert (- relaxer.constraint_priorities["LOCATION"]- > relaxer.constraint_priorities["RELATIONSHIP"]- )-- # Verify COMPARISON and STATISTIC are lowest priority- assert relaxer.constraint_priorities["COMPARISON"] <= 3- assert relaxer.constraint_priorities["STATISTIC"] <= 3-- def test_relax_constraints_sufficient_candidates(self):- """No relaxation when enough candidates are already found."""- from local_deep_research.advanced_search_system.constraint_checking.intelligent_constraint_relaxer import (- IntelligentConstraintRelaxer,- )-- relaxer = IntelligentConstraintRelaxer()-- mock_constraints = [Mock() for _ in range(5)]- mock_candidates = [Mock() for _ in range(10)]-- result = relaxer.relax_constraints_progressively(- constraints=mock_constraints,- candidates_found=mock_candidates,- target_candidates=5,- )-- # Should return original constraints unchanged- assert len(result) == 1- assert result[0] == mock_constraints-- def test_relax_constraints_progressively(self):- """Test progressive constraint removal when candidates are insufficient."""- from local_deep_research.advanced_search_system.constraint_checking.intelligent_constraint_relaxer import (- IntelligentConstraintRelaxer,- )-- relaxer = IntelligentConstraintRelaxer()-- # Create mock constraints with different types- constraints = []- for type_name in [- "NAME_PATTERN",- "LOCATION",- "TEMPORAL",- "STATISTIC",- "COMPARISON",- ]:- mock = Mock()- mock.type = Mock()- mock.type.value = type_name- constraints.append(mock)-- # Only 1 candidate found, need relaxation- mock_candidates = [Mock()]-- result = relaxer.relax_constraints_progressively(- constraints=constraints,- candidates_found=mock_candidates,- target_candidates=5,- )-- # Should have multiple relaxation strategies- assert len(result) >= 1-- def test_relax_statistical_constraint(self):- """Test number range expansion (10%, 20%, 50%)."""- from local_deep_research.advanced_search_system.constraint_checking.intelligent_constraint_relaxer import (- IntelligentConstraintRelaxer,- )-- relaxer = IntelligentConstraintRelaxer()-- mock_constraint = Mock()- mock_constraint.value = "population of 1000000"- mock_constraint.__str__ = lambda self: "population of 1000000"-- variations = relaxer._relax_statistical_constraint(mock_constraint)-- # Should create range variations- assert len(variations) > 0-- # Check that at least one variation contains "between" or "approximately"- variation_texts = [str(v) for v in variations]- has_range = any(- "between" in v.lower() or "approximately" in v.lower()- for v in variation_texts- )- assert (- has_range or len(variations) > 0- ) # Either range patterns or other relaxations-- def test_relax_temporal_constraint(self):- """Test year to decade conversion."""- from local_deep_research.advanced_search_system.constraint_checking.intelligent_constraint_relaxer import (- IntelligentConstraintRelaxer,- )- from local_deep_research.advanced_search_system.constraints.base_constraint import (- Constraint,- ConstraintType,- )-- relaxer = IntelligentConstraintRelaxer()-- constraint = Constraint(- id="c1",- type=ConstraintType.TEMPORAL,- description="Founded date",- value="founded in 1985",- )-- variations = relaxer._relax_temporal_constraint(constraint)-- # Should create decade-based variations- assert len(variations) > 0-- def test_get_constraint_type_inference(self):- """Test type inference from text patterns."""- from local_deep_research.advanced_search_system.constraint_checking.intelligent_constraint_relaxer import (- IntelligentConstraintRelaxer,- )- from local_deep_research.advanced_search_system.constraints.base_constraint import (- Constraint,- ConstraintType,- )-- relaxer = IntelligentConstraintRelaxer()-- # Test with constraint that has type attribute- # Note: _get_constraint_type returns the enum value, which is lowercase- name_constraint = Constraint(- id="c1",- type=ConstraintType.NAME_PATTERN,- description="Name pattern",- value="known as the Big Apple",- )- assert relaxer._get_constraint_type(name_constraint) == "name_pattern"-- location_constraint = Constraint(- id="c2",- type=ConstraintType.LOCATION,- description="Location",- value="located in France",- )- assert relaxer._get_constraint_type(location_constraint) == "location"-- temporal_constraint = Constraint(- id="c3",- type=ConstraintType.TEMPORAL,- description="Time",- value="the year 1990",- )- assert relaxer._get_constraint_type(temporal_constraint) == "temporal"-- comparison_constraint = Constraint(- id="c4",- type=ConstraintType.COMPARISON,- description="Comparison",- value="larger than previous",- )- assert (- relaxer._get_constraint_type(comparison_constraint) == "comparison"- )-- property_constraint = Constraint(- id="c5",- type=ConstraintType.PROPERTY,- description="Property",- value="some random text",- )- assert relaxer._get_constraint_type(property_constraint) == "property"diff --git a/tests/advanced_search_system/test_constraints/test_constraint_classes.py b/tests/advanced_search_system/test_constraints/test_constraint_classes.pyindex b7a1b63319..cef9f1d98a 100644--- a/tests/advanced_search_system/test_constraints/test_constraint_classes.py+++ b/tests/advanced_search_system/test_constraints/test_constraint_classes.py@@ -27,9 +27,6 @@ from local_deep_research.advanced_search_system.constraint_checking.strict_checkfrom local_deep_research.advanced_search_system.constraint_checking.threshold_checker import (ThresholdChecker,)-from local_deep_research.advanced_search_system.constraint_checking.intelligent_constraint_relaxer import (- IntelligentConstraintRelaxer,-)from local_deep_research.advanced_search_system.constraint_checking.rejection_engine import (RejectionEngine,)@@ -78,10 +75,6 @@ class TestConstraintCheckingImports:"""Test ThresholdChecker import."""assert ThresholdChecker is not None- def test_intelligent_constraint_relaxer_import(self):- """Test IntelligentConstraintRelaxer import."""- assert IntelligentConstraintRelaxer is not None-def test_rejection_engine_import(self):"""Test RejectionEngine import."""assert RejectionEngine is not None@@ -192,16 +185,6 @@ class TestRejectionEngine:logger.info("RejectionEngine with custom thresholds created")-class TestIntelligentConstraintRelaxer:- """Test IntelligentConstraintRelaxer functionality."""-- def test_instantiation(self):- """Test that relaxer can be instantiated."""- relaxer = IntelligentConstraintRelaxer()- assert relaxer is not None- logger.info("IntelligentConstraintRelaxer instantiated")--class TestConstraintDataClasses:"""Test constraint-related data classes."""