brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
cr-code-gate【Code Review 子 Agent · 门控二】对 git diff 逐项执行代码质量门控检查(运行时异常、性能瓶颈、安全漏洞、权限缺失、破坏性变更等 10 项),按 LOGAF h/m/l 分级输出,h 级清零后方可进入门控三。由 spec-driven-dev 的 code_review 阶段自动调用。
Independent GitHub snapshot · Automated classification · Original documentation governs
Code Review 流水线的第二道门控:代码质量静态门控子 Agent。
由 spec-driven-dev 的 code_review 阶段在 cr-commit-check 通过后调用,
对 diff 进行结构性问题扫描,参照 Sentry 工程实践的必检项分类。
| 字段 | 类型 | 说明 |
|---|---|---|
us_id | string | 用户故事 ID |
iter_id | string | 当前迭代 ID |
git_diff | string | git diff main...HEAD 的完整输出 |
iter_summary_path | string | requirements/{us_id}/docs/iteration_summary/current_iter.md 路径,用于核查架构变更审批记录 |
coding_standards_path | string | auxiliary/coding_standards.md 路径 |
Orchestrator 调用示例(OpenCode Sub-Agent 格式):
invoke_skill: cr-code-gate
with:
us_id: "US042"
iter_id: "iter_003"
git_diff: "<diff output>"
iter_summary_path: "requirements/US042/docs/iteration_summary/current_iter.md"
coding_standards_path: "auxiliary/coding_standards.md"
{
"agent": "cr-code-gate",
"verdict": "PASS | WARN | FAIL",
"h_count": 0,
"m_count": 0,
"l_count": 0,
"findings": [
{
"id": "GK-01",
"logaf": "h",
"result": "PASS | FAIL | WARN",
"file": "src/foo.py:42",
"description": "…",
"suggestion": "…"
}
]
}
[AGENT:cr-code-gate] START us_id={us_id} iter_id={iter_id}
git_diff,提取所有变更文件和具体行变更。current_iter.md,检索是否有架构/Schema 变更的 senior 确认记录(供 GK-08 使用)。coding_standards.md,获取项目命名与规范约定(供 GK-10 使用)。对 diff 中每一个变更文件/代码块执行以下 10 项检查:
h 级(任意一项命中 → 整体 FAIL)_ = err)(api_key|secret|password|token)\s*=\s*['"][^'"]+['"])pickle.loads、eval、exec 处理用户数据)../ 未过滤的文件路径拼接)string → int)m 级(命中 → WARN,记录后可继续)current_iter.md 中无 senior 确认记录l 级(命中 → INFO,可选修复)print()、console.log()、fmt.Println()、System.out.println())TODO / FIXMEcoding_standards.md 约定不一致每条发现使用统一格式:
[{logaf}] {GK-ID} | 文件: {path}:{line} | 问题: {描述} | 建议: {可操作方案}
示例:
[h] GK-03 | 文件: src/auth/handler.py:47 | 问题: API Key 硬编码在源文件 | 建议: 改为 os.getenv("API_KEY"),在 .env.example 添加占位符
[h] GK-01 | 文件: src/db/query.py:83 | 问题: result[0] 访问前未检查列表长度 | 建议: 改为 result[0] if result else None
[m] GK-07 | 文件: tests/test_auth.py | 问题: 缺少越权访问的拒绝场景测试 | 建议: 新增 test_access_denied_for_non_owner
[l] GK-09 | 文件: src/utils/parser.py:12 | 问题: 注释掉的旧代码块 | 建议: 删除或移至 CHANGELOG
{
"agent": "cr-code-gate",
"verdict": "FAIL",
"h_count": 2,
"m_count": 1,
"l_count": 1,
"findings": [
{
"id": "GK-03", "logaf": "h", "result": "FAIL",
"file": "src/auth/handler.py:47",
"description": "API Key 硬编码",
"suggestion": "改为 os.getenv('API_KEY')"
}
]
}
[AGENT:cr-code-gate] DONE verdict=PASS|WARN|FAIL h={N} m={N} l={N}
| 裁决 | 条件 | Orchestrator 行为 |
|---|---|---|
| PASS | 所有 h 级检查项均无命中(m/l 可有) | 继续调用 cr-logaf-review |
| WARN | 无 h 级命中,存在 m/l 级发现 | 继续调用 cr-logaf-review,m/l 发现传入汇总报告 |
| FAIL | 任意 h 级检查项命中 | 终止流水线,阻塞 release,返回修复清单 |
h 级问题降级为 m 或 l,即使代码作者附有解释。git_diff 为空时静默通过,应报告 GK-06 INFO(本次无代码变更)。