80 lines
2.3 KiB
Markdown
80 lines
2.3 KiB
Markdown
# Reasonix Worker A:SQLite control-plane store 骨架
|
||||
|
|
|
|||
|
|
Project root: `/mnt/Data1T/mnote`
|
|||
|
|
|
|||
|
|
你不是独自在代码库中工作。其他 worker 可能并行修改 auth、access policy 或迁移脚本。不要还原、覆盖或清理不属于你任务范围的改动。不要提交 git。
|
|||
|
|
|
|||
|
|
## 背景
|
|||
|
|
|
|||
|
|
上位设计稿:
|
|||
|
|
`design/02-convex-rust-long-term-architecture/process/2-8-convex-replace-with-rust-sqlite-control-plane-v1.md`
|
|||
|
|
|
|||
|
|
目标是用 Rust + SQLite 完全替换 Convex 控制面。你的任务只负责 SQLite store 骨架,不接运行时 route。
|
|||
|
|
|
|||
|
|
## Ownership
|
|||
|
|
|
|||
|
|
允许修改:
|
|||
|
|
- 优先新增 `rust/crates/control-plane/**`
|
|||
|
|
- 必要时修改 `rust/Cargo.toml`
|
|||
|
|
- 必要时新增/修改 `rust/crates/mnote-web/Cargo.toml` 仅用于依赖引用建议
|
|||
|
|
|
|||
|
|
禁止修改:
|
|||
|
|
- `rust/crates/mnote-web/src/routes/gateway.rs`
|
|||
|
|
- `rust/crates/mnote-web/src/routes/local_folder_source.rs`
|
|||
|
|
- `rust/crates/mnote-web/src/routes/session.rs`
|
|||
|
|
- `rust/crates/mnote-web/src/ssr/**`
|
|||
|
|
- `infra/convex/**`
|
|||
|
|
- `.env*`
|
|||
|
|
|
|||
|
|
如果发现 workspace crate 接入风险过大,先实现为可编译独立 crate;不要跨模块硬接 runtime。
|
|||
|
|
|
|||
|
|
## 任务
|
|||
|
|
|
|||
|
|
1. 新增 `control-plane` Rust crate 或等价最小模块,优先独立 crate。
|
|||
|
|
2. 定义核心 model 与 `ControlPlaneStore` trait。
|
|||
|
|
3. 实现 `SqliteControlPlaneStore`,支持临时路径 DB。
|
|||
|
|
4. 实现 migration v1,包含至少:
|
|||
|
|
- `users`
|
|||
|
|
- `auth_identities`
|
|||
|
|
- `auth_sessions`
|
|||
|
|
- `workspaces`
|
|||
|
|
- `workspace_members`
|
|||
|
|
- `directory_grants`
|
|||
|
|
- `share_links`
|
|||
|
|
- `sync_state`
|
|||
|
|
- `ai_policies`
|
|||
|
|
- `audit_log`
|
|||
|
|
- `outbox_events`
|
|||
|
|
- `legacy_id_map`
|
|||
|
|
5. 实现最小 CRUD:
|
|||
|
|
- upsert user
|
|||
|
|
- create/get session
|
|||
|
|
- ensure default workspace
|
|||
|
|
- grant/revoke directory access
|
|||
|
|
- append/drain outbox
|
|||
|
|
6. 补单测:migration 幂等、默认 workspace、owner grant、outbox drain。
|
|||
|
|
|
|||
|
|
## 验收命令
|
|||
|
|
|
|||
|
|
优先运行:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cargo test --manifest-path rust/Cargo.toml -p control-plane -- --nocapture
|
|||
|
|
cargo fmt --check --all
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
如果没有新增独立 crate,而是放入 mnote-web:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cargo test --manifest-path rust/Cargo.toml -p mnote-web control_plane -- --nocapture
|
|||
|
|
cargo fmt --check --all
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 最终回复格式
|
|||
|
|
|
|||
|
|
请列出:
|
|||
|
|
- 修改文件
|
|||
|
|
- 新增表和核心 API
|
|||
|
|
- 实际运行过的命令及结果
|
|||
|
|
- 未完成项/风险
|