Skip to content

fix: allow trusted scheduled Discord channel edits - #150182

Merged
shakkernerd merged 3 commits into
mainfrom
fix/scheduled-channel-admin
Sep 17, 2026
Merged

shakkernerd merged 3 commits into
mainfrom
fix/scheduled-channel-admin

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Trusted operator-created scheduled jobs have no inbound Discord sender. Before this change, channel-edit failed at the channel administration check even when the job had valid message access. Related: #140978.

This PR carries the canonical job grant through Discord channel editing, channel-name resolution, and provider retries. It uses the scheduled message admission and current tool-policy evaluation landed in #150166. It also fixes a caller completion check that discarded an accepted edit when disabling the job canceled its generated MCP request.

User Impact

Operator-created jobs with message access can edit Discord channels and use the action's existing thread edit options. Configured account and action restrictions, the job's current capability, and Discord permissions continue to apply.

Disabling, removing, replacing, or narrowing a job blocks later requests and rate-limit retries. Caller or plugin retirement also blocks subsequent I/O. Configuration changes apply to the next invocation; an admitted operation retains its configuration. A confirmed provider result survives job cancellation and the original MCP request's abort.

Why This Change Was Made

The optional SDK field ChannelMessageActionAdapter.writeAuthorityActions?: readonly ChannelMessageActionName[] declares that an adapter preserves the existing assertDirectAdapterHandoff callback through preparation and every provider request or retry. Action discovery and read support do not establish that write contract. The host independently selects eligible actions; Discord declares only channel-edit in this PR.

Admission checks the canonical job grant, configured action and account, and the active bundled or loader-verified official registration. Channel lookup retains the selected registration and request guard. Its read scope closes before the mutation, whose actual result is allowed to settle. The in-process Gateway retains the original signal and caller guards for later dispatches and mutation commits.

Older adapters remain source-compatible because the declaration is optional. Scheduled administration requires the updated adapter contract and its loaded registration. Account-created jobs do not inherit operator administration, and no run-wide owner flag or invented requester identity is introduced. Canonical SDK and automation documentation explains the interface, retained checks, configuration timing, and upgrade behavior.

Evidence

The existing isolated fixture exercises the real scheduler, CLI child protocol or embedded runner, generated HTTP MCP grants, registered Gateway handler, and official Discord adapter. Only model decisions and provider responses are synthetic. The original scheduler failure submitted no PATCH. A separate regression reproduced channel-directory I/O after revocation; the repaired path blocks it.

All six scheduler scenarios passed: the two read controls, CLI and embedded edits, disable-before-429-retry, and accepted-response settlement after the original MCP signal aborts. The disable cases use real cron.update calls, inspect the persisted disabled job, and verify the exact authenticated PATCH and completed run cleanup.

The operator-only candidate passed 477 selected runtime tests, core/root typing, all 20 selected core test type graphs, formatting, targeted lint, source ratchets, and both import-cycle checks. Retained proof covers outbound/registry/Discord siblings and SDK declaration compatibility. Independent implementation, caller-settlement, and integration reviews found no actionable issues; the recorded default-P0 automated reviews are clean.

The three writer commits were replayed unchanged onto main after #150166 landed. Final head 4c1df7ac6bbd36aac84cf376e7052168f0b2cde4 preserves all 20 contribution files from the tested current-main integration candidate e95ace9ce0841849a2e29f87bad86fe49bbd98cb (tree 1578b5592e5bb2e943393d450acc369415d7122b). That run includes the prerequisite's run-lifetime correction, the updated MCP request scope and CLI watchdog, and a controlled 120-second clock gap before CLI tool discovery. All six scheduler scenarios and combined core/root typing passed. Later main changes were checked against the writer's contracts; the recorded integration review is clean. The current-head ClawSweeper review is Platinum with no code or security findings. Current CI has one unrelated Qwen timeout-equality failure and its aggregate: the test expected 120000 after one elapsed millisecond, receiving 119999; 1,295 other cases in that bundle passed. The matching main-branch baseline failures are recorded in #150523, whose repair has landed in main. Those reported baseline runs used macOS/Node 26.8.2; this CI failure used Linux/Node 24.19.0. Source comparison tied the CI failure to the baseline's unchanged timeout/test inputs, with no writer interaction; the final main result retains the repair.

Retained execution output and checked provider outcomes

The following integration run includes the prerequisite's run-lifetime correction and the updated MCP request scope and CLI watchdog. All three writer commits remain patch-equivalent. Its CLI cases advance the fixture clock by 120 seconds before tool discovery.

[crabbox] verified source=e95ace9ce0841849a2e29f87bad86fe49bbd98cb tree=1578b5592e5bb2e943393d450acc369415d7122b carrier=ab03d829f547d3c8beb6f7b08df2684e5ec90803
 ✓  infra  test/cron-message-read.integration.test.ts > operator-created scheduled message actions > claude-cli/read 17547ms
 ✓  infra  test/cron-message-read.integration.test.ts > operator-created scheduled message actions > openclaw/channel-info 1988ms
 ✓  infra  test/cron-message-read.integration.test.ts > operator-created scheduled message actions > edits Discord through a trusted operato… 1991ms
 ✓  infra  test/cron-message-read.integration.test.ts > operator-created scheduled message actions > blocks a Discord 429 retry after cron.u… 1581ms
 ✓  infra  test/cron-message-read.integration.test.ts > operator-created scheduled message actions > preserves an accepted Discord edit afte… 2375ms
 ✓  infra  test/cron-message-read.integration.test.ts > operator-created scheduled message actions > openclaw/channel-edit 1645ms
PASS elapsed=62.919s
CHECK node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
PASS elapsed=49.922s
CHECK node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.root.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/test-root.tsbuildinfo
PASS elapsed=107.673s
Current-main scheduled writer integration passed.
blacksmith run summary sync=delegated command=5m23.902s total=5m26.206s exit=0

The scheduler and retained MCP cases checked these outcomes against the Gateway and fixture HTTP peers:

Scenario Checked provider and tool outcome
Account or forged-sender job The three account-administration calls are rejected with no PATCH; the named-target case issues no provider request.
Operator edit, CLI and embedded One authenticated PATCH /api/v10/channels/100000000000000003; the returned channel contains the requested topic.
Job disabled before a 429 response The stored job is disabled; one PATCH only, no retry; the MCP result is an error; active Cron runs drain to zero.
Job disabled before an accepted 200 response The original MCP signal aborts before the response is released; one PATCH only; isError is false and the returned channel/topic is preserved; active Cron runs drain to zero.

Current-head assertions: durable disablement and original-signal abort, tool outcome and sole PATCH, and account/forged-sender denial.

The account-denial and additional lifetime cases ran on the writer patch before the parent move. That verified tree was subsequently committed as 2128bd6. Nineteen contribution files remain byte-identical; the shared scheduler fixture gained the prerequisite's clock-gap setup, exercised by the current-main run above. All three writer commits remain patch-equivalent.

[crabbox] verified source=23f36f7e410218adf4828a77a5736eecf2e3372f tree=f8728e8ddbfc60a1f75cb6cb7ec96044dbf5f67e carrier=b9cd449e6394e8dfb3eab824d33f271f604bb213
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled channel-edit consumer > stops channel-name lookup after job permission is revoked 17ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled channel-edit consumer > does not promote an ordinary account job to administration 14ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled channel-edit consumer > does not promote an account job with a channel-name targ… to administration 13ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled channel-edit consumer > does not promote an account job with forged owner and se… to administration 13ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled channel-edit consumer > preserves immediate job revocation across a Discord 429 retry 21ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled channel-edit consumer > settles an accepted edit after scheduled permission is revoked without replay 22ms
Operator-only writer integration proof passed.
blacksmith run summary sync=delegated command=28m57.114s total=28m59.451s exit=0

The earlier differential run recorded the two failures below before their respective corrections. These selected fields are extracted from its retained diagnostics:

{
  "before_operator_write_admission": {
    "discordRequests": [],
    "mcpIsError": true,
    "mcpText": [
      "Error: Discord guild admin actions require a trusted Discord sender identity."
    ]
  },
  "before_caller_completion_fix": {
    "discordRequests": [
      {
        "method": "PATCH",
        "path": "/api/v10/channels/100000000000000003",
        "authorizationMatches": true
      }
    ],
    "mcpIsError": true,
    "mcpText": [
      "agent tool caller authority is no longer active"
    ],
    "providerStatus": 200
  }
}

@shakkernerd
shakkernerd requested a review from a team as a code owner September 16, 2026 17:02
@clawsweeper

clawsweeper Bot commented Sep 16, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 16, 2026, 11:57 PM ET / September 17, 2026, 03:57 UTC (Revision 6).

ClawSweeper review

What this changes

Allows trusted operator-created scheduled jobs to edit Discord channels, carrying live authorization through lookups and retries while preserving accepted edit results after cancellation.

Merge readiness

⛔ Blocked before merge - 4 items remain

This PR remains useful and has convincing authority-boundary proof, with no actionable code findings. The documented SDK authority expansion still needs explicit owner acceptance; the merged read prerequisite does not replace this work.

Priority: P2
Reviewed head: 4c1df7ac6bbd36aac84cf376e7052168f0b2cde4
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent implementation with strong production-boundary evidence and no actionable findings; owner acceptance is a separate merge requirement.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Retained terminal evidence exercises the real scheduler, generated MCP access, Gateway handler, official Discord adapter, and HTTP client against controlled peers: allowed edits succeed, account and forged-authority calls produce no mutation, revocation prevents retries, and accepted results survive cancellation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Retained terminal evidence exercises the real scheduler, generated MCP access, Gateway handler, official Discord adapter, and HTTP client against controlled peers: allowed edits succeed, account and forged-authority calls produce no mutation, revocation prevents retries, and accepted results survive cancellation.
Evidence reviewed 9 items Introduced authority boundary: The pinned introduction diff adds operator-only scheduled channel-edit admission, requires registered writer support, and projects senderIsOwner only into the admitted adapter context.
Final HTTP request enforcement: Discord captures the host assertion before queueing and invokes it immediately before HTTP execution; queued retries retain that assertion. Accepted responses settle without a subsequent authority rejection.
Scheduler and cancellation proof: The captured PR body records six passing scheduler scenarios on e95ace9ce0841849a2e29f87bad86fe49bbd98cb, including authenticated PATCH requests, persisted cron.update disablement, rejection before a 429 retry, and successful settlement after the original MCP signal aborts. Inspected head assertions verify those outcomes. The reported contribution-file equality to that execution revision could not be independently compared because that historical object was unavailable; this is a reviewer limitation, not missing contributor proof.
Findings None None.
Security None None.

How this fits together

Scheduled agents invoke the shared message tool through embedded execution or generated MCP access. The Gateway validates their job authority and dispatches approved actions through the Discord plugin to its HTTP transport.

flowchart TD
  A[Scheduled agent] --> B[Message tool and MCP]
  B --> C[Gateway job authority]
  C --> D{Trusted job and declared adapter?}
  D -->|No| E[Reject before provider request]
  D -->|Yes| F[Discord lookup and edit]
  F --> G[Check authority before each request]
  G --> H[Preserve accepted result]
Loading

Decision needed

Question Recommendation
Do SDK and security owners accept allowing trusted operator jobs to administer Discord channels through the optional writer declaration without an inbound sender? Accept the bounded writer contract: Record SDK/security-owner acceptance of operator-only channel-edit admission and the documented adapter upgrade contract.

Why: The implementation and boundary proof support the design, but repository policy reserves acceptance of this public authority expansion for its owners.

Before merge

  • Resolve merge risk (P1) - Trusted scheduled jobs gain channel administration without an inbound Discord sender; acceptance of that authority expansion remains unrecorded.
  • Resolve merge risk (P1) - Scheduled administration requires the updated plugin declaration and loaded registration; older adapters remain denied, making the public compatibility contract important to approve.
  • Complete next step (P2) - Record SDK/security-owner acceptance of operator-only scheduled channel administration and its adapter compatibility contract.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +249, Tests +712, Docs +65. Total +1026 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 13 459 210 +249
Tests 5 806 94 +712
Docs 2 67 2 +65
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 1332 306 +1026

Review metrics

Metric Value Why it matters
Public adapter contract 1 optional declaration; 1 enrolled action The new writer contract enables only channel-edit and leaves older adapters source-compatible.
Production versus validation growth Production net +249 lines; tests and test support net +712 lines Production growth has a stated purpose: carry live authority through preparation and settlement, with broader boundary coverage.

Merge-risk options

Maintainer options:

  1. Approve the documented authority and upgrade contract (recommended)
    Owners can accept the narrow operator-only expansion with the retained denial, revocation, and older-adapter controls.
  2. Pause scheduled administration
    Keep the existing sender requirement if owners do not accept the proposed unattended administration boundary.

Technical review

Best possible solution:

Keep scheduled administration narrowly bound to the existing operator job grant, with an accepted SDK contract, per-request revocation checks, and preserved mutation outcomes.

Do we have a high-confidence way to reproduce the issue?

Yes: the current dispatcher lacks scheduled writer admission, and the retained differential trace shows the trusted job rejected before PATCH. No target code was executed during this read-only review.

Is this the best way to solve the issue?

Yes, subject to owner acceptance: extending the existing job grant and Discord request guard avoids a competing authority mechanism and retains the established interactive path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 035227797aa6.

Labels

Label justifications:

  • P2: This is a bounded improvement to scheduled Discord administration without evidence of an urgent widespread outage.
  • merge-risk: 🚨 compatibility: The public adapter declaration creates an upgrade requirement for scheduled administration that needs owner acceptance.
  • merge-risk: 🚨 security-boundary: The patch allows trusted scheduled jobs to reach channel-administration effects without an inbound sender.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Retained terminal evidence exercises the real scheduler, generated MCP access, Gateway handler, official Discord adapter, and HTTP client against controlled peers: allowed edits succeed, account and forged-authority calls produce no mutation, revocation prevents retries, and accepted results survive cancellation.
  • proof: sufficient: Contributor real behavior proof is sufficient. Retained terminal evidence exercises the real scheduler, generated MCP access, Gateway handler, official Discord adapter, and HTTP client against controlled peers: allowed edits succeed, account and forged-authority calls produce no mutation, revocation prevents retries, and accepted results survive cancellation.

Evidence

What I checked:

  • Introduced authority boundary: The pinned introduction diff adds operator-only scheduled channel-edit admission, requires registered writer support, and projects senderIsOwner only into the admitted adapter context. (src/channels/plugins/message-action-dispatch.ts:469, 4c1df7ac6bbd)
  • Final HTTP request enforcement: Discord captures the host assertion before queueing and invokes it immediately before HTTP execution; queued retries retain that assertion. Accepted responses settle without a subsequent authority rejection. (extensions/discord/src/internal/rest.ts:239, 4c1df7ac6bbd)
  • Scheduler and cancellation proof: The captured PR body records six passing scheduler scenarios on e95ace9ce0841849a2e29f87bad86fe49bbd98cb, including authenticated PATCH requests, persisted cron.update disablement, rejection before a 429 retry, and successful settlement after the original MCP signal aborts. Inspected head assertions verify those outcomes. The reported contribution-file equality to that execution revision could not be independently compared because that historical object was unavailable; this is a reviewer limitation, not missing contributor proof. (test/cron-message-read.integration.test.ts:617, 4c1df7ac6bbd)
  • Forbidden principals and compatibility controls: Retained execution output and inspected integration cases cover account-job and forged-sender denial without PATCH, named-target denial without provider requests, missing writer declarations, plugin replacement during lookup, and provider permission rejection. Captured discussion identity: sourceRevision 7580197305fe01356a2430abc549f71cc422c7784a002611c201c2bbf52a07b5. (test/cli-message-authority.integration.test.ts:791, 4c1df7ac6bbd)
  • SDK acceptance requirement: The SDK guide requires SDK and security-owner acceptance when widening a capability's authority boundary. The new optional writer declaration is documented, and omission preserves denial of scheduled administration rather than breaking adapter source compatibility. (src/plugin-sdk/AGENTS.md:75, 4c1df7ac6bbd)
  • Review continuity: The previous review of the same head had no findings and requested SDK/security-owner acceptance. The refreshed reviews endpoint returned no submitted reviews, and the supplied body does not record that acceptance. (4c1df7ac6bbd)

Likely related people:

  • openclaw/openclaw-secops: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • JC: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record SDK/security-owner acceptance of the writer authority and adapter compatibility contract.

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 (5 earlier review cycles)
  • reviewed 2026-09-16T17:12:48.024Z sha 3652264 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-16T20:27:51.381Z sha b7050b3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-16T21:04:14.874Z sha b7050b3 :: blocked before merge. :: none
  • reviewed 2026-09-17T02:47:24.073Z sha b7050b3 :: blocked before merge. :: none
  • reviewed 2026-09-17T02:58:30.104Z sha 4c1df7a :: blocked before merge. :: none

@shakkernerd
shakkernerd force-pushed the fix/scheduled-message-reads branch from dbd5c6b to be56ced Compare September 16, 2026 20:11
@shakkernerd
shakkernerd force-pushed the fix/scheduled-channel-admin branch from 3652264 to b7050b3 Compare September 16, 2026 20:17
@shakkernerd shakkernerd self-assigned this Sep 16, 2026
@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
Base automatically changed from fix/scheduled-message-reads to main September 17, 2026 02:37
@shakkernerd
shakkernerd force-pushed the fix/scheduled-channel-admin branch from b7050b3 to 4c1df7a Compare September 17, 2026 02:48
@shakkernerd
shakkernerd merged commit 23a09df into main Sep 17, 2026
216 of 219 checks passed
@shakkernerd
shakkernerd deleted the fix/scheduled-channel-admin branch September 17, 2026 04:14
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: scheduled jobs created by an operator can edit Discord channels with live permission checks and preserved accepted results after cancellation.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
Enable Discord channel edits for scheduled jobs created by an operator. Preserve live job and plugin checks before further requests and keep accepted results when the caller is canceled.

Refs openclaw#140978.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant