docs(health-profile): 添加防编造加固修订记录到导出健康档案设计文档

补充了关于导出摘要出现虚构病例问题的详细分析和修复方案,
包括检索策略优化、空数据兜底处理和prompt重写等三层防护措施。
```
This commit is contained in:
link2026
2026-05-30 20:06:12 +08:00
parent dad9d43486
commit 7ad41c5f09
26 changed files with 9062 additions and 7697 deletions

View File

@@ -0,0 +1,81 @@
import Testing
import Foundation
@testable import
/// (`occurs(on:)`)
/// Gregorian , `Date.now` /
struct TodayRemindersLogicTests {
private var cal: Calendar {
var c = Calendar(identifier: .gregorian)
c.timeZone = TimeZone(identifier: "Asia/Shanghai")!
return c
}
private func date(_ y: Int, _ mo: Int, _ d: Int) -> Date {
cal.date(from: DateComponents(year: y, month: mo, day: d, hour: 12))!
}
// MARK: - CustomReminder
@Test func dailyOccursEveryDay() {
let r = CustomReminder(title: "跑步", frequency: .daily)
#expect(r.occurs(on: date(2026, 5, 30), calendar: cal))
#expect(r.occurs(on: date(2026, 1, 1), calendar: cal))
}
@Test func disabledNeverOccurs() {
let r = CustomReminder(title: "跑步", frequency: .daily, enabled: false)
#expect(!r.occurs(on: date(2026, 5, 30), calendar: cal))
}
@Test func weeklyOccursOnlyOnSelectedWeekdays() {
let d = date(2026, 5, 30)
let wd = cal.component(.weekday, from: d)
let other = wd == 1 ? 2 : 1
let hit = CustomReminder(title: "x", weekdays: [wd], frequency: .weekly)
#expect(hit.occurs(on: d, calendar: cal))
let miss = CustomReminder(title: "x", weekdays: [other], frequency: .weekly)
#expect(!miss.occurs(on: d, calendar: cal))
}
@Test func monthlyOccursOnlyOnMatchingDay() {
let d = date(2026, 5, 30) // 30
#expect(CustomReminder(title: "x", frequency: .monthly, dayOfMonth: 30).occurs(on: d, calendar: cal))
#expect(!CustomReminder(title: "x", frequency: .monthly, dayOfMonth: 15).occurs(on: d, calendar: cal))
}
@Test func monthlyDay31SkipsShortMonths() {
// 4 30 :31 4/30 ( 4/31,)
let apr30 = date(2026, 4, 30)
let r = CustomReminder(title: "x", frequency: .monthly, dayOfMonth: 31)
#expect(!r.occurs(on: apr30, calendar: cal))
}
@Test func yearlyOccursOnlyOnMatchingMonthAndDay() {
let d = date(2026, 5, 30)
#expect(CustomReminder(title: "x", frequency: .yearly, dayOfMonth: 30, month: 5).occurs(on: d, calendar: cal))
#expect(!CustomReminder(title: "x", frequency: .yearly, dayOfMonth: 30, month: 6).occurs(on: d, calendar: cal))
#expect(!CustomReminder(title: "x", frequency: .yearly, dayOfMonth: 29, month: 5).occurs(on: d, calendar: cal))
}
// MARK: - MetricReminder
@Test func metricReminderOccursOnSelectedWeekday() {
let d = date(2026, 5, 30)
let wd = cal.component(.weekday, from: d)
let other = wd == 1 ? 2 : 1
#expect(MetricReminder(metricId: "bp", displayName: "血压", weekdays: [wd]).occurs(on: d, calendar: cal))
#expect(!MetricReminder(metricId: "bp2", displayName: "血压", weekdays: [other]).occurs(on: d, calendar: cal))
}
@Test func disabledMetricReminderNeverOccurs() {
let d = date(2026, 5, 30)
let wd = cal.component(.weekday, from: d)
let r = MetricReminder(metricId: "bp", displayName: "血压", weekdays: [wd], enabled: false)
#expect(!r.occurs(on: d, calendar: cal))
}
}