From 8e5108751cd57e625ce0a27630ef94272c716fc9 Mon Sep 17 00:00:00 2001 From: wangdl Date: Sat, 20 Jun 2026 17:03:28 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85=20AuditLogProcessor?= =?UTF-8?q?=20=E8=A1=8C=E4=B8=BA=E5=88=86=E6=9E=90=20+=20ContentSafetyServ?= =?UTF-8?q?ice=20=E6=9C=AA=E4=BD=BF=E7=94=A8=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - W4 新增 process() 方法完整代码和行为说明 - 标注因队列无生产者,Processor 从未被触发 - 新增 ContentSafetyService 注入未使用 QueueService 的依赖清理建议 Co-Authored-By: Claude --- .../m-ai-03-current-execution-audit.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/architecture/m-ai-03-current-execution-audit.md b/docs/architecture/m-ai-03-current-execution-audit.md index 0a10637..e7d20b0 100644 --- a/docs/architecture/m-ai-03-current-execution-audit.md +++ b/docs/architecture/m-ai-03-current-execution-audit.md @@ -165,6 +165,35 @@ async send(data: { userId: string; type: string; title: string; body: string }) - 行 65–77: 逐个创建 `KnowledgeItem` - 行 79–82: `updateStatus(importId, 'completed')` +**W4** `src/modules/admin-audit-log/audit-log.processor.ts:8-27` +```typescript +async process(job: Job) { + await this.prisma.adminAuditLog.create({ + data: { + adminUserId: job.data.adminUserId, + action: job.data.action, + resourceType: job.data.resourceType, + resourceId: job.data.resourceId, + beforeJson: job.data.beforeJson, + afterJson: job.data.afterJson, + ip: job.data.ip, + userAgent: job.data.userAgent, + riskLevel: job.data.riskLevel, + reason: job.data.reason, + }, + }); +} +``` +- 行为:直接从 BullMQ Job payload 写入 `AdminAuditLog` 表 +- **当前因队列无生产者,此 Processor 从未被触发** + +### 未使用的依赖注入 + +| 文件 | 注入 | 状态 | 建议 | +|------|------|------|------| +| `content-safety.service.ts:17` | `QueueService` | ❌ 未使用 — 构造函数注入但全文无 `this.queue.add()` 或 `this.queue.getJob()` 调用 | 若模块未来不计划使用队列,可清理以减少依赖 | +| `content-safety.module.ts:6,12` | `QueueService` 导入 + 注册为 provider | 仅为满足 `ContentSafetyService` 构造函数 | 同上 | + --- ## 4. AiRuntimeJob 完整链路(System B — REST Poll) @@ -502,6 +531,7 @@ pending → locked → running → succeeded / failed / cancelled | DocumentImport 使用独立 model | 🟡 中 | 不在 M-AI-03 范围,但未来统一需注意 | | RuntimeInternal 无事务保证 | 🔴 高 | result + job update 分两步,非原子 | | 孤儿队列(notification/domain-events/audit-logs) | 🟡 中 | Consumer 已注册但无活跃 Producer;`NotificationWorker` 和 `AuditLogProcessor` 实为永久空转 | +| `ContentSafetyService` 注入未使用的 `QueueService` | 🟢 低 | 构造函数注入但全文无 `this.queue.*` 调用;`content-safety.module.ts` 仅为满足此注入而注册 provider,可清理以减少依赖 | ---