feat(backend): deliver Phase 3 document and voice integration
Add authenticated upload, review, retry and knowledge-selection HTTP flows with bounded JSON processing and frozen OCR policy. Preserve Gemini/OpenAI provider selection and fenced lifecycle semantics; retain FAQ preambles and uncertain vision candidates, and expose opt-in uncalibrated voice transport diagnostics. Include frontend integration examples, aligned contracts and deterministic regressions. Validation: 1767 provider-free tests passed; all 404 PostgreSQL scenarios have passing evidence across the documented runs.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""Framework preparation must precede live admission and tool deadlines."""
|
||||
import asyncio
|
||||
from threading import get_ident
|
||||
from types import SimpleNamespace
|
||||
|
||||
from app.main import lifespan
|
||||
from app.api.v1 import dependencies
|
||||
|
||||
|
||||
def test_framework_prepared_off_loop_before_reconciliation_and_readiness(monkeypatch):
|
||||
app = SimpleNamespace(state=SimpleNamespace(ready=False))
|
||||
order = []
|
||||
loop_thread = get_ident()
|
||||
prepare = dependencies.prepare_search_tools
|
||||
def framework():
|
||||
assert not app.state.ready and get_ident() != loop_thread
|
||||
prepare()
|
||||
order.append('framework')
|
||||
def reconcile():
|
||||
assert order == ['framework'] and not app.state.ready
|
||||
order.append('reconcile')
|
||||
monkeypatch.setattr(dependencies, 'prepare_search_tools', framework)
|
||||
monkeypatch.setattr(dependencies, 'get_engine', lambda: SimpleNamespace(dispose=lambda: order.append('dispose')))
|
||||
monkeypatch.setattr(dependencies, 'get_lifecycle_service', lambda engine: SimpleNamespace(reconcile_startup=reconcile))
|
||||
monkeypatch.setattr(dependencies, '_TOOL_RUNNER', None)
|
||||
async def run():
|
||||
async with lifespan(app):
|
||||
assert order == ['framework', 'reconcile'] and app.state.ready
|
||||
assert not app.state.ready and order[-1] == 'dispose'
|
||||
asyncio.run(run())
|
||||
|
||||
|
||||
def test_document_only_installation_keeps_framework_optional(monkeypatch):
|
||||
import builtins
|
||||
from app.modules.knowledge.langchain_tool import prepare_search_tools
|
||||
original = builtins.__import__
|
||||
def optional(name, *args, **kwargs):
|
||||
if name == 'langchain_core.tools':
|
||||
raise ModuleNotFoundError(name='langchain_core')
|
||||
return original(name, *args, **kwargs)
|
||||
monkeypatch.setattr(builtins, '__import__', optional)
|
||||
assert prepare_search_tools() is None
|
||||
Reference in New Issue
Block a user