Refactor channel approval capability seams#58634
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa064c824d
ℹ️ 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.
Pull request overview
This PR introduces a canonical approvalCapability seam for channel plugins and refactors native approval delivery/auth to use shared SDK helpers, with compatibility fallbacks for partially migrated plugins.
Changes:
- Add
approvalCapabilityto the channel plugin contract and implement generic resolution/merging with legacyauth+approvalsfields. - Move/shared approval helpers into
plugin-sdk/approval-runtime(client profile helpers, native routing helpers, native runtime factory). - Migrate Discord/Slack/Telegram approval flows onto the shared capability/runtime seams and expand regression coverage + SDK docs/baselines.
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/plugin-sdk/channel-contract.ts | Re-export ChannelApprovalAdapter/ChannelApprovalCapability via plugin SDK contract entrypoint. |
| src/plugin-sdk/approval-runtime.ts | Export new approval capability builders and shared native routing/runtime helpers. |
| src/plugin-sdk/approval-native-helpers.ts | Add SDK helpers to resolve origin targets + approver DM targets for native approval delivery. |
| src/plugin-sdk/approval-native-helpers.test.ts | Tests for the new native routing helper factories. |
| src/plugin-sdk/approval-delivery-helpers.ts | Introduce canonical capability builder + split/compat helpers; keep legacy adapter wrapper. |
| src/plugin-sdk/approval-delivery-helpers.test.ts | Tests for capability builder + legacy split compatibility behavior. |
| src/plugin-sdk/approval-client-helpers.ts | Add shared exec-approval client/profile helpers (targets matching, filters, prompt suppression). |
| src/plugin-sdk/approval-client-helpers.test.ts | Tests for shared exec-approval client/profile helpers. |
| src/infra/exec-approval-surface.ts | Read approval availability + DM-route state via resolved approval capability/adapter. |
| src/infra/exec-approval-surface.test.ts | Cover approvalCapability fallback/merge behavior in initiating surface + DM route detection. |
| src/infra/channel-approval-auth.ts | Resolve /approve authorization via approvalCapability (with legacy fallback). |
| src/infra/channel-approval-auth.test.ts | Add test ensuring approvalCapability overrides legacy auth wiring. |
| src/infra/approval-native-runtime.ts | Add createChannelNativeApprovalRuntime to unify native delivery hooks with shared runtime. |
| src/infra/approval-native-runtime.test.ts | Tests for new native runtime factory behavior (kind/content propagation, expiry). |
| src/channels/plugins/types.ts | Export ChannelApprovalCapability type from plugins types module. |
| src/channels/plugins/types.plugin.ts | Add approvalCapability?: ChannelApprovalCapability to channel plugin type. |
| src/channels/plugins/types.adapters.ts | Define ChannelApprovalCapability (adapter + approval-auth hooks). |
| src/channels/plugins/index.ts | Export resolveChannelApprovalCapability from plugin registry index. |
| src/channels/plugins/approvals.ts | Implement capability resolution/merge with legacy auth + approvals. |
| src/channels/plugins/approvals.test.ts | Tests for capability resolution fallbacks + merging rules. |
| src/auto-reply/reply/commands.test.ts | Add Signal /approve authorization regression and adjust Telegram denial expectations. |
| src/auto-reply/reply/commands-approve.ts | Refactor approval method selection/fallback and centralize submit error formatting. |
| extensions/telegram/test-support.ts | Expose approvalCapability in Telegram test plugin and keep legacy split adapter for compat. |
| extensions/telegram/src/exec-approvals.ts | Migrate Telegram exec approval auth/profile logic to shared SDK profile helpers. |
| extensions/telegram/src/exec-approvals-handler.ts | Switch Telegram handler to createChannelNativeApprovalRuntime and shared request handling. |
| extensions/telegram/src/channel.ts | Replace legacy approvals/auth wiring with approvalCapability (plus render adapter). |
| extensions/telegram/src/channel.test.ts | Add regression coverage for Telegram command conversation routing bindings. |
| extensions/telegram/src/approval-native.ts | Migrate Telegram native approval routing + capability creation to shared SDK helpers. |
| extensions/slack/src/monitor/exec-approvals.ts | Switch Slack handler to shared native runtime and shared request gating. |
| extensions/slack/src/monitor/exec-approvals.test.ts | Add coverage for approvers inferred from allowFrom without explicit execApprovals.approvers. |
| extensions/slack/src/exec-approvals.ts | Migrate Slack exec approval auth/profile logic to shared SDK profile helpers. |
| extensions/slack/src/channel.ts | Replace legacy approvals/auth wiring with approvalCapability. |
| extensions/slack/src/approval-native.ts | Migrate Slack native approval routing + capability creation to shared SDK helpers. |
| extensions/slack/src/approval-native.test.ts | Update tests for optional delivery fields and updated suppression input shapes. |
| extensions/discord/src/monitor/exec-approvals.ts | Switch Discord handler to shared native runtime and capability-driven native adapter. |
| extensions/discord/src/channel.ts | Replace legacy approvals/auth wiring with approvalCapability. |
| extensions/discord/src/approval-native.ts | Introduce Discord approvalCapability factory + shared native routing helpers + request gating. |
| docs/plugins/sdk-overview.md | Update SDK overview entry for expanded approval-runtime responsibilities. |
| docs/plugins/sdk-migration.md | Update migration doc to reflect expanded approval-runtime contents. |
| docs/plugins/sdk-channel-plugins.md | Document the new canonical approvalCapability seam and recommended helper usage. |
| docs/plugins/architecture.md | Add approval-runtime to recommended SDK imports and document approvalCapability guidance. |
| docs/.generated/plugin-sdk-api-baseline.jsonl | Update generated SDK API baseline to include new exports/types. |
| docs/.generated/plugin-sdk-api-baseline.json | Update generated SDK API baseline (JSON form) to include new exports/types. |
Greptile SummaryThis PR introduces a canonical Key changes:
One P1 concern: the old Telegram Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/telegram/src/exec-approvals.ts
Line: 49-61
Comment:
**Missing `fallbackAgentIdFromSessionKey` in Telegram profile**
The old `matchesFilters` function in `exec-approvals-handler.ts` explicitly passed `fallbackAgentIdFromSessionKey: true` to `matchesApprovalRequestFilters`. The new `telegramExecApprovalProfile` does not set this flag, so it silently defaults to `false`.
This is a behavioral regression: when a Telegram approval config uses `agentFilter` and the request's `agentId` is absent (relying on extraction from the session key), filter matching will now fail where it previously succeeded.
```suggestion
const telegramExecApprovalProfile = createChannelExecApprovalProfile({
resolveConfig: resolveTelegramExecApprovalConfig,
resolveApprovers: getTelegramExecApprovalApprovers,
isTargetRecipient: isTelegramExecApprovalTargetRecipient,
matchesRequestAccount: ({ cfg, accountId, request }) => {
const boundAccountId = resolveApprovalRequestAccountId({
cfg,
request,
channel:
request.request.turnSourceChannel?.trim().toLowerCase() === "telegram" ? null : "telegram",
});
return (
!boundAccountId ||
!accountId ||
normalizeAccountId(boundAccountId) === normalizeAccountId(accountId)
);
},
fallbackAgentIdFromSessionKey: true,
requireClientEnabledForLocalPromptSuppression: false,
});
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/discord/src/approval-native.ts
Line: 64-69
Comment:
**`shouldHandleDiscordApprovalRequest` returns `true` when config is absent**
When both `configOverride` and the account's `execApprovals` are `null`/`undefined`, `config` is falsy and the function returns `true`. This is surprising for a predicate named `should handle` — callers reasonably expect `false` when no approval config is present.
While the downstream delivery pipeline guards against actual delivery (via `hasApprovers` → `enabled: false` in `describeDeliveryCapabilities`), the semantics of this exported function are misleading and could cause confusion for future consumers.
Consider returning `false` here, since an absent config means approvals are not configured:
```suggestion
if (!config) {
return false;
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Refactor channel approval capability sea..." | Re-trigger Greptile |
dddda5e to
0fea432
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23d7654a58
ℹ️ 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".
a24254f to
52729e1
Compare
52729e1 to
c9ad4e4
Compare
|
Merged via squash.
Thanks @gumadeiras! |
Merged via squash. Prepared head SHA: c9ad4e4 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
Merged via squash. Prepared head SHA: c9ad4e4 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
Merged via squash. Prepared head SHA: c9ad4e4 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
Merged via squash. Prepared head SHA: c9ad4e4 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
Merged via squash. Prepared head SHA: c9ad4e4 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
Merged via squash. Prepared head SHA: c9ad4e4 Co-authored-by: gumadeiras <[email protected]> Co-authored-by: gumadeiras <[email protected]> Reviewed-by: @gumadeiras
Summary
approvalCapabilityseam with generic capability/adapter resolution and partial-migration fallbackTesting