-
Notifications
You must be signed in to change notification settings - Fork 7
feat(session): 增加 Todo 状态持久化与校验 #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Session Todo 设计说明 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reviewed end-to-end against the current implementation in |
||
|
|
||
| 本文档补充说明 `internal/session` 中 Todo 的数据模型、持久化语义与边界约束。 | ||
|
|
||
| ## 设计目标 | ||
|
|
||
| - Todo 归属于 `Session`,不单独引入新的持久化子系统。 | ||
| - Todo 只表示结构化待办状态,不替代现有 `TaskState`。 | ||
| - Todo 的校验、规范化和基础增删改查统一收敛在 `internal/session`。 | ||
|
|
||
| ## 数据模型 | ||
|
|
||
| `Session` 新增 `todos` 字段,对应 `[]TodoItem`。 | ||
|
|
||
| 单个 `TodoItem` 目前包含: | ||
|
|
||
| - `id` | ||
| - `content` | ||
| - `status` | ||
| - `dependencies` | ||
| - `created_at` | ||
| - `updated_at` | ||
| - 可选 `priority` | ||
|
|
||
| 其中 `status` 固定为以下三个值: | ||
|
|
||
| - `pending` | ||
| - `in_progress` | ||
| - `completed` | ||
|
|
||
| ## 持久化语义 | ||
|
|
||
| - Todo 跟随 `Session` 一起通过现有 JSONStore 保存和加载。 | ||
| - `Save` 前会对 Todo 执行统一规范化与校验: | ||
| - `id`、`content` 去空白 | ||
| - 空状态默认收敛为 `pending` | ||
| - `dependencies` 去空白、去重、保持顺序 | ||
| - 拒绝重复 ID | ||
| - 拒绝自依赖 | ||
| - 拒绝引用不存在的依赖项 | ||
| - `Load` 允许 session JSON 缺失 `todos` 字段,并按空 Todo 列表处理。 | ||
|
|
||
| ## 与 TaskState 的关系 | ||
|
|
||
| - `TaskState` 仍是 runtime/context 用于 compact 与续航的 durable summary。 | ||
| - `Todo` 是更细粒度的结构化状态,不直接注入 context,不写入消息历史。 | ||
| - 如果未来需要收敛两者关系,应通过单独演进,让 `TaskState` 从 `Todo` 派生摘要,而不是直接复用同一字段。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-checked this section in the latest commit: the UTF-8 text is readable and aligned with the current Todo persistence behavior.