Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 12:05 AM ET / 04:05 UTC. ClawSweeper reviewWhat this changesThe PR repairs Discord and Slack approval-button codecs and shared presentation normalization so operators can answer system-agent change requests through native cards. Merge readiness✅ Ready for maintainer review Keep open as a useful, well-supported fix: current main still rejects these callbacks, and the prior Slack finding is resolved. No actionable introduced defect remains; the pre-existing reaction-channel gap does not warrant blocking this PR. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw sends Gateway-owned change requests to channel approval cards. Discord and Slack decode button clicks, authenticate the reviewer, and forward the decision to the Gateway, which checks the pending record and current authority. flowchart TD
A[Gateway change request] --> B[Shared approval presentation]
B --> C[Discord or Slack card]
C --> D[Button callback codec]
D --> E[Configured reviewer check]
E --> F[Gateway custody and live authority]
F --> G[Recorded decision and terminal card]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +16, Tests +304. Total +320 across 9 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Preserve the existing Gateway-owned approval lifecycle and align each transport codec with its established three-kind contract. Do we have a high-confidence way to reproduce the issue? Yes, from source: the native runtime emits system-agent buttons, while current-main Discord parsing rejects that kind before authorization or resolution. This review did not execute contributor code. Is this the best way to solve the issue? Yes. Updating the existing codecs and normalizer is a narrow repair of the documented contract, with regression coverage and no new execution, configuration, or authorization path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 259a2a3bbd86. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
4f5d93e to
e4f3dba
Compare
e4f3dba to
eab8c29
Compare
eab8c29 to
1210e54
Compare
1210e54 to
c54dc40
Compare
|
Note on the red |
… and Slack codecs System-agent approval cards rendered by the Discord or Slack native adapters can now be resolved through their transport-private callback codecs. Both kind allowlists stay closed to the three canonical kinds; malformed ids, unknown kinds, and unknown decisions still fail closed. Fixes openclaw#137142
c54dc40 to
94e963a
Compare
|
Rebased onto latest |
|
Rebase continuity evidence (rating context for the Sept 7 review) The Sept 3 review of The previously reviewed head is still available on the fork — the git fetch https://github.com/LiuwqGit/openclaw c54dc40841f66f9b1de82975a4cfa8b5ef825679Continuity check (verified locally): git diff c54dc40841f^..c54dc40841f > reviewed.patch # patch as reviewed on Sept 3 (parent: 8544aed)
git diff origin/main...94e963a3e73 > rebased.patch # patch after the CI-repair rebase
diff reviewed.patch rebased.patchResult: the only difference is the hunk-header @clawsweeper re-review — please re-establish patch continuity against the fetchable |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
## 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]>
|
Thanks @LiuwqGit! Proof: Merged #147152 supersedes this PR. It keeps your commit under your authorship in its PR history and preserves your credit in the merged change. The real Gateway approval flow passed with local transport fixtures; no human click.
|
…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]>
Closes #137142
What Problem This Solves
Fixes an issue where a system-agent approval delivered to Discord renders an "OpenClaw Change" approval card, but clicking its native buttons is rejected by the Discord callback parser before the configured-approver check or the canonical
approval.resolvepath runs. The operator sees the pending request but cannot complete it from Discord and must switch to another approval surface.Why This Change Was Made
Extend the Discord transport-private approval-kind allowlist from
exec | pluginto the existing three-kind contractexec | plugin | system-agentin the custom-ID builder/parser, align the shared interactive presentation normalizer to the same contract, and extend Slack's transport-private callback envelope (decodeSlackApprovalAction) to the identical three-kind contract so a system-agent card rendered by either native adapter stays decodable end to end. The native approval runtimes, typed approval views (allow-once/denyfor system-agent), approver authorization, and the canonical Gateway resolver already support system-agent approvals, so no channel-specific execution or authorization path is added.kind: "system-agent".exec/plugin— that pre-existing gap is unchanged by this PR and is not repaired here, so this PR must not be read as complete native-channel parity (per the clawsweeper merge-risk note, it warrants a separate owner-boundary repair).User Impact
Operators who use Discord or Slack as their primary approval surface can now complete a system-agent (OpenClaw Change) approval entirely through the rendered native card: the exact pending operation is shown, only the allowed
allow-once/denydecisions are presented, the configured approver is authenticated, and the terminal card reflects the applied or non-applied canonical outcome. Previously a Slack-rendered system-agent button was rejected as invalid on click, and a Discord one was rejected by the callback parser before authorization.parseExecApprovalData(Discord) anddecodeSlackApprovalAction(Slack); both button handlers forward the exactsystem-agentkind to the resolver; malformed and unsupported kinds still fail closed;allow-alwaysis not presented for system-agent; exec/plugin behavior unchanged.extensions/discord/src/approval-custom-id.ts,extensions/slack/src/approval-actions.ts,src/interactive/payload.ts, and the system-agent regression fixtures in Discordapproval-handler.runtime.test.ts,monitor/exec-approvals.test.ts,shared-interactive.test.ts, Slackapproval-actions.test.tsandmonitor/events/interactions.test.ts, plussrc/infra/approval-view-model.test.ts.Evidence
Real environment tested: local worktree on branch
feat/issue-137142-discord-system-agent-approval(Node v26.7.0),validate.shgreen (oxfmt + oxlint + same-dir vitest +tsgo:core).Exact steps or commands run after this patch:
Evidence after fix: Slack codec parity —
decodeSlackApprovalAction(encodeSlackApprovalAction({approvalKind: "system-agent", decision}))round-trips forallow-onceanddeny; unknown kindtooland unknown decisionacceptstill returnnull. The Slack interaction handler resolves a clicked system-agent button through the configured exec approver (resolveApprovalOverGatewaycalled withapprovalKind: "system-agent",senderId: "U123", terminal cardResolved: Allowed once) and blocks a non-approver (U999) with an ephemeral "You are not authorized to approve this request." before any resolution. Suites:Test Files 3 passed (3),Tests 101 passed (101).Evidence after fix (ephemeral-Gateway authority-chain harness, L3): an in-process harness runs the real components end to end — real Discord custom-id codec (encode →
parseCustomId→parseExecApprovalData, including the durable resolution-ref path for long ids), real Discord button handler with an SDK-shaped interaction, realresolveApprovalOverGateway(canonical branch, no override) insidewithGatewayNativeApprovalRuntime(the same in-process principal wiring the Gateway uses for channel account tasks), realapproval.resolveGateway handler invoked with the same synthetic APPROVALS-scope principal the Gateway's native-approval runtime uses, real channel custody (prepareApprovalChannelCustody→ real discord pluginauthorizeActorAction), and a real SQLite-persistedExecApprovalManager<SystemAgentApprovalRequestPayload>with a real claimed run authority:123∈ approvers) clicksallow-onceon a pending system-agent recordallow-once; terminal card "Approval resolved: Allowed once"; durable record resolved with resolver{kind: "channel", id: "discord:default"}— pass999) clicksallow-once), no re-opened execution rights — passexeckind sent against asystem-agentrecord)allow-always)run-abortedbefore application I/O; terminal card "Already resolved: Cancelled" — passFull structured JSON:
ephemeral-gateway-proof.json(7/7 cases, verdict "all authority-chain cases behaved as specified"). Synthetic parts, stated honestly: no WebSocket transport (the harness dispatches the realapproval.resolvehandler in-process, mirroring the Gateway's own native-approval in-process dispatch), and the pending record is created through the realmanager.create/registerAPI (the same APIprepareDelegatedSystemAgentApprovalcalls) instead of a live system-agent chat turn.Observed result after fix: all seven authority-chain cases behaved as specified (authorized resolve applied with channel-resolver attribution; non-approver, stale, custody-mismatch, kind-mismatch, disallowed-decision, and revoked-authority cases all fail closed before application I/O); Slack suites 101/101, Discord suites 65/65,
payload.test.ts45/45;validate.shreports[validate] 全部通过 ✅.Documented mock-gateway run (boundary evidence, L2): the approval authority chain is additionally exercised at the Discord button-handler boundary with the plugin-sdk gateway runtime mocked at the transport call site (
monitor/exec-approvals.test.ts): allowed approver resolves, non-approver rejected before resolution, rendered buttons round-trip the codec, unsupported kinds / malformed ids fail closed.Test Files 3 passed (3),Tests 65 passed (65);payload.test.ts45 passed.Before evidence: on
origin/mainthe new regression tests failed —buildDiscordApprovalCustomIdreturnedundefinedforsystem-agent(generic builder dropped the button),parseExecApprovalDatareturnednullforsystem-agentcustom ids (round-trip failed), and the button handler never reached the resolver ("no longer valid" reply).What was not tested: live Discord/Slack API interaction round trips (require real bot credentials not available in this environment); the system-agent chat turn that creates the approval record in production (the harness admits the record through the same manager API that turn uses); WebSocket transport (replaced by the in-process dispatch described above); reaction-based channels (Signal/WhatsApp/iMessage) whose system-agent registration gap predates this PR. Gateway-owned custody/state checks run against the live approval record on the Gateway side and are unchanged by this PR.
Proof tier: L3 for the authority chain (real gateway approval service, custody, resolver, and manager with real SQLite persistence driven by the real channel handler code), L2 for codec round-trips.
Review state: clawsweeper re-review of
c54dc40841frates proof and patch qualityplatinum hermitwith no actionable findings (proof: sufficient,status: ready for maintainer look); the remaining before-merge item is the maintainer decision on the pre-existing reaction-channel parity gap noted above.