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

@@ -16,6 +16,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from app.core.config import settings
from app.core.logging import get_logger
from app.features.memory.models import MemoryChunk, MemorySource
from app.features.memory.constants import memory
from app.features.memory.repo import (
create_curation_action,
get_first_chunk_after_cursor,
@@ -227,7 +228,7 @@ async def run_memory_compaction(
cand_sources = [str(x) for x in cand_sources]
has_candidate_filter = "candidate_chunk_ids" in ctx or "candidate_source_ids" in ctx
max_chunks = settings.memory_compaction_max_chunks_per_run
max_chunks = memory.compaction_max_chunks_per_run
incremental = await list_incremental_chunks_for_compaction(
db,
user_id=user_id,
@@ -248,7 +249,7 @@ async def run_memory_compaction(
cursor_ts,
cursor_id,
max_steps=max(
settings.memory_compaction_max_chunks_per_run * 2,
memory.compaction_max_chunks_per_run * 2,
500,
),
)
@@ -288,12 +289,12 @@ async def run_memory_compaction(
"skipped_reason": "empty_incremental",
}
sim_th = settings.memory_compaction_chunk_similarity_threshold
min_layers = settings.memory_compaction_min_layers_for_exclude
jaccard_min = settings.memory_compaction_text_jaccard_min
year_w = settings.memory_compaction_metadata_event_year_window
max_neighbors = settings.memory_compaction_max_neighbors_per_chunk
max_excludes = settings.memory_compaction_max_excludes_per_run
sim_th = memory.compaction_chunk_similarity_threshold
min_layers = memory.compaction_min_layers_for_exclude
jaccard_min = memory.compaction_text_jaccard_min
year_w = memory.compaction_metadata_event_year_window
max_neighbors = memory.compaction_max_neighbors_per_chunk
max_excludes = memory.compaction_max_excludes_per_run
local_excluded: set[str] = set()
excludes_done = 0