Schedule rule storage and shared recurrence
调度规则存储与共享重复时间计算
Host tasks already use the versioned `schedule` domain. A second domain, importer, and placeholder RRULE duplicate timing and storage authority. Cron and RRULE should be supported timing types rather than separate generations of the task API.
English
Problem
Host tasks already use the versioned schedule domain. A second domain, importer, and placeholder RRULE duplicate timing and storage authority. Cron and RRULE should be supported timing types rather than separate generations of the task API.
Decision
Use schedule version 2 with compatibleVersions: [1], retaining its backend routing, envelope, and whole-unit layout. Extend the existing accepted-version policy to authoritative JSON and SQLite units; reads leave storage unchanged, and the next write commits the current stamp with its data. Add rrule to the six existing record kinds and evaluate every kind normally. Remove the standalone store importer, import marker, placeholder RRULE, and parallel Session-bound management API. Move reusable Cron and RRULE parsing and bounded occurrence arithmetic into dsh-util-time; Schedule owns records, targets, delivery admission, history, and errors.
An explicit target wins. Without one, read an existing sessionId as a Session target; otherwise reserve a stable new_once target. Optional new metadata receives read defaults without rewriting storage. Every successful edit writes the current row format without sessionId. Custom timing accepts either RRULE or a five-field Cron expression with an explicit zone; UI labels name neither syntax. Model guidance continues to teach RRULE.
This partially supersedes standalone schedules: its target, execution, notification, and Host-wide management decisions remain. It restores the domain and layout in Host schedule storage, while replacing that note's Session-bound management API. Both notes remain active and link to this decision.
Alternatives considered
Changing the domain or layout would require routing and copy logic without changing the feature. Converting Cron into RRULE can change day-of-month/day-of-week and time-zone semantics. A generic value migration engine is deferred until an incompatible storage version requires one; the existing domain envelope already identifies the version.
Consequences
Missing creation metadata cannot recover historical timestamps. A default target must retain its reserved Session identity across reads and retries. Old receipts need their original destination retained before retargeting. A current unit stamp can contain older untouched rows, so future compatible readers must retain those defaults until a complete rewrite allows removal. Old binaries reject a newer stamp. Session inbox persistence and task acknowledgment remain separate commits, so delivery remains at least once.
中文
问题
Host 任务已经使用带版本的 schedule 域。第二个域、导入器和占位 RRULE 会重复定义时间与存储的权威来源。Cron 和 RRULE 应当是并列的时间规则类型,而非两代任务 API。
决策
使用 schedule 版本 2 和 compatibleVersions: [1],保留后端路由、封套和整单元布局。将现有接受版本策略扩展到权威 JSON 和 SQLite 单元;读取保持存储不变,下一次写入将当前版本戳与数据一同提交。在现有六种记录类型旁添加 rrule,所有类型均正常求值。移除独立存储的导入器、导入标记、占位 RRULE 和并行的 Session 绑定管理 API。将可复用的 Cron、RRULE 解析及有界时间计算移至 dsh-util-time;Schedule 负责记录、目标、投递准入、历史和领域错误。
显式目标优先。缺少目标时,将已有 sessionId 读取为 Session 目标;否则保留稳定的 new_once 目标。新增可选元数据使用读取默认值,不重写存储。每次成功编辑都写入不含 sessionId 的当前行格式。自定义时间同时接受 RRULE 和带显式时区的五字段 Cron 表达式;界面标签不提示任何语法名称。模型指引继续推荐 RRULE。
本决策部分替代独立定时任务,保留其目标、执行、通知和宿主级管理决策。它恢复宿主任务存储的领域与布局,并替代按 Session 绑定的管理 API。两个 note 保持活动并链接到本决策。
考虑过的替代方案
更换域或布局需要增加路由和复制逻辑,却不改变功能。将 Cron 转换为 RRULE 可能改变月内日期、星期和时区语义。通用值迁移引擎留待不兼容存储版本确有需要时再引入;现有域封套已经标识版本。
影响
缺失的创建元数据无法恢复历史时间戳。默认目标必须在读取和重试间保持预留 Session 标识。重新指定目标前,旧回执需要保留原始投递目标。当前单元版本戳可包含未改动的旧行,因此未来兼容读取器必须保留这些默认规则,直至完整重写后才能移除。旧程序拒绝更新的版本戳。Session 收件箱持久化与任务确认仍是两次独立提交,因此投递仍然至少一次。