refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)

配置 SSOT(TOML + .env)
统一错误契约
Auth 与事务边界
Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client
可观测性(OpenTelemetry + LGTM)
This commit is contained in:
Sully
2026-05-22 13:44:50 +08:00
committed by GitHub
parent f09ae248f9
commit 53e0065e3e
298 changed files with 15247 additions and 4344 deletions

View File

@@ -10,7 +10,7 @@ from datetime import datetime
from sqlalchemy.ext.asyncio import AsyncSession
from app.core.db import utc_now
from app.core.db import transactional, utc_now
from app.core.logging import get_logger
from app.core.security import hash_password
from app.features.auth import repo as auth_repo
@@ -64,8 +64,8 @@ class ReplayConversationService:
subscription_type="free",
created_at=utc_now(),
)
await auth_repo.create_user(user, self._db)
await self._db.commit()
async with transactional(self._db):
await auth_repo.create_user(user, self._db)
await self._db.refresh(user)
conversation_id = str(uuid.uuid4())
@@ -159,13 +159,6 @@ class ReplayConversationService:
segment = await conv_service.create_user_segment(conv, conv.user_id, text)
segment_ids.append(segment.id)
ts = segment.created_at or conv.last_message_at
if not skip_memoir:
await memoir_ingest_scheduler.queue_segment(
conv.user_id,
segment.id,
text_char_count=len(text),
trigger="evaluation_replay",
)
await process_user_message(
conversation_id=cid,
user_message=text,
@@ -175,6 +168,8 @@ class ReplayConversationService:
user=user,
user_message_timestamp=ts,
force_skip_tts=skip_tts,
memoir_trigger="evaluation_replay",
schedule_memoir=not skip_memoir,
)
count += 1