恢复等长 provider 的原地替换,并增加快速同步模式 - #92
Open
cccat6 wants to merge 5 commits into
Open
Conversation
Restore the equal-length provider optimization from cccat6 PR Dailin521#51 (7231881, cdcde35, 84a60d3) following the v0.4 transaction refactor in Dailin521#71. Persist v3 mutation evidence before applying; recover same-inode writes through the existing journal, including bounded partial writes and append-preserving rollback. MOSS trial scope only. Windows retains the prior worker; .NET/Windows parity and formal PR review are deferred. References Dailin521#51, Dailin521#71, Dailin521#69 and the active-writer inode review finding.
Extend the PR Dailin521#51 optimization restored by 1e0f8b3 with Windows exclusive-handle writes and recovery, post-write guards, and explicit metadata-only sync. Keep backup-first per-target journal semantics from Dailin521#71/Dailin521#69 and reject unknown recovery bytes. Fuse default body diagnostics, cover failures on Node 16/24 and native Windows, and document proposed mtime/schema compatibility boundaries. No production deployment or upstream publication.
Restore stable-file mtime without backdating concurrent appends, including interrupted timestamp repair. Skip stale Windows preconditions before mutation, compensate valid rollout targets despite other byte conflicts, and keep v2 for backups without byte descriptors. Bound header verification, remove redundant state and duplicate review/worker scaffolding, and cover the audit findings with regression tests. No production deployment.
Write the official v2 metadata and manifest with optional byte-undo records while retaining all standard restore fields and v1/v2 support. Remove the unpublished v3 format branch. Verified both directions against unmodified upstream Node and .NET Core, including applying-only partial writes.
cccat6
marked this pull request as ready for review
August 28, 2026 11:01
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
目的
Provider 同步应当遵循最小必要写入原则。修改少量元数据,不应让整个会话历史承担全量重写的成本。这个 PR 在保留备份、事务和恢复保障的前提下补回 in-place,避免把不必要的等待和磁盘写入留给用户。
关联
延续 #51 的等长 provider 优化,修复 #71 事务重构后的路径缺失,并保留 #69 要求的逐目标恢复证据。
改动
sync --fast/switch <provider-id> --fast:只读必要的首行元数据,保留模型,明确提示未执行的历史检查。不满足原地条件时直接报错,不自动回退到全量重写。备份继续使用官方 v2 格式,并支持恢复 v1/v2。新增的字节记录是可选字段,原有恢复数据完整保留,没有另起一套备份格式。
建议 provider ID 统一用 6 个 ASCII 字符,比如把
provider_a写成prov_a,因为内置的openai就是 6 个字符,相对最通用。影响范围
Node CLI/共享服务、Windows worker、备份恢复,以及相关测试和文档。没有加入账户管理、认证或进程重启功能,没有修改桌面 UI 和 .NET 业务实现。
数据写入仍限于既有操作涉及的配置、rollout 元数据、SQLite、workspace 状态和托管备份;不修改消息正文或
updated_at。验证
git diff --check通过。所有测试均使用临时夹具。32 MiB 的 ext4 临时文件测试中,原地路径的计账写入约 44 KiB,完整重写约 32 MiB;快速模式的逻辑读取约 341 KiB。这里包含备份和日志开销,不是对实际大库耗时的保证。
边界与未验证项
旧工具可以恢复数据,但仍使用它原来的恢复方式,不会自动获得 in-place 优化。完整 Windows Node、macOS 和 WSL 验证仍待 CI/对应环境补齐,不能将其标为已通过。
本分支基于
main@c7ff852;#90 的新版架构还需要在合并前按最终主线对齐。检查清单
ci-gate全部通过。