Skip to content

fix(sync): try full app-state sync before recovery - #369

Open
goutamadwant wants to merge 1 commit into
openclaw:mainfrom
goutamadwant:fix/full-sync-before-app-state-recovery
Open

fix(sync): try full app-state sync before recovery#369
goutamadwant wants to merge 1 commit into
openclaw:mainfrom
goutamadwant:fix/full-sync-before-app-state-recovery

Conversation

@goutamadwant

Copy link
Copy Markdown
Contributor

Closes #367

What changed

  • attempt one guarded full app-state sync when a collection reports an LTHash mismatch
  • request a primary-device recovery snapshot only when that full sync also returns an LTHash mismatch
  • stop escalation after a successful full sync or an unrelated full-sync failure
  • cover successful recovery, mismatch escalation, duplicate events, and unrelated errors with the fake WhatsApp transport

Why

The sync error handler previously jumped directly to RequestAppStateRecovery. That skipped the cheaper local full-sync reset and could leave a collection stuck when the primary device did not answer the snapshot request.

Behavior proof

Before the fix, the focused regression failed because no full-sync call occurred and the recovery request fired immediately. After the fix, the fake transport records exactly one FetchAppState(..., fullSync=true, onlyIfNotSynced=false) call per collection. A repeated LTHash mismatch then produces one recovery request, while a successful full sync and a non-LTHash full-sync failure produce none.

Validation

go test ./internal/app -run 'TestAppState(LTHashMismatchAttemptsFullSyncBeforeRecovery|LTHashMismatchStopsAfterSuccessfulFullSync|LTHashMismatchDoesNotEscalateOtherFullSyncFailures|NonLTHashErrorDoesNotRequestRecovery)$' -count=1
go test -race ./internal/app -run 'TestAppState(LTHashMismatchAttemptsFullSyncBeforeRecovery|LTHashMismatchStopsAfterSuccessfulFullSync|LTHashMismatchDoesNotEscalateOtherFullSyncFailures|NonLTHashErrorDoesNotRequestRecovery)$' -count=1
go test ./internal/app -count=1
pnpm lint
pnpm test
pnpm build
"$(go env GOROOT)/bin/gofmt" -d internal/app/sync_events.go internal/app/sync_test.go
git diff --check

Limitations

No live WhatsApp account was used. The repository's fake transport exercises the full-sync and recovery-request boundary deterministically without provider mutation.

Disclosure: AI was used to understand the codebase and review the fix.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

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.

sync: try a full app-state sync before requesting a recovery snapshot on LTHash mismatch

1 participant