refactor(Dockerfile): 使用requirements.txt替代硬编码依赖

将Dockerfile中的硬编码pip包列表替换为通过requirements.txt文件安装,
提高依赖管理的灵活性和可维护性。

feat(scheduling): 移除内置APScheduler,采用独立调度系统

移除app/core/background/scheduler.py中原来的APScheduler实现,
改为使用新的应用级调度系统app.application.scheduling。

refactor(task_queue): 调整任务队列模块结构和导入路径

将任务队列相关常量从app.core.background.task_queue.constants迁移至
app.tasks.constants,并更新所有相关导入路径和引用。

refactor(events): 将事件服务重构为独立的应用层组件

将事件分发逻辑从核心层迁移到应用层,使用app.application.events.EventDispatchService
替代原有的app.modules.events.services.EventService。

feat(ai_memory): 增强AI记忆自动写入的安全策略

新增ai_memory_blocked_content_terms配置项用于阻止敏感内容,
添加TTL过期机制控制自动写入条目的生命周期。

fix(security): 强化生产环境安全验证机制

增加model_validator确保生产环境中数据库连接、API密钥、CORS设置等
关键安全配置符合要求。

feat(risks): 优化风险事件操作动作的外键约束

为RiskEventAction模型的风险事件ID字段添加外键约束,
防止孤立记录并增强数据完整性。

refactor(audit): 优化审计服务方法命名和事务处理

将AuditService的log方法重命名为record以反映其阶段行为,
并调整事务提交时机以提高性能。

feat(events): 增强领域事件并发处理和响应模型

添加事件锁定机制防止重复处理,更新API响应模型以提供
更准确的数据类型定义。
```
This commit is contained in:
2026-07-15 16:36:42 +08:00
parent 267b01b9f4
commit db751f03b4
73 changed files with 1615 additions and 933 deletions

View File

@@ -1,4 +1,4 @@
from app.core.background.task_queue.constants import (
from app.tasks.constants import (
TASK_DISPATCH_PENDING_EVENTS,
TASK_GENERATE_RISK_EVENTS,
TASK_PUSH_ATTENDANCE_SUMMARY,

View File

@@ -1,13 +0,0 @@
TASK_PUSH_DAILY_BRIEF = "reports.push_daily_brief"
TASK_PUSH_PROJECT_WEEKLY = "reports.push_project_weekly"
TASK_PUSH_ATTENDANCE_SUMMARY = "reports.push_attendance_summary"
TASK_PUSH_RISK_PROGRESS = "reports.push_risk_progress"
TASK_PUSH_WORK_DAILY = "reports.push_work_daily"
TASK_PUSH_WORK_WEEKLY = "reports.push_work_weekly"
TASK_GENERATE_RISK_EVENTS = "risks.generate_events"
TASK_SYNC_LEGACY_PROJECTS = "legacy.sync_projects"
TASK_SYNC_LEGACY_TASKS = "legacy.sync_tasks"
TASK_DISPATCH_PENDING_EVENTS = "events.dispatch_pending"
TASK_RUN_LIFECYCLE = "reports.run_lifecycle"
TASK_RUN_MARKET_REPORT = "market.report.run"
TASK_RUN_MARKET_CLOSE = TASK_RUN_MARKET_REPORT

View File

@@ -1,7 +1,8 @@
from typing import Any
from app.application.events import EventDispatchService
from app.core.config import get_settings
from app.core.background.task_queue.constants import (
from app.tasks.constants import (
TASK_DISPATCH_PENDING_EVENTS,
)
from app.core.background.task_queue.dispatcher import dispatch_task
@@ -13,11 +14,10 @@ def enqueue_event_dispatch(
) -> dict[str, Any]:
def inline() -> Any:
from app.core.database import SessionLocal
from app.modules.events.services import EventService
db = SessionLocal()
try:
return EventService(db).dispatch_pending(
return EventDispatchService(db).dispatch_pending(
limit=limit or get_settings().event_dispatch_batch_size,
worker_id=actor,
)

View File

@@ -1,6 +1,6 @@
from typing import Any
from app.core.background.task_queue.constants import (
from app.tasks.constants import (
TASK_SYNC_LEGACY_PROJECTS,
TASK_SYNC_LEGACY_TASKS,
)

View File

@@ -1,10 +1,10 @@
from typing import Any
from app.core.background.task_queue.constants import TASK_RUN_LIFECYCLE
from app.tasks.constants import TASK_RUN_LIFECYCLE
from app.core.config import get_settings
from app.core.constants import ActorValue
from app.core.database import SessionLocal
from app.modules.reports.lifecycle_pipeline import LifecyclePipelineService
from app.application.pipelines import LifecyclePipelineService
def enqueue_lifecycle_report(

View File

@@ -1,7 +1,7 @@
from datetime import date
from typing import Any
from app.core.background.task_queue.constants import TASK_RUN_MARKET_REPORT
from app.tasks.constants import TASK_RUN_MARKET_REPORT
from app.core.config import get_settings

View File

@@ -1,7 +1,7 @@
from collections.abc import Callable
from typing import Any
from app.core.background.task_queue.constants import (
from app.tasks.constants import (
TASK_PUSH_ATTENDANCE_SUMMARY,
TASK_PUSH_DAILY_BRIEF,
TASK_PUSH_PROJECT_WEEKLY,
@@ -135,6 +135,7 @@ def _enqueue_report_push(
)
def inline() -> Any:
from app.application.delivery import ReportDeliveryService
from app.core.database import SessionLocal
from app.modules.reports.services import ReportService
@@ -142,7 +143,9 @@ def _enqueue_report_push(
try:
service = ReportService(db)
report = build_report(service, actor)
return service.push_report(report, receive_id, receive_id_type, actor)
return ReportDeliveryService(db).push_report(
report, receive_id, receive_id_type, actor
)
finally:
db.close()

View File

@@ -1,6 +1,6 @@
from typing import Any
from app.core.background.task_queue.constants import (
from app.tasks.constants import (
TASK_GENERATE_RISK_EVENTS,
)
from app.core.background.task_queue.dispatcher import dispatch_task