Skip to content

fix(whatsapp): migrate unscoped credentials through Doctor - #163203

Merged
steipete merged 5 commits into
mainfrom
fix/lg-runtime-whatsapp-canonical-credentials
Oct 3, 2026
Merged

steipete merged 5 commits into
mainfrom
fix/lg-runtime-whatsapp-canonical-credentials

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

WhatsApp runtime implicitly selected shared-root credentials when the default account directory had none. The old Doctor move plan lacked a complete verified backup and reliable recovery for interrupted claims or incomplete destination sets. Published OpenClaw 2026.9.7 still selects and writes this credential layout, so its migration remains supported.

Why This Change Was Made

WhatsApp's existing Doctor artifact now owns the import. It saves exact private .migrated backups, verifies the complete destination before removing sources, and records durable intent in existing plugin SQLite state. Receipts bind the source credential digest to the expected destination fingerprint without storing credential bytes. Changed or missing destinations require recovery instead of silently relinking an account after logout. Explicit account authDir settings remain authoritative; conflicting identities and orphaned key files remain preserved. Each filesystem effect and receipt commit rechecks the existing offline migration authority.

Runtime account resolution and auth discovery consume canonical account directories or explicit overrides. The credential repair adds no core migration module, storage owner, schema, or protocol.

The published-driver cell exposed an admission gap: an older installed plugin could validate or repair a setting that the candidate had retired, so admission emitted a warning and a later Doctor refused it after snapshotting. Candidate admission now checks the original source with the existing shared retired-config detector before planning any plugin repair. This adds nine production lines and returns the existing typed invalid-config refusal before mutable execution.

Production +321 / -90 / net +231, refreshed from the complete paginated PR files API at head e93674677dcfeb305e84092001c752e7dc94184b (17 files, 8 production files, all pages consumed). The measurement covers src/** and extensions/**, excluding tests, test support/helpers/utilities, e2e, and fixtures. The preference retirement contributes +4 / -27 / net -23. Remaining growth protects credentials, key material, and logout across crashes under the durable-data exception.

The rebase preserves main's account-routing warnings, Telegram/Nextcloud/Talk retirement rules, Teams include-persistence tests, and OAuth retirement documentation. The three credential commits are patch-identical; all six WhatsApp production owner files have the same blobs as the prior 3f9acb0 head. The three conflicts were adjacent additions in the shared detector, test file, and migration docs. Main's behavior is retained alongside WhatsApp's additions. Earlier overlaps with #161466 and #124305 concern separate account-policy fields.

User Impact

The obsolete WhatsApp exposeErrorText cleanup is removed as a same-owner offset. Its schema/type was introduced and removed on April 29; later published schemas only stripped the already ignored preference. The existing shared retired-config detector now names root and account occurrences before backup recovery or writes, including explicit false values during an update. Remove the reported key before retrying; doing so does not change error delivery. Alternatively, OpenClaw 2026.9.5 Doctor contains the old cleanup. Current Doctor preserves the authored config and gives that explicit bridge instruction instead of repeatedly suggesting a repair it no longer performs.

The installed 2026.9.7 updater runs first. The completed cell installed published core and its WhatsApp package, seeds exposeErrorText: false at the root and declared default account, and runs that unmodified openclaw update against the exact candidate artifacts. It verified a candidate-owned protocol-1 invalid-config refusal with the 2026.9.5 remedy, unchanged config/credential/package bytes and plugin records, and no snapshot, activation, or rollback. The fixture then removed only those synthetic ignored fields and completed the credential update.

Before any manual candidate Doctor, the retry verified installed artifact identities, executed credential migration, canonical and backup bytes, private permissions, and unrelated OAuth preservation. A second Doctor confirmed idempotence. The fixture uses the repository's version-only next-version transformation and checks that runtime archive members remain byte-identical; it publishes nothing and does not claim same-version replacement coverage.

A separate artifact step loaded the candidate's packed Doctor and auth-presence surfaces against the real published 2026.9.7 SDK. Canonical-state loading retains that API compatibility path. Legacy repair additionally requires the existing offline authority, backup helper, and keyed-store binding; an older host lacking them receives update-core guidance before any write. Direct plugin replacement requires openclaw doctor --fix.

Evidence

Current head: e93674677dcfeb305e84092001c752e7dc94184b; tree: 0dc40ddac043a0254202e4dd174cc79d92df3b10; parent: 2a79d1ff1201be7c4378b10e851bf24cb968c7aa; captured main base: 260a31989937cb1ac3d2d0a2280a65ef5312a81a.

  • Formatting and git diff --check passed. Fresh independent Codex P2 review of the nine-line admission fix and two real CLI-entry regressions is scoped-clean. The earlier rebase retained main's detector/test/docs additions and all three credential commits unchanged.
  • Prior-head CI: run 37116993384 passed at exact head 2a79d1ff1201be7c4378b10e851bf24cb968c7aa; its hosted published-driver cell was skipped. This is not current-head CI or a passing WhatsApp update cell.
  • Failed v5 live proof retained: Hetzner lease cbx_ff09028debc1, run run_3307afc26ac578dcfac4ed90471f6d2e, built the exact 2a79d1f package successfully in 929s, after frozen install in 11s. All 22 WhatsApp Doctor-contract tests passed in 7s; the retired-config refusal file passed in 140s (command wall times). The published-driver stage failed after 319s at its strict early-refusal assertion.
  • Read-only diagnostic run run_3765c1f9b5284eb92b99e64c865a7464 confirmed protocol-1 admission returned admit with a config warning, then candidate-state-snapshot ran and candidate-doctor failed on the two retired WhatsApp fields with the 2026.9.5 remedy. This was a real late-admission defect, not merely an error-label difference. The later preservation assertions were not reached. Neither the failed artifact nor the installed driver was patched, and no assertion was relaxed.
  • Existing credential regressions cover Baileys filename families, exact backups, interrupted claims, authority loss, conflicting/incomplete destinations, explicit account roots, and no relink after logout. Older hosted run 37007407911, at credential head 669161610f341793e8fca66f3fb62048bc0307d0, passed all 15 migration cases in 3.093s reported test time; the two-file database-worker shard took 54.96s including transforms. These remain historical measurements.

Current-head CI and the complete published-driver cell passed. Exact-head hosted CI 37128643488 passed at e936746, including its hosted published-driver job (11m24s). The separate strict cell ran on Hetzner lease cbx_ff09028debc1, run run_8a7599227d4cce69f8c6e3f4e3276d89, with frozen install first and a newly built e936746 artifact. The entire remote command took 2227.702s; package/integrity checks took 910.11s and the published-driver phase took 902s.

The two new real CLI-entry admission cases failed on 2a79d1f specifically because old code admitted the retired configuration with exit 0 (44.91s command wall). They passed on this candidate (46.67s); the full admission owner passed (39.42s), all 22 WhatsApp Doctor-contract tests passed (6.96s), and the retired-config refusal owner passed (139.01s). These controls preserved the same assertions; the dirty baseline-plus-test worktree was never packaged.

The actual unmodified published 2026.9.7 updater first returned the candidate-owned protocol-1 invalid-config refusal. It preserved config, credential and package bytes and plugin records, with no copied-state snapshot, activation, or rollback. After removing only the synthetic ignored preference keys, the credential update completed in 644s; installed routing/artifact and first-hop credential assertions passed before manual Doctor. Repeated Doctor passed in 29s, followed by exact idempotence assertions and update status. The candidate's packed Doctor/auth-presence surfaces also loaded against the real published 9.7 SDK.

This is a --no-restart package/config/state cell, not a live WhatsApp messaging or running-Gateway PID-preservation claim. The version-only fixture produced 2026.9.9-first-hop.0, verifying unchanged runtime members; nothing was published and same-version replacement is not claimed. Earlier v5 failure evidence remains preserved and is not relabeled as success.

Independent P2 review of the final source and v6 proof was clean. No local tests or builds ran.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web size: L labels Oct 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 3, 2026, 10:32 AM ET / 14:32 UTC (Revision 11).

ClawSweeper review

What this changes

Moves legacy WhatsApp credentials through Doctor with verified backups and recovery receipts, removes implicit runtime fallback, and refuses retired configuration before update repair.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains useful work: current main and the latest release retain implicit shared-root credential fallback. No concrete introduced correctness defect was found, but the WhatsApp-specific upgrade evidence remains incomplete despite passing current-head CI.

Priority: P2
Reviewed head: e93674677dcfeb305e84092001c752e7dc94184b

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has coherent ownership and no identified blocking code defect, but credential upgrade compatibility remains unproven.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Independently, credential layout and persistent receipts require upgrade compatibility: the captured WhatsApp-specific published-driver and packed-plugin results remain pending, and the passing generic CI fixture disables plugins. Existing-state compatibility is therefore unresolved.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Independently, credential layout and persistent receipts require upgrade compatibility: the captured WhatsApp-specific published-driver and packed-plugin results remain pending, and the passing generic CI fixture disables plugins. Existing-state compatibility is therefore unresolved.
Evidence reviewed 11 items Pinned change ownership: Reviewed the introduced merge-base-to-head delta, not endpoint drift. The supplied test merge is stale and cannot establish what merging would remove from current main.
Still necessary on main: Fetched main retains the per-file legacy move planner and selects shared-root credentials when default-account credentials are absent. It does not contain this branch's complete-set backup and receipt implementation.
Latest-release behavior: The supplied latest release, v2026.9.8, also retains shared-root fallback; the central cutover has not already shipped there.
Findings None None.
Security None None.

How this fits together

The WhatsApp plugin resolves account credentials used to connect linked devices. Doctor normalizes older credential layouts before runtime starts, while update admission checks whether the candidate can safely accept existing configuration.

flowchart TD
  A[Existing configuration and credentials] --> B[Candidate update admission]
  B --> C{Retired settings present?}
  C -->|Yes| D[Preserve installation and explain recovery]
  C -->|No| E[WhatsApp Doctor migration]
  E --> F[Private backups and SQLite receipts]
  E --> G[Canonical account credentials]
  G --> H[WhatsApp runtime]
Loading

Before merge

  • Resolve merge risk (P1) - Existing implicit shared-root accounts can appear unlinked if migration does not complete before runtime starts. The captured evidence has not established the current candidate's WhatsApp-specific published-updater cutover, packed-plugin compatibility, or retired-setting refusal and recovery.
  • Complete next step (P2) - Record the current candidate's WhatsApp-specific published-updater and packed-plugin compatibility results, plus admission negative-control results and changed-suite timing evidence.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +231, Tests +344, Docs +9. Total +584 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 8 321 90 +231
Tests 7 435 91 +344
Docs 2 11 2 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 767 183 +584

Review metrics

Metric Value Why it matters
Production versus regression coverage production net +231 lines; tests net +343 lines The stated production growth protects credential backups and crash recovery, while added coverage exercises migration preservation and update admission.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/whatsapp/doctor-contract-api.ts, migration/backfill/repair: extensions/whatsapp/src/doctor-contract.ts, unknown-data-model-change: extensions/whatsapp/src/doctor-contract.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Finish the prepared upgrade evidence (recommended)
    Record the current candidate's published-2026.9.7 WhatsApp update and packed-plugin results, including credential preservation and retired-setting recovery, before accepting the runtime cutover.

Technical review

Best possible solution:

Keep credential normalization with WhatsApp Doctor and establish published-install upgrade compatibility before removing runtime fallback.

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

Yes for the source mechanism: current main selects implicit shared-root credentials and migrates through independent file plans. A failing current-main crash or upgrade scenario was not executed during this read-only review.

Is this the best way to solve the issue?

Yes, the plugin-owned Doctor migration is the appropriate repair boundary and reuses existing backup, authority, and storage owners; upgrade compatibility still needs the scoped evidence already prepared.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b94391aa2c5a.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded WhatsApp credential and upgrade-safety repair without evidence of an ongoing broad outage.
  • merge-risk: 🚨 compatibility: Removing implicit credential fallback and automatic retired-key cleanup changes existing-install recovery paths that generic green CI does not exercise.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Independently, credential layout and persistent receipts require upgrade compatibility: the captured WhatsApp-specific published-driver and packed-plugin results remain pending, and the passing generic CI fixture disables plugins. Existing-state compatibility is therefore unresolved.

Evidence

What I checked:

  • Pinned change ownership: Reviewed the introduced merge-base-to-head delta, not endpoint drift. The supplied test merge is stale and cannot establish what merging would remove from current main. (e93674677dcf)
  • Still necessary on main: Fetched main retains the per-file legacy move planner and selects shared-root credentials when default-account credentials are absent. It does not contain this branch's complete-set backup and receipt implementation. (extensions/whatsapp/src/accounts.ts:99, b94391aa2c5a)
  • Latest-release behavior: The supplied latest release, v2026.9.8, also retains shared-root fallback; the central cutover has not already shipped there. (extensions/whatsapp/src/accounts.ts:99, fc23bc864e45)
  • Credential preservation and authority: The migration requires offline authority, creates backups through the existing source-backup owner, binds receipt operations to current authority, persists intent before publication, and verifies destination identity before source removal. Existing receipts block automatic recreation after logout or destination changes. (extensions/whatsapp/src/state-migrations.ts:116, e93674677dcf)
  • Admission repair: The new guard checks sourceConfigBeforeMigrations before the legacy plugin repair projection and returns the existing typed invalid-config refusal. Two added CLI-entry cases cover older plugins that consider the retired configuration valid or repairable. (src/cli/update-cli/update-command-admit.ts:114, e93674677dcf)
  • Captured upgrade evidence: The captured body explicitly preserves the failed prior-head v5 published-2026.9.7 run: admission allowed a warning, snapshotting occurred, and candidate Doctor then refused retired WhatsApp settings. Credential-preservation assertions were not reached. The current v6 WhatsApp update cell and packed-plugin compatibility results are described as pending, rather than passing. (e93674677dcf)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Record the prepared current-candidate WhatsApp published-updater and packed-plugin compatibility results.
  • Record the new admission regression controls and required changed-suite wall times.

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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-02T06:49:19.995Z sha dff61c0 :: blocked before merge. :: none
  • reviewed 2026-10-02T12:13:20.167Z sha dff61c0 :: blocked before merge. :: none
  • reviewed 2026-10-02T12:44:56.526Z sha 6691616 :: blocked before merge. :: none
  • reviewed 2026-10-02T13:26:13.855Z sha dcc1dae :: blocked before merge. :: none
  • reviewed 2026-10-03T04:50:53.810Z sha 3f9acb0 :: blocked before merge. :: none
  • reviewed 2026-10-03T05:10:54.582Z sha 3f9acb0 :: blocked before merge. :: none
  • reviewed 2026-10-03T10:42:31.334Z sha 2a79d1f :: blocked before merge. :: none
  • reviewed 2026-10-03T14:14:49.850Z sha e936746 :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review October 2, 2026 12:09
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete force-pushed the fix/lg-runtime-whatsapp-canonical-credentials branch from 3f9acb0 to 2a79d1f Compare October 3, 2026 10:36
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Oct 3, 2026
@steipete
steipete merged commit 55e3daa into main Oct 3, 2026
143 checks passed
@steipete
steipete deleted the fix/lg-runtime-whatsapp-canonical-credentials branch October 3, 2026 17:37
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…163203)

Move shared-root credential import into WhatsApp's existing Doctor owner. Preserve exact private backups and explicit account roots, verify complete destination bytes before source removal, and retain durable replay protection across interrupted migration and logout. Runtime uses canonical account directories or explicit overrides.

Check retired source configuration before plugin repair planning so the candidate refuses before copied-state snapshots or package mutation.

Independent P2 review, exact-head CI, strict negative and positive admission controls, and the published 2026.9.7 update cell passed. The package/config/state cell used --no-restart and a version-only candidate fixture with unchanged runtime bytes; it does not claim live WhatsApp messaging. Proof, costs, retention history, and behavior changes are in the PR.

Production +321/-90/net +231 under the credential exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant