feat(backend): integrate document deletion and grounded speech providers

Enable replay-safe document deletion and public deployment model identifiers with the forward voice-model schema revision.

Add GapGPT dialogue and ElevenLabs speech routing, strict extractive grounding, ten-source retrieval and regression coverage.

Validation: 199 targeted provider-free tests passed. The full provider-free run stalled and was interrupted; PostgreSQL acceptance was not run because TEST_DATABASE_URL is unset.
This commit is contained in:
amirhosein mazaheri
2026-10-20 09:00:37 +03:30
parent 2bffb9476a
commit 42400495af
27 changed files with 1003 additions and 28 deletions
+6 -5
View File
@@ -9,7 +9,8 @@ from sqlalchemy.orm import sessionmaker
from app.modules.documents.types import EmbeddingProfile
LIVE_REVISION = "0005_live_owner_chain"
LIVE_REVISION = "0006_voice_model_settings"
OWNER_CHAIN_REVISION = "0005_live_owner_chain"
PREVIOUS_LIVE_REVISION = "0004_live_lifecycle"
SCHEMA_REVISION = "0003_extraction_review"
WORKER_REVISION = "0002_worker_artifact"
@@ -65,19 +66,19 @@ def check_compatibility(connection: Connection, profile: EmbeddingProfile, *, re
schema = connection.execute(text("SELECT current_schema()")).scalar_one()
assert_foundation_scope(connection, schema)
revision = connection.execute(text("SELECT version_num FROM alembic_version")).scalar_one()
allowed = (SCHEMA_REVISION, PREVIOUS_LIVE_REVISION, LIVE_REVISION) if require_worker else (
FOUNDATION_REVISION, WORKER_REVISION, SCHEMA_REVISION, PREVIOUS_LIVE_REVISION, LIVE_REVISION
allowed = (SCHEMA_REVISION, PREVIOUS_LIVE_REVISION, OWNER_CHAIN_REVISION, LIVE_REVISION) if require_worker else (
FOUNDATION_REVISION, WORKER_REVISION, SCHEMA_REVISION, PREVIOUS_LIVE_REVISION, OWNER_CHAIN_REVISION, LIVE_REVISION
)
if revision not in allowed:
raise CompatibilityError("Unexpected ingestion schema revision")
if revision in (WORKER_REVISION, SCHEMA_REVISION, PREVIOUS_LIVE_REVISION, LIVE_REVISION):
if revision in (WORKER_REVISION, SCHEMA_REVISION, PREVIOUS_LIVE_REVISION, OWNER_CHAIN_REVISION, LIVE_REVISION):
artifact_type = connection.execute(text("""
SELECT format_type(atttypid,atttypmod) FROM pg_attribute
WHERE attrelid=to_regclass('documents') AND attname='extraction_state' AND NOT attisdropped
""")).scalar_one_or_none()
if artifact_type != "jsonb":
raise CompatibilityError("Missing worker artifact attachment column")
if revision in (SCHEMA_REVISION, PREVIOUS_LIVE_REVISION, LIVE_REVISION):
if revision in (SCHEMA_REVISION, PREVIOUS_LIVE_REVISION, OWNER_CHAIN_REVISION, LIVE_REVISION):
definitions = connection.execute(text("""
SELECT pg_get_constraintdef(oid) FROM pg_constraint
WHERE conrelid=to_regclass(\'audit_events\')