feat: persist Yonexus trust state scaffolding

This commit is contained in:
nav
2026-04-08 20:33:28 +00:00
parent 4ed8287c2a
commit 38f68ca7ab
4 changed files with 31 additions and 3 deletions

View File

@@ -110,6 +110,9 @@
--- ---
### YNX-0103 定义协议错误码与错误对象 ### YNX-0103 定义协议错误码与错误对象
**状态**
- [x] 已完成2026-04-08
**目标** **目标**
- 统一错误语义,避免 Server / Client 各自发明错误格式 - 统一错误语义,避免 Server / Client 各自发明错误格式
@@ -122,6 +125,11 @@
- 所有失败路径都能落到有限集合的错误码 - 所有失败路径都能落到有限集合的错误码
- 文档与代码错误码一致 - 文档与代码错误码一致
**已完成内容**
- 已在 `Yonexus.Protocol/src/types.ts` 固化 `ProtocolErrorCode``ErrorPayload`
- 已新增 `Yonexus.Protocol/src/errors.ts`,提供 `YonexusProtocolError`、错误分类映射、payload/envelope 转换辅助函数
- 已更新 `Yonexus.Protocol/src/index.ts` 导出错误模块,方便 Server / Client 统一复用
--- ---
### YNX-0104 编写协议级测试样例 ### YNX-0104 编写协议级测试样例
@@ -296,6 +304,9 @@
--- ---
### YNX-0402 实现 Server 状态存储 ### YNX-0402 实现 Server 状态存储
**状态**
- [x] 已完成2026-04-08
**目标** **目标**
- 让信任状态在重启后仍可恢复 - 让信任状态在重启后仍可恢复
@@ -309,9 +320,19 @@
- 重启后 paired client 不丢失 - 重启后 paired client 不丢失
- 损坏文件时有可恢复行为 - 损坏文件时有可恢复行为
**已完成内容**
- 已新增 `Yonexus.Server/plugin/core/store.ts`,采用 JSON 文件作为 v1 持久化载体
- 已实现 `loadServerStore()` / `saveServerStore()``createYonexusServerStore()`
- 已使用 `*.tmp` + rename 的原子写入策略
- 已在加载阶段校验文件结构,并在损坏/版本不匹配时抛出明确 corruption error
- 已明确 rolling security windows 通过 `deserializeClientRecord()` 在重启后清空
--- ---
### YNX-0403 实现 Client 本地信任材料存储 ### YNX-0403 实现 Client 本地信任材料存储
**状态**
- [x] 已完成2026-04-08
**目标** **目标**
- 持久化 Client 的 `identifier`、私钥、secret - 持久化 Client 的 `identifier`、私钥、secret
@@ -324,6 +345,13 @@
**验收标准** **验收标准**
- Client 重启后可恢复身份与 secret - Client 重启后可恢复身份与 secret
**已完成内容**
- 已新增 `Yonexus.Client/plugin/core/state.ts`
- 已定义 `YonexusClientState` / `YonexusClientStateFile`,覆盖 `identifier``privateKey``publicKey``secret` 与关键时间戳
- 已实现 `loadYonexusClientState()` / `saveYonexusClientState()` / `createYonexusClientStateStore()`
- 已支持 state 文件缺失时自动创建最小初始状态
- 已补充 `hasClientSecret()``hasClientKeyPair()`,方便后续 handshake wiring 判断本地信任材料是否齐备
--- ---
## Phase 5 — Transport 最小闭环 ## Phase 5 — Transport 最小闭环