1
0
Files
DiAL/openspec/changes/archive/2026-05-10-abstract-target-expect-checkers/tasks.md

51 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 1. 类型与配置契约
- [x] 1.1 重构 checker 类型定义为 `http``command` 判别联合,并新增 `CheckFailure``durationMs``statusDetail` 等结果字段,将 `maxLatencyMs` 重命名为 `maxDurationMs`
- [x] 1.2 更新 YAML 配置类型,新增 `runtime.maxConcurrentChecks``defaults.http``defaults.command` 和 typed target 配置
- [x] 1.3 实现 size 解析工具,支持 `B``KB``MB``GB` 并覆盖 `100MB=104857600` 的测试
- [x] 1.4 重构 config-loader 校验逻辑,移除顶层 HTTP 字段支持并校验 type、http.url、command.exec、并发和 size 格式ResolvedConfig 需携带配置文件目录,用于 command cwd 相对路径解析
- [x] 1.5 更新配置解析测试,覆盖最简 HTTP、最简 command、per-target 覆盖、默认值、非法 type、缺失字段和非法 size
## 2. Expect 与失败信息
- [x] 2.1 抽取通用值操作符,使 equals、contains、match、empty、exists、gte、lte、gt、lt 可复用于 header、body、stdout 和 stderr
- [x] 2.2 将 HTTP `expect.body` 重构为有序规则数组,并支持 contains、regex、json、css、xpath 规则
- [x] 2.3 实现 HTTP expect pipeline按 status、duration、headers、body[] 顺序执行并应用默认 `status: [200]`
- [x] 2.4 实现 command expect pipeline按 exitCode、duration、stdout[]、stderr[] 顺序执行并应用默认 `exitCode: [0]`
- [x] 2.5 实现结构化 failure 生成与 actual 摘要截断,区分 `error``mismatch`
- [x] 2.6 将 expect 相关文件body、http、command、failure移入 `checker/expect/` 子目录,统一导入路径并更新测试文件引用
- [x] 2.7 更新 expect 单元测试,覆盖规则顺序、快速失败、默认 status、默认 exitCode、失败 path 和 actual 截断
## 3. Runner 与调度引擎
- [x] 3.1 将现有 fetcher 拆分或重命名为 HTTP runner并改为读取 status、duration、headers 后再按需读取 body
- [x] 3.2 在 HTTP runner 中实现 maxBodyBytes 限制、超时处理、statusDetail 和结构化执行错误
- [x] 3.3 新增 command runner使用 `exec + args` 执行本地命令且不经过 shell
- [x] 3.4 在 command runner 中实现 cwd 相对配置文件目录解析、env 覆盖、timeout kill 和 maxOutputBytes 合计限制
- [x] 3.5 重构 ProbeEngine 按 target.type 选择 runner并引入全局 maxConcurrentChecks 并发池
- [x] 3.6 更新 runner 和 engine 测试,覆盖 HTTP 快速失败不读 body、command 非零退出、启动失败、超时、输出超限和并发限制
## 4. 存储与 API
- [x] 4.1 重建 SQLite schema使用 targets 的 type、target、config 字段和 check_results 的 duration_ms、status_detail、failure 字段
- [x] 4.2 更新目标同步逻辑,持久化 HTTP URL 摘要和 command 命令摘要
- [x] 4.3 更新检查结果写入和聚合查询,使用 duration_ms 计算平均耗时、P99 耗时和趋势数据
- [x] 4.4 更新 shared API 类型,将 avgLatencyMs、p99LatencyMs、latencyMs、statusCode 替换为 avgDurationMs、p99DurationMs、durationMs、statusDetail 和 failure
- [x] 4.5 更新 API handler 映射逻辑,返回 type、target、durationMs、statusDetail、failure 和新的统计字段
- [x] 4.6 更新 store 和 API 测试,覆盖结构化 failure 入库、目标摘要、summary、targets、history 和 trend 响应
## 5. Dashboard 与文档
- [x] 5.1 更新 Dashboard 总览卡片、目标表格和详情面板,将 URL/方法/延迟改为类型、目标、耗时和失败原因展示
- [x] 5.2 更新趋势图和 Sparkline 数据字段,从 latency 切换为 duration
- [x] 5.3 更新前端类型引用和组件测试或相关断言,覆盖 HTTP 与 command target 展示
- [x] 5.4 更新 README 的项目说明、配置说明、目标状态判定、API 字段和已知限制
- [x] 5.5 更新 `probes.example.yaml`,提供 HTTP 与 command typed target 示例以及 100MB 默认说明
- [x] 5.6 更新 smoke test 配置和断言,确保生产 executable 可使用新配置启动并服务 API 与 Dashboard
## 6. 质量验证
- [x] 6.1 运行 `bun run check`修复类型检查、lint、格式检查和单元测试问题
- [x] 6.2 运行 `bun run verify`,修复生产构建和 smoke test 问题
- [x] 6.3 复查 OpenSpec change 与实现一致性,确认所有任务完成且 README、测试和示例同步更新