Skip to content

feat(whatsapp): per-group allowFrom for sender authorization - #81053

Closed
davidv399 wants to merge 1 commit into
openclaw:mainfrom
davidv399:fix/whatsapp-per-group-allow-from
Closed

davidv399 wants to merge 1 commit into
openclaw:mainfrom
davidv399:fix/whatsapp-per-group-allow-from

Conversation

@davidv399

Copy link
Copy Markdown
Contributor

Fixes #69926.

Brings WhatsApp to parity with Feishu, IRC, LINE, Telegram, and Nextcloud-talk by accepting a per-group allowFrom list on channels.whatsapp.groups.<jid> (and the matching account-scoped entry). A non-empty per-group allowFrom overrides (does not merge with) the channel/account-level groupAllowFrom for that one JID, while groups without an override keep the channel/account-level list. Empty arrays fall back to the channel/account-level allowlist.

ClawSweeper triage explicitly cleared this as "narrow, source-proven feature gap with clear files, tests, and boundaries."

Change

  • WhatsAppGroupEntrySchema and WhatsAppGroupConfig gain an optional allowFrom: string[] (E.164 phone numbers).
  • New resolveWhatsAppConversationGroupAllowFrom resolver in extensions/whatsapp/src/inbound-policy.ts, wired into resolveWhatsAppIngressAccess so the effective groupAllowFrom passed to resolveStableChannelMessageIngress reflects the per-group override for group conversations.
  • The resolver respects the same multi-account inheritance guard as the rest of the WhatsApp config: account-scoped groups[<jid>].allowFrom takes precedence over a root-scope entry for the same JID, so root groups do not silently leak into accounts with their own groups map.
  • bundled-channel-config-metadata.generated.ts regenerated to surface the new field in the bundled channel schema (verified via pnpm config:channels:check).
  • docs/channels/whatsapp.md documents the per-group override semantics and shows a mixed-trust example.

Verification

  • pnpm test extensions/whatsapp/src/inbound-policy.test.ts extensions/whatsapp/src/config-schema.test.ts -- 17/17 pass (6 new resolver cases + 2 new schema cases + existing schema tests).
  • pnpm config:channels:check clean.
  • pnpm exec oxfmt --check --threads=1 clean on every touched file.

Real behavior proof

Behavior addressed: operators should be able to express different sender allowlists per WhatsApp group (e.g. "Group A: any team member can drive the bot; Group B: only staff; Group C: only me") without dropping back to a single channel-wide allowlist. The runtime resolver should also honor the multi-account inheritance guard so root-scope per-group lists do not leak into accounts with their own groups map.

Real environment tested: local Linux 6.17 (Node 22.22.2). Live Node process driving the real production resolveWhatsAppInboundPolicy and resolveWhatsAppConversationGroupAllowFrom helpers from this PR (no mocks). The proof feeds the helper realistic OpenClaw configs (single-account, multi-account, override+inherit+empty cases) and prints the effective groupAllowFrom the inbound gate would apply.

Exact steps or command run after this patch:

node --import tsx /tmp/proof-69926.mts

Where /tmp/proof-69926.mts directly imports the production resolver helpers from extensions/whatsapp/src/inbound-policy.ts and validates per-group override, fallback on empty, account-scoped override, and inheritance behavior across seven scenarios.

Evidence after fix: terminal output captured directly from the live Node process exercising the production helpers.

--- channel-level only (single-account) ---
  group with per-group allowFrom override
    -> ["+15550003333","+15550004444"]
  group with a different per-group allowFrom
    -> ["+15550005555"]
  group WITHOUT override -> inherits channel-level
    -> ["+15550001111"]
  empty per-group allowFrom -> inherits channel-level
    -> ["+15550001111"]

--- multi-account: account-scoped groups override account-level groupAllowFrom ---
  work account, group has per-group override
    -> ["+15550007777"]
  work account, no override on this jid -> inherits work groupAllowFrom
    -> ["+15550008888"]
  personal account, no groups map at all -> inherits personal groupAllowFrom
    -> ["+15550006666"]

Observed result after fix:

  • Group with a per-group allowFrom returns exactly that list, suppressing the channel-level groupAllowFrom for that JID.
  • A different per-group entry returns its own list independently -- the override is per-JID, not channel-wide.
  • A group without a per-group entry returns the channel-level groupAllowFrom, so existing configs keep working unchanged.
  • An empty allowFrom: [] falls back to the channel-level list, so accidental empties do not silently fail closed for the group.
  • In a multi-account config, the work account's per-group override applies for that JID, and groups without overrides correctly inherit the work account's groupAllowFrom rather than leaking from the personal account or the channel root.
  • The personal account, which has no groups map of its own, falls back to its own account-level groupAllowFrom.

What was not tested: a live WhatsApp message ingress against a real WhatsApp Web account. The runtime proof above exercises the production resolver and resolveWhatsAppInboundPolicy chain, and the unit suite covers the schema acceptance plus the resolver semantics under every documented case, but neither runs a real inbound WhatsApp event against a paired account.

…w#69926)

Bring WhatsApp to parity with Feishu, IRC, LINE, Telegram, and
Nextcloud-talk by accepting a per-group `allowFrom` list on
`channels.whatsapp.groups.<jid>` (and the matching account-scoped
entry). A non-empty per-group `allowFrom` overrides (does not merge
with) the channel/account-level `groupAllowFrom` for that one JID,
while groups without an override keep the channel/account-level list.
Empty arrays fall back to the channel/account-level allowlist.

The resolver respects the same multi-account inheritance guard as the
rest of the WhatsApp config: account-scoped `groups[<jid>].allowFrom`
takes precedence over a root-scope entry for the same JID, so root
groups do not silently leak into accounts with their own groups map.

Changes:

- `WhatsAppGroupEntrySchema` and `WhatsAppGroupConfig` gain an
  optional `allowFrom: string[]` (E.164 phone numbers).
- New `resolveWhatsAppConversationGroupAllowFrom` resolver in
  `inbound-policy.ts`, wired into `resolveWhatsAppIngressAccess` so
  the effective `groupAllowFrom` passed to
  `resolveStableChannelMessageIngress` reflects the per-group
  override for group conversations.
- `bundled-channel-config-metadata.generated.ts` regenerated to
  surface the new field in the bundled channel schema.
- `docs/channels/whatsapp.md` documents the per-group override and
  shows a mixed-trust example.

Tests:

- New `extensions/whatsapp/src/inbound-policy.test.ts` covers the
  resolver semantics: override applied, empty list falls back,
  unrelated groups inherit the account-level list, account-scoped
  groups override root-scope entries, missing groups map returns the
  account-level allowlist.
- `extensions/whatsapp/src/config-schema.test.ts` gains two cases for
  the new field at root and account scope.

Fixes openclaw#69926.
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web size: M proof: supplied External PR includes structured after-fix real behavior proof. labels May 12, 2026
@clawsweeper

clawsweeper Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 3, 2026, 11:51 PM ET / 03:51 UTC.

Summary
The PR adds optional allowFrom to WhatsApp per-group config/schema/types/generated metadata/docs/tests and resolves it as a per-conversation override for inbound group sender authorization.

PR surface: Source +24, Tests +202, Docs +29, Generated 0. Total +255 across 8 files.

Reproducibility: yes. for the review defect from source: the PR's effective per-group allowlist reaches ingress, while current main's WhatsApp context callers still pass inboundPolicy.groupAllowFrom into quoted-reply and group-history filters. I did not run tests because this cleanup review is read-only.

Review metrics: 1 noteworthy metric.

  • WhatsApp config surface: 1 optional group field added. A new sender-authorization key under channels.whatsapp.groups.<jid> needs consistent enforcement across every WhatsApp authorization consumer before merge.

Stored data model
Persistent data-model change detected: unknown-data-model-change: src/config/bundled-channel-config-metadata.generated.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #69926
Summary: This PR is the implementation candidate for the canonical WhatsApp per-group sender allowlist request; nearby WhatsApp safety and group-management items overlap only partially or are adjacent.

Members:

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

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Apply the effective per-group allowlist in WhatsApp context filtering and add focused coverage for quoted/history context exclusion.
  • Refresh the conflicting branch against current main and rerun the WhatsApp policy tests plus bundled channel metadata check.

Risk before merge

  • [P1] Merging as-is would split one WhatsApp sender-authorization boundary: ingress would use the stricter per-group allowFrom, while quoted-reply and buffered group-history context on current main would still use the broader account/channel groupAllowFrom.
  • [P1] The PR is currently conflicting with main, so the repaired branch needs a refresh that preserves current admission/context APIs before final review.

Maintainer options:

  1. Repair context visibility before merge (recommended)
    Reuse the per-group allowFrom resolver in WhatsApp context filtering, add focused quoted/history context tests, and refresh the conflicting branch before maintainer review.
  2. Wait for account-policy refactor
    If maintainers want the open WhatsApp account-policy refactor to own the shared seam, pause this branch until that path is settled and then port the feature through it.
  3. Accept ingress-only semantics
    Maintainers could deliberately land ingress-only behavior, but they would own the documented mismatch for supplemental context until a follow-up closes it.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Update the WhatsApp per-group allowFrom PR so the same effective group sender allowlist is used by inbound admission and context visibility. Add focused tests for unauthorized group sender exclusion from auto-reply quoted/history context, keep groups without overrides or empty arrays on the existing fallback behavior, and validate with the WhatsApp policy/context tests plus bundled channel metadata check.

Next step before merge

  • [P2] A narrow automated repair can reuse the new resolver in WhatsApp context filtering and add focused tests; final product acceptance still belongs to maintainer review.

Security
Needs attention: The diff improves WhatsApp sender authorization but leaves a concrete supplemental-context path on the older broader allowlist.

Review findings

  • [P1] Apply per-group allowFrom to context visibility — extensions/whatsapp/src/inbound-policy.ts:167-172
Review details

Best possible solution:

Use one WhatsApp-owned effective per-conversation group sender allowlist for ingress admission, command authorization, quoted replies, and group-history visibility before merging.

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

Yes for the review defect from source: the PR's effective per-group allowlist reaches ingress, while current main's WhatsApp context callers still pass inboundPolicy.groupAllowFrom into quoted-reply and group-history filters. I did not run tests because this cleanup review is read-only.

Is this the best way to solve the issue?

No, not yet. The schema and resolver direction is plausible, but the same effective per-conversation allowlist needs to feed supplemental context visibility before this is the narrow maintainable fix.

Full review comments:

  • [P1] Apply per-group allowFrom to context visibility — extensions/whatsapp/src/inbound-policy.ts:167-172
    This computes an effective per-group sender allowlist only for resolveStableChannelMessageIngress. Current main's WhatsApp auto-reply path still feeds quoted-reply and group-history filters with inboundPolicy.groupAllowFrom, so a sender blocked by the new group override can still appear in supplemental context under the broader account/channel allowlist.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9d68f877ac3e.

Label changes

Label justifications:

  • P2: This is a bounded WhatsApp authorization feature with a concrete merge-blocking consistency defect, but it is not an outage or active regression.
  • merge-risk: 🚨 security-boundary: The PR changes who may influence WhatsApp group handling, and one supplemental context path would still use the broader allowlist.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body includes after-fix terminal output from a live Node process importing the production resolver helpers and exercising override, fallback, and multi-account cases; it does not cover the context-visibility finding.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from a live Node process importing the production resolver helpers and exercising override, fallback, and multi-account cases; it does not cover the context-visibility finding.
Evidence reviewed

PR surface:

Source +24, Tests +202, Docs +29, Generated 0. Total +255 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 25 1 +24
Tests 2 202 0 +202
Docs 2 29 0 +29
Config 0 0 0 0
Generated 1 2 2 0
Other 0 0 0 0
Total 8 258 3 +255

Security concerns:

  • [medium] Sender boundary split across ingress and context — extensions/whatsapp/src/inbound-policy.ts:167
    Per-group allowFrom is enforced for ingress admission, but context visibility still receives the account/channel groupAllowFrom, which can expose unauthorized sender messages to auto-reply context despite a stricter group override.
    Confidence: 0.9

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/whatsapp/src/inbound-policy.test.ts extensions/whatsapp/src/auto-reply/monitor/inbound-context.test.ts extensions/whatsapp/src/auto-reply/monitor/process-message.test.ts extensions/whatsapp/src/config-schema.test.ts.
  • [P1] pnpm config:channels:check.
  • [P1] git diff --check.

What I checked:

  • Repository policy applied: Root and scoped repository policy were read; the WhatsApp channel config and sender-authorization change is compatibility- and security-boundary-sensitive under the repo review rules. (AGENTS.md:1, 9d68f877ac3e)
  • Scoped extension/docs policy read: The touched bundled plugin and docs paths are covered by scoped AGENTS.md guidance, which was read and applied where relevant. (extensions/AGENTS.md:1, 9d68f877ac3e)
  • PR applies effective allowlist at ingress: At the PR head, resolveWhatsAppIngressAccess computes effectiveGroupAllowFrom and passes it into resolveStableChannelMessageIngress, so the new resolver is only wired into the ingress admission path. (extensions/whatsapp/src/inbound-policy.ts:167, 3f60f7b316a5)
  • Current main context callers still use broad list: Current main passes inboundPolicy.groupAllowFrom into WhatsApp quoted-reply and group-history visibility filtering, so a repaired merge must carry the per-group override into these sibling consumers too. (extensions/whatsapp/src/auto-reply/monitor/process-message.ts:298, 9d68f877ac3e)
  • Context filters enforce the supplied allowlist: resolveVisibleWhatsAppGroupHistory and resolveVisibleWhatsAppReplyContext decide supplemental context visibility from their groupAllowFrom parameter, making the caller's effective allowlist security-sensitive. (extensions/whatsapp/src/auto-reply/monitor/inbound-context.ts:52, 9d68f877ac3e)
  • Current main lacks requested config field: Current main's strict WhatsApp group schema and WhatsAppGroupConfig type do not include per-group allowFrom, so the central feature is not already implemented on main. (src/config/zod-schema.providers-whatsapp.ts:23, 9d68f877ac3e)

Likely related people:

  • mcaxtr: Recent history shows work across WhatsApp inbound admission, inbound policy, process-message, and context files that this PR needs to update consistently. (role: recent WhatsApp admission/context contributor; confidence: high; commits: 8686f0469936, 27581406073a, eebcb100b835; files: extensions/whatsapp/src/inbound-policy.ts, extensions/whatsapp/src/auto-reply/monitor/process-message.ts, extensions/whatsapp/src/auto-reply/monitor/inbound-context.ts)
  • steipete: History shows supplemental-context and context-visibility changes on the exact sibling path that must consume the effective allowlist. (role: adjacent supplemental-context contributor; confidence: high; commits: 1507a9701b83, 35e16051479f; files: extensions/whatsapp/src/auto-reply/monitor/inbound-context.ts, extensions/whatsapp/src/auto-reply/monitor/process-message.ts)
  • Bluetegu: Authored the merged WhatsApp group/direct system-prompt PR that expanded the same groups config map, schema, docs, and process-message surfaces. (role: adjacent group config surface author; confidence: medium; commits: 08bc16853ef4; files: docs/channels/whatsapp.md, src/config/types.whatsapp.ts, src/config/zod-schema.providers-whatsapp.ts)
  • omarshahine: Merged the adjacent WhatsApp group config PR and was explicitly pulled into the linked issue discussion for this follow-up direction. (role: adjacent reviewer/merger; confidence: medium; commits: 08bc16853ef4; files: docs/channels/whatsapp.md, src/config/types.whatsapp.ts, src/config/zod-schema.providers-whatsapp.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 27, 2026
@clawsweeper

clawsweeper Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg: 🔥 warming; proof passed, review follow-up or readiness checks remain. Hatch with @clawsweeper hatch when eligible.

Rules and details

Hatchability:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

About:

  • Eggs appear after real-behavior proof passes. They are collectible flavor only.
  • Review momentum changes the shell state: follow-up work warms it, re-review makes it wobble, and a clean final review lets it hatch.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat(whatsapp): per-group allowFrom for sender authorization This is item 1/1 in the current shard. Shard 14/20.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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 docs Improvements or additions to documentation merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: WhatsApp: per-group allowFrom for sender authorization (parity with Feishu/IRC/LINE/Telegram/Nextcloud-talk)

1 participant