Files
SubsTracker/tests/data
wangwangit b9de410f6f feat(observability): 三类可观测性仓库 + 迁移扩展
新增三个 KV 仓库(v3 通知/调度可观测性数据底座):

1. src/data/reminders.repo.js
   - reminder_rules:{subId} 数组,支持 CRUD + 智能预设(4 条:到期前 7/3/1/当天)
   - legacyFieldToRule 把 v2 的 reminderUnit/reminderValue 单点提醒
     转成 1 条等价 before_expiry 规则
   - normalizeRule 修复非法字段,repeatInterval 仅 after_expiry 类型保留

2. src/data/notification-logs.repo.js
   - notify_log:{ymdh}:{subId}:{ruleId}:{channel}:{rand}, TTL 30 天
   - writeLog / query(subId/channel/status/since/until/limit 过滤)
   - 时间倒序,KV.list 拉全后排序

3. src/data/scheduler-logs.repo.js
   - sched_log:{isoUtc}, TTL 30 天
   - writeLog / getRecent(按时间倒序)

迁移扩展:MIGRATION_STEPS 追加两个 step
   - reminder_rules_v3:为现有订阅生成默认提醒规则
   - scheduler_logs_v3:v2 的 scheduler_status_history 转换到新表

调试页新增链接:/debug?export=sched_logs&limit=50 直接下载 JSON

测试:
- tests/data/reminders.test.js (13)
- tests/data/notification-logs.test.js (8)
- tests/data/scheduler-logs.test.js (4)
- 共 85 条测试全绿;lint 干净

Refs Task 4 of refactor/v3-product-grade plan.
2026-05-24 18:03:01 +08:00
..