feat: v2.0 iteration — test coverage, reliability, observability

M0: Test coverage expansion (151 → 321 tests, 61% → 66% lines)
  - normalizeKnowledge CRLF/LF normalization fix
  - gooseReviewer: 11 tests, 97.35% coverage
  - r2 storage: 22 tests, 100% coverage
  - triage processor: 11 tests, exported buildTriagePrompt/labelName
  - webhook processor: 35 tests, 72.39% coverage
  - conflict resolver: 12 tests
  - review processor: 7 tests

M1: Reliability hardening
  - Smart retry with jitter, maxTotalTimeoutMs, custom retryable predicate
  - MergeGuard: in-memory merge dedup tracker (100% coverage)
  - failureMessages: 7-category failure classifier (100% coverage)

M2: Observability
  - MetricsCollector: Actions-run metrics with snapshot/markdown/reset
  - 11 tests, 100% coverage

New files: 12 test files, 3 source modules
All gates: typecheck ✓ lint ✓ format ✓ 321/321 tests ✓ build ✓
This commit is contained in:
ghbot committed 2026-08-24 17:34:04 +08:00
1 parent db53296d78
commit 78bf8e9e41
87 files changed
+6003 -2587

No files matched your search

+4
View File
@@ -16,11 +16,13 @@
## 技术原则
### 架构
- 单一职责:一个模块只回答一个问题(谁调用它、它调用谁、失败时谁兜底)。
- 共享清单单一来源:安全排除/脱敏/路径策略只允许一份实现(src/security/, src/runtimePaths.ts)。
- 行为不变的重构必须与功能变更分开提交,且全量测试保护。
### 质量门禁(提交前全部通过)
1. `npm run typecheck` — 0 错误
2. `npm run lint` — 0 error
3. `npm run format:check` — 通过
@@ -29,6 +31,7 @@
6. `npm audit --omit=dev` — 无 high 以上
### 安全红线(继承 CLAUDE.md,不可协商)
- AUTO_MERGE=false 默认值不可改
- 恢复缓存审查结果必须重新完整审查,不得直接复用旧决策
- fork 推送必须 SHA 钉住 --force-with-lease
@@ -37,6 +40,7 @@
## 决策框架
技术选型按序评估:
1. 是否触碰安全红线?(触碰 → 拒绝)
2. 是否可用现有轮子解决?(可以 → 不写新代码)
3. 失败时的降级行为是否清晰?(不清晰 → 先设计降级)
@@ -9,36 +9,46 @@ ghbot 已在生产仓库运行(自动审查/分类/合并/冲突修复)。
## 用户故事
### US-1: 部署者首次接入
作为部署者,我希望按 README 从零配置后一次跑通,无需口口相传的隐性前提。
**验收**:
- [ ] .env.example 覆盖全部 config schema 字段且默认值一致
- [ ] README 步骤与实际命令一一对应
- [ ] 新增配置项有文档说明
### US-2: 事件全链路
作为仓库维护者,任何支持的事件触发后都有确定行为与反馈。
**验收**:
- [ ] workflow 触发的事件类型 ⊆ runReview.ts 处理集合(无静默吞事件)
- [ ] issue_comment 三链路互不阻断
- [ ] 每条失败路径都有可见反馈或日志
### US-3: 审查结果可信
作为 PR 作者,审查评论必须准确、可定位、不误导。
**验收**:
- [ ] finding 的 path/line 经净化后才提交
- [ ] 无法 inline 的 findings 折叠展示不丢失
- [ ] 状态横幅与 disposition 一致
### US-4: webhook 服务可运维
作为运维者,服务健康可探活、指标可观测、异常可恢复。
**验收**:
- [ ] /healthz 与 /metrics 真实可用
- [ ] 队列满/签名错/超大包均有明确响应码
- [ ] 失败投递进程内重试后仍可被 GitHub 重投
### US-5: 剩余指南项落地
指南 7.1 / 6.4 / 8.5 / 4.4 不再是"候选",全部实现或有明确的不适用结论。
**验收**:
- [ ] 每项有代码证据或书面不适用理由
- [ ] 全部门禁通过
@@ -1,10 +1,12 @@
# Implementation Tasks: 001-production-hardening
## Phase 1: Spec and audit
- [x] 1.1 Constitution + spec
- [x] 1.2 Parallel contract/security/error/docs audit
## Phase 2: Production guards
- [x] 2.1 Merge SHA recheck + pulls.merge sha
- [x] 2.2 Conflict lock + git command timeout + dirty worktree reset
- [x] 2.3 Webhook body timeout/size and request catch
@@ -16,6 +18,7 @@
- [x] 2.9 Event logger child bindings
## Phase 3: Verify and handoff
- [ ] 3.1 Local gates (typecheck/lint/format/test)
- [ ] 3.2 Webhook HTTP E2E
- [ ] 3.3 Independent review