Add the scoped PostgreSQL/pgvector schema, independent ingestion settings and ports, embedding profile checks, and trusted administrator bootstrap. Include repository contracts and guidance, organized provider-free and PostgreSQL tests, deployment setup, and byte-preserving migration attributes. Validation: 163 tests passed; all 48 PostgreSQL cases passed with pgvector Python 0.5.0 and 0.3.6. No production schema or historical metadata was changed.
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
"""Ingestion imports do not initialize providers or chat."""
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def test_ingestion_imports_do_not_initialize_chat_or_io():
|
|
script = """
|
|
import importlib, sys
|
|
class BlockImports:
|
|
def find_spec(self, fullname, *args):
|
|
if fullname.startswith(("app.services", "app.core.config", "openai",
|
|
"fastembed", "langchain", "chromadb")):
|
|
raise AssertionError("Forbidden import: " + fullname)
|
|
sys.meta_path.insert(0, BlockImports())
|
|
def audit(event, args):
|
|
if event in ("socket.connect", "os.walk", "os.scandir"):
|
|
raise AssertionError("Unexpected I/O: " + event)
|
|
sys.addaudithook(audit)
|
|
for name in ("app.modules.documents.settings", "app.modules.documents.types",
|
|
"app.modules.documents.ports", "app.infrastructure.database", "app.bootstrap"):
|
|
importlib.import_module(name)
|
|
assert "app.core.config" not in sys.modules
|
|
"""
|
|
environment = {k: v for k, v in os.environ.items()
|
|
if not k.startswith(("INGEST_", "API_KEY", "LLM_"))}
|
|
result = subprocess.run([sys.executable, "-c", script], env=environment,
|
|
capture_output=True, text=True)
|
|
assert result.returncode == 0, result.stderr
|