Skip to content

feat(rust): migrate wire, identity and atomic SQLite metadata storage - #235

Merged
LIghtJUNction merged 25 commits into
mainfrom
migration/rust-wire-phase1
Oct 13, 2026
Merged

LIghtJUNction merged 25 commits into
mainfrom
migration/rust-wire-phase1

Conversation

@LIghtJUNction

@LIghtJUNction LIghtJUNction commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

第三批已落地:原生 SQLite 写事务;独立 Rust CI 已通过

保持 Draft,不合并、不部署。Python 保留 msg CLI、管理/迁移脚本与开发工具。没有修改运行中的 Python 源码、入口、生产数据库、配置、路由或部署文件;没有通过 Rust 调用 Python 冒充迁移。

本批提交:fffea47606cf4db999ecf915910bdbe372360bb5。
精确源码树:265e8a8c294c920df39246aa55437deb8417c628。上传文件的 Git blob SHA、最终远端树和云端测试归档中的源码树均与本地通过测试的树一致。

本批原生实现

  • SqliteWriter 单独打开已由 Python 迁移的 WAL 数据库,不创建数据库、不修改表结构。检查所需表、列、主键、唯一约束、外键、唯一根目录索引、只追加审计保护;拒绝危险链接及数据库文件替换。
  • 保留 Python 同名 .writer.lock / flock 跨进程写入锁。锁覆盖 SQLite 回滚和全部逆序补偿,防止另一进程在补偿期间插入写入。
  • 存储层持有提交权;调用者不能取得 SQL 连接、自行提交、带出会话或跨线程移动会话。只有 COMMIT 成功才返回成功值。写入失败即使被忽略,也不能提交部分修改;SQLite 隐式回滚后不能继续自动提交。
  • 保存点、嵌套回滚、panic 清理、逆序补偿及失败记录。提交结果不确定时,不做可能误删已提交数据的补偿,并禁用当前写入实例。
  • 资源创建/更新、版本冲突、创建事实保护、父级循环、路径别名、标签及授权版本更新;修订与关系、设置、请求结果、事件、现有审计摘要链。
  • 同一事务可保存资源修改、请求结果、事件及审计。结果按主体和请求 ID 隔离,检查摘要冲突,保留 100,000 行容量限制。
  • 只读快照和写会话共用事务内的身份/授权数据读取接口。

这些是受信任的内部存储接口,不是完整资源授权或业务执行器。save_result 不签发回执、不负责秘密脱敏。测试中的 once 仅用于验证原子存储边界,不含身份校验,绝不能开放为网络接口。

已验证的本批证据

精确提交的独立 Rust wire compatibility / push run 37259212454 已完成,结论 success。本地与云端都是 Rust 1.85.0 / Python 3.15.0rc2,依赖固定。

检查 本地及独立云端结果
原生单元测试 32 项通过,其中本批新增 18 项
编译拒绝测试 5 项通过:身份对象不可由 JSON 创建;事务不可自行提交、逃逸、跨线程移动;只读会话不可写
Debug / Release 协议对照 各 18,447 项,0 失败
Debug / Release 身份与读取对照 各 61,734 项,0 失败
Debug / Release 新增存储对照 各 71 项,0 失败:49 项 Python 对照、7 项更严格的安全检查、15 项真实进程检查
Rustfmt / Ruff / Clippy -D warnings 全部通过

身份测试的 61,734 项中,61,440 为简单权限组合,其余 294 为其他检查。容量测试使用 100,000 行,但只计一个场景,不扩大用例数。

已下载并核对 原始证据 artifact 11323892841:六份 JSON 报告、原生及编译拒绝测试日志、源码 SHA/源码树、工具链版本和 Cargo.lock。锁文件与提交逐字节一致。ZIP SHA-256:3a7c910943e9af9fe916e8120cf2dcc6801e0e6ed4e121f41da77a18ea79bd58。

存储对照直接使用实际 Python SqliteMetadataStore 创建临时数据库,比较完整记录、规范化字节、结果、补偿顺序和未修改的表结构。真实进程检查覆盖:提交前 SIGKILL 后无半写;提交后丢失响应再试不重复提交;并发同请求只产生一个结果/审计;Python 与 Rust 双向互斥;SQL 回滚后补偿完成前仍保留写锁。提交不确定情况是确定性错误注入,不是物理磁盘故障实验。

本批累计补丁以第二批 78e8d5d44cbbe49078a1e6eb4bb8e079eea3db72 为基线,已在独立 Git 索引中检查并实际应用,所得树与本次提交一致。中间依赖导出工作流在基线和最终树中均不存在。临时 writer 依赖导出工作流已删除。

PR 的 Python quality、FUSE mount 已通过;其余完整回归及合并基线上的 Rust run 在本次最终核对时仍在运行。不宣称整个 PR 已完成验收,不自动合并或部署。

前两批保留

第一批 91d8d3209d09f04269b4d9807793d6a0a8da7eba:原生 canonical-v1、ID、Ed25519、请求与签名字节。通过证据 run 37246877514。

第二批 78e8d5d44cbbe49078a1e6eb4bb8e079eea3db72:身份/凭据/证书校验、当前撤销和恢复版本、实时委托、OAuth/MCP 目标服务及恢复绑定、只读 SQLite。通过证据 run 37252150014。旧提交的通过状态不能代替本批验收。

Admission::Fresh 仅表示身份已验证,不表示资源授权。Admission::Replay 仅携带符合条件的已提交结果,不产生可执行新操作的 Principal。OAuth 目前是绑定校验,不是完整签发/刷新服务。

尚未完成 / 切换门槛

  1. 完整资源授权、真实操作注册表、业务处理函数、回执签名和秘密交付;私有资源、成员、共享、私信和工具权限仍须接入。
  2. 剩余写入存储、身份/OAuth 签发/轮换/刷新/恢复、加密密钥封装、PostgreSQL。
  3. Blob/Git 外部写入、持久化恢复日志、全服务暂停与恢复处理。当前进程终止实验仅验证 SQLite 元数据;SIGKILL 不会运行补偿回调。提交不确定保护仅禁用当前写入实例,重新打开连接本身不等于恢复。
  4. 原生 msgd serve、HTTP/MCP、msgd worker、打包、隔离部署与回滚演练。

兼容差异写入 rust/README.md:输入体积/深度、时间别名、固定宽度模型整数、错误码、历史 Ed25519、十六进制 ID 别名及完整 Unicode 标签规范化等仍是切换门槛。现有测试不证明全部 Python 输入兼容。未做等价负载内存/吞吐实测,不承诺降幅。

已读仓库 AGENTS、入口技能及部署 /AGENTS.md。编辑环境没有选定已有 MSG 签名身份,因此未创建生产身份、私有协作线程或公开协调帖;本次进度记录在现有分支/PR。

…ration

Keep Python CLI/admin/tooling and existing production daemon unchanged.
Add bounded native core, Ed25519 primitives and request envelope handling,
with Python-source differential conformance CI and explicit cutover gates.
Apply the cloud rustfmt patch, commit Cargo's resolved lock, enforce locked
builds, and include the Python harness in the existing Ruff style checks.
Native tests and Clippy passed on the initial cloud build.
Apply the cloud Ruff patch and use non-mutating style checks. Record the
exact source/toolchain and exercise the same Python parity corpus against
debug and optimized native binaries. No Python runtime entry points change.
Add native current-state credential, certificate, delegation, OAuth binding
and recovery checks; distinguish committed-result replay from fresh identity.
Read Python-created SQLite databases through bounded read-only snapshots.

Keep Python CLI/server/deployment unchanged. Full resource authorization,
write transactions, native serve/HTTP/MCP and worker remain cutover gates.

Validated exact tree 8f31a96 locally:
14 unit tests, 1 compile-fail doc test, fmt/Ruff/Clippy; both debug/release
wire parity 18,447 and authority parity 61,734 (61,440 simple mode decisions).
Remove temporary offline-editor export workflow; extend independent Rust CI.
@LIghtJUNction LIghtJUNction changed the title feat(rust): start native server migration with Python wire compatibility feat(rust): migrate wire protocol, identity admission and SQLite authority reads Oct 5, 2026
Port resource/revision/result/event/audit/settings writes into private native
transactions over the existing Python-created WAL schema. Keep the Python
flock fence through rollback compensation, isolate savepoints, fail closed on
ignored writes and ambiguous commit outcomes, and compare real Python/Rust
rows plus process-kill/retry behavior. Preserve Python CLI and live services.

Remove the temporary writer-dependency export workflow. No merge or cutover.
@LIghtJUNction LIghtJUNction changed the title feat(rust): migrate wire protocol, identity admission and SQLite authority reads feat(rust): migrate wire, identity and atomic SQLite metadata storage Oct 5, 2026
LIghtJUNction and others added 14 commits October 5, 2026 11:57
Implement streamed native content storage, verified range reads, compatible
pins and immutable revision graphs. Preserve binary hardlinks and fence
publication behind digest checks, fsync and no-clobber installation.

Add 14 native tests and 170 bidirectional Python/Rust content checks per
profile, including real process interruption cases. Keep production Python
unchanged, remove temporary preparation workflows, and record the fixed
migration acceptance checklist (completed/remaining: 5/6).

Validated source tree: 94c6c50
Local Rust 1.85.0 / Python 3.15.0rc3 checks passed; fresh cloud CI required.
This is a storage primitive, not a complete daemon or deployment.

Copy link
Copy Markdown
Contributor Author

当前 head fead32f 的 Rust native conformance 已通过,Python quality、FUSE、Recovery safety、Deployment rehearsal、Service alias contracts 也已通过;完整验收仍受 Issue recovery regressions 和 Rewrite contracts 阻塞。

已核对 recovery job 的实际堆栈:test_complete_recovery_proof.py 在 recovery_state.py:120 的 catalogue shape 比较返回 recovery_schema_unsupported。当前 main 4fa4234 的 对应 job 同样是 2 failed / 109 passed / 23 errors,且同一位置、同一错误,因此这项不能直接归因于本 PR 的 Rust 改动;应独立修复基线的 schema/fixture 一致性,保留 fail-closed 检查后复跑。

正文的“本批提交”与验收表仍指向 fffea476 和旧 run;建议更新为当前 head 的分项证据,继续保留 draft 和未完成的切换门槛。这里仅确认现有远端日志,没有新增本地运行、合并或部署。

Copy link
Copy Markdown
Contributor Author

补充 10 月 9 日的核对结果:main 已推进到 2d89b331,10 月 8 日的 Issue recovery regressions 和 Rewrite contracts 均已通过,不能再沿用上一条评论中“当前 main 同样失败”的状态。

本 PR 仍停在 fead32f,落后 main 9 个提交。直接核对 recovery-state-schema.json,PR 分支的 catalog 仍缺少 main 已补齐的 login_bindings 表、约束和索引。目前没有包含该修复后的 PR 验收证据。建议更新分支后,在新 head 上重跑 recovery、rewrite 和 Rust conformance,再同步正文中的提交与验收链接;现阶段继续保留 draft。

以上结论来自当前远端代码和已完成的 CI 记录,没有新增运行或修改分支。

@LIghtJUNction
LIghtJUNction marked this pull request as ready for review October 11, 2026 19:01
Copilot AI balanced review requested due to automatic review settings October 11, 2026 19:01
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@LIghtJUNction

Copy link
Copy Markdown
Contributor Author

Blocking against current main (0511984d48983a81a572319c1cc939d848bd27ec), not against the historical phase-1 fixture:

  • rust/tests/test_identity_parity.py:43 still imports msg.oauth_config (OAuthConfig, OAuthClient, SCOPES). Main removed that module during the key-only identity migration. The parity test cannot collect against current source.
  • The same file constructs OAuthConfig at line 312 and writes oauth_states throughout lines 829 onward. Current storage uses credential/session state and explicitly retires OAuth/Bearer authority. Restoring the deleted module or stale tables just to make parity green would reintroduce the revoked contract.
  • Rebase the native storage schema and identity implementation onto the key-only contract, replace those parity cases with current credential/session approval plus rejected legacy-authority cases, and validate the exact merged content locally. Rust unit results against the old API do not demonstrate current Python/Rust parity.
  • Keep daily Rust validation local/opt-in; preserve official release build/signing workflows. Do not launch another automatic CI cycle to compensate for this incompatibility.

The native migration is not merged or included in the deployment. Existing signing chains were preserved; no CA or credential scope was expanded to bypass a failed test.

@LIghtJUNction
LIghtJUNction marked this pull request as draft October 13, 2026 00:08
@LIghtJUNction

Copy link
Copy Markdown
Contributor Author

正在修复当前 main 兼容性:已移除 native OAuth 模块,换为 key-approved browser/API binding;SQLite/PostgreSQL authority store 使用 credential_states;加入恢复旧 t_oauth_/t_browser_ 权限仍拒绝的差分用例,以及关闭 browser、循环/过深 session source 的失败关闭单元测试。Rust 1.85.0 全部 unit、doc、clippy 已通过;identity 差分 61,726 个比较无差异,其中 61,440 是模式权限组合,不是独立身份情景。其余 SQLite/PostgreSQL/process/content 差分验收进行中,完成后推送、取消 draft 并合并。native 服务切换仍未实现,不会将此库合并描述为生产 Rust 服务。MSG 父任务引用受 credential_ceiling 限制,仅在此记录脱敏代码进展。

@LIghtJUNction
LIghtJUNction marked this pull request as ready for review October 13, 2026 01:01
@LIghtJUNction

Copy link
Copy Markdown
Contributor Author

兼容性修复已推送至 08c87c1。Rust 1.85.0 fmt、unit/all-targets、doc、clippy -D warnings 通过;Debug 与 Release 两个 profile 的 wire/identity/SQLite storage/content/authorization/PostgreSQL/process 全部 8 组本机验收通过。identity 为 61,726 个比较(含 61,440 个简单模式组合);另有关闭 browser、循环/过深 source 的失败关闭单元覆盖。使用当前 Python 参考,不复活 OAuth/Bearer模块;当前 schema credential_states 在 SQLite/PostgreSQL 均验证。没有远程自动 CI 重跑。此 PR 只完成 native 基础库,不含 Rust serve/worker/生产流量切换;下一步合并,并部署 main 的 Python 服务和已验收的 PR243 功能。

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@LIghtJUNction
LIghtJUNction merged commit ae55419 into main Oct 13, 2026
18 checks passed
@LIghtJUNction
LIghtJUNction deleted the migration/rust-wire-phase1 branch October 13, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants