Skip to content

fix: restore scheduled Discord message writes - #150191

Merged
shakkernerd merged 3 commits into
mainfrom
fix/scheduled-message-writes
Sep 17, 2026
Merged

shakkernerd merged 3 commits into
mainfrom
fix/scheduled-message-writes

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Scheduled jobs permitted to use message can still fail to edit, delete, pin, or unpin Discord messages through an official installed plugin. These actions previously required an inbound conversation even when the job had a recorded principal and Discord could authorize its target. This addresses the scheduled message management portion of #140978.

This contribution uses the scheduled grants established by #150166 and #150278, together with the SDK writer contract and settlement behavior from #150182. The account and SDK contributions are independent prerequisites.

User Impact

Eligible scheduled jobs can perform all four actions. Account jobs retain their recorded creator account, creator origin, and delegated target policy; trusted operator jobs use operator target policy. Discord action settings, target restrictions, and bot permissions continue to apply.

An omitted accountId selects the saved creator before credential preparation and Gateway routing, even when delivery or provider defaults name another account. Request deduplication uses that same account, so two saved accounts cannot accidentally share a write result. Explicit account arguments retain their existing validation and scope checks.

The shared writer lifetime preserves a confirmed mutation's result after job or caller cancellation while stopping later requests and retries. Existing interactive actions and bundled provider paths retain their admission behavior; older installed adapters require the supported write declaration for scheduled writes.

Why This Change Was Made

Discord enrolls edit, delete, pin, and unpin through the optional SDK declaration ChannelMessageActionAdapter.writeAuthorityActions. Host admission remains specific to each action and uses active plugin registration, the private scheduled grant, and provider checks for target authorization. Account jobs do not acquire an owner flag.

The account correction belongs at the existing preparation and routing owners: validate the selected account before resolving secrets, carry it through the message action, and bind the request key to it. Read completion fencing remains separate from write settlement. Canonical cron and SDK docs describe the supported actions, policy, and plugin upgrade requirements.

Evidence

  • The current replay is a9b9f5f on main 1c9914a, with all prerequisites and fix: allow dashboard reads through official plugins #150309 effective. Independent review accepted the dashboard integration, and all seven fast preflight categories passed in 21.40 seconds. The exact replay passed 23 existing context/account cases on Blacksmith Testbox: 16 message-tool execution cases and seven Gateway write-account cases, including all four default-account changes, explicit-account rejection and same-key account isolation. The native command exited 0. Focused current-head run.

  • The earlier replay, 60b6a15, passed 22 tests across the execution fixture and its existing scheduled-account sibling after the upstream fixture integration. Vitest took 20.32 seconds; the native command exited 0 in 106.76 seconds. Focused replay check.

  • Additional Blacksmith Testbox validation passed the existing eight scheduler scenarios on the composition of main revision a90b969, the corrected run-bound issuer, and both account and writer prerequisites. Every CLI row includes a controlled 120-second clock advance before tools/list; cancellation before a 429 retry, confirmed success after the original caller aborts, and both account rows passed. Vitest took 76.64 seconds, and the native command exited 0 in 169.55 seconds. Integrated scheduler run.

  • The earlier consumer replay was qualified against source 102787f. The subsequent upstream location-fixture changes passed the focused replay check above. The current integration retains the reviewed contribution and account controls, with the two explicit source adjustments described above.

  • The account prerequisite's later bridge passed all four existing operator/account × CLI/embedded read journeys on main 9a44681 plus its account contribution, tree 6011f69f78b34fedb212b69a64e536c97c0db156. Current model/configuration producer check. Subsequent caller, configuration, loader, registration, and settlement changes were source-qualified against the unchanged contribution; these checks retain their original execution identities.

  • Retained native Blacksmith Testbox validation passed 167 tests across eight files on the exact source tree committed as 102787fc731ff7ad17ae35f75c3da26e6cab0fae. The test run took 120.08 seconds; the delegated native command exited 0 in 422.07 seconds. Runner context.

  • The run includes all eight real scheduler scenarios across CLI/MCP and embedded execution, account creation and delivery independence, job disablement during a 429 retry, and accepted-write settlement after the original MCP request signal aborts. It also covers 47 CLI/MCP cases, direct Gateway account routing, credential selection, Discord metadata siblings, and registered writer/request lifetime controls.

  • Controlled regressions fail on the earlier source: all four writes resolve credentials before rejecting a missing account; all four select the wrong provider default after it changes; two saved accounts sharing a key produce only the first pin request. The corrected cases pass, including positive credential identity for both accounts and unchanged ordinary-send account behavior.

  • The existing integration fixture verifies the request methods and routes for all four actions under both principal modes, edit payloads, action/account/target denials, directory lookup, provider permission denial without replay, and adapter compatibility. Installer provenance and scheduled source lifetime are explicit fixture seams; this evidence makes no live Discord permission claim.

  • Retained independent source, test, and integration reviews found no remaining P0–P2 findings. Their applicability follows the preserved contribution and the fresh review of its two dashboard-integration adjustments. Changed-path formatting, focused syntax and boundary lint, line caps, whitespace and MDX checks passed on the committed replay; no baseline or assertion exception was added.

  • Retained remote production and root-test typing on qualified source 102787f passed, together with the agents-tools and gateway-other test graphs selected for the changed source tests. The paired graphs ran with concurrency two on the observed worker. Type-check runner.

  • CI passed on qualified source 102787fc731f, including full core-test type coverage. The retained P0–P2 automated review and the fresh integration review are clean. ClawSweeper Revision 9 reviewed current head a9b9f5f: Platinum 4/6, proof Diamond 5/6, no correctness or security findings.

  • Current-head CI completed with one unrelated Linux Doctor fixture failure and its aggregate; all other selected CI lanes succeeded. The executed merge was d12a51c20a9d5bac64ad95191088bc6d9c49b88f on main 7d2933b. That unchanged main revision reproduced the same failure: the old test double permits only busctl, while the service-inspection change in fix(update): continue when service inspection is unavailable #150494 also asks systemctl to classify an unavailable manager. The four-case baseline run produced three passes and that same failure, with native exit 1. Source and dependency inspection establish that the message-write contribution does not cause it. The failed checks remain recorded as failures.

  • A fresh Blacksmith Testbox run passed the existing eight scheduler scenarios on composition 17884b38c9c4504b639763095482fb0db9216d9f, tree 1e625a9b26e536345fea6b535a5acf728656fefd, combining main 7885f84 with the prior public contribution. CLI/MCP and embedded, operator/account, controlled 120-second discovery delay, disabled-job retry and accepted-write settlement all passed. Vitest took 47.50 seconds; the native command exited 0 in 103.82 seconds. Fresh scheduler run. Subsequent MCP requester/connection cleanup and the dashboard integration were source-qualified for these actual routes; this is not a claim that those later revisions were executed in that run.

Observed native execution output

Selected lines from the retained run above, with ANSI styling removed.

{"sourceTree":"a1364c529ceb9a3042137d659162b5213bbe7a4d","cpus":4,"memoryGiB":15}
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > dispatches edit through the provider route for a trusted scheduled job 20ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > dispatches delete through the provider route for a trusted scheduled job 17ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > dispatches pin through the provider route for a trusted scheduled job 17ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > dispatches unpin through the provider route for a trusted scheduled job 24ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > dispatches edit through the provider route for a account scheduled job 18ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > dispatches delete through the provider route for a account scheduled job 16ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > dispatches pin through the provider route for a account scheduled job 17ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > dispatches unpin through the provider route for a account scheduled job 16ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > denies another configured account before message mutation 14ms
 ✓  tooling  test/cli-message-authority.integration.test.ts > CLI message authority integration > scheduled message management > settles an accepted delete after job permission revocation and blocks the next call 18ms
 ✓  gateway-database-workers  src/gateway/server-methods/send.scheduled-reads.integration.test.ts > Gateway scheduled write accounts through an installed Discord plugin > keeps same-key pins separate for different saved accounts 6ms
 ✓  infra  test/cron-message-read.integration.test.ts > scheduled message actions > blocks a Discord 429 retry after cron.u… 1285ms
 ✓  infra  test/cron-message-read.integration.test.ts > scheduled message actions > preserves an accepted Discord edit afte… 2092ms
 ✓  infra  test/cron-message-read.integration.test.ts > scheduled message actions > account/claude-cli/channel-info 1600ms
 ✓  infra  test/cron-message-read.integration.test.ts > scheduled message actions > account/openclaw/read 1322ms
 ✓  agents-tools  src/agents/tools/message-tool-execution.test.ts > rejects a missing scheduled account before resolving another provider's credentials for edit 4ms
[test] passed 6 Vitest shards in 120.08s
blacksmith run summary sync=delegated command=7m2.069s total=7m2.341s exit=0

The issuer, SDK, and account prerequisites are landed through #150166, #150182, and #150278. The contribution remains scoped to its own eleven files on main. The current integration has passing focused account/context proof, clean review and exact-head Platinum ClawSweeper evidence. The remaining CI failure is independently reproduced and attributed to its unchanged-main fixture; it does not change this contribution's behavior.

Recovery after an ambiguous lost Discord response remains tracked separately in #127536. The settlement evidence above covers confirmed provider success and authority cancellation; it does not claim that retry-recovery issue is resolved.

@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 agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Sep 16, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 17, 2026, 4:15 AM ET / 08:15 UTC (Revision 9).

ClawSweeper review

What this changes

Restores scheduled Discord message editing, deletion, pinning, and unpinning while preserving the creator account through credential selection, authorization, and request deduplication.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded repair that current main does not provide. No actionable correctness or security defect was found, and retained production-path evidence supports the changed authority boundary.

Priority: P2
Reviewed head: a9b9f5f05aebdfe6948bcb919c26547cf85d69a6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with strong retained boundary proof, useful regression coverage, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Retained Testbox evidence exercises the real message tool, authenticated MCP/Gateway path, Discord adapter, and HTTP transport with controlled provider responses. It demonstrates allowed writes, forbidden account/target rejection, revocation blocking later I/O, and accepted-write settlement; the current replay preserves those controls without claiming a fresh runtime execution.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Retained Testbox evidence exercises the real message tool, authenticated MCP/Gateway path, Discord adapter, and HTTP transport with controlled provider responses. It demonstrates allowed writes, forbidden account/target rejection, revocation blocking later I/O, and accepted-write settlement; the current replay preserves those controls without claiming a fresh runtime execution.
Evidence reviewed 9 items Pinned contribution and clean checkout: The reviewed checkout matches the pinned original head. The merge-base delta contains the scheduled-write contribution; unrelated base-branch changes were excluded. Whitespace validation passed and the checkout remained clean.
Current main still lacks these scheduled writes: Current main's host eligibility predicate permits only channel-edit, and Discord's declaration likewise contains only channel-edit. The merged read, account, dashboard, and writer prerequisites therefore do not supersede this contribution.
Latest-release comparison: The supplied latest release's Discord adapter declares provider-owned read gates but has no scheduled write-authority declaration; it does not contain this installed-plugin repair.
Findings None None.
Security None None.

How this fits together

Scheduled agents invoke the shared message tool through embedded execution or authenticated MCP requests. The Gateway checks job and plugin authority before Discord applies its account, target, and provider-permission rules.

flowchart LR
  A[Scheduled agent] --> B[Message tool]
  B --> C[Saved creator account]
  C --> D[Gateway job authority]
  D --> E[Registered Discord plugin]
  E --> F[Target and request checks]
  F --> G[Discord message mutation]
  G --> H[Confirmed result]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +39, Tests +562, Docs +13. Total +614 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 59 20 +39
Tests 4 659 97 +562
Docs 2 32 19 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 750 136 +614

Review metrics

Metric Value Why it matters
Production versus test growth Production net +39 lines; tests net +562 lines Production growth extends existing admission owners; most added coverage exercises account isolation, forbidden targets, settlement, and adapter compatibility.

Technical review

Best possible solution:

Use the existing scheduled grant and writer lifetime for these actions, preserving creator-account selection, provider target restrictions, and confirmed mutation results.

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

Yes, from source: a scheduled grant without inbound conversation context cannot admit these four writes through the installed Discord adapter on current main. This review did not execute a reproduction.

Is this the best way to solve the issue?

Yes. The patch extends the existing scheduled authority and account-selection owners instead of introducing a parallel permission mechanism, with meaningful boundary coverage.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs a bounded scheduled Discord message-management failure without evidence of a broader outage.
  • 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 Testbox evidence exercises the real message tool, authenticated MCP/Gateway path, Discord adapter, and HTTP transport with controlled provider responses. It demonstrates allowed writes, forbidden account/target rejection, revocation blocking later I/O, and accepted-write settlement; the current replay preserves those controls without claiming a fresh runtime execution.
  • proof: sufficient: Contributor real behavior proof is sufficient. Retained Testbox evidence exercises the real message tool, authenticated MCP/Gateway path, Discord adapter, and HTTP transport with controlled provider responses. It demonstrates allowed writes, forbidden account/target rejection, revocation blocking later I/O, and accepted-write settlement; the current replay preserves those controls without claiming a fresh runtime execution.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (8 earlier review cycles)
  • reviewed 2026-09-16T17:26:22.638Z sha c0ce79c :: blocked before merge. :: none
  • reviewed 2026-09-16T18:00:33.718Z sha c0ce79c :: blocked before merge. :: none
  • reviewed 2026-09-16T20:49:16.362Z sha 102787f :: blocked before merge. :: none
  • reviewed 2026-09-16T21:00:01.064Z sha 102787f :: blocked before merge. :: none
  • reviewed 2026-09-16T21:15:34.622Z sha 102787f :: blocked before merge. :: none
  • reviewed 2026-09-17T05:13:59.182Z sha 60b6a15 :: blocked before merge. :: none
  • reviewed 2026-09-17T05:42:38.667Z sha 5a5115e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-17T06:37:34.360Z sha 5a5115e :: needs maintainer review before merge. :: none

@shakkernerd
shakkernerd force-pushed the fix/scheduled-channel-admin branch from 3652264 to b7050b3 Compare September 16, 2026 20:17
@shakkernerd
shakkernerd requested a review from a team as a code owner September 16, 2026 20:17
@shakkernerd
shakkernerd force-pushed the fix/scheduled-message-writes branch from c0ce79c to 102787f Compare September 16, 2026 20:40
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XL and removed size: L labels Sep 16, 2026
@shakkernerd
shakkernerd changed the base branch from fix/scheduled-channel-admin to fix/scheduled-account-reads September 16, 2026 20:42
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 16, 2026
@shakkernerd
shakkernerd force-pushed the fix/scheduled-account-reads branch 2 times, most recently from 2c85b0f to 4ce184f Compare September 17, 2026 02:51
@shakkernerd
shakkernerd force-pushed the fix/scheduled-account-reads branch 2 times, most recently from 3dcd846 to 0b628f7 Compare September 17, 2026 04:37
@shakkernerd
shakkernerd force-pushed the fix/scheduled-message-writes branch from 102787f to 60b6a15 Compare September 17, 2026 05:06
Base automatically changed from fix/scheduled-account-reads to main September 17, 2026 05:21
@shakkernerd
shakkernerd force-pushed the fix/scheduled-message-writes branch from 60b6a15 to 5a5115e Compare September 17, 2026 05:32
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 17, 2026
@shakkernerd shakkernerd self-assigned this Sep 17, 2026
@shakkernerd
shakkernerd force-pushed the fix/scheduled-message-writes branch from 5a5115e to a9b9f5f Compare September 17, 2026 08:05
@shakkernerd
shakkernerd merged commit 50720cb into main Sep 17, 2026
216 of 218 checks passed
@shakkernerd
shakkernerd deleted the fix/scheduled-message-writes branch September 17, 2026 09:04
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Scheduled jobs can edit, delete, pin, and unpin Discord messages with the intended account and permission checks.

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 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: L 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