Skip to content

feat(messaging): add Zalo ClawBot host-qr channel - #5726

Closed
hunglp6d wants to merge 14 commits into
mainfrom
feat/messaging-channel-zalo-clawbot
Closed

hunglp6d wants to merge 14 commits into
mainfrom
feat/messaging-channel-zalo-clawbot

Conversation

@hunglp6d

@hunglp6d hunglp6d commented Jun 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds Zalo ClawBot as a built-in OpenClaw messaging channel — an owner-bound personal Zalo bot paired via QR. NemoClaw renders the QR and captures the bot token host-side during onboarding (the WeChat host-qr model), then seeds it into the plugin's account store so the sandboxed agent starts already logged in. OpenClaw's in-sandbox channels login is WhatsApp-only and cannot drive this channel, so host-qr capture-and-seed is required.

Related Issue

Parts of #5492

Token Onboarding Guide

NemoClaw E2E Onboarding with Messaging Channels

Result

image

Changes

  • New zalo-clawbot channel manifest: auth.mode: host-qr, owner-bound (no allowlist/dmPolicy), plugin @zalo-platforms/[email protected] (pinned).
  • Host-side QR login client (qr.ts request-login + status poll, login.ts orchestration) capturing the bot token, plus the zalo-clawbot.qrLogin enroll hook and zalo-clawbot.seedOpenClawAccount build hook. The token is seeded as an openshell:resolve:env: placeholder (resolved by the OpenShell proxy at request time) and never lands raw in the image.
  • New zalo-clawbot egress preset: bot-api.zaloplatforms.com (runtime long-poll + send) and bot.zaloplatforms.com (QR login/provisioning).
  • Registered in built-ins.ts, the messaging hook registry, and the OpenClaw agent's messaging_platforms.
  • Updated the channel/metadata/manifests/diagnostics/policy enumeration tests; added login and enroll/seed hook unit tests.
  • Ratcheted the policies.test.ts size budget by 1 line for the new preset's required entry in the canonical preset-name allowlist.

Docs: deferred to the tech writer post-merge

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Git hooks passed during commit and push, or npx prek run --from-ref main --to-ref HEAD passes
  • Targeted tests pass for changed behavior
  • Full npm test passes (broad runtime changes only)
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Hung Le [email protected]

Summary by CodeRabbit

  • New Features
    • Added the Zalo Clawbot messaging channel with built-in manifest/metadata, credential environment keys, and QR login + OpenClaw account seeding hook registrations.
    • Added a zalo-clawbot policy preset and updated preset listings/agent manifest expectations accordingly.
  • Bug Fixes
    • Hardened the host QR login flow with clearer timeout/expiry handling, abort support, safer account-id validation, and more robust token/account derivation.
  • Tests
    • Expanded coverage for channel manifests/metadata, hook implementations, diagnostics, and built-in registries.
  • Chores
    • Minor CI/test expectation and file-size budget updates.

@copy-pr-bot

copy-pr-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds zalo-clawbot as a new built-in messaging channel with QR-based host login, a manifest, hook-driven account seeding, a policy preset, and registry/test updates.

Changes

Zalo ClawBot channel integration

Layer / File(s) Summary
Zalo QR session client
src/lib/messaging/channels/zalo-clawbot/qr.ts, src/lib/messaging/channels/zalo-clawbot/login.ts, src/lib/messaging/channels/zalo-clawbot/login.test.ts
Defines session constants and typed login contracts, adds the host QR login flow, and covers session polling, refresh, error, and credential-mapping behavior.
Channel manifest and network policy preset
src/lib/messaging/channels/zalo-clawbot/manifest.ts, nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml, agents/openclaw/manifest.yaml
Defines the zaloClawbot manifest with host-qr auth, inputs, credential mapping, OpenClaw rendering and runtime visibility, pinned package, persistent state, and hooks. Adds the zalo-clawbot policy preset and registers the platform in the OpenClaw agent manifest.
Hook implementations and defaults
src/lib/messaging/channels/zalo-clawbot/hooks/*
Implements the QR login hook, the OpenClaw account seeding hook, the host QR login runtime defaults, and the Zalo ClawBot hook registration entry point. Includes tests for injected login handling, credential persistence, timeout behavior, placeholder token seeding, and unsafe account IDs.
Registry wiring and test suite updates
src/lib/messaging/channels/built-ins.ts, src/lib/messaging/hooks/builtins.ts, src/lib/messaging/channels/metadata.ts, src/lib/messaging/channels/manifests.test.ts, src/lib/messaging/channels/metadata.test.ts, src/lib/messaging/diagnostics.test.ts, src/lib/sandbox/channels.test.ts, src/lib/messaging/hooks/hook-runner.test.ts, src/lib/onboard/messaging-prep.test.ts, src/lib/agent/defs.test.ts, src/lib/messaging-channel-config.test.ts, test/policies.test.ts, test/channels-add-preset.test.ts, test/sandbox-provider-cleanup.test.ts, ci/test-file-size-budget.json
Registers zaloClawbotManifest in the built-in channel list, wires zalo-clawbot hook registrations into the built-in hook registry, updates metadata typing, and extends diagnostics, sandbox, onboarding, manifest, policy, preset, and size-budget tests for zalo-clawbot.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant QrLoginHook as createZaloClawbotQrLoginHook
  participant LoginOrch as runZaloClawbotHostQrLogin
  participant QrClient as qr.ts
  participant ZaloAPI as bot.zaloplatforms.com

  User->>QrLoginHook: enroll in interactive mode
  QrLoginHook->>LoginOrch: runLogin()
  LoginOrch->>QrClient: requestZaloClawbotLogin()
  QrClient->>ZaloAPI: GET /agent/request-login
  ZaloAPI-->>QrClient: loginUrl, zbsk
  QrClient-->>LoginOrch: session
  LoginOrch-->>User: render QR code

  loop poll until completion
    LoginOrch->>QrClient: pollZaloClawbotLoginStatus(zbsk)
    QrClient->>ZaloAPI: GET /agent/get-login-status
    ZaloAPI-->>QrClient: pending / expired / connected
    QrClient-->>LoginOrch: status
  end

  LoginOrch-->>QrLoginHook: ok credentials
  QrLoginHook->>QrLoginHook: saveCredential(botToken)
  QrLoginHook->>QrLoginHook: set env vars
  QrLoginHook-->>User: hook outputs
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested labels

enhancement: feature, enhancement: integration, enhancement: messaging

Poem

A rabbit hopped through silicon grass,
To Zalo ClawBot the messages pass.
QR squares shimmered, then credentials sang,
And cozy new hooks in the burrow all sprang. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a new Zalo ClawBot host-qr messaging channel.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/messaging-channel-zalo-clawbot

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the feat/messaging-chann... branch is 96%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main feat/messaging-chann... a9f6796 +/-
nemoclaw/src/se...cret-scanner.ts — 100% —
nemoclaw/src/commands/slash.ts — 100% —
nemoclaw/src/li...bprocess-env.ts — 100% —
nemoclaw/src/bl...eprint/state.ts — 98% —
nemoclaw/src/onboard/config.ts — 98% —
nemoclaw/src/bl...int/snapshot.ts — 97% —
nemoclaw/src/bl...print/runner.ts — 95% —
nemoclaw/src/co...ration-state.ts — 94% —
nemoclaw/src/bl...ate-networks.ts — 94% —
nemoclaw/src/index.ts — 94% —

TypeScript / code-coverage/cli

The overall coverage in the feat/messaging-chann... branch is 47%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main feat/messaging-chann... a9f6796 +/-
src/lib/state/o...oard-session.ts — 91% —
src/lib/inference/local.ts — 76% —
src/lib/sandbox/config.ts — 72% —
src/lib/actions...dbox/rebuild.ts — 71% —
src/lib/onboard/preflight.ts — 64% —
src/lib/actions...licy-channel.ts — 60% —
src/lib/state/sandbox.ts — 55% —
src/lib/onboard...er-gpu-patch.ts — 50% —
src/lib/policy/index.ts — 49% —
src/lib/onboard.ts — 19% —

Updated June 25, 2026 17:02 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@hunglp6d
hunglp6d marked this pull request as ready for review June 24, 2026 09:14
@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: cloud-onboard-e2e, messaging-providers-e2e, network-policy-e2e, channels-add-remove-e2e, credential-sanitization-e2e
Optional E2E: channels-stop-start-openclaw-e2e, token-rotation-e2e, openclaw-onboard-security-posture-e2e

Dispatch hint: cloud-onboard-e2e,messaging-providers-e2e,network-policy-e2e,channels-add-remove-e2e,credential-sanitization-e2e

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • cloud-onboard-e2e (medium): Validates the hosted OpenClaw onboarding path after adding a built-in host-QR messaging channel and changing OpenClaw supported messaging platforms. This should catch regressions where the new channel manifest or hook registration breaks normal non-interactive onboarding even when Zalo is not selected.
  • messaging-providers-e2e (high): Best existing E2E for messaging credential provider/placeholder plumbing, token isolation, OpenClaw config patching, runtime discovery, and messaging API egress paths. The PR adds a new token-backed host-QR channel with a provider placeholder and seeded account files.
  • network-policy-e2e (high): Required because the PR adds a new sandbox network policy preset and changes the allowed runtime egress surface for a messaging channel. This exercises policy loading, application, enforcement, and restricted-mode behavior.
  • channels-add-remove-e2e (high): Covers the existing channel add/remove lifecycle and preset-before-rebuild invariant. The new channel participates in the same manifest-driven policy preset, provider binding, registry plan, and rebuild surfaces.
  • credential-sanitization-e2e (medium): Required for credential/security-boundary changes: the Zalo token is captured on the host, stored in OpenShell, injected as a placeholder, and used to seed files. Existing credential sanitization coverage is the best merge-blocking guard against raw-token leakage into sandbox env/config/backups.

Optional E2E

  • channels-stop-start-openclaw-e2e (high): Useful adjacent confidence for OpenClaw channel disable/enable and rebuild persistence. The current script is hardcoded to existing channels, so it may not directly exercise Zalo unless extended, but it can catch regressions in shared channel lifecycle code.
  • token-rotation-e2e (medium): Adjacent coverage for messaging token hashing, credential rotation detection, and provider updates. Relevant because Zalo adds another token-backed channel, though existing assertions focus on Telegram/Discord/Slack.
  • openclaw-onboard-security-posture-e2e (medium): Additional confidence for OpenClaw onboarding security posture after adding host-side QR login code, third-party plugin installation, and new runtime visibility metadata.

New E2E recommendations

  • Zalo ClawBot host-QR onboarding (high): No existing E2E appears to exercise a complete Zalo ClawBot flow: fake Zalo session service, QR login completion, credential capture, OpenShell provider creation, build-file seeding, OpenClaw plugin enablement, and successful sandbox startup without interactive QR inside the sandbox.
    • Suggested test: Add a hermetic zalo-clawbot-host-qr-e2e using a local fake bot.zaloplatforms.com session service and fake bot-api.zaloplatforms.com runtime API.
  • Zalo-specific network policy (high): The new preset deliberately allows bot-api.zaloplatforms.com but omits bot.zaloplatforms.com from sandbox egress. Existing network policy E2E is generic and does not prove this Zalo-specific boundary.
    • Suggested test: Extend network-policy-e2e or add a focused Zalo policy case proving bot-api.zaloplatforms.com is allowed for node while bot.zaloplatforms.com remains blocked from the sandbox.
  • Messaging lifecycle coverage for OpenClaw-only channels (medium): Existing channel stop/start E2E is hardcoded to telegram/discord/wechat/slack/whatsapp and includes Hermes. Zalo is OpenClaw-only and may need special lifecycle assertions for add/remove/stop/start, registry plan persistence, policy preset application, and provider cleanup.
    • Suggested test: Extend channels-add-remove-e2e and channels-stop-start-openclaw-e2e with a Zalo ClawBot shard seeded by fake QR credentials.

Dispatch hint

  • Workflow: nightly-e2e.yaml
  • jobs input: cloud-onboard-e2e,messaging-providers-e2e,network-policy-e2e,channels-add-remove-e2e,credential-sanitization-e2e

@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Recommendation

Required Vitest E2E scenarios: messaging-providers-vitest, channels-add-remove-vitest
Optional Vitest E2E scenarios: None

Dispatch required Vitest E2E scenarios:

  • gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=messaging-providers-vitest
  • gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=channels-add-remove-vitest

Workflow run

Full Vitest E2E advisor summary

Vitest E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required Vitest E2E scenarios

  • messaging-providers-vitest: The PR adds a built-in OpenClaw messaging channel with provider credential metadata, host-QR token capture, config hydration, and OpenShell placeholder seeding. The messaging-providers live Vitest job is the narrow free-standing coverage for messaging provider placeholder/redaction and channel credential plumbing.
    • Dispatch: gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=messaging-providers-vitest
  • channels-add-remove-vitest: The PR adds a channel policy preset and built-in channel manifest/hook registration that can affect channels add/remove, policy application before rebuild, and gateway credential reuse behavior.
    • Dispatch: gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=channels-add-remove-vitest

Optional Vitest E2E scenarios

  • None.

Relevant changed files

  • agents/openclaw/manifest.yaml
  • nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml
  • src/lib/messaging/channels/built-ins.ts
  • src/lib/messaging/channels/zalo-clawbot/hooks/host-qr-login-runtime.ts
  • src/lib/messaging/channels/zalo-clawbot/hooks/index.ts
  • src/lib/messaging/channels/zalo-clawbot/hooks/qr-login.ts
  • src/lib/messaging/channels/zalo-clawbot/hooks/seed-openclaw-account.ts
  • src/lib/messaging/channels/zalo-clawbot/login.ts
  • src/lib/messaging/channels/zalo-clawbot/manifest.ts
  • src/lib/messaging/channels/zalo-clawbot/qr.ts
  • src/lib/messaging/hooks/builtins.ts

@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor — Blocked

Merge posture: Do not merge until addressed
Primary next action: Fix PRA-4: Host QR login accepts an arbitrary session-service base URL; then add or justify PRA-T1.
Open items: 2 required · 9 warnings · 0 suggestions · 8 test follow-ups
Since last review: 0 prior items resolved · 11 still apply · 0 new items found

Action checklist

  • PRA-4 Fix: Host QR login accepts an arbitrary session-service base URL in src/lib/messaging/channels/zalo-clawbot/qr.ts:79
  • PRA-5 Fix: Zalo-specific manifest assertions grow the large central manifest test hotspot in src/lib/messaging/channels/manifests.test.ts:667
  • PRA-1 Resolve or justify: Source-of-truth review needed: Malformed 2xx Zalo login-status tolerance
  • PRA-2 Resolve or justify: Source-of-truth review needed: Zalo sandbox policy wildcard exception
  • PRA-3 Resolve or justify: Source-of-truth review needed: Zalo owner-bound authorization contract
  • PRA-6 Resolve or justify: Malformed successful login-status payloads wait until the login deadline in src/lib/messaging/channels/zalo-clawbot/qr.ts:193
  • PRA-7 Resolve or justify: Zalo sandbox policy grants wildcard GET and POST paths in nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml:18
  • PRA-8 Resolve or justify: Owner-bound Zalo authorization remains an external trust contract in src/lib/messaging/channels/zalo-clawbot/manifest.ts:11
  • PRA-9 Resolve or justify: User-facing messaging docs omit the new Zalo ClawBot channel in docs/manage-sandboxes/messaging-channels.mdx:6
  • PRA-10 Resolve or justify: Third-party OpenClaw plugin install lacks durable dependency-review evidence in src/lib/messaging/channels/zalo-clawbot/manifest.ts:107
  • PRA-11 Resolve or justify: Zalo host-QR non-interactive and build-plan paths need focused validation in src/lib/messaging/channels/zalo-clawbot/hooks/qr-login.ts:42
  • PRA-T1 Add or justify test follow-up: Runtime validation
  • PRA-T2 Add or justify test follow-up: Runtime validation
  • PRA-T3 Add or justify test follow-up: Runtime validation
  • PRA-T4 Add or justify test follow-up: Runtime validation
  • PRA-T5 Add or justify test follow-up: Runtime validation
  • PRA-T6 Add or justify test follow-up: Zalo-specific manifest assertions grow the large central manifest test hotspot
  • PRA-T7 Add or justify test follow-up: Zalo host-QR non-interactive and build-plan paths need focused validation
  • PRA-T8 Add or justify test follow-up: Acceptance clause

Findings index

ID Severity Category Location Required action
PRA-1 Resolve/justify architecture — Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
PRA-2 Resolve/justify architecture — Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
PRA-3 Resolve/justify architecture — Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
PRA-4 Required security src/lib/messaging/channels/zalo-clawbot/qr.ts:79 Remove the `sessionServiceUrl` override if alternate session services are not a product requirement. If it must remain as a test seam, validate before any fetch: require `https:`, require exactly `bot.zaloplatforms.com`, and reject userinfo, path/query/hash, IP literals, localhost, private ranges, and link-local ranges.
PRA-5 Required tests src/lib/messaging/channels/manifests.test.ts:667 Move the Zalo-specific assertions into a channel-local file such as `src/lib/messaging/channels/zalo-clawbot/manifest.test.ts`. Leave only cross-channel registration, availability, serialization, and side-effect-import assertions in `manifests.test.ts`.
PRA-6 Resolve/justify correctness src/lib/messaging/channels/zalo-clawbot/qr.ts:193 Keep transport errors and 5xx responses retryable, but classify malformed 2xx status payloads as protocol errors once they are not a documented pending, expired, or connected shape. Return `kind: "error"` from `runZaloClawbotHostQrLogin()` with a clear message.
PRA-7 Resolve/justify security nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml:18 Constrain the preset to exact required paths if the plugin contract is known. If the paths are truly dynamic or undocumented, add a durable named exception in the preset or docs and a policy test proving the wildcard is intentional, host-limited, and does not include the host-side login service.
PRA-8 Resolve/justify security src/lib/messaging/channels/zalo-clawbot/manifest.ts:11 Add a durable trust-boundary note in user docs or manifest comments identifying the exact Zalo/plugin owner-filtering contract and why local filtering cannot be implemented here. If the plugin/API can simulate a non-owner event, add a negative test or diagnostic expectation; otherwise document why the guarantee must remain external.
PRA-9 Resolve/justify docs docs/manage-sandboxes/messaging-channels.mdx:6 Update `docs/manage-sandboxes/messaging-channels.mdx` in this PR with a focused Zalo ClawBot section and table/list updates. Include OpenClaw-only support, host-side QR capture, non-interactive behavior, `zalo-clawbot` policy preset, owner-bound authorization model, and pinned third-party plugin provenance/version-bump expectations.
PRA-10 Resolve/justify security src/lib/messaging/channels/zalo-clawbot/manifest.ts:107 If NemoClaw has a dependency or plugin allowlist/audit convention, add this package there. Also document the package owner/source, exact pinned version, and review expectation for future version bumps in the Zalo docs or manifest comments.
PRA-11 Resolve/justify tests src/lib/messaging/channels/zalo-clawbot/hooks/qr-login.ts:42 Add focused compiler/build-plan tests for Zalo rather than relying only on manifest enumeration and direct hook unit tests.

🚨 Required before merge

Address these before merging unless a maintainer explicitly overrides the advisor with rationale.

PRA-4 Required — Host QR login accepts an arbitrary session-service base URL

PRA-5 Required — Zalo-specific manifest assertions grow the large central manifest test hotspot

  • Location: src/lib/messaging/channels/manifests.test.ts:667
  • Category: tests
  • Problem: The PR adds a channel-specific `declares Zalo ClawBot as host-qr...` block to the central manifest test file, which drift analysis reports as 875 lines after this change.
  • Impact: Keeping channel-local assertions in the central registry test increases merge conflicts with active messaging-channel work and makes the central manifest suite harder to maintain.
  • Required action: Move the Zalo-specific assertions into a channel-local file such as `src/lib/messaging/channels/zalo-clawbot/manifest.test.ts`. Leave only cross-channel registration, availability, serialization, and side-effect-import assertions in `manifests.test.ts`.
  • Expected follow-up: Fix before merge or get explicit maintainer override.
  • Verification: Inspect `src/lib/messaging/channels/manifests.test.ts` and confirm the Zalo-specific block is gone while central registry tests still verify that `zalo-clawbot` is exposed for OpenClaw only.
  • Missing regression test: The existing assertions already provide the needed regression coverage; relocate them to a channel-local manifest test and keep a small central assertion for built-in ordering/availability.
  • Done when: The required change is committed and verification passes: Inspect `src/lib/messaging/channels/manifests.test.ts` and confirm the Zalo-specific block is gone while central registry tests still verify that `zalo-clawbot` is exposed for OpenClaw only.
  • Evidence: The diff imports `zaloClawbotManifest` into `manifests.test.ts` and adds assertions for `ZALOCLAWBOT_BOT_TOKEN`, the seed hook, `npm:@zalo-platforms/[email protected]`, and OpenClaw runtime metadata.
Review findings by urgency: 2 required fixes, 9 items to resolve/justify, 0 in-scope improvements

⚠️ Resolve or justify before merge

Investigate these in the current review; either fix them, explain why they are not applicable, or document the accepted risk.

PRA-1 Resolve/justify — Source-of-truth review needed: Malformed 2xx Zalo login-status tolerance

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Missing; existing tests cover malformed `request-login` and unexpected 4xx, but not malformed successful `get-login-status`.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: The final branch in `pollZaloClawbotLoginStatus()` returns pending for every other 2xx body.

PRA-2 Resolve/justify — Source-of-truth review needed: Zalo sandbox policy wildcard exception

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Missing; add a policy test proving the wildcard is intentional, host-limited, and excludes the host-side login service.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: `zalo-clawbot.yaml` allows `GET /**` and `POST /**` under `bot-api.zaloplatforms.com`.

PRA-3 Resolve/justify — Source-of-truth review needed: Zalo owner-bound authorization contract

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Missing unless the external API cannot simulate non-owner events; in that case the durable regression evidence should be a documented manifest/docs assertion of the trust boundary.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: `enrollmentHelp` says Zalo drops everyone else at the platform level, and the manifest has no allowlist input.

PRA-6 Resolve/justify — Malformed successful login-status payloads wait until the login deadline

  • Location: src/lib/messaging/channels/zalo-clawbot/qr.ts:193
  • Category: correctness
  • Problem: `pollZaloClawbotLoginStatus()` treats any non-4xx/non-5xx 2xx response that is not recognized as connected or expired as a benign pending status.
  • Impact: If the Zalo session service returns a protocol-invalid successful payload, onboarding can leave the QR flow waiting until the full login deadline instead of failing fast with a useful diagnostic.
  • Recommended action: Keep transport errors and 5xx responses retryable, but classify malformed 2xx status payloads as protocol errors once they are not a documented pending, expired, or connected shape. Return `kind: "error"` from `runZaloClawbotHostQrLogin()` with a clear message.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read the final return path in `pollZaloClawbotLoginStatus()` and confirm documented pending responses are distinguishable from malformed successful responses such as `{ result: { isLogin: true } }` without `botToken`.
  • Missing regression test: Add `returns protocol error for malformed successful Zalo login-status payload` with a 200 response containing `isLogin: true` but no `botToken`, and assert `runZaloClawbotHostQrLogin()` returns `kind: "error"` without waiting for the timeout loop.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read the final return path in `pollZaloClawbotLoginStatus()` and confirm documented pending responses are distinguishable from malformed successful responses such as `{ result: { isLogin: true } }` without `botToken`.
  • Evidence: After handling 498, 5xx, 4xx, and `body.isLogin && typeof body.botToken === "string"`, the function returns `{ connected: false, expired: false }` for every other successful body.

PRA-7 Resolve/justify — Zalo sandbox policy grants wildcard GET and POST paths

  • Location: nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml:18
  • Category: security
  • Problem: The new sandbox policy allows `GET /**` and `POST /**` to `bot-api.zaloplatforms.com` for the Zalo plugin runtime.
  • Impact: The preset is host-limited, but wildcard paths are broader than least privilege if the Zalo Bot Platform runtime paths are known. A compromised or buggy in-sandbox plugin gets any GET/POST path on that API host.
  • Recommended action: Constrain the preset to exact required paths if the plugin contract is known. If the paths are truly dynamic or undocumented, add a durable named exception in the preset or docs and a policy test proving the wildcard is intentional, host-limited, and does not include the host-side login service.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect `nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml` and confirm either exact runtime paths are listed or the wildcard is explicitly justified and scoped only to `bot-api.zaloplatforms.com`.
  • Missing regression test: Add `zalo-clawbot preset only allows bot-api runtime host and omits bot login host`, asserting the preset contains `bot-api.zaloplatforms.com`, does not contain `bot.zaloplatforms.com`, and documents or narrows any `/**` rules.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect `nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml` and confirm either exact runtime paths are listed or the wildcard is explicitly justified and scoped only to `bot-api.zaloplatforms.com`.
  • Evidence: The preset contains `allow: { method: GET, path: "/**" }` and `allow: { method: POST, path: "/**" }` under `host: bot-api.zaloplatforms.com`.

PRA-8 Resolve/justify — Owner-bound Zalo authorization remains an external trust contract

  • Location: src/lib/messaging/channels/zalo-clawbot/manifest.ts:11
  • Category: security
  • Problem: The manifest omits an allowlist because it expects Zalo/platform/plugin owner filtering to drop all non-owner messages.
  • Impact: If the external owner-bound guarantee changes or is misunderstood, NemoClaw has no local authorization layer to prevent non-owner messages from reaching the agent.
  • Recommended action: Add a durable trust-boundary note in user docs or manifest comments identifying the exact Zalo/plugin owner-filtering contract and why local filtering cannot be implemented here. If the plugin/API can simulate a non-owner event, add a negative test or diagnostic expectation; otherwise document why the guarantee must remain external.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read the Zalo manifest and messaging docs and confirm they explain the owner-bound trust boundary, its source, and the absence of a local allowlist.
  • Missing regression test: If a fixture can represent non-owner events, add `rejects non-owner Zalo ClawBot events before agent delivery`; if that cannot be simulated locally, add docs-backed test or manifest assertion that the external owner-bound contract is intentionally documented.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read the Zalo manifest and messaging docs and confirm they explain the owner-bound trust boundary, its source, and the absence of a local allowlist.
  • Evidence: `enrollmentHelp` says the bot is owner-bound and Zalo drops everyone else at the platform level, while `inputs` contains no allowlist or require-mention authorization controls.

PRA-9 Resolve/justify — User-facing messaging docs omit the new Zalo ClawBot channel

  • Location: docs/manage-sandboxes/messaging-channels.mdx:6
  • Category: docs
  • Problem: The PR adds a user-visible messaging channel, but the messaging channel guide still lists Telegram, Discord, Slack, WeChat, and WhatsApp only.
  • Impact: Operators will not see the Zalo channel's OpenClaw-only support, host-side QR flow, non-interactive behavior, policy preset, owner-bound authorization model, or third-party plugin trust constraints in the primary setup documentation.
  • Recommended action: Update `docs/manage-sandboxes/messaging-channels.mdx` in this PR with a focused Zalo ClawBot section and table/list updates. Include OpenClaw-only support, host-side QR capture, non-interactive behavior, `zalo-clawbot` policy preset, owner-bound authorization model, and pinned third-party plugin provenance/version-bump expectations.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Search `docs/manage-sandboxes/messaging-channels.mdx` for `zalo` and confirm the frontmatter, intro, requirements table, onboarding flow, and `channels add` examples cover the new channel.
  • Missing regression test: No automated test exists for this docs gap; add or update a docs/link snapshot if the repo has one, otherwise the regression evidence is the updated page content itself.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Search `docs/manage-sandboxes/messaging-channels.mdx` for `zalo` and confirm the frontmatter, intro, requirements table, onboarding flow, and `channels add` examples cover the new channel.
  • Evidence: The docs frontmatter description and visible guide text mention Telegram, Discord, Slack, WeChat, and WhatsApp, and do not mention Zalo ClawBot.

PRA-10 Resolve/justify — Third-party OpenClaw plugin install lacks durable dependency-review evidence

  • Location: src/lib/messaging/channels/zalo-clawbot/manifest.ts:107
  • Category: security
  • Problem: The PR adds `npm:@zalo-platforms/[email protected]` as a required OpenClaw plugin package.
  • Impact: The package is exact-pinned, but it is a new third-party 0.x plugin that runs in the sandbox with messaging token access. Without durable provenance or review notes, future maintainers lack an audit trail for why this installer trust boundary is acceptable and how version bumps should be reviewed.
  • Recommended action: If NemoClaw has a dependency or plugin allowlist/audit convention, add this package there. Also document the package owner/source, exact pinned version, and review expectation for future version bumps in the Zalo docs or manifest comments.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the manifest and docs for a durable provenance note beyond the package string, and check whether any existing dependency/plugin audit list needs the new package.
  • Missing regression test: Add a lightweight manifest/provenance assertion such as `documents pinned Zalo ClawBot plugin provenance`, or update the repo's dependency-review artifact if one exists.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the manifest and docs for a durable provenance note beyond the package string, and check whether any existing dependency/plugin audit list needs the new package.
  • Evidence: `agentPackages` declares `spec: "npm:@zalo-platforms/[email protected]"`, `pin: true`, and `required: true`; no additional allowlist or audit artifact for this package appears in the changed files.

PRA-11 Resolve/justify — Zalo host-QR non-interactive and build-plan paths need focused validation

  • Location: src/lib/messaging/channels/zalo-clawbot/hooks/qr-login.ts:42
  • Category: tests
  • Problem: The hook throws in non-interactive mode and the manifest uses `onFailure: "skip-channel"`, but the changed tests do not prove the manifest compiler/add-channel path skips Zalo cleanly or emits the expected OpenClaw package/build-file steps when active.
  • Impact: A regression in compiler wiring could either silently activate a host-QR channel without credentials in non-interactive flows or omit the plugin install/account seed build steps despite the lower-level hook tests passing.
  • Recommended action: Add focused compiler/build-plan tests for Zalo rather than relying only on manifest enumeration and direct hook unit tests.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Search `src/lib/messaging/compiler/manifest-compiler.test.ts` for `zalo`; it currently has no Zalo coverage even though the built-in compiler path is where enrollment outputs become credential bindings and build steps.
  • Missing regression test: Add `skips Zalo host-QR channel in non-interactive add-channel without build steps` and `compiles active Zalo ClawBot OpenClaw plan with plugin install and seed build files`, asserting the credential placeholder, `openclawPluginPackage`, `openclawZaloclawbotAccountFile`, and `openclawConfigPatch` are present only when enrollment succeeds.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Search `src/lib/messaging/compiler/manifest-compiler.test.ts` for `zalo`; it currently has no Zalo coverage even though the built-in compiler path is where enrollment outputs become credential bindings and build steps.
  • Evidence: `qr-login.ts` branches on `context.isInteractive === false`, while `manifest-compiler.test.ts` contains no `zalo` references and the new hook tests exercise `runMessagingHook()` directly rather than the compiler/build-step path.

💡 In-scope improvements

These are lower-risk, not throwaway. Prefer fixing them in this PR when they are local to changed code; defer only with rationale or a linked follow-up.

  • None.
Simplification opportunities: 1 possible cut

These are safe simplification checks only. Do not remove validation, security controls, data-loss prevention, or required tests.

  • PRA-5 shrink (src/lib/messaging/channels/manifests.test.ts:667): Cut the Zalo-specific manifest assertion block from the central `src/lib/messaging/channels/manifests.test.ts` hotspot.
    • Replacement: Create `src/lib/messaging/channels/zalo-clawbot/manifest.test.ts` for Zalo-only assertions; keep central tests limited to registry availability, JSON serializability, and side-effect-import checks.
    • Net: 0 lines
    • Safety boundary: Do not remove coverage for the Zalo credential binding, seed hook outputs, plugin package spec, OpenClaw-only availability, or runtime visibility; only relocate channel-local assertions.
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Runtime validation — rejects unsafe Zalo sessionServiceUrl before fetch. The PR changes host-side QR credential enrollment, sandbox network policy, OpenClaw plugin installation, and build-file seeding. Unit tests cover several pieces, but the compiler/build-plan and trust-boundary paths need behavior-specific validation.
  • PRA-T2 Runtime validation — returns protocol error for malformed successful Zalo login-status payload. The PR changes host-side QR credential enrollment, sandbox network policy, OpenClaw plugin installation, and build-file seeding. Unit tests cover several pieces, but the compiler/build-plan and trust-boundary paths need behavior-specific validation.
  • PRA-T3 Runtime validation — zalo-clawbot preset only allows bot-api runtime host and omits bot login host. The PR changes host-side QR credential enrollment, sandbox network policy, OpenClaw plugin installation, and build-file seeding. Unit tests cover several pieces, but the compiler/build-plan and trust-boundary paths need behavior-specific validation.
  • PRA-T4 Runtime validation — skips Zalo host-QR channel in non-interactive add-channel without build steps. The PR changes host-side QR credential enrollment, sandbox network policy, OpenClaw plugin installation, and build-file seeding. Unit tests cover several pieces, but the compiler/build-plan and trust-boundary paths need behavior-specific validation.
  • PRA-T5 Runtime validation — compiles active Zalo ClawBot OpenClaw plan with plugin install and seed build files. The PR changes host-side QR credential enrollment, sandbox network policy, OpenClaw plugin installation, and build-file seeding. Unit tests cover several pieces, but the compiler/build-plan and trust-boundary paths need behavior-specific validation.
  • PRA-T6 Zalo-specific manifest assertions grow the large central manifest test hotspot — Move the Zalo-specific assertions into a channel-local file such as `src/lib/messaging/channels/zalo-clawbot/manifest.test.ts`. Leave only cross-channel registration, availability, serialization, and side-effect-import assertions in `manifests.test.ts`.
  • PRA-T7 Zalo host-QR non-interactive and build-plan paths need focused validation — Add focused compiler/build-plan tests for Zalo rather than relying only on manifest enumeration and direct hook unit tests.
  • PRA-T8 Acceptance clause — No deterministic linked issue clauses were available in the validation context. — add test evidence or identify existing coverage. The validation context reported `linkedIssues: []`; PR body text that says `Parts of feat(messaging): onboard additional experimental messaging channels #5492` was treated as untrusted evidence and was not used as an authoritative acceptance clause.
Since last review details

Current findings, using the urgency labels above:

PRA-1 Resolve/justify — Source-of-truth review needed: Malformed 2xx Zalo login-status tolerance

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Missing; existing tests cover malformed `request-login` and unexpected 4xx, but not malformed successful `get-login-status`.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: The final branch in `pollZaloClawbotLoginStatus()` returns pending for every other 2xx body.

PRA-2 Resolve/justify — Source-of-truth review needed: Zalo sandbox policy wildcard exception

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Missing; add a policy test proving the wildcard is intentional, host-limited, and excludes the host-side login service.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: `zalo-clawbot.yaml` allows `GET /**` and `POST /**` under `bot-api.zaloplatforms.com`.

PRA-3 Resolve/justify — Source-of-truth review needed: Zalo owner-bound authorization contract

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Missing unless the external API cannot simulate non-owner events; in that case the durable regression evidence should be a documented manifest/docs assertion of the trust boundary.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: `enrollmentHelp` says Zalo drops everyone else at the platform level, and the manifest has no allowlist input.

PRA-4 Required — Host QR login accepts an arbitrary session-service base URL

PRA-5 Required — Zalo-specific manifest assertions grow the large central manifest test hotspot

  • Location: src/lib/messaging/channels/manifests.test.ts:667
  • Category: tests
  • Problem: The PR adds a channel-specific `declares Zalo ClawBot as host-qr...` block to the central manifest test file, which drift analysis reports as 875 lines after this change.
  • Impact: Keeping channel-local assertions in the central registry test increases merge conflicts with active messaging-channel work and makes the central manifest suite harder to maintain.
  • Required action: Move the Zalo-specific assertions into a channel-local file such as `src/lib/messaging/channels/zalo-clawbot/manifest.test.ts`. Leave only cross-channel registration, availability, serialization, and side-effect-import assertions in `manifests.test.ts`.
  • Expected follow-up: Fix before merge or get explicit maintainer override.
  • Verification: Inspect `src/lib/messaging/channels/manifests.test.ts` and confirm the Zalo-specific block is gone while central registry tests still verify that `zalo-clawbot` is exposed for OpenClaw only.
  • Missing regression test: The existing assertions already provide the needed regression coverage; relocate them to a channel-local manifest test and keep a small central assertion for built-in ordering/availability.
  • Done when: The required change is committed and verification passes: Inspect `src/lib/messaging/channels/manifests.test.ts` and confirm the Zalo-specific block is gone while central registry tests still verify that `zalo-clawbot` is exposed for OpenClaw only.
  • Evidence: The diff imports `zaloClawbotManifest` into `manifests.test.ts` and adds assertions for `ZALOCLAWBOT_BOT_TOKEN`, the seed hook, `npm:@zalo-platforms/[email protected]`, and OpenClaw runtime metadata.

PRA-6 Resolve/justify — Malformed successful login-status payloads wait until the login deadline

  • Location: src/lib/messaging/channels/zalo-clawbot/qr.ts:193
  • Category: correctness
  • Problem: `pollZaloClawbotLoginStatus()` treats any non-4xx/non-5xx 2xx response that is not recognized as connected or expired as a benign pending status.
  • Impact: If the Zalo session service returns a protocol-invalid successful payload, onboarding can leave the QR flow waiting until the full login deadline instead of failing fast with a useful diagnostic.
  • Recommended action: Keep transport errors and 5xx responses retryable, but classify malformed 2xx status payloads as protocol errors once they are not a documented pending, expired, or connected shape. Return `kind: "error"` from `runZaloClawbotHostQrLogin()` with a clear message.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read the final return path in `pollZaloClawbotLoginStatus()` and confirm documented pending responses are distinguishable from malformed successful responses such as `{ result: { isLogin: true } }` without `botToken`.
  • Missing regression test: Add `returns protocol error for malformed successful Zalo login-status payload` with a 200 response containing `isLogin: true` but no `botToken`, and assert `runZaloClawbotHostQrLogin()` returns `kind: "error"` without waiting for the timeout loop.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read the final return path in `pollZaloClawbotLoginStatus()` and confirm documented pending responses are distinguishable from malformed successful responses such as `{ result: { isLogin: true } }` without `botToken`.
  • Evidence: After handling 498, 5xx, 4xx, and `body.isLogin && typeof body.botToken === "string"`, the function returns `{ connected: false, expired: false }` for every other successful body.

PRA-7 Resolve/justify — Zalo sandbox policy grants wildcard GET and POST paths

  • Location: nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml:18
  • Category: security
  • Problem: The new sandbox policy allows `GET /**` and `POST /**` to `bot-api.zaloplatforms.com` for the Zalo plugin runtime.
  • Impact: The preset is host-limited, but wildcard paths are broader than least privilege if the Zalo Bot Platform runtime paths are known. A compromised or buggy in-sandbox plugin gets any GET/POST path on that API host.
  • Recommended action: Constrain the preset to exact required paths if the plugin contract is known. If the paths are truly dynamic or undocumented, add a durable named exception in the preset or docs and a policy test proving the wildcard is intentional, host-limited, and does not include the host-side login service.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect `nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml` and confirm either exact runtime paths are listed or the wildcard is explicitly justified and scoped only to `bot-api.zaloplatforms.com`.
  • Missing regression test: Add `zalo-clawbot preset only allows bot-api runtime host and omits bot login host`, asserting the preset contains `bot-api.zaloplatforms.com`, does not contain `bot.zaloplatforms.com`, and documents or narrows any `/**` rules.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect `nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml` and confirm either exact runtime paths are listed or the wildcard is explicitly justified and scoped only to `bot-api.zaloplatforms.com`.
  • Evidence: The preset contains `allow: { method: GET, path: "/**" }` and `allow: { method: POST, path: "/**" }` under `host: bot-api.zaloplatforms.com`.

PRA-8 Resolve/justify — Owner-bound Zalo authorization remains an external trust contract

  • Location: src/lib/messaging/channels/zalo-clawbot/manifest.ts:11
  • Category: security
  • Problem: The manifest omits an allowlist because it expects Zalo/platform/plugin owner filtering to drop all non-owner messages.
  • Impact: If the external owner-bound guarantee changes or is misunderstood, NemoClaw has no local authorization layer to prevent non-owner messages from reaching the agent.
  • Recommended action: Add a durable trust-boundary note in user docs or manifest comments identifying the exact Zalo/plugin owner-filtering contract and why local filtering cannot be implemented here. If the plugin/API can simulate a non-owner event, add a negative test or diagnostic expectation; otherwise document why the guarantee must remain external.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read the Zalo manifest and messaging docs and confirm they explain the owner-bound trust boundary, its source, and the absence of a local allowlist.
  • Missing regression test: If a fixture can represent non-owner events, add `rejects non-owner Zalo ClawBot events before agent delivery`; if that cannot be simulated locally, add docs-backed test or manifest assertion that the external owner-bound contract is intentionally documented.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read the Zalo manifest and messaging docs and confirm they explain the owner-bound trust boundary, its source, and the absence of a local allowlist.
  • Evidence: `enrollmentHelp` says the bot is owner-bound and Zalo drops everyone else at the platform level, while `inputs` contains no allowlist or require-mention authorization controls.

PRA-9 Resolve/justify — User-facing messaging docs omit the new Zalo ClawBot channel

  • Location: docs/manage-sandboxes/messaging-channels.mdx:6
  • Category: docs
  • Problem: The PR adds a user-visible messaging channel, but the messaging channel guide still lists Telegram, Discord, Slack, WeChat, and WhatsApp only.
  • Impact: Operators will not see the Zalo channel's OpenClaw-only support, host-side QR flow, non-interactive behavior, policy preset, owner-bound authorization model, or third-party plugin trust constraints in the primary setup documentation.
  • Recommended action: Update `docs/manage-sandboxes/messaging-channels.mdx` in this PR with a focused Zalo ClawBot section and table/list updates. Include OpenClaw-only support, host-side QR capture, non-interactive behavior, `zalo-clawbot` policy preset, owner-bound authorization model, and pinned third-party plugin provenance/version-bump expectations.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Search `docs/manage-sandboxes/messaging-channels.mdx` for `zalo` and confirm the frontmatter, intro, requirements table, onboarding flow, and `channels add` examples cover the new channel.
  • Missing regression test: No automated test exists for this docs gap; add or update a docs/link snapshot if the repo has one, otherwise the regression evidence is the updated page content itself.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Search `docs/manage-sandboxes/messaging-channels.mdx` for `zalo` and confirm the frontmatter, intro, requirements table, onboarding flow, and `channels add` examples cover the new channel.
  • Evidence: The docs frontmatter description and visible guide text mention Telegram, Discord, Slack, WeChat, and WhatsApp, and do not mention Zalo ClawBot.

PRA-10 Resolve/justify — Third-party OpenClaw plugin install lacks durable dependency-review evidence

  • Location: src/lib/messaging/channels/zalo-clawbot/manifest.ts:107
  • Category: security
  • Problem: The PR adds `npm:@zalo-platforms/[email protected]` as a required OpenClaw plugin package.
  • Impact: The package is exact-pinned, but it is a new third-party 0.x plugin that runs in the sandbox with messaging token access. Without durable provenance or review notes, future maintainers lack an audit trail for why this installer trust boundary is acceptable and how version bumps should be reviewed.
  • Recommended action: If NemoClaw has a dependency or plugin allowlist/audit convention, add this package there. Also document the package owner/source, exact pinned version, and review expectation for future version bumps in the Zalo docs or manifest comments.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the manifest and docs for a durable provenance note beyond the package string, and check whether any existing dependency/plugin audit list needs the new package.
  • Missing regression test: Add a lightweight manifest/provenance assertion such as `documents pinned Zalo ClawBot plugin provenance`, or update the repo's dependency-review artifact if one exists.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the manifest and docs for a durable provenance note beyond the package string, and check whether any existing dependency/plugin audit list needs the new package.
  • Evidence: `agentPackages` declares `spec: "npm:@zalo-platforms/[email protected]"`, `pin: true`, and `required: true`; no additional allowlist or audit artifact for this package appears in the changed files.

PRA-11 Resolve/justify — Zalo host-QR non-interactive and build-plan paths need focused validation

  • Location: src/lib/messaging/channels/zalo-clawbot/hooks/qr-login.ts:42
  • Category: tests
  • Problem: The hook throws in non-interactive mode and the manifest uses `onFailure: "skip-channel"`, but the changed tests do not prove the manifest compiler/add-channel path skips Zalo cleanly or emits the expected OpenClaw package/build-file steps when active.
  • Impact: A regression in compiler wiring could either silently activate a host-QR channel without credentials in non-interactive flows or omit the plugin install/account seed build steps despite the lower-level hook tests passing.
  • Recommended action: Add focused compiler/build-plan tests for Zalo rather than relying only on manifest enumeration and direct hook unit tests.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Search `src/lib/messaging/compiler/manifest-compiler.test.ts` for `zalo`; it currently has no Zalo coverage even though the built-in compiler path is where enrollment outputs become credential bindings and build steps.
  • Missing regression test: Add `skips Zalo host-QR channel in non-interactive add-channel without build steps` and `compiles active Zalo ClawBot OpenClaw plan with plugin install and seed build files`, asserting the credential placeholder, `openclawPluginPackage`, `openclawZaloclawbotAccountFile`, and `openclawConfigPatch` are present only when enrollment succeeds.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Search `src/lib/messaging/compiler/manifest-compiler.test.ts` for `zalo`; it currently has no Zalo coverage even though the built-in compiler path is where enrollment outputs become credential bindings and build steps.
  • Evidence: `qr-login.ts` branches on `context.isInteractive === false`, while `manifest-compiler.test.ts` contains no `zalo` references and the new hook tests exercise `runMessagingHook()` directly rather than the compiler/build-step path.

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml`:
- Around line 21-31: Remove the unnecessary bot.zaloplatforms.com allowlist
entry from the sandbox preset unless there is a confirmed seeded-runtime
dependency. Update the zalo-clawbot preset so it only permits the hosts actually
required by in-sandbox execution, and keep the login/provisioning flow host-side
as described in src/lib/messaging/channels/zalo-clawbot/manifest.ts. Verify the
remaining egress rules still cover any needed runtime calls without expanding
sandbox SSRF surface.

In `@src/lib/messaging/channels/manifests.test.ts`:
- Around line 243-246: The forbidden-import scan in the manifest test is missing
the new production file host-qr-login-runtime.ts, so it won’t be checked for
banned imports. Update the phase-1 import guard in manifests.test.ts to include
the new Zalo hook file alongside the existing zalo-clawbot manifest and hook
entries, using the same pattern as the other listed paths. This ensures the scan
covers the new runtime path in the same test coverage as qr-login.ts and
seed-openclaw-account.ts.

In `@src/lib/messaging/channels/zalo-clawbot/hooks/qr-login.ts`:
- Around line 75-76: The QR login hook is leaving stale account metadata in the
mutable env object because `ownerId` and `oaId` are only assigned when truthy
and never removed when omitted. Update the `qr-login` flow that mutates
`options.env ?? process.env` so that `ZALOCLAWBOT_OWNER_ID` and
`ZALOCLAWBOT_OA_ID` are explicitly cleared/deleted whenever `ownerId` or `oaId`
are absent, ensuring reused processes don’t retain values from a previous
enrollment.

In `@src/lib/messaging/channels/zalo-clawbot/hooks/seed-openclaw-account.ts`:
- Around line 45-47: The seed-openclaw-account hook is silently falling back to
ZALOCLAWBOT_TOKEN_PLACEHOLDER when credential.zaloClawbotBotToken.placeholder is
missing, which hides broken wiring. In seed-openclaw-account.ts, update the
botToken assignment to require the placeholder input from
optionalInputString(inputs, "credential.zaloClawbotBotToken.placeholder") and
fail fast if it is absent, instead of synthesizing a default fallback. Keep the
change localized to the botToken initialization so the hook’s declared input
contract is enforced.

In `@src/lib/messaging/channels/zalo-clawbot/qr.ts`:
- Around line 171-186: The polling result handling in qr.ts is treating all
non-498 4xx responses as pending, which hides permanent
session-service/auth/config failures. Update the response parsing in the QR poll
flow so that only network errors and 5xx remain retryable, while unexpected 4xx
responses from the same status/body checks fail fast by surfacing an error or
terminal failure instead of returning { connected: false, expired: false }. Use
the existing poll result logic around the 498/status/body.code/body.error_code
checks and the login success branch to distinguish retryable from non-retryable
outcomes.
- Around line 123-135: Propagate the caller cancellation through
requestZaloClawbotLogin so the initial session request and QR refreshes can stop
immediately when onboarding is aborted. Add an AbortSignal parameter to
requestZaloClawbotLogin and thread it into the getJson call, then update the
login flow call sites in login.ts to pass opts.signal alongside fetch and
sessionServiceUrl. Ensure the existing ZaloClawbot QR request path continues to
use the same timeout behavior when no signal is provided.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3e8ca2e9-6e93-405c-ae9a-b3eb2ba2d498

📥 Commits

Reviewing files that changed from the base of the PR and between 6fb9754 and b8772a3.

📒 Files selected for processing (24)
  • agents/openclaw/manifest.yaml
  • ci/test-file-size-budget.json
  • nemoclaw-blueprint/policies/presets/zalo-clawbot.yaml
  • src/lib/agent/defs.test.ts
  • src/lib/messaging-channel-config.test.ts
  • src/lib/messaging/channels/built-ins.ts
  • src/lib/messaging/channels/manifests.test.ts
  • src/lib/messaging/channels/metadata.test.ts
  • src/lib/messaging/channels/metadata.ts
  • src/lib/messaging/channels/zalo-clawbot/hooks/host-qr-login-runtime.ts
  • src/lib/messaging/channels/zalo-clawbot/hooks/implementations.test.ts
  • src/lib/messaging/channels/zalo-clawbot/hooks/index.ts
  • src/lib/messaging/channels/zalo-clawbot/hooks/qr-login.ts
  • src/lib/messaging/channels/zalo-clawbot/hooks/seed-openclaw-account.ts
  • src/lib/messaging/channels/zalo-clawbot/login.test.ts
  • src/lib/messaging/channels/zalo-clawbot/login.ts
  • src/lib/messaging/channels/zalo-clawbot/manifest.ts
  • src/lib/messaging/channels/zalo-clawbot/qr.ts
  • src/lib/messaging/diagnostics.test.ts
  • src/lib/messaging/hooks/builtins.ts
  • src/lib/onboard/messaging-prep.test.ts
  • src/lib/sandbox/channels.test.ts
  • test/channels-add-preset.test.ts
  • test/policies.test.ts

@wscurran wscurran added area: messaging Messaging channels, bridges, manifests, or channel lifecycle area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow feature PR adds or expands user-visible functionality integration: openclaw OpenClaw integration behavior labels Jun 24, 2026
@wscurran

Copy link
Copy Markdown
Contributor

@jyaunches jyaunches added v0.0.69 and removed v0.0.68 labels Jun 25, 2026
@sandl99
sandl99 marked this pull request as draft June 26, 2026 06:04
@cv cv removed the v0.0.69 label Jun 28, 2026
@sandl99 sandl99 closed this Jul 6, 2026
@cv
cv deleted the feat/messaging-channel-zalo-clawbot branch November 21, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: messaging Messaging channels, bridges, manifests, or channel lifecycle area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow feature PR adds or expands user-visible functionality integration: openclaw OpenClaw integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants