feat(drive): watch resilience, conflict reconciliation, and incremental sync#78
Merged
Conversation
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.
依 sync improvements design 的 A / B / C / D 四個子項,實作 wspc-cli sync engine 改動。搭配 wspc server 的 PR sadcoderlabs/wspc#844 一起看。
A. Watch 韌性
scan/hash 對單一路徑的
ENOENT/EPERM/EBUSY記 debugerror事件後跳過,不再終止 watch;root 讀取失敗或非暫時性錯誤仍照舊拋出,避免把掃描失敗誤判為本地全刪。D. 觀測性
debug log 新增
error事件({ ts, event, path, op?, code?, message }),sync_end.errors每筆都有對應事件。B. Conflict reconciliation
state_only(收斂),使用者可自行解除卡住的 conflict。edit_edit/create_create一次性解決:clean merge 失敗時 local 當主檔上傳、remote 存 conflict copy、base state 更新,下一輪不再重判。C. 增量 sync + echo 抑制
manifest_cursor,帶since_cursor抓 delta 並以 base state 合成完整遠端視圖;server 回resync_required時退回全量。x-wspc-client: drive-sync/<client_id>,realtime 收到自己的origin_client_id時只推進 cursor 不 sync;watcher 忽略.wspc-*.tmp。測試
516 passed(一個既有 Windows config-lock flaky,與本改動無關),typecheck 綠。全程 TDD red→green。
注意
getManifest用的since_cursor/latest_cursor/resync_required尚未進 generated SDK 型別(server 剛加、spec 未 regen),暫用型別放寬(query as never)。server PR 合併後需重跑npm run sync-spec && npm run generate重生 SDK 並移除放寬。