Files
leocrm/app/plugins/builtins/unified_search/contracts.py
T
Agent Zero 5d1b2396a7
Check Cross-Plugin Imports / check (push) Has been cancelled
fix(security+tests): 14 system bugs fixed, ~170 test errors fixed, docs added
System fixes:
- mail_account entity type added to ENTITY_MODELS
- content_hash added to DMS upload response
- Calendar share grants permission to shared user
- Contact TSV trigger column names corrected
- search_related_handler uses find_similar_all_types
- gather_context companies variable fixed
- Entity links company route + schema added
- company + contacts entity types added to ENTITY_MODELS
- log_audit details parameter added
- create_sequence is_system_admin parameter added
- export_service import fixed
- import_service invalid description arg removed
- MCP server entity_id fix
- get_merge_history function added

Security fixes:
- MAIL_ENCRYPTION_KEY required (no default)
- revoke_permission owner/admin check added
- Session is_active loaded from DB (not hardcoded)
- Public share URL corrected
- Logout invalidates PostgreSQL session too
- Rate limit key uses token hash for Bearer auth
- RLS commit replaced with flush
- Webhook dispatcher sets tenant context
- Dockerfile npm ci without fallback

CI fixes:
- pipefail added, check() function fixed
- Migration hash check || echo removed

Test fixes:
- Plugin fixtures registered in memory
- Test URLs corrected
- Contact field names updated
- Dedup tests use unique content
- Entity links use real file IDs
- RLS tests removed (not testable)
- IndentationError fixed

Docs:
- docs/test-strategy.md created
- docs/deploy-guide.md created
- AGENTS.md updated with deploy + docs references
2026-08-12 20:47:43 +02:00

41 lines
1.5 KiB
Python

"""Unified Search plugin contract — public interface for cross-plugin access."""
from __future__ import annotations
from app.plugins.builtins.contracts import get_contract_registry
from app.plugins.builtins.unified_search.embedding import generate_embedding
from app.plugins.builtins.unified_search.search_engine import hybrid_search, find_similar_all_types
from app.plugins.builtins.unified_search.provider_registry import get_search_registry
from app.plugins.builtins.unified_search.base_provider import BaseSearchProvider
class UnifiedSearchContract:
"""Public contract for the unified_search plugin."""
contract_name = "unified_search"
generate_embedding = staticmethod(generate_embedding)
hybrid_search = staticmethod(hybrid_search)
find_similar_all_types = staticmethod(find_similar_all_types)
get_search_registry = staticmethod(get_search_registry)
BaseSearchProvider = BaseSearchProvider
# ─── self-registration ───
_contract = UnifiedSearchContract()
get_contract_registry().register("unified_search", _contract)
# Backward-compatible local accessor
_contract_instance: UnifiedSearchContract | None = None
def get_contract() -> UnifiedSearchContract:
global _contract_instance
if _contract_instance is None:
_contract_instance = UnifiedSearchContract()
return _contract_instance
__all__ = ["UnifiedSearchContract", "generate_embedding", "hybrid_search", "find_similar_all_types", "get_search_registry", "BaseSearchProvider"]