@modus-ai/modus 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -4
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +9 -8
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/global.js +1 -1
- package/dist/commands/global.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +0 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/status.js +2 -2
- package/dist/generators/claude.d.ts.map +1 -1
- package/dist/generators/claude.js +0 -36
- package/dist/generators/claude.js.map +1 -1
- package/dist/generators/copilot.d.ts.map +1 -1
- package/dist/generators/copilot.js +0 -1
- package/dist/generators/copilot.js.map +1 -1
- package/dist/utils/config.d.ts +32 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +10 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/file-system.d.ts.map +1 -1
- package/dist/utils/file-system.js +2 -1
- package/dist/utils/file-system.js.map +1 -1
- package/package.json +1 -1
- package/schemas/knowledge-schema.yaml +123 -1
- package/templates/behavior-guard.md +165 -0
- package/templates/commands/auto.md +3 -1
- package/templates/commands/commit.md +63 -0
- package/templates/commands/harness.md +15 -8
- package/templates/commands/vibe.md +1 -1
- package/templates/knowledge-catalog.md +66 -10
- package/templates/skills/modus-agents/analyst/SKILL.md +16 -0
- package/templates/skills/modus-agents/deployer/SKILL.md +114 -62
- package/templates/skills/modus-agents/designer/SKILL.md +104 -92
- package/templates/skills/modus-agents/developer/SKILL.md +106 -67
- package/templates/skills/modus-agents/perf-auditor/SKILL.md +98 -61
- package/templates/skills/modus-agents/reviewer/SKILL.md +25 -2
- package/templates/skills/modus-agents/security-auditor/SKILL.md +111 -67
- package/templates/skills/modus-agents/skill-creator/SKILL.md +37 -19
- package/templates/skills/modus-agents/tester/SKILL.md +100 -54
- package/templates/skills/modus-auto/SKILL.md +16 -1
- package/templates/skills/modus-design-brief/SKILL.md +31 -13
- package/templates/skills/modus-harness/SKILL.md +78 -12
- package/templates/skills/modus-init/SKILL.md +801 -161
- package/templates/skills/modus-plan/SKILL.md +109 -43
- package/templates/skills/modus-spec/SKILL.md +175 -331
- package/templates/skills/modus-vibe/SKILL.md +147 -44
|
@@ -1,109 +1,148 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: modus-developer
|
|
3
|
-
description: Use this skill when the Harness orchestrator needs to implement code
|
|
3
|
+
description: Use this skill when the Harness orchestrator needs to implement code based on the sprint plan in 01-analysis.md and design brief in 01.5-design-brief.md. Executes each sprint layer by layer (data→service→orchestration→api), validates with build command after each sprint, and generates 02-sprint-contract.md. Triggered by modus-harness after Gate A0.5 passes.
|
|
4
4
|
allowed-tools: Read, Write, Glob, Bash
|
|
5
5
|
disable: false
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# modus-developer(代码开发 SubAgent)
|
|
9
9
|
|
|
10
|
-
**调用方:** Harness Orchestrator
|
|
11
|
-
**输入:** `01-analysis.md` +
|
|
12
|
-
**产出物:** `modus/plans/active/{story-id}/02-sprint-contract.md` +
|
|
10
|
+
**调用方:** Harness Orchestrator(Gate A0.5 通过后触发)
|
|
11
|
+
**输入:** `01-analysis.md` + `01.5-design-brief.md` + 业务 Skill 内容 + constitution
|
|
12
|
+
**产出物:** `modus/plans/active/{story-id}/02-sprint-contract.md` + 代码变更
|
|
13
13
|
|
|
14
14
|
## 职责
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
按照设计方案(01.5-design-brief.md)的实现蓝图和 01-analysis.md 的 Sprint 计划,逐层实现代码。每个 Sprint 完成后自动验证编译,确保代码质量前置。
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
## 执行流程
|
|
21
21
|
|
|
22
|
-
### Step 1
|
|
22
|
+
### Step 1:读取输入
|
|
23
23
|
|
|
24
|
-
1. 读取 `01-
|
|
25
|
-
2.
|
|
26
|
-
3.
|
|
24
|
+
1. 读取 `01.5-design-brief.md`(技术方案,重点关注节 5-8)
|
|
25
|
+
2. 读取 `01-analysis.md`(Sprint 执行计划、验收标准)
|
|
26
|
+
3. 确认 `constitution.hard_rules` 和 `key_patterns`(最高优先级约束)
|
|
27
|
+
4. 按需读取 Skill 关键文件索引中的实际代码文件(Level 3 加载,≤ 10 个文件)
|
|
27
28
|
|
|
28
|
-
### Step 2:逐 Sprint
|
|
29
|
+
### Step 2:逐 Sprint 实现(严格按层顺序,禁止跳层)
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
**标准层次顺序(每层必须完成并通过编译验证后才能进入下一层):**
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
```
|
|
34
|
+
Sprint 1:数据层
|
|
35
|
+
→ Mapper 接口(必须在 dao 包下)
|
|
36
|
+
→ XML Mapper 或注解式 SQL
|
|
37
|
+
→ Domain / Entity 对象
|
|
38
|
+
|
|
39
|
+
Sprint 2:服务层
|
|
40
|
+
→ Manager / Service(核心业务逻辑)
|
|
41
|
+
→ 事务边界(@Transactional,必须通过 AopContext.currentProxy() 调用)
|
|
42
|
+
→ 分布式锁(如需,@DistributedLock)
|
|
43
|
+
|
|
44
|
+
Sprint 3:接口层(如有)
|
|
45
|
+
→ Controller / Facade
|
|
46
|
+
→ Request / Response DTO(含 @Valid 校验注解)
|
|
47
|
+
→ 权限注解(如 @UserAuthorization)
|
|
48
|
+
|
|
49
|
+
Sprint 4:集成层(如有)
|
|
50
|
+
→ MQ Consumer / Producer
|
|
51
|
+
→ 定时任务
|
|
52
|
+
→ 跨服务 RPC 调用
|
|
53
|
+
```
|
|
36
54
|
|
|
37
|
-
|
|
38
|
-
遵循的通用原则:
|
|
39
|
-
- 命名遵循项目现有风格(从 Skill 或现有代码中获取规范)
|
|
40
|
-
- 新增文件放置到正确的包/目录层次
|
|
41
|
-
- 事务注解使用项目规范方式(避免同类内部调用失效)
|
|
42
|
-
- 分布式锁按项目已有模式使用
|
|
43
|
-
- 参数校验在接口层完成,服务层做业务校验
|
|
44
|
-
- 所有数据库操作必须在正确的事务边界内
|
|
45
|
-
- 金额字段使用 BigDecimal,避免浮点精度问题
|
|
55
|
+
**每个 Sprint 完成后立即执行编译验证:**
|
|
46
56
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- 关键实现决策(与 `01-analysis.md` 中建议有出入时说明原因)
|
|
57
|
+
```bash
|
|
58
|
+
{constitution.build_command} # 如 mvn clean compile -q
|
|
59
|
+
```
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
编译失败 → 立即修复,修复后重新验证,不进入下一 Sprint。
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
### Step 3:Self Code Review(每个 Sprint 完成后执行)
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
在记录产出物前,对本 Sprint 的代码进行自检:
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
```
|
|
68
|
+
自检清单(必须全部通过):
|
|
69
|
+
□ Mapper 接口是否在 dao 包下(来自 constitution.hard_rules)
|
|
70
|
+
□ 金额字段是否符合 constitution 的金额规范
|
|
71
|
+
□ @Transactional 的同类调用是否通过 AopContext.currentProxy()
|
|
72
|
+
□ 是否存在 for 循环内的 DB 查询(N+1 风险)
|
|
73
|
+
□ 新增写入操作是否有事务保护
|
|
74
|
+
□ 对外接口是否有参数校验(@NotNull/@Valid 等)
|
|
75
|
+
□ 是否引用了 Skill [pitfall] 中记录的已知风险点并做了处理
|
|
76
|
+
□ 所有修改是否都能追溯到 01.5-design-brief.md 的追踪矩阵
|
|
77
|
+
```
|
|
62
78
|
|
|
63
|
-
|
|
64
|
-
- 完成 Sprint: {N} 个
|
|
65
|
-
- 新增文件: {N} 个
|
|
66
|
-
- 修改文件: {N} 个
|
|
67
|
-
- 实现时间: {YYYY-MM-DD HH:mm}
|
|
79
|
+
发现问题 → 立即修复,记入 02-sprint-contract.md 的「自检发现」字段。
|
|
68
80
|
|
|
69
|
-
|
|
81
|
+
### Step 4:写入 Sprint Contract
|
|
70
82
|
|
|
71
|
-
|
|
72
|
-
**状态:** ✅ 完成
|
|
83
|
+
每个 Sprint 完成后,将执行情况追加到 `02-sprint-contract.md`:
|
|
73
84
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- 修改: `{文件路径}` — {变更内容}
|
|
85
|
+
```markdown
|
|
86
|
+
## Sprint {N}:{层次名称}
|
|
77
87
|
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
### 实现文件
|
|
89
|
+
| 文件路径 | 变更类型 | 说明 |
|
|
90
|
+
|---------|---------|-----|
|
|
91
|
+
| {path} | 新增/修改 | {1句话} |
|
|
80
92
|
|
|
81
|
-
###
|
|
82
|
-
|
|
93
|
+
### 关键实现决策
|
|
94
|
+
- {架构决策:如「选择注解式 SQL 而非 XML,因为逻辑简单」}
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
- {
|
|
96
|
+
### 自检结果
|
|
97
|
+
- ✅ 所有检查通过 / ⚠️ 发现并修复:{问题描述}
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
-
|
|
89
|
-
- {性能风险点提示}
|
|
90
|
-
- {安全风险点提示}
|
|
99
|
+
### 编译验证
|
|
100
|
+
- 结果:✅ 通过 / ❌ 失败(已修复)
|
|
91
101
|
```
|
|
92
102
|
|
|
93
103
|
---
|
|
94
104
|
|
|
95
|
-
##
|
|
105
|
+
## 产出物格式(02-sprint-contract.md)
|
|
106
|
+
|
|
107
|
+
```markdown
|
|
108
|
+
<!--HANDOFF
|
|
109
|
+
agent: "02-developer"
|
|
110
|
+
story_id: "{story-id}"
|
|
111
|
+
sprint_count: {N}
|
|
112
|
+
sprints_completed: {N}
|
|
113
|
+
gate_status: "{passed|failed}"
|
|
114
|
+
changed_files:
|
|
115
|
+
- "{文件路径}"
|
|
116
|
+
key_decisions:
|
|
117
|
+
- "{实现中做出的关键决策}"
|
|
118
|
+
-->
|
|
119
|
+
|
|
120
|
+
# 代码开发执行合同 — {Story 标题}
|
|
121
|
+
|
|
122
|
+
## 开发摘要
|
|
123
|
+
- 开发时间: {YYYY-MM-DD HH:mm}
|
|
124
|
+
- 完成 Sprint: {N}/{总计N}
|
|
125
|
+
- 变更文件数: {N}
|
|
126
|
+
|
|
127
|
+
{各 Sprint 详情,见 Step 4}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**`gate_status` 赋值规则:**
|
|
131
|
+
- `passed`:所有 Sprint 完成,编译通过,Self Review 无 P1 问题
|
|
132
|
+
- `failed`:编译失败无法自愈,或发现无法自行解决的架构问题 → 上报 Orchestrator
|
|
133
|
+
|
|
134
|
+
---
|
|
96
135
|
|
|
97
|
-
|
|
136
|
+
## 编码规范(来自 constitution + 通用最佳实践)
|
|
98
137
|
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
138
|
+
- **最高优先级**:`constitution.hard_rules` 中的规则不可违反
|
|
139
|
+
- **事务**:同类方法调用事务失效问题,统一用 `AopContext.currentProxy().{method}()` 解决
|
|
140
|
+
- **响应封装**:统一用 `constitution.key_patterns` 中规定的响应封装方式
|
|
141
|
+
- **异常处理**:使用项目已有的异常类,不自创异常类
|
|
142
|
+
- **日志**:关键业务操作(创建/修改/删除)必须有入参日志;异常必须 `log.error` 记录
|
|
104
143
|
|
|
105
|
-
##
|
|
144
|
+
## 越权禁止
|
|
106
145
|
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
146
|
+
- 不修改测试文件(由 SubAgent 03 负责)
|
|
147
|
+
- 不修改 Skill 文件(由 SubAgent 00 负责)
|
|
148
|
+
- 不操作部署流程(由 SubAgent 07 负责)
|
|
@@ -1,116 +1,153 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: modus-perf-auditor
|
|
3
|
-
description: Use this skill when the Harness orchestrator needs to perform static performance audit on code
|
|
4
|
-
allowed-tools: Read,
|
|
3
|
+
description: Use this skill when the Harness orchestrator needs to perform static performance audit on changed code. Detects N+1 queries, missing batch operations, unprotected large data queries, deep pagination risks, and ES query issues. Quantifies each risk by data volume impact and grades as high/medium/low. Generates 04-perf-report.md with HANDOFF block. Triggered by modus-harness in parallel with tester and security-auditor after Gate A passes.
|
|
4
|
+
allowed-tools: Read, Glob
|
|
5
5
|
disable: false
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# modus-perf-auditor(性能审计 SubAgent)
|
|
9
9
|
|
|
10
|
-
**调用方:** Harness Orchestrator
|
|
11
|
-
**输入:** `02-sprint-contract.md
|
|
10
|
+
**调用方:** Harness Orchestrator(Gate A 通过后,与 03/05 并行触发)
|
|
11
|
+
**输入:** `02-sprint-contract.md`(变更文件列表)+ 代码变更 + 业务 Skill(≤ 2 个)
|
|
12
12
|
**产出物:** `modus/plans/active/{story-id}/04-perf-report.md`
|
|
13
13
|
|
|
14
14
|
## 职责
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
对本次代码变更进行静态性能审计,重点检测高频性能反模式,量化每个风险的潜在影响(N 条数据 → N 次 SQL),按高/中/低分级输出报告。不执行代码,不修改文件。
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## 检测规则
|
|
21
21
|
|
|
22
|
-
### 1
|
|
22
|
+
### Rule 1:N+1 查询(高风险)
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
- 循环体内包含 DB 查询调用(`for/while` 内调用 `mapper.select*`)
|
|
26
|
-
- 循环内调用 RPC/HTTP 接口
|
|
24
|
+
**触发条件:** Service / Manager 类的 for 循环 / forEach / stream 内包含 Mapper 调用
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
```java
|
|
27
|
+
// ❌ 触发 N+1
|
|
28
|
+
for (Long orderId : orderIds) {
|
|
29
|
+
Order order = orderMapper.selectById(orderId); // N 次 SQL
|
|
30
|
+
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
// ✅ 正确:批量查询
|
|
33
|
+
List<Order> orders = orderMapper.selectByIds(orderIds); // 1 次 SQL
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**量化影响:** `N 个订单 → N+1 次 SQL(实测 1000 条 ≈ 1001 次查询)`
|
|
37
|
+
**修复建议:** 改用 `selectByIds(ids)` 批量查询,结果用 Map 分组后使用
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### Rule 2:无分页保护的大数据量查询(高风险)
|
|
42
|
+
|
|
43
|
+
**触发条件:** Mapper/SQL 中存在以下任一情况:
|
|
44
|
+
- `selectAll()` / `SELECT * FROM table` 无 WHERE 限制
|
|
45
|
+
- 列表查询缺少 `LIMIT` 或时间范围条件
|
|
46
|
+
- 分页参数未设置最大页大小保护
|
|
47
|
+
|
|
48
|
+
**量化影响:** `全表扫描,数据量增长后 OOM 风险`
|
|
49
|
+
**修复建议:** 添加 `LIMIT` 或时间范围条件;分页接口验证 `pageSize ≤ 200`
|
|
35
50
|
|
|
36
51
|
---
|
|
37
52
|
|
|
38
|
-
###
|
|
53
|
+
### Rule 3:深分页风险(中风险)
|
|
39
54
|
|
|
40
|
-
|
|
41
|
-
- 循环内调用单条 insert/update
|
|
42
|
-
- 应使用 `insertBatch` 但使用了逐条 `insert`
|
|
55
|
+
**触发条件:** SQL 中使用 `LIMIT offset, size` 且 offset 无上限控制
|
|
43
56
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- 大批量操作分批提交(每批 500-1000 条),避免超大事务
|
|
57
|
+
**量化影响:** `offset=10000, size=10 → 扫描 10010 行,只返回 10 行`
|
|
58
|
+
**修复建议:** 改用游标分页(`WHERE id > lastId LIMIT size`)或设置 offset 上限
|
|
47
59
|
|
|
48
60
|
---
|
|
49
61
|
|
|
50
|
-
###
|
|
62
|
+
### Rule 4:循环内批量写操作(中风险)
|
|
51
63
|
|
|
52
|
-
|
|
53
|
-
- 查询无 LIMIT 限制
|
|
54
|
-
- 分页查询缺少总数上限保护
|
|
55
|
-
- 深分页(`OFFSET` 过大)
|
|
56
|
-
- 全表扫描风险(无索引条件)
|
|
64
|
+
**触发条件:** for 循环内包含 `insert` / `update` / `delete` 调用(而非批量接口)
|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
- 深分页改用游标分页(基于最后一条记录的 ID)
|
|
66
|
+
**量化影响:** `N 个写入 → N 次 SQL,N 个事务提交`
|
|
67
|
+
**修复建议:** 改用 `insertBatch(list)` / `updateBatch(list)`,单事务批量提交
|
|
61
68
|
|
|
62
69
|
---
|
|
63
70
|
|
|
64
|
-
###
|
|
71
|
+
### Rule 5:缺少索引的高频查询(中风险)
|
|
72
|
+
|
|
73
|
+
**触发条件:** SQL 的 WHERE 条件字段组合在 Entity 注解或已知索引列表中不存在对应索引
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- 缺少 `trackTotalHits: false`(数据量大时计算总数代价高)
|
|
69
|
-
- 聚合查询无 `size: 0`(无需 hits 时)
|
|
75
|
+
**量化影响:** `全表扫描,数据量 > 10 万行后查询超时风险`
|
|
76
|
+
**修复建议:** 添加复合索引 `idx_{field1}_{field2}`
|
|
70
77
|
|
|
71
78
|
---
|
|
72
79
|
|
|
73
|
-
###
|
|
80
|
+
### Rule 6:前缀模糊匹配(低风险)
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
- `@Transactional` 方法内包含远程调用(RPC/HTTP)
|
|
77
|
-
- 事务内包含大量数据查询或处理逻辑
|
|
82
|
+
**触发条件:** SQL 中使用 `LIKE '%keyword%'`(前缀通配符导致索引失效)
|
|
78
83
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
**量化影响:** `索引失效,全表扫描`
|
|
85
|
+
**修复建议:** 改用全文索引(FULLTEXT)或引入 ES 搜索
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 执行流程
|
|
90
|
+
|
|
91
|
+
### Step 1:确定审计范围
|
|
92
|
+
|
|
93
|
+
读取 `02-sprint-contract.md` 的 `changed_files`,筛选需要审计的文件:
|
|
94
|
+
- Service / Manager 类(Rule 1/4)
|
|
95
|
+
- Mapper 接口 + XML(Rule 2/3/5/6)
|
|
96
|
+
- Controller(Rule 2 的分页参数)
|
|
97
|
+
|
|
98
|
+
### Step 2:逐规则扫描
|
|
99
|
+
|
|
100
|
+
对每个目标文件,逐一应用上述 6 条规则,记录发现的风险。
|
|
101
|
+
|
|
102
|
+
### Step 3:风险分级与量化
|
|
103
|
+
|
|
104
|
+
| 风险等级 | 定义 | 处理要求 |
|
|
105
|
+
|---------|------|---------|
|
|
106
|
+
| 高(需 P2 重入)| 生产环境下数据量正常情况即会触发的性能问题 | modus-reviewer 将标记为 P2,触发 Loop 2 |
|
|
107
|
+
| 中(建议修复)| 数据量增长后可能触发,当前影响有限 | cr-report 中作为 P3 建议 |
|
|
108
|
+
| 低(记录观察)| 仅在极端场景下触发 | 记录但不阻塞 |
|
|
82
109
|
|
|
83
110
|
---
|
|
84
111
|
|
|
85
112
|
## 产出物格式(04-perf-report.md)
|
|
86
113
|
|
|
87
114
|
```markdown
|
|
88
|
-
|
|
115
|
+
<!--HANDOFF
|
|
116
|
+
agent: "04-perf-auditor"
|
|
117
|
+
story_id: "{story-id}"
|
|
118
|
+
gate_status: "passed"
|
|
119
|
+
high_risks: {N}
|
|
120
|
+
medium_risks: {N}
|
|
121
|
+
-->
|
|
122
|
+
|
|
123
|
+
# 性能审计报告 — {Story 标题}
|
|
89
124
|
|
|
90
125
|
## 审计摘要
|
|
91
126
|
- 审计文件数: {N}
|
|
92
127
|
- 高风险: {N} 个 | 中风险: {N} 个 | 低风险: {N} 个
|
|
93
128
|
|
|
94
|
-
##
|
|
129
|
+
## 高风险(需修复)
|
|
95
130
|
|
|
96
|
-
### [HIGH-01] N+1 查询
|
|
131
|
+
### [PERF-HIGH-01] N+1 查询 — {ClassName}.{method}()
|
|
97
132
|
- **位置:** `{文件名}.java:{行号}`
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
List<Long> ids = orders.stream().map(Order::getId).collect(toList());
|
|
104
|
-
Map<Long, Order> orderMap = orderMapper.selectBatchIds(ids)
|
|
105
|
-
.stream().collect(toMap(Order::getId, o -> o));
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## 中风险问题
|
|
133
|
+
- **风险描述:** 循环内调用 `{MapperClass}.{queryMethod}()`
|
|
134
|
+
- **量化影响:** N 个{实体} → N+1 次 SQL(1000 条 ≈ 1001 次查询)
|
|
135
|
+
- **修复建议:** 改为 `{MapperClass}.selectByIds(ids)` 批量查询
|
|
136
|
+
|
|
137
|
+
## 中风险(建议修复)
|
|
109
138
|
...
|
|
110
139
|
|
|
111
|
-
##
|
|
140
|
+
## 低风险(观察记录)
|
|
112
141
|
...
|
|
113
142
|
|
|
114
|
-
##
|
|
115
|
-
{
|
|
143
|
+
## 无风险确认
|
|
144
|
+
{若某类规则未发现风险,明确写出「Rule N:未发现 XXX 问题」}
|
|
116
145
|
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 质量标准
|
|
150
|
+
|
|
151
|
+
- 每个风险必须有文件路径 + 行号定位
|
|
152
|
+
- 高风险必须量化影响(N 条数据 → N 次查询)
|
|
153
|
+
- **HANDOFF 块必须位于文件最顶部**,`high_risks` 字段供 modus-reviewer 决定是否报 P2
|
|
@@ -53,8 +53,8 @@ disable: false
|
|
|
53
53
|
- 日志是否完整(入参、出参、异常信息)
|
|
54
54
|
|
|
55
55
|
**金额处理:**
|
|
56
|
-
-
|
|
57
|
-
-
|
|
56
|
+
- 金额字段是否符合项目宪法的规范(以 `constitution.hard_rules` 为准,如规则为「金额字段使用 Long(单位:分)」则检查 Long 类型,如规则为「使用 BigDecimal」则检查 BigDecimal;**不得硬编码检查某一具体类型**)
|
|
57
|
+
- 若 `constitution.hard_rules` 未明确金额规范,则默认检查是否使用 BigDecimal,并在报告中标注「未找到金额规范配置,使用默认规则」
|
|
58
58
|
|
|
59
59
|
### 维度 3:测试覆盖(参考 03-test-report.md)
|
|
60
60
|
|
|
@@ -81,6 +81,23 @@ disable: false
|
|
|
81
81
|
## 产出物格式(cr-report.md)
|
|
82
82
|
|
|
83
83
|
```markdown
|
|
84
|
+
<!--HANDOFF
|
|
85
|
+
agent: "06-review"
|
|
86
|
+
story_id: "{story-id}"
|
|
87
|
+
gate_status: "{passed|failed}"
|
|
88
|
+
issues:
|
|
89
|
+
- id: "P1-01"
|
|
90
|
+
level: "P1"
|
|
91
|
+
sprint: {受影响的 Sprint 编号,如 2}
|
|
92
|
+
file: "{文件名}.java:{行号}"
|
|
93
|
+
summary: "{一句话问题摘要,供 Orchestrator 定位重入范围}"
|
|
94
|
+
- id: "P2-01"
|
|
95
|
+
level: "P2"
|
|
96
|
+
sprint: {N}
|
|
97
|
+
file: "{文件名}.java:{行号}"
|
|
98
|
+
summary: "{一句话问题摘要}"
|
|
99
|
+
-->
|
|
100
|
+
|
|
84
101
|
# 代码评审报告
|
|
85
102
|
|
|
86
103
|
## 评审摘要
|
|
@@ -116,6 +133,12 @@ disable: false
|
|
|
116
133
|
{如无 P1/P2 → "通过评审,可进入 Final Review"}
|
|
117
134
|
```
|
|
118
135
|
|
|
136
|
+
**HANDOFF 块填写规则:**
|
|
137
|
+
- `gate_status`:无 P1/P2 → `passed`;有 P1/P2 → `failed`
|
|
138
|
+
- `issues`:仅列 P1/P2 问题(P3 不阻塞,Orchestrator 不读取);无 P1/P2 时写空列表 `issues: []`
|
|
139
|
+
- 每条 issue 的 `sprint` 字段:填写受影响代码所属的 Sprint 编号,供 Orchestrator 精准定位重入范围
|
|
140
|
+
- HANDOFF 块**必须位于文件最顶部**,Orchestrator 仅读此块(≤ 20 行)以决策是否触发 Loop 2
|
|
141
|
+
|
|
119
142
|
---
|
|
120
143
|
|
|
121
144
|
## 创建 Bug 单(可选)
|