This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-08-11
|
||||
@@ -0,0 +1,28 @@
|
||||
## Context
|
||||
|
||||
事件投影已批量加载资源,但未加载 `tb_integration_log`;请求和关联时间线已有按 `audit_event_id` 归集集成引用的逻辑。
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- 为列表和详情的事件投影一次批量补全稳定集成交互引用。
|
||||
- 复用现有去重规则,保持空数组响应形态。
|
||||
|
||||
**Non-Goals:**
|
||||
- 不通过请求、关联标识、资源、名称或时间推断关联。
|
||||
- 不变更 Integration Log 写入链路、数据库结构或现有时间线行为。
|
||||
|
||||
## Decisions
|
||||
|
||||
- 在事件投影中使用当前页/当前详情的内部审计事件 ID 批量查询 `tb_integration_log.audit_event_id IN (...)`,再按 ID 归集。该字段是唯一明确的事件归属;逐事件查询会造成 N+1 查询。
|
||||
- 复用 `integrationRefsByAuditID` 和 `uniqueIntegrationRefs`。不增加新的查询层或 DTO。
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- [历史集成日志未写入 `audit_event_id`] → 保持为空,不猜测关系;由写入链路后续补齐新数据。
|
||||
|
||||
## Migration Plan
|
||||
|
||||
1. 部署查询代码变更,无迁移。
|
||||
2. 用同时存在关联与未关联日志的事件验证列表和详情响应。
|
||||
3. 回滚时恢复事件投影的关联日志批量查询与引用合并代码。
|
||||
@@ -0,0 +1,23 @@
|
||||
## Why
|
||||
|
||||
审计事件列表和详情已声明可返回外部集成交互跳转引用,但当前投影未读取关联日志,导致 `integration_refs` 始终为空,前端无法从事件直接进入对应集成记录。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 为全局审计事件列表和单事件详情补全由已关联 Integration Log 生成的 `investigation_refs.integration_refs`。
|
||||
- 保持没有关联日志的事件返回空数组,且不根据名称、时间或摘要推断关联。
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
- 无。
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `operations-audit`: 审计事件查询返回与事件稳定关联的外部集成交互跳转引用。
|
||||
|
||||
## Impact
|
||||
|
||||
- `internal/query/audit/events.go` 的事件投影。
|
||||
- `GET /api/admin/audit/events` 和 `GET /api/admin/audit/events/{event_id}` 的响应内容;无需新增依赖或迁移。
|
||||
@@ -0,0 +1,23 @@
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: 审计时间线
|
||||
|
||||
系统 SHALL 支持按事件、操作者、资源、请求、关联标识和资金维度查询已记录的审计事实。事件列表和事件详情中的 `investigation_refs.integration_refs` SHALL 仅包含 `tb_integration_log.audit_event_id` 稳定关联至该事件的非空 `integration_id`;没有关联记录时 SHALL 返回空数组,系统 MUST NOT 按名称、时间或摘要推断关联。
|
||||
|
||||
#### Scenario: 审计时间线
|
||||
|
||||
- **GIVEN** 审计事实已存在
|
||||
- **WHEN** 使用对应维度查询
|
||||
- **THEN** 返回匹配的事实与稳定动作编码,不用访问日志替代
|
||||
|
||||
#### Scenario: 事件返回已关联外部交互引用
|
||||
|
||||
- **GIVEN** 一个在线审计事件有 `tb_integration_log.audit_event_id` 指向其内部 ID 的外部交互记录
|
||||
- **WHEN** 查询全局审计事件列表或该事件详情
|
||||
- **THEN** 该事件的 `investigation_refs.integration_refs` 返回该记录的 `integration_id`
|
||||
|
||||
#### Scenario: 事件没有关联外部交互引用
|
||||
|
||||
- **GIVEN** 一个在线审计事件没有稳定关联的外部交互记录
|
||||
- **WHEN** 查询全局审计事件列表或该事件详情
|
||||
- **THEN** `investigation_refs.integration_refs` 返回空数组
|
||||
@@ -0,0 +1,9 @@
|
||||
## 1. 审计事件投影
|
||||
|
||||
- [x] 1.1 批量查询当前审计事件关联的 Integration Log,并按审计事件内部 ID 归集非空集成交互 ID。
|
||||
- [x] 1.2 在列表和详情共用的事件投影中填充并去重 `investigation_refs.integration_refs`,无关联时保留空数组。
|
||||
|
||||
## 2. 验证
|
||||
|
||||
- [x] 2.1 运行格式化和构建,验证包含关联与未关联 Integration Log 的事件投影行为。
|
||||
- [x] 2.2 运行 OpenSpec 校验。
|
||||
Reference in New Issue
Block a user