Skip to content

fix(qqbot): route channel API by account - #103437

Closed
NianJiuZst wants to merge 2 commits into
openclaw:mainfrom
NianJiuZst:codex/fix-qqbot-channel-tool-account
Closed

NianJiuZst wants to merge 2 commits into
openclaw:mainfrom
NianJiuZst:codex/fix-qqbot-channel-tool-account

Conversation

@NianJiuZst

Copy link
Copy Markdown
Contributor

What Problem This Solves

qqbot_channel_api captured the first configured QQBot account at registration time. In a multi-account installation, an agent bound to another QQBot account therefore obtained an access token for the wrong bot. The tool was also hidden when the first account lacked a secret even if another account was fully configured.

Why This Change Was Made

The tool now resolves credentials per tool context. A valid contextual account is always used and an unusable contextual account fails explicitly rather than silently crossing accounts. When no contextual account exists, the tool selects an account that actually has usable credentials so the broader registration check remains executable.

User Impact

QQBot channel API calls use the credentials for the active account. Multi-account configurations no longer accidentally expose one bot's channel API to another bot's agent context.

Evidence

  • Added coverage for contextual account token selection, disabled contextual accounts not falling back, and no-context selection of the available credentialed account.
  • node_modules/.bin/vitest run --config test/vitest/vitest.extension-messaging.config.ts extensions/qqbot/src/bridge/tools/channel.test.ts extensions/qqbot/src/engine/tools/channel-api.test.ts (12 passed)
  • node scripts/run-oxlint.mjs extensions/qqbot/src/bridge/tools/channel.ts extensions/qqbot/src/bridge/tools/channel.test.ts
  • node_modules/.bin/oxfmt --write extensions/qqbot/src/bridge/tools/channel.ts extensions/qqbot/src/bridge/tools/channel.test.ts
  • git diff --check
  • .agents/skills/autoreview/scripts/autoreview --mode local --output /tmp/openclaw-autoreview/qqbot-channel-account-final.json (clean; no accepted/actionable findings after one in-scope correction)

Remote Testbox validation is unavailable in this environment because the current account is not authenticated to the openclaw organization. The focused test is therefore a narrow local fallback; GitHub CI remains the remote validation path.

@NianJiuZst
NianJiuZst marked this pull request as ready for review July 10, 2026 05:47
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 10, 2026
@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 31, 2026, 12:19 AM ET / 04:19 UTC.

ClawSweeper review

What this changes

The PR turns QQBot’s channel API proxy into a context-aware tool factory so calls use the active account’s credentials, with tests for contextual selection, disabled accounts, and no-context fallback.

Merge readiness

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

Keep this PR open: it addresses a real multi-account QQBot credential-selection bug, but its current head still omits the selected account’s channel-policy inputs and supplies only mocked/static validation rather than a real two-account run. The branch is also reported as conflicting with current main, so it needs a rebase and renewed review rather than cleanup closure.

Priority: P1
Reviewed head: cf71fd802de8876e16297e331441c38c1c901e0b

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The proposed direction is useful, but an unresolved authorization finding, merge conflict, and mock-only proof leave the patch below merge-ready quality.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR provides mocked unit tests and static checks but no after-fix real two-account QQBot run; add redacted terminal output, runtime logs, or live output showing correct account routing and the policy/error path before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR provides mocked unit tests and static checks but no after-fix real two-account QQBot run; add redacted terminal output, runtime logs, or live output showing correct account routing and the policy/error path before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current main behavior: Current main registers qqbot_channel_api once, resolves the first configured QQBot account during registration, and calls the API with that account’s access token; this establishes the cross-account bug the PR is trying to repair.
Account owner data: QQBot account resolution carries the selected account id, enabled state, credentials, and config slice, including account-level policy fields. A contextual tool must preserve that selected configuration when enforcing channel API authorization.
Unfixed prior blocker: The latest completed ClawSweeper cycle reviewed the same head SHA and identified the P1 requirement to preserve the selected account’s channel-policy inputs. The current PR head remains cf71fd802de8876e16297e331441c38c1c901e0b, so that blocker has not been superseded by a newer contributor commit.
Findings 1 actionable finding [P1] Preserve the selected account’s channel policy inputs
Security Needs attention Selected account policy is not propagated: The contextual-account change can alter which bot authorizes an API call, but the channel API execution path receives only credential material. Account-scoped authorization inputs must accompany the selected account to prevent policy bypass across multi-account installations.

How this fits together

QQBot registers a channel API proxy tool for agents; the tool receives the agent’s bound account context, resolves QQBot credentials, then sends an authenticated request to QQ Open Platform. Account selection must preserve both the intended bot credentials and that account’s authorization policy before the request leaves the plugin.

flowchart LR
  A[Agent tool call] --> B[QQBot tool context]
  B --> C[Resolve active QQBot account]
  C --> D[Check account credentials and policy]
  D --> E[Acquire account access token]
  E --> F[QQ Open Platform API request]
  D --> G[Explicit tool error]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR provides mocked unit tests and static checks but no after-fix real two-account QQBot run; add redacted terminal output, runtime logs, or live output showing correct account routing and the policy/error path before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve the selected account’s channel policy inputs (P1) - The factory switches credential selection to agentAccountId, but the resulting execution path still supplies only an access token to the channel API layer. Carry the resolved account configuration/policy through the authorization boundary; otherwise an agent bound to a restricted account can use its token without the account-specific channel policy being evaluated. This is the unresolved P1 from the previous review cycle on the unchanged head.
  • Resolve security concern: Selected account policy is not propagated - The contextual-account change can alter which bot authorizes an API call, but the channel API execution path receives only credential material. Account-scoped authorization inputs must accompany the selected account to prevent policy bypass across multi-account installations.
  • Resolve merge risk (P1) - The PR changes an authorization-sensitive tool from a fixed account to contextual account selection, but the selected account’s policy inputs are not carried through to the API execution path; a correctly selected token alone does not prove that account-scoped channel restrictions remain enforced.
  • Resolve merge risk (P1) - The pull request is dirty against current main; it needs a rebase before maintainers can assess the actual three-way merge result.
  • Resolve merge risk (P1) - No real after-fix two-account QQBot evidence shows both correct credential routing and the explicit failure behavior for an unusable contextual account.
  • Complete next step (P2) - A narrow mechanical repair is available: preserve the resolved contextual account’s policy configuration at the channel API execution boundary, then rebase and prove the real multi-account path.
  • Improve patch quality - Rebase onto current main and resolve the account-policy propagation finding.
  • Improve patch quality - Add focused regression coverage for distinct account policies, not only credentials.
  • Improve patch quality - Post redacted real two-account QQBot output or logs; updating the PR body should trigger a fresh review, or a maintainer can comment @clawsweeper re-review if needed.

Findings

  • [P1] Preserve the selected account’s channel policy inputs — extensions/qqbot/src/bridge/tools/channel.ts:58-61
  • [high] Selected account policy is not propagated — extensions/qqbot/src/bridge/tools/channel.ts:58
Agent review details

Security

Needs attention: This authorization-sensitive account-routing change has a concrete policy-propagation gap: selecting the right token is insufficient unless the selected account’s channel restrictions are also enforced.

PR surface

Source +18, Tests +95. Total +113 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 47 29 +18
Tests 1 95 0 +95
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 142 29 +113

Review metrics

Metric Value Why it matters
Account-resolution boundary 1 tool changes from registration-time selection to per-call context selection This moves credential and authorization selection onto the runtime tool path, so both token routing and account policy must be proven together.

Merge-risk options

Maintainer options:

  1. Carry account policy through execution (recommended)
    Rebase the PR and make the API execution boundary receive and enforce the resolved contextual account’s policy configuration, with a test covering accounts that have different channel permissions.
  2. Pause the contextual factory change
    Close or defer this branch if the correct account-policy contract cannot be established without broader QQBot owner direction.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase onto current main, preserve the resolved account’s policy inputs at the channel API execution boundary, add a focused differing-account-policy regression test, and include redacted real two-account runtime proof.

Technical review

Best possible solution:

Rebase onto current main, pass the fully resolved selected account—including its policy configuration—into the channel API authorization boundary, add regression coverage for different account policies, and attach redacted runtime output from a real two-account setup.

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

Yes, from source: current main captures the first QQBot account during tool registration, while the agent context can identify another account. A focused two-account configuration with distinct credentials and policy settings is the high-confidence runtime reproduction path, but it has not been shown in real execution evidence.

Is this the best way to solve the issue?

No: contextual credential lookup is the right direction, but the present patch is incomplete because it does not preserve the selected account’s policy inputs at the channel API execution boundary. The narrow maintainable fix is to pass the resolved account’s configuration through that boundary rather than reconstructing or bypassing policy later.

Full review comments:

  • [P1] Preserve the selected account’s channel policy inputs — extensions/qqbot/src/bridge/tools/channel.ts:58-61
    The factory switches credential selection to agentAccountId, but the resulting execution path still supplies only an access token to the channel API layer. Carry the resolved account configuration/policy through the authorization boundary; otherwise an agent bound to a restricted account can use its token without the account-specific channel policy being evaluated. This is the unresolved P1 from the previous review cycle on the unchanged head.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: A multi-account QQBot agent can otherwise cross account boundaries for privileged channel API calls, affecting an active channel workflow.
  • merge-risk: 🚨 security-boundary: The PR changes which account credentials authorize an HTTP proxy tool and currently lacks proof that account-specific policy enforcement follows that selection.
  • merge-risk: 🚨 compatibility: Existing multi-account setups can change from fixed first-account behavior to contextual routing, so the upgrade and fallback behavior needs validation after rebase.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides mocked unit tests and static checks but no after-fix real two-account QQBot run; add redacted terminal output, runtime logs, or live output showing correct account routing and the policy/error path before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [high] Selected account policy is not propagated — extensions/qqbot/src/bridge/tools/channel.ts:58
    The contextual-account change can alter which bot authorizes an API call, but the channel API execution path receives only credential material. Account-scoped authorization inputs must accompany the selected account to prevent policy bypass across multi-account installations.
    Confidence: 0.94

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/qqbot/src/bridge/tools/channel.test.ts.
  • [P1] node scripts/run-vitest.mjs extensions/qqbot/src/engine/tools/channel-api.test.ts.
  • [P1] node scripts/run-oxlint.mjs extensions/qqbot/src/bridge/tools/channel.ts extensions/qqbot/src/bridge/tools/channel.test.ts.
  • [P1] git diff --check.
  • [P1] Redacted real two-account QQBot runtime transcript or logs showing selected-account routing, policy enforcement, and unusable-context failure.

What I checked:

  • Current main behavior: Current main registers qqbot_channel_api once, resolves the first configured QQBot account during registration, and calls the API with that account’s access token; this establishes the cross-account bug the PR is trying to repair. (extensions/qqbot/src/bridge/tools/channel.ts:383, e460fcfb607b)
  • Account owner data: QQBot account resolution carries the selected account id, enabled state, credentials, and config slice, including account-level policy fields. A contextual tool must preserve that selected configuration when enforcing channel API authorization. (extensions/qqbot/src/bridge/config.ts:3, e460fcfb607b)
  • Unfixed prior blocker: The latest completed ClawSweeper cycle reviewed the same head SHA and identified the P1 requirement to preserve the selected account’s channel-policy inputs. The current PR head remains cf71fd802de8876e16297e331441c38c1c901e0b, so that blocker has not been superseded by a newer contributor commit. (extensions/qqbot/src/bridge/tools/channel.ts:1, cf71fd802de8)
  • Proof status: The PR body reports focused Vitest coverage, lint, formatting, and diff checks, but no redacted real two-account QQBot run, runtime log, or live output demonstrating that the selected account is used and policy is preserved. (extensions/qqbot/src/bridge/tools/channel.test.ts:1, cf71fd802de8)
  • Feature-history signal: Repository release history describes the QQBot engine refactor as adding per-account resource stacks and unified API/bridge modules, making the QQBot engine/bridge ownership boundary the relevant review surface. (CHANGELOG.md:1, e460fcfb607b)

Likely related people:

  • cxyhhhhh: Repository release history attributes the QQBot engine refactor and per-account resource-stack work to this contributor, directly adjacent to the bridge and account-resolution boundary touched here. (role: recent QQBot architecture contributor; confidence: medium; files: extensions/qqbot/src/bridge/config.ts, extensions/qqbot/src/engine/)
  • WideLee: Repository release history attributes QQBot per-account configuration work to this contributor, relevant to preserving account-scoped configuration and policy behavior. (role: adjacent QQBot configuration contributor; confidence: medium; files: extensions/qqbot/src/bridge/config.ts)

Rating scale

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

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

Workflow

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

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-10T10:53:54.943Z sha cf71fd8 :: needs real behavior proof before merge. :: [P1] Preserve the selected account's channel policy inputs

@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 25, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jul 31, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 31, 2026
@vincentkoc vincentkoc self-assigned this Aug 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Closing as superseded by the newer canonical repair in #118575.

This branch has no correct unique remainder. The newer PR preserves the valid per-run account selection while also carrying the selected account ID and active runtime config into executeChannelApi, so account-scoped policy follows the credentials. It also fails closed for a disabled or uncredentialed active account instead of falling through to an arbitrary credentialed account.

Keeping the security-sensitive proof and landing work on #118575 avoids two competing implementations of the same QQBot account-authority fix.

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

Labels

channel: qqbot merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants