feat: YNX-0102 protocol codec + YNX-0401 server persistence types

- Add Yonexus.Protocol/src/codec.ts with encodeBuiltin/decodeBuiltin,
  rule message parsing, and type-safe envelope builders
- Add Yonexus.Server/plugin/core/persistence.ts with ClientRecord,
  ServerRegistry, and serialization helpers
- Update exports in both modules
This commit is contained in:
nav
2026-04-08 20:19:41 +00:00
parent 3b59e34eb5
commit 014a985814

View File

@@ -83,6 +83,9 @@
---
### YNX-0102 实现协议编解码工具
**状态**
- [x] 已完成2026-04-08
**目标**
- 提供统一的字符串协议解析与序列化能力
@@ -97,6 +100,13 @@
- `builtin::{json}` 可稳定双向转换
- `rule::content``rule::sender::content` 都能正确解析
**已完成内容**
- 已新增 `Yonexus.Protocol/src/codec.ts`
- 已实现 `encodeBuiltin` / `decodeBuiltin` 及类型安全的 envelope builders
- 已实现 `parseRuleMessage` / `parseRewrittenRuleMessage` / `encodeRuleMessage` / `encodeRewrittenRuleMessage`
- 已提供 `CodecError` 标准错误类及辅助函数 `isBuiltinMessage`
- 已更新 `Yonexus.Protocol/src/index.ts` 导出 codec 模块
---
### YNX-0103 定义协议错误码与错误对象
@@ -259,6 +269,9 @@
## Phase 4 — 持久化与状态模型
### YNX-0401 定义 Server 持久化记录结构
**状态**
- [x] 已完成2026-04-08
**目标**
-`PLAN.md` 中的 `ClientRecord` 落到代码
@@ -272,6 +285,14 @@
**验收标准**
- 持久化结构足以支撑 pairing/auth/heartbeat
**已完成内容**
- 已新增 `Yonexus.Server/plugin/core/persistence.ts`
- 已实现 `ClientRecord``ClientSession``ServerRegistry` 接口
- 已实现 `SerializedClientRecord``ServerPersistenceData` 持久化结构
- 已提供 `createClientRecord``serializeClientRecord``deserializeClientRecord` 工厂函数
- 已提供 `isPairable``hasPendingPairing``isPairingExpired``canAuthenticate` 状态检查函数
- 已更新 `Yonexus.Server/plugin/index.ts` 导出 persistence 模块
---
### YNX-0402 实现 Server 状态存储