Skip to content

feat(drive): watch resilience, conflict reconciliation, and incremental sync#78

Merged
yurenju merged 7 commits into
mainfrom
claude/sync-improvements
Jul 13, 2026
Merged

feat(drive): watch resilience, conflict reconciliation, and incremental sync#78
yurenju merged 7 commits into
mainfrom
claude/sync-improvements

Conversation

@yurenju

@yurenju yurenju commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

依 sync improvements design 的 A / B / C / D 四個子項,實作 wspc-cli sync engine 改動。搭配 wspc server 的 PR sadcoderlabs/wspc#844 一起看。

A. Watch 韌性

scan/hash 對單一路徑的 ENOENT/EPERM/EBUSY 記 debug error 事件後跳過,不再終止 watch;root 讀取失敗或非暫時性錯誤仍照舊拋出,避免把掃描失敗誤判為本地全刪。

D. 觀測性

debug log 新增 error 事件({ ts, event, path, op?, code?, message }),sync_end.errors 每筆都有對應事件。

B. Conflict reconciliation

  • decision 短路:local 與 remote 內容相同時判 state_only(收斂),使用者可自行解除卡住的 conflict。
  • edit_edit / create_create 一次性解決:clean merge 失敗時 local 當主檔上傳、remote 存 conflict copy、base state 更新,下一輪不再重判。
  • conflict copy 檔名改用完整 version id(先前截斷易撞名)。

C. 增量 sync + echo 抑制

  • scan cache:state.json 記 mtime+size→hash,未變檔案不重讀。
  • dirty-path 增量 scan:local 觸發只 re-stat 髒路徑與子樹;initial/retry/remote 走全量兜底。
  • manifest delta:存 manifest_cursor,帶 since_cursor 抓 delta 並以 base state 合成完整遠端視圖;server 回 resync_required 時退回全量。
  • echo 抑制:上傳帶 x-wspc-client: drive-sync/<client_id>,realtime 收到自己的 origin_client_id 時只推進 cursor 不 sync;watcher 忽略 .wspc-*.tmp
  • rename:同 hash 的 delete+create 改呼叫 server move API,失敗退回 upload+delete。

測試

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 並移除放寬。

@yurenju
yurenju merged commit 9308a5b into main Jul 13, 2026
2 checks passed
@yurenju
yurenju deleted the claude/sync-improvements branch July 13, 2026 06:27
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.

1 participant