Skip to content

fix(discord): accept system-agent approval callbacks through the custom-id codec - #137169

Closed
LiuwqGit wants to merge 1 commit into
openclaw:mainfrom
LiuwqGit:feat/issue-137142-discord-system-agent-approval
Closed

LiuwqGit wants to merge 1 commit into
openclaw:mainfrom
LiuwqGit:feat/issue-137142-discord-system-agent-approval

Conversation

@LiuwqGit

@LiuwqGit LiuwqGit commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

AI-assisted: yes

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.resolve path runs. The operator sees the pending request but cannot complete it from Discord and must switch to another approval surface.

  • Related: feat(gateway): deliver delegated system-agent config approvals to channels #134670 (introduced first-class system-agent native-channel delivery and left this narrow callback-codec gap); maintainer clawsweeper review confirms a focused three-kind codec repair with no open competing PR, and flagged that widening the shared normalizer also reaches Slack's callback envelope — this PR now brings both transport-private codecs to the same three-kind contract.

Why This Change Was Made

Extend the Discord transport-private approval-kind allowlist from exec | plugin to the existing three-kind contract exec | plugin | system-agent in 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/deny for system-agent), approver authorization, and the canonical Gateway resolver already support system-agent approvals, so no channel-specific execution or authorization path is added.

  • Intended outcome: a Discord or Slack system-agent card's buttons round-trip that channel's callback codec, authenticate the configured approver, and resolve the Gateway-owned record with kind: "system-agent".
  • Out of scope: Gateway authorization, config, persistence, decision sets, Control UI behavior, and reaction-based native channels: Signal, WhatsApp, and iMessage also subscribe to system-agent approvals but their reaction-target registration still accepts only 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).
  • Highest-risk area: widening a parse allowlist could accidentally accept an unsupported kind, or strand a rendered button whose channel codec rejects the new kind (the cross-channel regression clawsweeper identified for Slack).
  • How is that risk mitigated? each allowlist is closed to exactly the three canonical kinds in its own transport-private codec; malformed ids, unknown kinds, and unknown decisions still fail closed (existing rejection tests retained); Slack codec and interaction regressions cover system-agent round-trip, authorized resolution, and non-approver rejection before resolution.

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/deny decisions 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.

  • Success criteria: system-agent custom ids built by the native runtimes and the generic interactive builder round-trip parseExecApprovalData (Discord) and decodeSlackApprovalAction (Slack); both button handlers forward the exact system-agent kind to the resolver; malformed and unsupported kinds still fail closed; allow-always is not presented for system-agent; exec/plugin behavior unchanged.
  • What should reviewers focus on? extensions/discord/src/approval-custom-id.ts, extensions/slack/src/approval-actions.ts, src/interactive/payload.ts, and the system-agent regression fixtures in Discord approval-handler.runtime.test.ts, monitor/exec-approvals.test.ts, shared-interactive.test.ts, Slack approval-actions.test.ts and monitor/events/interactions.test.ts, plus src/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.sh green (oxfmt + oxlint + same-dir vitest + tsgo:core).

  • Exact steps or commands run after this patch:

    node scripts/run-vitest.mjs extensions/discord/src/approval-handler.runtime.test.ts extensions/discord/src/monitor/exec-approvals.test.ts extensions/discord/src/shared-interactive.test.ts
    node scripts/run-vitest.mjs extensions/slack/src/approval-actions.test.ts extensions/slack/src/approval-handler.runtime.test.ts extensions/slack/src/monitor/events/interactions.test.ts
    node scripts/run-vitest.mjs src/interactive/payload.test.ts src/infra/approval-view-model.test.ts
    # L2: direct production-function round trip (no mocks)
    node --import ./scripts/tsx.mjs /tmp/issue-137142-evidence.mts
    # L3: full ephemeral-Gateway authority-chain harness (real gateway components, no mocked resolver)
    node --import ./scripts/tsx.mjs <evidence-dir>/ephemeral-gateway-proof.mts
    
  • Evidence after fix: Slack codec parity — decodeSlackApprovalAction(encodeSlackApprovalAction({approvalKind: "system-agent", decision})) round-trips for allow-once and deny; unknown kind tool and unknown decision accept still return null. The Slack interaction handler resolves a clicked system-agent button through the configured exec approver (resolveApprovalOverGateway called with approvalKind: "system-agent", senderId: "U123", terminal card Resolved: 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, real resolveApprovalOverGateway (canonical branch, no override) inside withGatewayNativeApprovalRuntime (the same in-process principal wiring the Gateway uses for channel account tasks), real approval.resolve Gateway handler invoked with the same synthetic APPROVALS-scope principal the Gateway's native-approval runtime uses, real channel custody (prepareApprovalChannelCustody → real discord plugin authorizeActorAction), and a real SQLite-persisted ExecApprovalManager<SystemAgentApprovalRequestPayload> with a real claimed run authority:

    Authority-chain case Verdict
    Authorized Discord reviewer (123 ∈ approvers) clicks allow-once on a pending system-agent record applied; manager decision allow-once; terminal card "Approval resolved: Allowed once"; durable record resolved with resolver {kind: "channel", id: "discord:default"} — pass
    Non-approver (999) clicks ephemeral "⛔ You are not authorized to approve requests." at the Discord boundary; resolver never reached; record still pending — pass
    Stale click (record already resolved) "This approval was already resolved: Allowed once."; first-answer winner intact (allow-once), no re-opened execution rights — pass
    Custody mismatch (button rendered by another Discord account than the record's bound account) Gateway rejects with approval-not-found before resolution; record still pending — pass
    Kind mismatch (exec kind sent against a system-agent record) fail-closed malformed-verdict deny; the operation is never applied — pass
    Disallowed decision (allow-always) fail-closed malformed-verdict deny — pass
    Run authority revoked after the request was admitted force-denied with run-aborted before application I/O; terminal card "Already resolved: Cancelled" — pass

    Full 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 real approval.resolve handler in-process, mirroring the Gateway's own native-approval in-process dispatch), and the pending record is created through the real manager.create/register API (the same API prepareDelegatedSystemAgentApproval calls) 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.ts 45/45; validate.sh reports [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.ts 45 passed.

  • Before evidence: on origin/main the new regression tests failed — buildDiscordApprovalCustomId returned undefined for system-agent (generic builder dropped the button), parseExecApprovalData returned null for system-agent custom 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 c54dc40841f rates proof and patch quality platinum hermit with 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.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 12:05 AM ET / 04:05 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 94e963a3e73d5e4f84bc3c87ee4f9c986f7bc0de

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused contract repair with strong boundary evidence, useful negative cases, and the prior Slack defect resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured body records after-fix Discord execution through the real codec, handler, in-process Gateway resolver, custody checks, and persisted approval manager, including authorized resolution and six rejection/staleness cases. Slack codec output and its isolated channel-boundary harness cover the matching repair under repository policy; live platform transport remains outside the demonstrated scope.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body records after-fix Discord execution through the real codec, handler, in-process Gateway resolver, custody checks, and persisted approval manager, including authorized resolution and six rejection/staleness cases. Slack codec output and its isolated channel-boundary harness cover the matching repair under repository policy; live platform transport remains outside the demonstrated scope.
Evidence reviewed 9 items Current main still needs the repair: Both transport codecs retain exec/plugin-only rejection on fetched main; Discord rejects system-agent in both the generic builder and callback parser.
Latest release retains the Discord defect: The v2026.9.2 source also rejects system-agent callbacks, so the requested fix is neither already implemented on inspected main nor present in the supplied latest release.
Existing documented contract: The channel SDK documentation already defines exec, plugin, and system-agent native approvals and requires preserving the explicit kind through canonical resolution. This patch repairs transport implementations of that contract without adding a parallel plugin API.
Findings None None.
Security None None.

How this fits together

OpenClaw 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +16, Tests +304. Total +320 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 3 20 4 +16
Tests 6 318 14 +304
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 338 18 +320

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137142
Summary: This PR is the explicit candidate repair for the open Discord callback-codec report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best 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.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: Existing native approval cards cannot complete the operator's change-approval workflow on current main and the latest inspected release.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body records after-fix Discord execution through the real codec, handler, in-process Gateway resolver, custody checks, and persisted approval manager, including authorized resolution and six rejection/staleness cases. Slack codec output and its isolated channel-boundary harness cover the matching repair under repository policy; live platform transport remains outside the demonstrated scope.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body records after-fix Discord execution through the real codec, handler, in-process Gateway resolver, custody checks, and persisted approval manager, including authorized resolution and six rejection/staleness cases. Slack codec output and its isolated channel-boundary harness cover the matching repair under repository policy; live platform transport remains outside the demonstrated scope.

Evidence

What I checked:

  • Current main still needs the repair: Both transport codecs retain exec/plugin-only rejection on fetched main; Discord rejects system-agent in both the generic builder and callback parser. (extensions/discord/src/approval-custom-id.ts:81, 259a2a3bbd86)
  • Latest release retains the Discord defect: The v2026.9.2 source also rejects system-agent callbacks, so the requested fix is neither already implemented on inspected main nor present in the supplied latest release. (extensions/discord/src/approval-custom-id.ts:81, 3928bad9badf)
  • Existing documented contract: The channel SDK documentation already defines exec, plugin, and system-agent native approvals and requires preserving the explicit kind through canonical resolution. This patch repairs transport implementations of that contract without adding a parallel plugin API. Public docs: docs/plugins/sdk-channel-plugins.md. (docs/plugins/sdk-channel-plugins.md:592, 94e963a3e73d)
  • Prior Slack finding addressed: The decoder now accepts the same three canonical kinds as shared presentation normalization. Added codec and interaction cases cover allow-once/deny, rejection of unknown kinds, authorized resolution, and non-approver rejection before resolution. (extensions/slack/src/approval-actions.ts:57, 94e963a3e73d)
  • Gateway authorization remains authoritative: The resolver selects custody from the stored record kind, checks the current account/reviewer against the live record, preserves terminal winners, and rejects mismatched kinds or disallowed decisions. The approval manager checks live runtime authority before non-deny resolution; delegated application passes its live-authority guard onward to the engine. (src/gateway/server-methods/approval.ts:409, 94e963a3e73d)
  • Supplied production-boundary proof: The complete captured PR body, sourceRevision 83c4ae2915e7fa51c1abba8dc870f8e92c4e165cfa5ae29374e82bf492c239bb, records an isolated in-process run through the real Discord codec, button handler, canonical resolver, Gateway custody, and SQLite-backed manager. It reports successful authorized resolution and rejection of unauthorized, stale, wrong-account, wrong-kind, disallowed-decision, and revoked-authority cases. Slack has production-codec round-trip output and a channel-boundary harness. Live Discord/Slack API transport and a real initiating chat turn were explicitly not exercised; no embedded commands were executed during review.

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-03T08:15:02.111Z sha 4f5d93e1418a8b4b6635db4d57d50c4fd58532d1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-03T09:32:15.530Z sha eab8c29c52b5f1d9ea1f28565371e62e5050df8a :: needs real behavior proof before merge. :: [P1] Keep Slack system-agent controls decodable
  • reviewed 2026-09-03T09:55:16.317Z sha 1210e54f43e22e9c154c7bdd3ebfb13033160916 :: needs real behavior proof before merge. :: [P1] Keep Slack system-agent controls decodable
  • reviewed 2026-09-03T10:44:52.515Z sha c54dc40841f66f9b1de82975a4cfa8b5ef825679 :: blocked before merge. :: none
  • reviewed 2026-09-03T11:07:09.405Z sha c54dc40841f66f9b1de82975a4cfa8b5ef825679 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T03:00:07.307Z sha 94e963a :: needs maintainer review before merge. :: none

@LiuwqGit
LiuwqGit force-pushed the feat/issue-137142-discord-system-agent-approval branch from 4f5d93e to e4f3dba Compare September 3, 2026 09:19
@LiuwqGit
LiuwqGit force-pushed the feat/issue-137142-discord-system-agent-approval branch from e4f3dba to eab8c29 Compare September 3, 2026 09:24
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 3, 2026
@LiuwqGit
LiuwqGit force-pushed the feat/issue-137142-discord-system-agent-approval branch from eab8c29 to 1210e54 Compare September 3, 2026 09:45
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Sep 3, 2026
@LiuwqGit
LiuwqGit force-pushed the feat/issue-137142-discord-system-agent-approval branch from 1210e54 to c54dc40 Compare September 3, 2026 10:36
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 3, 2026
@LiuwqGit

LiuwqGit commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Note on the red checks-node-compact-small-6 job: the failing test is src/commands/agent-exec.test.ts > bounds blocked service-relay construction through the shipped CLI command, a fake-CLI pid-file timeout (1s budget) unrelated to this PR's approval-codec diff. The same shard also failed with the same test on the previous head 1210e54 before the Slack parity changes, so it looks like an environment flake; rerunning the failed job should clear it (external contributors cannot rerun upstream jobs).

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 3, 2026
… 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
@LiuwqGit
LiuwqGit force-pushed the feat/issue-137142-discord-system-agent-approval branch from c54dc40 to 94e963a Compare September 7, 2026 02:54
@LiuwqGit

LiuwqGit commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (94e963a) to pick up the upstream agent-exec timeout-coverage stabilization (ef917b1). The failing checks-node-compact-small-6 job was the agent-exec.test.ts real-process timeout test, which was unrelated to this PR's changes and has since been removed upstream; it does not exist on the rebased branch. Local targeted validation (oxfmt + oxlint + same-dir vitest for all changed files + tsgo:core) passes green on the rebased head.

@openclaw-barnacle openclaw-barnacle Bot added the channel: slack Channel integration: slack label Sep 7, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 7, 2026
@LiuwqGit

LiuwqGit commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Rebase continuity evidence (rating context for the Sept 7 review)

The Sept 3 review of c54dc40841f rated this PR 🦞 diamond lobster; the post-rebase review rates 🐚 platinum hermit and notes: "The earlier reviewed commit object was unavailable, so patch-identical rebase continuity was not independently established."

The previously reviewed head is still available on the fork — the --force-with-lease push only moved the branch ref; the commit object is intact and fetchable by full SHA:

git fetch https://github.com/LiuwqGit/openclaw c54dc40841f66f9b1de82975a4cfa8b5ef825679

Continuity 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.patch

Result: the only difference is the hunk-header index line for extensions/slack/src/monitor/events/interactions.test.ts — the blob hashes differ because upstream main itself edited that file between the two bases (the canary-text assertion change around line 2703, outside this PR's hunks). Every hunk body is byte-identical: the rebase introduced no patch change. Its sole purpose was to pick up ef917b1 (upstream removal of the flaky agent-exec real-process timeout test that failed checks-node-compact-small-6 on the previous head) so CI could pass.

@clawsweeper re-review — please re-establish patch continuity against the fetchable c54dc40841f above.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 7, 2026
obviyus added a commit that referenced this pull request Sep 13, 2026
## 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]>
@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

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.

  • Bug: Change approval buttons appeared but could not resolve the request.
  • Fix: Your codec repair is included with final-card preservation and lost-receipt cleanup.
Before After
Valid approval buttons were rejected or left pending Allow Once and Deny resolve correctly, and final application cards survive

@obviyus obviyus closed this Sep 13, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…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]>
@LiuwqGit
LiuwqGit deleted the feat/issue-137142-discord-system-agent-approval branch September 22, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: slack Channel integration: slack P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Discord system-agent approval buttons are emitted but rejected before resolution

2 participants