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

+12 -8
View File
@@ -9,6 +9,7 @@
## 1. 研究分析(已完成)
v1.0.0 后指南中仍未落地项盘点:
- D-02(三处 listPullRequestFiles 重复)
- D-09(redactProcessArgs 脆弱索引)、D-13(运行时目录硬编码)
- 6.1(审查输出排版)、6.3(命令 ack 反馈)、8.4(错误输出脱敏接线)
@@ -19,14 +20,14 @@ v1.0.0 后指南中仍未落地项盘点:
## 4. 执行日志(全部完成 ✅)
| 提交 | 指南项 | 内容 | 验证 |
|------|--------|------|------|
| `941e1d2` | D-02 | 三处重复函数统一到 `src/github/pulls.ts` | test 134 全绿 |
| `d9666c9` | D-13 | `GHBOT_RUNTIME_DIR` + `src/runtimePaths.ts` 集中目录;cacheStore/gooseCli/chat/conflictResolver/cache 五处接入;+3 测试 | test 137 全绿 |
| `a35587e` | 6.1 | 状态横幅 + `<details>` 折叠 + 加粗计数;format 测试扩展断言 | test 137 全绿 |
| `3408c9d` | 6.3 | `formatCommandAckMessage` 统一 ack 文案;processor 接线;+2 测试 | test 139 全绿 |
| `cd30a49`+`65907f4` | D-09 | 显式哨兵参数替代标签匹配;新旧测试同步更新 | test 139 全绿 |
| `31ff19e`+`8304c98` | 8.4 | `commandFailureOutput` 输出经 `redactSecrets` 掩码后进入 prompt/评论/日志;+3 测试 | test 142 全绿 |
| 提交 | 指南项 | 内容 | 验证 |
| ------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------- | ------------- |
| `941e1d2` | D-02 | 三处重复函数统一到 `src/github/pulls.ts` | test 134 全绿 |
| `d9666c9` | D-13 | `GHBOT_RUNTIME_DIR` + `src/runtimePaths.ts` 集中目录;cacheStore/gooseCli/chat/conflictResolver/cache 五处接入;+3 测试 | test 137 全绿 |
| `a35587e` | 6.1 | 状态横幅 + `<details>` 折叠 + 加粗计数;format 测试扩展断言 | test 137 全绿 |
| `3408c9d` | 6.3 | `formatCommandAckMessage` 统一 ack 文案;processor 接线;+2 测试 | test 139 全绿 |
| `cd30a49`+`65907f4` | D-09 | 显式哨兵参数替代标签匹配;新旧测试同步更新 | test 139 全绿 |
| `31ff19e`+`8304c98` | 8.4 | `commandFailureOutput` 输出经 `redactSecrets` 掩码后进入 prompt/评论/日志;+3 测试 | test 142 全绿 |
### 4.3 最终门禁(实测输出)
@@ -59,15 +60,18 @@ CI run 32617043840 (push main): typecheck-lint-test → success (35s)
## 5. 回顾总结
### 成果
- 指南缺陷表 D-02/D-09/D-13 全部关闭;6.1/6.3/8.4 三项体验与安全项落地
- 测试 134 → 142;总体覆盖率 61.64% → 62.51%
### 经验
1. node -e 内联脚本做跨文件批量替换时,正则转义极易失配——复杂替换改用 Edit 工具更可靠(8.4 第一次替换静默失败即为教训)
2. 改共享函数签名时必须同轮 grep 所有测试调用点,否则出现"实现绿、旧测试红"
3. Windows 下后台启动服务后立即 curl 可能撞上启动窗口,sleep 2 重试即可,不必重启
### 剩余建议(下一轮候选)
- 7.1 事件路由器解耦(processor.ts 编排覆盖率的根本解法)
- 6.4 语言字典(BOT_REPLY_LANGUAGE)
- 8.5 goose CLI 校验和固定下载