Repository navigation
fix: keep approval requests on the owning channel account - #121673
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
7a08bb5 to
f396281
Compare
f396281 to
8f52933
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 3:51 PM ET / 19:51 UTC. ClawSweeper reviewWhat this changesThe PR carries complete channel, account, and actor identity through native approval delivery and resolution so only the owning account can display or approve a request. Regression provenancePossible regression — probable (reviewed change; failure trace; known regression link). No predecessor PR is attributed. Merge readinessKeep open: current main still permits the reported cross-account approval behavior, while this maintainer-owned PR adds a shared delivery selector and Gateway-side custody check. The prior Discord override finding is addressed; merge still needs an exact-head refresh after its behind-main base is reconciled. Priority: P1 Review scores
Verification
How this fits togetherChannel runtimes receive pending approvals and choose eligible account-specific delivery targets. Their approval controls send reviewer facts to the Gateway, which authorizes that actor and atomically records the decision. flowchart LR
A[Pending approval] --> B[Channel account runtimes]
B --> C[Shared route selection]
C --> D[Native approval control]
D --> E[Gateway custody check]
E --> F[Atomic approval decision]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +319, Tests +844, Generated +1, Other 0. Total +1164 across 62 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Mantis proof suggestionA Telegram Desktop recording would directly demonstrate owning-account delivery and rejection of a copied action from another account. A maintainer can ask Mantis to capture proof by posting this exact PR comment: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one canonical approval-custody flow: shared runtime selection for delivery, plus a live Gateway recheck before the resolution CAS, without restoring plugin-local sibling scans. Do we have a high-confidence way to reproduce the issue? Yes, from current source: an unbound approval makes the matcher accept every account at src/infra/approval-request-account-binding.ts:153, and each runtime independently invokes its adapter at src/infra/approval-native-runtime.ts:232. Focused execution was not performed in this read-only review. Is this the best way to solve the issue? Yes. Shared selection owns cross-runtime delivery, while the Gateway owns authorization against the live record immediately before resolution; a channel-local guard alone would leave copied IDs and non-native controls unchecked. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8a5978154f69. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Unrelated main breakage blocking this PR's merge gate, healed here per landing policy: - #121653 left dead exports in src/skills/workshop: make removeSkillCollectionDirectory and SkillCollectionRestoreResult module-local; register collection-review.ts under the documented knip ignoreIssues test-only-export convention (production runs it via the scheduled maintenance loop). - #121673 added ApprovalResolveParams.reviewer without regenerating the Swift mirror; regenerate GatewayModels.swift (additive only).
Unrelated main breakage blocking this PR's merge gate, healed here per landing policy: - #121653 left dead exports in src/skills/workshop: make removeSkillCollectionDirectory and SkillCollectionRestoreResult module-local; register collection-review.ts under the documented knip ignoreIssues test-only-export convention (production runs it via the scheduled maintenance loop). - #121673 added ApprovalResolveParams.reviewer without regenerating the Swift mirror; regenerate GatewayModels.swift (additive only).
* feat(agents): rename spawn_task tool to suggest_task Models across vendors read the name spawn_task as 'starts background work' and refuse to call it when the user has not asked to start anything (Claude Sonnet 5, verbatim: 'spawn_task (which actively starts background work)... Since you didn't ask me to start work, I'm flagging this as a follow-up instead'). The tool only records a suggestion card, so the name defeated the feature. Rename the model-facing tool to suggest_task everywhere (catalog, descriptors, presets, display config, OpenClawKit tool-display, docs) and migrate persisted operator state via doctor: config tool policies and cron SQLite toolsAllow entries that reference spawn_task are rewritten to suggest_task. No runtime alias remains; runtime exposes only the canonical name. Live clean-room matrix on a dev gateway (virgin session per cell): suggested-task-card phrasing now yields exactly one card on anthropic/claude-sonnet-5, claude-haiku-4-5, openai/gpt-5.6-sol, gpt-5.6-luna, and google/gemini-3.1-pro; pre-rename the same bait produced prose-only follow-ups. * chore(doctor): keep legacy tool-name predicate module-local isLegacyTaskSuggestionToolName has no external consumers; the exported form tripped the knip unused-export gate (deadcode:exports). * fix(doctor): keep tool-name migration out of plugin-owned config The rename migration traversed the whole raw config, so any object carrying a toolsAllow key was rewritten - including opaque plugins.entries.*.config, which core must not mutate. Scope the apply pass to the typed core roots (tools, agents, channels, gateway) and pin plugin config preservation in the test. Plugin-owned tool lists migrate via the owning plugin's doctor contract instead. * fix(ci): heal main deadcode and stale Swift protocol mirror Unrelated main breakage blocking this PR's merge gate, healed here per landing policy: - #121653 left dead exports in src/skills/workshop: make removeSkillCollectionDirectory and SkillCollectionRestoreResult module-local; register collection-review.ts under the documented knip ignoreIssues test-only-export convention (production runs it via the scheduled maintenance loop). - #121673 added ApprovalResolveParams.reviewer without regenerating the Swift mirror; regenerate GatewayModels.swift (additive only). * fix(ci): satisfy generic approval-runtime request signature in resolver test Third main-heal carried by this PR: #121673 (9935ca3) left the scoped-request mock's concrete inferred type unassignable to the generic GatewayNativeApprovalRuntime request signature, breaking check-test-types on main. Cast the mock at the runtime literal; assertions keep the Mock. * chore(ci): drop approval-test cast superseded by main's typed mock rewrite * chore(ci): drop duplicate knip entry superseded by main's heal
…1673) Native approval delivery and resolution now stay bound to the originating or explicitly targeted channel account. Unbound requests fail closed across multiple eligible accounts; trusted reviewer-less SDK callers remain compatible. Co-authored-by: Ayaan Zaidi <[email protected]>
* feat(agents): rename spawn_task tool to suggest_task Models across vendors read the name spawn_task as 'starts background work' and refuse to call it when the user has not asked to start anything (Claude Sonnet 5, verbatim: 'spawn_task (which actively starts background work)... Since you didn't ask me to start work, I'm flagging this as a follow-up instead'). The tool only records a suggestion card, so the name defeated the feature. Rename the model-facing tool to suggest_task everywhere (catalog, descriptors, presets, display config, OpenClawKit tool-display, docs) and migrate persisted operator state via doctor: config tool policies and cron SQLite toolsAllow entries that reference spawn_task are rewritten to suggest_task. No runtime alias remains; runtime exposes only the canonical name. Live clean-room matrix on a dev gateway (virgin session per cell): suggested-task-card phrasing now yields exactly one card on anthropic/claude-sonnet-5, claude-haiku-4-5, openai/gpt-5.6-sol, gpt-5.6-luna, and google/gemini-3.1-pro; pre-rename the same bait produced prose-only follow-ups. * chore(doctor): keep legacy tool-name predicate module-local isLegacyTaskSuggestionToolName has no external consumers; the exported form tripped the knip unused-export gate (deadcode:exports). * fix(doctor): keep tool-name migration out of plugin-owned config The rename migration traversed the whole raw config, so any object carrying a toolsAllow key was rewritten - including opaque plugins.entries.*.config, which core must not mutate. Scope the apply pass to the typed core roots (tools, agents, channels, gateway) and pin plugin config preservation in the test. Plugin-owned tool lists migrate via the owning plugin's doctor contract instead. * fix(ci): heal main deadcode and stale Swift protocol mirror Unrelated main breakage blocking this PR's merge gate, healed here per landing policy: - openclaw#121653 left dead exports in src/skills/workshop: make removeSkillCollectionDirectory and SkillCollectionRestoreResult module-local; register collection-review.ts under the documented knip ignoreIssues test-only-export convention (production runs it via the scheduled maintenance loop). - openclaw#121673 added ApprovalResolveParams.reviewer without regenerating the Swift mirror; regenerate GatewayModels.swift (additive only). * fix(ci): satisfy generic approval-runtime request signature in resolver test Third main-heal carried by this PR: openclaw#121673 (ca933de) left the scoped-request mock's concrete inferred type unassignable to the generic GatewayNativeApprovalRuntime request signature, breaking check-test-types on main. Cast the mock at the runtime literal; assertions keep the Mock. * chore(ci): drop approval-test cast superseded by main's typed mock rewrite * chore(ci): drop duplicate knip entry superseded by main's heal
## What Problem This Solves The OpenClaw Change approval card appears, but its buttons cannot approve. A late callback can overwrite the application result, and a Slack card can stay pending after its delivery receipt is lost. ## Fix and Impact Accept the existing three approval kinds in Discord, Slack, and shared presentation validation. Native updates and callbacks share a per-message queue in each channel. Callbacks read current controls before editing, so old pending cards finish and final Applied, Not applied, or Denied cards survive. Native delivery keeps its existing frozen runtime selection from #121673. Restart/list replay does not send a second card; an authorized operator can still resolve the original card. No schema, migration, config-key, protocol, dependency, or delivery-policy change. Supersedes #137169 by @LiuwqGit. Contributor authorship is preserved. Reported by @anyech in #137142. Refs #134670. ## Consumers The shared presentation normalizer also feeds Telegram and the fallback renderers for other channels. Telegram already accepts the system-agent callback kind. Its existing typed-action tests remain intact. Other renderers retain their existing unsupported-control and text-fallback behavior; this change does not claim native approval support for them. ## Documentation No product documentation change is required. `docs/plugins/sdk-channel-plugins/approvals.md:104` already requires all three kinds and the final application result. The Slack codec unit test covers a direct encoder/decoder round trip; the registered-handler and real Gateway evidence below establish the complete approval flow. ## Evidence - Main `37130969fa54`: both emitted Discord buttons returned “This approval is no longer valid”; SQLite stayed pending and the resolver was not reached. - Slack baseline `fc188ff0b943`: after native delivery and runtime stop, Allow Once and Deny persisted their decisions but left the original card pending with buttons. - Narrowed candidate `b5e76a8386f03380a369dd5150f57b5e488cd64b`: three fresh real Slack handler → Gateway → application/SQLite → card cases passed. Actual stop/start/list replay selects no replacement and sends no second card. Original Allow Once and Deny clear the controls; the threaded case reads and finishes the exact original reply. Full captures: `runtime-narrowed-3.json`. - Retained evidence: 21 non-replay Slack cases at `73fba5283a4b` cover both native/callback orders, Applied/Not applied/Denied, generic controls, stale winners, authority checks, and exec/plugin siblings. Source-aware review confirmed unchanged inputs. These are reused records, not new executions. Earlier replacement-delivery records are historical only. The retained 21 Discord Gateway scenarios cover the real dispatcher, approval resolver, application executor, SQLite results, and final cards against local HTTP responses. The boundary uses a real bundled Gateway and native HTTP clients with isolated local HTTP and deterministic inference fixtures. Recorded harness commands (`SLACK_PROOF` is the retained evidence directory; start runs in a separate terminal): ```sh node "$SLACK_PROOF/start.mjs" narrowed node "$SLACK_PROOF/call.mjs" narrowed node "$SLACK_PROOF/verify.mjs" ``` Fresh merge `f9ccdd51aa0d590adb72d35c83eb937bbe9fa13e` has direct parents candidate `b5e76a8386f03380a369dd5150f57b5e488cd64b` and main `adb6e518a44218650883f3daec4bd319165e0017`. The affected approval lifecycle group passed 836 tests (2 skipped), full Slack passed 3,017, and the Discord native/registered-callback sibling passed 44. All three commands exited 0. ```sh pnpm changed:lanes --json --base 3713096 --head f9ccdd51aa0d590adb72d35c83eb937bbe9fa13e node --import tsx scripts/ci-run-node-test-shard.mts ``` The retained plan and command/result receipts specify each CI config, include list, and environment. Local `pnpm exec oxlint --config .oxlintrc.json` passed for all 15 retained PR files plus both reverted files; `oxlint-final.json` records the exact command and exit. Unchanged suite evidence remains tied to its earlier merge `68930a5e67a2`, rather than being counted as a new run. CI run `34773959228` completed successfully at landing head `f08ae38f5237e35276bdf9bb2f50c68cbe4af31b`, including the previously failing type-aware jobs. The last commit changes only two Discord test fixtures; production and the accepted Gateway evidence are unchanged. Both affected test files also passed all 44 local tests. Limit: no human click. Co-authored-by: LiuwqGit <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…147152) ## What Problem This Solves The OpenClaw Change approval card appears, but its buttons cannot approve. A late callback can overwrite the application result, and a Slack card can stay pending after its delivery receipt is lost. ## Fix and Impact Accept the existing three approval kinds in Discord, Slack, and shared presentation validation. Native updates and callbacks share a per-message queue in each channel. Callbacks read current controls before editing, so old pending cards finish and final Applied, Not applied, or Denied cards survive. Native delivery keeps its existing frozen runtime selection from openclaw#121673. Restart/list replay does not send a second card; an authorized operator can still resolve the original card. No schema, migration, config-key, protocol, dependency, or delivery-policy change. Supersedes openclaw#137169 by @LiuwqGit. Contributor authorship is preserved. Reported by @anyech in openclaw#137142. Refs openclaw#134670. ## Consumers The shared presentation normalizer also feeds Telegram and the fallback renderers for other channels. Telegram already accepts the system-agent callback kind. Its existing typed-action tests remain intact. Other renderers retain their existing unsupported-control and text-fallback behavior; this change does not claim native approval support for them. ## Documentation No product documentation change is required. `docs/plugins/sdk-channel-plugins/approvals.md:104` already requires all three kinds and the final application result. The Slack codec unit test covers a direct encoder/decoder round trip; the registered-handler and real Gateway evidence below establish the complete approval flow. ## Evidence - Main `f700a855a470`: both emitted Discord buttons returned “This approval is no longer valid”; SQLite stayed pending and the resolver was not reached. - Slack baseline `fc188ff0b943`: after native delivery and runtime stop, Allow Once and Deny persisted their decisions but left the original card pending with buttons. - Narrowed candidate `b5e76a8386f03380a369dd5150f57b5e488cd64b`: three fresh real Slack handler → Gateway → application/SQLite → card cases passed. Actual stop/start/list replay selects no replacement and sends no second card. Original Allow Once and Deny clear the controls; the threaded case reads and finishes the exact original reply. Full captures: `runtime-narrowed-3.json`. - Retained evidence: 21 non-replay Slack cases at `73fba5283a4b` cover both native/callback orders, Applied/Not applied/Denied, generic controls, stale winners, authority checks, and exec/plugin siblings. Source-aware review confirmed unchanged inputs. These are reused records, not new executions. Earlier replacement-delivery records are historical only. The retained 21 Discord Gateway scenarios cover the real dispatcher, approval resolver, application executor, SQLite results, and final cards against local HTTP responses. The boundary uses a real bundled Gateway and native HTTP clients with isolated local HTTP and deterministic inference fixtures. Recorded harness commands (`SLACK_PROOF` is the retained evidence directory; start runs in a separate terminal): ```sh node "$SLACK_PROOF/start.mjs" narrowed node "$SLACK_PROOF/call.mjs" narrowed node "$SLACK_PROOF/verify.mjs" ``` Fresh merge `f9ccdd51aa0d590adb72d35c83eb937bbe9fa13e` has direct parents candidate `b5e76a8386f03380a369dd5150f57b5e488cd64b` and main `e08263bdd3341031c219bb147638f23a1f4c3c03`. The affected approval lifecycle group passed 836 tests (2 skipped), full Slack passed 3,017, and the Discord native/registered-callback sibling passed 44. All three commands exited 0. ```sh pnpm changed:lanes --json --base f700a85 --head f9ccdd51aa0d590adb72d35c83eb937bbe9fa13e node --import tsx scripts/ci-run-node-test-shard.mts ``` The retained plan and command/result receipts specify each CI config, include list, and environment. Local `pnpm exec oxlint --config .oxlintrc.json` passed for all 15 retained PR files plus both reverted files; `oxlint-final.json` records the exact command and exit. Unchanged suite evidence remains tied to its earlier merge `68930a5e67a2`, rather than being counted as a new run. CI run `34773959228` completed successfully at landing head `f08ae38f5237e35276bdf9bb2f50c68cbe4af31b`, including the previously failing type-aware jobs. The last commit changes only two Discord test fixtures; production and the accepted Gateway evidence are unchanged. Both affected test files also passed all 44 local tests. Limit: no human click. Co-authored-by: LiuwqGit <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #112067
What Problem This Solves
Fixes native exec or plugin approvals without an account binding appearing on every eligible account for the same channel. It also prevents a copied approval ID from being resolved through an account that did not own the request route.
Why This Change Was Made
Native approval routing and resolution now share one account-custody contract. A closed reviewer identity (
channel,accountId,senderId) reaches the Gateway; the Gateway checks the authoritative live request and one config snapshot immediately before the existing resolution CAS. Exact source/session accounts and explicit forwarding targets remain a union. Accountless targets use the documented default. Unbound requests belong only to the sole actor-authorized account.Canonical and legacy prefix resolution enforce custody before ambiguity and terminal lookup. Discord and QQBot propagate the real clicking actor. The old client-side list/find/enabled-account preflight is deleted, so visibility-filtered lists cannot bypass Gateway custody and delivery runtime availability cannot disable manual approval.
Native delivery separately snapshots raw-eligible live runtimes once per approval and channel. Bound or explicitly targeted accounts remain a union. An unbound route selects only its sole live candidate; multiple candidates produce one visible manual-approval outcome. The snapshot remains stable through expiry, so stopped or late runtimes cannot steal or duplicate delivery.
No config, persistent state, cache, or retry path was added.
Maintainer Decision
Decision owner: Ayaan Zaidi — APPROVED. Preserve the shipped reviewer-less Plugin SDK resolver path as a temporary compatibility exception for trusted legacy/admin callers. Every bundled channel control now sends the complete channel/account/sender reviewer triple; partial reviewer facts fail closed. This PR claims account custody only for complete-reviewer channel controls. Do not fabricate a default account for omitted SDK facts. Make reviewer custody mandatory only through a future versioned Plugin SDK cutover.
User Impact
Operators with several bots or workspaces on one channel receive approval commands only on intended accounts. Explicit multi-account forwarding still works. Copied IDs and buttons from unrelated accounts fail without executing the request. Same-account manual approval remains available when rich delivery is stopped or unavailable.
Evidence
620ca5f00880; main advanced again after push, with the PR remaining mergeable.git diff --check; targeted Oxfmt/Oxlint; core and extension production tsgo; extension-test tsgo. The untouched generic mock insrc/infra/approval-gateway-resolver.test.tsremains the only core-test tsgo diagnostic.Exact-head Telegram behavior
Local
$telegram-e2e-userbotproof on968a0df9used the broker's real QA user and SUT bot plus a deterministic second Telegram account on the same candidate Gateway. The owning account emitted exactly one approval card. The second account emitted no approval card; its injected copied/approvereturned the expected unknown/expired result. The provider log stayed at one request, so no command or second model turn ran. The real-user recording observed progress plus the approval card, zero edits, and zero deletes. Runner-owned processes, ports, and the QA lease were clean after exit.