Skip to content

fix: apply encrypted message edits during sync - #363

Open
goutamadwant wants to merge 1 commit into
openclaw:mainfrom
goutamadwant:fix/decrypt-encrypted-message-edits
Open

fix: apply encrypted message edits during sync#363
goutamadwant wants to merge 1 commit into
openclaw:mainfrom
goutamadwant:fix/decrypt-encrypted-message-edits

Conversation

@goutamadwant

Copy link
Copy Markdown
Contributor

Summary

  • decrypt SecretEncryptedMessage{MESSAGE_EDIT} envelopes before parsing and persistence
  • validate the decrypted protocol edit and preserve the envelope's target message key
  • cover live sync, history sync, target mismatches, and history ordering

Closes #362

Behavior proof

The regression fixtures seed an original message and then deliver a secret-encrypted edit. Both live sync and history sync now update the original row with the edited body, mark it edited, and keep the database at one row instead of persisting the opaque envelope. A mismatched decrypted target is rejected without changing the original row.

Validation

  • go test ./internal/app -run 'Test(LiveSyncDecryptsSecretMessageEditBeforeStorage|LiveSyncRejectsSecretMessageEditTargetMismatch|HistorySyncDecryptsSecretMessageEditBeforeStorage|HistorySyncEditedMessageSurvivesOlderOriginal|SyncEventHandlerPanicHasStackAndCounter)$' -count=1
  • go test ./internal/wa ./internal/app
  • pnpm format:check
  • pnpm lint
  • pnpm test
  • pnpm build
  • git diff --check

Limitations

No live WhatsApp account was used for validation; behavior proof is provided by deterministic sync fixtures using the project client interface and storage layer.

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

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 22, 2026, 10:50 PM ET / August 23, 2026, 02:50 UTC.

ClawSweeper review

What this changes

The PR decrypts WhatsApp secret-encrypted message-edit envelopes during live and history sync so the original stored message is updated through existing edit reconciliation.

Merge readiness

Blocked until real behavior proof from a real setup is added - 2 items remain

This PR remains necessary: released current main still stores these encrypted edit envelopes without decrypting them into the established edit path. The focused patch appears correct, but redacted real WhatsApp sync evidence is still required before merge.

Priority: P1
Reviewed head: c2253b86c27dbea0c10ca8f1e7af6ea5c2e61290

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation and regression coverage are promising, but fixture-only evidence does not prove the affected WhatsApp transport path.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR provides fake-client and storage fixtures, but no after-fix real-account sync; add a redacted live or history transcript before merge, then update the PR body for re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR provides fake-client and storage fixtures, but no after-fix real-account sync; add a redacted live or history transcript before merge, then update the PR body for re-review.
Evidence reviewed 6 items Current main lacks encrypted-edit handling: The released main branch passes live messages directly to parsing and history records directly through history parsing; neither path decrypts secret-encrypted edit envelopes before storage.
Existing edit contract: The parser already applies a protocol edit's target key and marks the replacement as edited, so routing validated decrypted content through it preserves the existing reconciliation model.
Focused regression coverage: The PR adds live and history fixtures for encrypted edits plus target mismatch and ordering cases.
Findings None None.
Security None None.

How this fits together

WACLI receives live WhatsApp events and downloaded history, parses them into message records, then stores them in SQLite. Protocol edit metadata redirects a revision to the original message row before persistence.

flowchart LR
A[Live WhatsApp event] --> C[Sync handler]
B[History sync record] --> C
C --> D[Decrypt encrypted edit]
D --> E[Parse protocol edit]
E --> F[Reconcile original message]
F --> G[SQLite message store]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR provides fake-client and storage fixtures, but no after-fix real-account sync; add a redacted live or history transcript before merge, then update the PR body for re-review.
  • Resolve merge risk (P1) - This changes the live and historical inputs to message reconciliation; without an affected-account run, the real WhatsApp envelope behavior remains unproven.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus tests production +71, tests +162 The bounded sync-path change is accompanied by more than twice as many focused regression-test lines.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #362
Summary: This PR is the concrete candidate repair for the encrypted-edit persistence bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Verify an affected-account sync before merge (recommended)
    Add redacted live or history sync output showing that an encrypted edit updates the original row without creating an opaque row, then retain the existing patch.

Technical review

Best possible solution:

Retain this narrow decryption-and-validation path once a redacted affected-account sync demonstrates that the original row is edited and no opaque envelope row is stored.

Do we have a high-confidence way to reproduce the issue?

Yes—current source establishes the missing decryption path, and the linked issue provides an affected-account procedure; this review did not execute an account-backed sync.

Is this the best way to solve the issue?

Yes—the patch decrypts only MESSAGE_EDIT envelopes, validates the resulting protocol edit, and reuses established reconciliation rather than creating a parallel storage path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 97e14efdf91a.

Labels

Label justifications:

  • P1: Affected WhatsApp accounts store edits as unusable opaque rows instead of retaining corrected message content.
  • merge-risk: 🚨 message-delivery: The patch changes how live and history edit events are decrypted, validated, and targeted for persistence.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides fake-client and storage fixtures, but no after-fix real-account sync; add a redacted live or history transcript before merge, then update the PR body for re-review.

Evidence

What I checked:

  • Current main lacks encrypted-edit handling: The released main branch passes live messages directly to parsing and history records directly through history parsing; neither path decrypts secret-encrypted edit envelopes before storage. (internal/app/sync_events.go:529, 97e14efdf91a)
  • Existing edit contract: The parser already applies a protocol edit's target key and marks the replacement as edited, so routing validated decrypted content through it preserves the existing reconciliation model. (internal/wa/messages.go:260, c2253b86c27d)
  • Focused regression coverage: The PR adds live and history fixtures for encrypted edits plus target mismatch and ordering cases. (internal/app/sync_test.go:2862, c2253b86c27d)
  • Patch integrity: The two-file patch adds 71 production lines and 162 test lines; its whitespace check is clean. (internal/app/sync_events.go:531, c2253b86c27d)
  • Release check: v0.17.1 contains current main, while no local tag contains this PR head; the reported behavior remains in the latest release. (internal/app/sync_events.go:529, 97e14efdf91a)
  • Area history: Recent history identifies opaque-message diagnostics as adjacent sync work, supporting routing to the current sync area rather than attributing the reported defect to a predecessor. (internal/app/sync_events.go:528, f5f5c6f6846d)

Likely related people:

  • Doron Vainrub: Authored the recent opaque-payload diagnostics change on the same sync event surface. (role: recent sync-area contributor; confidence: medium; commits: f5f5c6f6846d; files: internal/app/sync_events.go)
  • Peter Steinberger: Recent history includes sync fixes in this subsystem and the current release commit; the shallow local history prevents a stronger feature-origin attribution. (role: recent adjacent contributor; confidence: low; commits: 54d436db0168, 97e14efdf91a; files: internal/app/sync_events.go)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted after-fix output showing that an encrypted edit updates the original message and no opaque envelope row remains.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-15T18:46:04.359Z sha c2253b8 :: needs real behavior proof before merge. :: none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SecretEncryptedMessage{MESSAGE_EDIT} edits are stored as opaque rows instead of being applied

1 participant