Repository navigation
feat: add before_route_inbound_message plugin hook for channel bridging - #81198
DranboFieldston wants to merge 7 commits into
Conversation
…ssionKey for adapter mode redirects
…pdate params.ctxPayload.SessionKey directly
…ct and suppressDelivery
|
Codex review: needs real behavior proof before merge. Reviewed July 3, 2026, 11:46 PM ET / 03:46 UTC. Summary PR surface: Source +213, Tests +89. Total +302 across 6 files. Reproducibility: yes. for source-level PR blockers: the PR head awaits the new claiming hook before record/dispatch, lacks a default timeout, and targets an old compatibility file. The linked capability gap itself is a feature/API request rather than a broken existing contract. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land a maintainer-approved, documented, bounded pre-routing hook on the current inbound owner with fail-open timeout, a complete event contract, and redacted real bridge proof. Do we have a high-confidence way to reproduce the issue? Yes for source-level PR blockers: the PR head awaits the new claiming hook before record/dispatch, lacks a default timeout, and targets an old compatibility file. The linked capability gap itself is a feature/API request rather than a broken existing contract. Is this the best way to solve the issue? No as-is: a pre-routing hook is plausible, but this branch needs maintainer-approved API/security scope, current-main rebase, timeout/fail-open behavior, docs, a complete event contract, and real bridge proof before merge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9d68f877ac3e. Label changesLabel justifications:
Evidence reviewedPR surface: Source +213, Tests +89. Total +302 across 6 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
…ging
Implement a new plugin hook that fires before OpenClaw resolves the
canonical session key for an inbound message. This enables plugins
(like the channel-bridge) to:
- Redirect messages to a different session via redirectSessionKey
- Suppress delivery entirely via suppressDelivery
The hook follows the 'claiming' pattern (first handler returning
{ handled: true } wins), similar to before_dispatch and reply_dispatch.
Integration points:
- Hook types in src/plugins/hook-types.ts (PluginHookName union,
PLUGIN_HOOK_NAMES array, PluginHookHandlerMap entry)
- Event/context/result types in src/plugins/hook-message.types.ts
- Handler in src/plugins/hooks.ts (runBeforeRouteInboundMessage)
- Dispatch pipeline wiring in src/plugin-sdk/inbound-reply-dispatch.ts
(dispatchChannelMessageReplyWithBase — the main inbound routing path)
The hook extracts metadata from MsgContext (NativeChannelId,
OriginatingTo, MessageThreadId, ChatType, From) to populate the
event payload with conversation context.
Fixes: openclaw#81061
|
Update: Added full hook infrastructure (types, handler, kernel integration). PR now contains all necessary changes. @clawsweeper re-review? |
- Remove unnecessary String() wrappers (oxlint no-unnecessary-type-conversion) - Fix ctxPayload access: read from resolved.turn, not params (RunChannelTurnParams doesn't have ctxPayload) - Update test assertion to call .toHaveBeenCalledOnce() instead of referencing without invocation
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper PR egg: 🎁 locked until real behavior proof passes. Details
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat: add before_route_inbound_message plugin hook for channel bridging This is item 1/1 in the current shard. Shard 6/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. |
|
Closing per ClawSweeper review verdict |
Summary
Implements the
before_route_inbound_messageplugin hook as proposed in #81061.This hook fires before OpenClaw resolves the canonical session key for an inbound message, allowing plugins (like the channel-bridge) to:
redirectSessionKeysuppressDeliveryHook Signature
Integration Points
src/plugins/hook-types.tsPluginHookNameunion,PLUGIN_HOOK_NAMESarray, andPluginHookHandlerMapsrc/plugins/hook-message.types.tssrc/plugins/hooks.tsrunBeforeRouteInboundMessage()usingrunClaimingHooksrc/channels/turn/kernel.tsrunChannelTurn()afterresolveTurn()Pattern
Uses the claiming hook pattern (
runClaimingHook) — first handler returning{ handled: true }wins, matchingbefore_dispatchandreply_dispatchsemantics. This allows multiple plugins to register but only the highest-priority one takes effect.Why Here?
Hook fires in
runChannelTurn()right afterresolveTurn(), which is the convergence point for all channel adapters (Discord, Telegram, etc.). At this point:ctxPayload.SessionKeyis already resolved and baked inThis ensures redirects work across both modern adapters and compat paths.
Unit Tests
Added 2 new tests in
src/channels/turn/kernel.test.ts:Both tests verify:
ctxPayload.SessionKeyfor downstream record/dispatchProof: supplied
This PR adds a new plugin hook infrastructure with unit test coverage. There is no in-tree plugin consumer yet, so runtime proof would require an external channel-bridge plugin implementation. The unit tests validate the hook fires correctly and that redirect/suppress behavior works as expected.
Fixes: #81061