Repository navigation
Fix: move bootstrap session grammar into plugin-owned session-key surfaces - #58400
Conversation
Greptile SummaryThis PR completes the channel plugin boundary established in #58100 by moving Telegram Key changes:
Confidence Score: 5/5Safe to merge — no P0 or P1 issues found; all behavioral changes are intentional and covered by tests. The refactor is well-scoped and well-tested. All shared callers that needed updating were updated, the plugin seam is clearly defined, the new dispatcher correctly handles both the generic 🧵 case and plugin-delegated session grammars, and the removal of the Telegram-specific channelHint path from core is clean. The only findings are P2 style observations that do not affect correctness for any current or planned use. No files require special attention. src/channels/plugins/session-conversation.ts is the new core dispatcher and worth a quick read before any future plugin adds both hooks. Prompt To Fix All With AIReviews (1): Last reviewed commit: "Refactor: move session conversation gram..." | Re-trigger Greptile |
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🔵 Potential event-loop DoS via synchronous filesystem checks/module loading on sessionKey parsing path
Description
Although Vulnerable code: if (!resolveBundledPluginPublicSurfacePath({
rootDir: OPENCLAW_PACKAGE_ROOT,
bundledPluginsDir: resolveBundledPluginsDir(),
dirName,
artifactBasename: SESSION_KEY_API_ARTIFACT_BASENAME,
})) {
return null;
}
const resolveSessionConversation =
loadBundledPluginPublicSurfaceModuleSync({ dirName, artifactBasename: SESSION_KEY_API_ARTIFACT_BASENAME })
.resolveSessionConversation;RecommendationAvoid synchronous filesystem and module-loading work on paths reachable with attacker-controlled Suggested mitigations (choose applicable):
const publicSurfaceExistsCache = new Map<string, boolean>();
function bundledSessionKeyApiExists(dirName: string): boolean {
const key = `${dirName}:${SESSION_KEY_API_ARTIFACT_BASENAME}`;
const cached = publicSurfaceExistsCache.get(key);
if (cached != null) return cached;
const exists = Boolean(resolveBundledPluginPublicSurfacePath({
rootDir: OPENCLAW_PACKAGE_ROOT,
bundledPluginsDir: resolveBundledPluginsDir(),
dirName,
artifactBasename: SESSION_KEY_API_ARTIFACT_BASENAME,
}));
publicSurfaceExistsCache.set(key, exists);
return exists;
}
Analyzed PR: #58400 at commit Last updated on: 2026-03-31T17:53:59Z |
There was a problem hiding this comment.
Pull request overview
Refactors session conversation parsing so that provider-specific session-id grammar (Telegram topics, Feishu sender/topic scoping + inheritance) is owned by each channel plugin instead of being hard-coded in core session helpers. This tightens the core/plugin boundary while keeping generic :thread: parsing in core.
Changes:
- Introduces plugin-owned session conversation hooks (
resolveSessionConversation,resolveParentConversationCandidates) on the channel messaging adapter, plus a core dispatcher (src/channels/plugins/session-conversation.ts). - Moves Telegram
:topic:thread parsing and Feishu parent-candidate inheritance logic into their respective channel plugins. - Updates core consumers (delivery/reset/model override/routing tools) and tests to route through the new dispatcher; updates docs to reflect the boundary.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/test-utils/session-conversation-registry.ts | Adds a dedicated test plugin registry that implements session-grammar hooks for seam tests. |
| src/sessions/session-key-utils.ts | Removes Telegram-specific :topic: handling from generic thread parsing; introduces raw session conversation ref parsing. |
| src/routing/session-key.test.ts | Updates expectations so :topic: is no longer treated as a generic thread suffix. |
| src/gateway/server-methods/config.ts | Updates restart-routing comment to reflect plugin-owned session grammar. |
| src/config/sessions/reset.ts | Switches thread-session detection to the new session conversation resolver. |
| src/config/sessions/reset.test.ts | Activates a plugin registry in tests to exercise plugin-owned session grammar. |
| src/config/sessions/delivery-info.ts | Routes delivery thread extraction through the new resolver. |
| src/config/sessions/delivery-info.test.ts | Activates a plugin registry in tests to exercise plugin-owned session grammar. |
| src/channels/plugins/types.core.ts | Extends ChannelMessagingAdapter with session-grammar and parent-candidate hooks. |
| src/channels/plugins/session-conversation.ts | New core dispatcher that combines generic :thread: parsing with plugin-owned grammar + parent candidates. |
| src/channels/plugins/session-conversation.test.ts | New seam tests validating generic vs plugin-owned session grammar behavior. |
| src/channels/model-overrides.ts | Reworks model-override candidate generation to use plugin-owned parent conversation candidates. |
| src/channels/model-overrides.test.ts | Activates a plugin registry in tests to exercise plugin-owned parent-candidate logic. |
| src/auto-reply/reply/model-selection.ts | Switches parent session derivation to the new resolver. |
| src/auto-reply/reply/model-selection.test.ts | Activates a plugin registry in tests to exercise plugin-owned session grammar. |
| src/agents/tools/sessions-send-helpers.ts | Switches announce-target parsing to the new resolver. |
| src/agents/tools/sessions-send-helpers.test.ts | Uses the new session-conversation test registry (reduces duplicated test stubs). |
| src/agents/tools/gateway-tool.ts | Updates restart-routing comment to reflect plugin-owned session grammar. |
| src/agents/pi-tools.policy.ts | Switches thread parent session derivation to the new resolver. |
| src/agents/pi-tools-agent-config.test.ts | Activates a plugin registry in tests to exercise plugin-owned session grammar. |
| extensions/telegram/src/channel.ts | Implements plugin-owned Telegram topic session grammar via messaging hook. |
| extensions/telegram/src/channel.test.ts | Adds tests asserting Telegram plugin owns topic parsing + parent candidates. |
| extensions/feishu/src/channel.ts | Implements plugin-owned Feishu session inheritance candidates via messaging hook. |
| extensions/feishu/src/channel.test.ts | Adds tests asserting Feishu plugin owns sender/topic inheritance candidates. |
| docs/plugins/sdk-channel-plugins.md | Documents that session grammar belongs in channel plugins and points to the new hooks. |
| docs/plugins/architecture.md | Updates architecture boundary documentation to include plugin-owned session conversation grammar. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99e5c4382c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da8337e4bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3c3b29644
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
279e675 to
efa8632
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3ee04de63
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Merged via squash.
Thanks @gumadeiras! |
…faces (#58400) Merged via squash. Prepared head SHA: b062b18 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
…faces (openclaw#58400) Merged via squash. Prepared head SHA: b062b18 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
…faces (openclaw#58400) Merged via squash. Prepared head SHA: b062b18 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
…faces (openclaw#58400) Merged via squash. Prepared head SHA: b062b18 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
…faces (openclaw#58400) Merged via squash. Prepared head SHA: b062b18 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
…faces (openclaw#58400) Merged via squash. Prepared head SHA: b062b18 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
…faces (openclaw#58400) Merged via squash. Prepared head SHA: b062b18 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
…faces (openclaw#58400) Merged via squash. Prepared head SHA: b062b18 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
…faces (openclaw#58400) Merged via squash. Prepared head SHA: b062b18 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
Summary
This PR moves provider-specific session conversation grammar out of core and into plugin-owned session-key surfaces.
Core now owns:
:thread:parsingChannel plugins now own:
End State
src/channels/plugins/session-conversation.tsis the shared resolver for persisted session keys.messaging.resolveSessionConversation(...)from the active channel plugin.session-key-api.tssurfaces when the runtime registry is not available.:thread:remains core-owned.baseConversationIdinstead of array-tail assumptions.Plugin-Owned Surfaces
extensions/telegram/session-key-api.tsextensions/telegram/src/session-conversation.tsextensions/feishu/session-key-api.tsextensions/feishu/src/session-conversation.tsContract
The canonical channel-plugin hook is:
messaging.resolveSessionConversation({ kind, rawId })It returns:
idthreadId?baseConversationId?parentConversationCandidates?parentConversationCandidates, when present, are ordered from narrowest parent to broadest/base conversation.The legacy compatibility hook remains supported:
messaging.resolveParentConversationCandidates(...)Core only uses the legacy hook when the canonical hook omits
parentConversationCandidates.Behavior
:Topic:parsing remains accepted.:Topic:/:Sender:parsing remains accepted.Verification
Passed:
pnpm test -- src/channels/plugins/session-conversation.test.ts extensions/telegram/src/channel.test.ts extensions/feishu/src/channel.test.ts src/agents/pi-tools-agent-config.test.ts src/agents/pi-tools.policy.test.tspnpm test -- src/channels/model-overrides.test.ts src/auto-reply/reply/model-selection.test.tspnpm test -- src/agents/tools/sessions-send-helpers.test.ts src/channels/plugins/session-conversation.test.ts src/channels/model-overrides.test.ts src/agents/pi-tools-agent-config.test.ts src/auto-reply/reply/model-selection.test.ts src/config/sessions/delivery-info.test.ts src/config/sessions/reset.test.tspnpm plugin-sdk:api:checkKnown unrelated repo failures on current mainline / tree:
pnpm buildpnpm checkThese still fail outside this PR in existing
ModelRegistry/provider test surfaces.