Skip to content

refactor(channels): deslop discord and slack second pass - #158085

Merged
steipete merged 2 commits into
mainfrom
deslop/l45-discord-slack-second-pass
Sep 25, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/l45-discord-slack-second-pass

Conversation

@steipete

@steipete steipete commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Maintainer-requested second-pass cleanup removes redundant execution paths and obsolete private adapters from the Discord and Slack plugins, following the first passes in #156579 and #156773.

User Impact

The refactor preserves authorization and pairing, interaction/webhook verification, credential precedence and diagnostics, outbound formatting and rate limits, command registration, public exports, configuration, tool schemas, and persisted state. The accompanying Slack fix keeps a replacement webhook handler registered when cleanup from an older registration runs again.

Why This Change Was Made

  • Discord component send/edit now share preparation, transport error mapping, registry updates, and activity recording, while create-only nonce protection, send authority and delivery callback ordering remain explicit.
  • Discord action discovery uses ordered action groups and one account-gate path. Secret-target descriptors use the existing SDK owner without changing their paths, order, or metadata.
  • Remove unused private Carbon-era one-off component waiters, entity mutation helpers, ignored client options, and cast-only interaction adapters. Public compatibility exports remain.
  • Consolidate Discord presence rendering, thread refetching, native fallback construction, reply options, status reactions, and system-event formatting.
  • Slack message sends share per-part posting and receipt handling across native blocks, fallback cards/text, and ordinary chunks. Keep transport-specific metadata, identity fallback, broadcast and thread handling intact.
  • Slack interaction events share enqueue/wake handling; setup, diagnostics, prepared message context, and chart/table fallbacks reuse their existing owners.
  • Delete private forwarding modules and duplicate local helpers in both plugins, migrating consumers and mocks directly to the documented SDK or plugin owner. Lazy imports remain lazy. No SDK export changes.

Fixes found along the way

Slack's HTTP route disposer previously deleted whichever handler currently occupied its path. Reusing an old disposer after replacement could remove the new route. Cleanup is now idempotent and tied to its captured registry/handler. The regression invokes the registered HTTP dispatch boundary, deliberately reuses the same callback for the replacement, and verifies both replacement survival and normal removal.

Resolution against current main

Rebased onto 9e5c2e2458416d5491be7135757f92151592bfe2, including #157185 (8518d3913e4). Only the four pre-authorized files conflicted.

  • Discord message-handler.hydration.ts: use main byte-for-byte. Drop this PR's older merge/fallback/parser cleanup; main's direct native Message construction supersedes it. No old hydration helper is restored.
  • Slack prepare-thread-context.ts: keep main's inline thread-history and bot-root handling. Retain only the direct openclaw/plugin-sdk/session-store-runtime import for readSessionUpdatedAt and resolveChannelResetConfig, because this PR deletes the old forwarding module that re-exported those exact helpers.
  • Slack prepare-thread-context-root.ts: use main byte-for-byte and drop this PR's predicate/policy simplifications. Upstream retained a 24-line isSlackThreadAuthorCurrentBot owner used by thread context and room history; it did not delete the file. The six removed helper exports stay removed.
  • Assertion ledger: regenerated with scripts/check-assertion-safety-ratchet.mts --base origin/main --prune, then enforced the coordinator’s shrink-only rule. Every retained row matches the current count; 28 allowances are removed relative to main. The tool found one inherited, unlisted assertion in unchanged src/gateway/server-methods/send.ts; its row stays absent as on main rather than adding an allowance. The canonical verification command passes.

The automatically merged Discord run-queue hunk retains only the approved single-use cancellation-wrapper inline, preserving main's new prepared context/job ownership.

Evidence

Current rebased head: 6108a3f3104a3554bdabbac429065fdbb2c72afe. Independent review of the complete rebased diff through P2 is clean. Production shortstat against the pinned main is 187 files, +1,566/-3,332, net -1,766 lines; test/support remains net -134.

Fresh proof on Blacksmith Testbox tbx_01m3cgct955ekj7484g8mw0bzw (lease workflow); the lease is stopped:

  • pnpm test:extensions:batch discord: 297 files / 4,210 tests passed in 169 seconds.
  • pnpm test:extensions:batch slack: 174 files / 3,136 tests passed in 130 seconds.
  • Seven focused hydration, preflight, queue, ingress-recovery, thread-context, root-identity, and room-history files: 200 tests passed in 31 seconds using node scripts/run-vitest.mjs.
  • Canonical ledger regeneration and verification passed. The verified ledger SHA-256 is 78e0afa6eb53c85ad548e46c6e2a6df428aa9f6972c9371ca011fa755dc3a3b6, identical locally and remotely.
  • node scripts/check-changed.mjs passed its earlier selected stages, then stopped at the existing core agents-root inventory: 721 roots, limit 720. This PR changes neither those roots nor their configs/guard. A same-Testbox A/B reproduced the identical 721/720 message and exit 1 on both the candidate and clean base 9e5c2e2458416d5491be7135757f92151592bfe2, using separate physical frozen dependencies for the base. An initial shared-install probe was rejected by the declaration-ownership guard and is not counted as baseline proof. The repository's documented policy makes size/count limits advisory only in actual GitHub Actions; no limit, baseline, or environment signal was altered. The full delegated changed-file gate is not claimed green. Fresh exact-head CI completed the remaining type/lint/architecture gates successfully under the repository’s existing GitHub Actions policy.

The previously approved head 57b4fe6937481a66b6e0b52209ce731eb193d1e2 passed CI, including openclaw/ci-gate; the rebased head passed exact-head CI, including openclaw/ci-gate (112 successful jobs).

Earlier CI found two type-import cycles repaired in this PR, and an unrelated model-discovery fixture failure fixed upstream by #158115. No production model-catalog change is included.

Prior scoped proof:

Blacksmith Testbox tbx_01m3bst4eh467kks5c3q5xb8km (lease workflow):

  • pnpm build: passed in 576 seconds, including plugin assets, declarations, bootstrap import checks, and SDK generation.
  • node scripts/run-vitest.mjs cross-shard consumer selection: 15 files across five shards passed in 143 seconds, covering read authority, transcript lifecycle, secret targets, bundled plugin shape, and public runtime exports.
  • Slack route-disposal regression: failed on the original implementation (7 passed / 1 failed), then passed 8/8 after the fix. Remote standalone file wall time: 2 seconds.
  • Independent Codex review through P2: scoped-clean. No accepted/actionable findings remain.
  • pnpm test:extensions:batch discord: 298 files / 4,213 tests passed in 130 seconds.
  • pnpm test:extensions:batch slack: 174 files / 3,152 tests passed in 118 seconds. Final hosted CI also passed the full Discord and Slack selections; the timing table below records changed-file test execution from that run.
  • node scripts/check-changed.mjs: passed on replacement Testbox tbx_01m3bzgh6byb0cc7cbykkxk0nm (lease workflow), including production/test types, full extension/tooling lint (zero warnings/errors), dead exports, runtime import cycles, ratchets, storage and plugin boundaries. The original lease had completed before this last run could start.
  • After the final mechanical lint corrections, six focused files passed 135 tests covering Discord command options, secret descriptors, gateway/components, and Slack slash/audio paths. The earlier full-batch and build proof is reused for unaffected behavior.
  • The first hosted CI run found two type-import cycles that the runtime-only changed-file gate does not include. Move the unchanged request data type to the serializer leaf, and define a voice listener contract explicitly implemented by its manager. All private consumers now import their contract owner directly. The exact GOGC=30 GOMEMLIMIT=3GiB pnpm check:architecture command now passes, including Madge (zero cycles); independent review of this repair is scoped-clean through P2.
  • Final repair proof on Blacksmith Testbox tbx_01m3c3zzs8s0mc9t6n00dtxbpb (lease workflow): the full architecture command, node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfo, and targeted node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json over the ten changed repair files all passed. node scripts/run-vitest.mjs extensions/discord/src/internal/api.test.ts extensions/discord/src/internal/rest.test.ts extensions/discord/src/voice/manager.ready-listener.test.ts passed 3 files / 63 tests in 55.16 seconds. The combined frozen-install and proof payload completed in 841 seconds.
  • Initial plugin-batch failures exposed fixture cutovers: recursive real-sender mocks after barrel removal, explicit optional-argument expectations, and a hoisted SDK mock. These now pass in both full batches and standalone runs. Three oversized fixtures now shrink by removing copied parser/default mock logic and sharing ordered stream-call collection. No assertions, retries, timeouts, or coverage were weakened. The production typecheck also caught two annotations, corrected at their owners before the final gate.

Production change after the authorized rebase: 1,766 net lines removed; test/support change: 134 net lines removed. The assertion allowance ledger decreases by 28, confined to these plugins. No SDK export changes. All 180 production files over 200 lines were read during the scoped sweep, along with the smaller modules. All three deslop proof leases are stopped. The separate clean-main diagnosis used Blacksmith Testbox tbx_01m3c688ds0hpwyba4t6cdm21t (lease workflow), which is also stopped.

Standalone changed-test cost

Measured with pnpm test <file> --maxWorkers=1 on Testbox. Wall time includes runner startup; the new route-registry regression performs no I/O, polling, or sleeps. Other test changes update fixtures and preserve their existing assertions. CI test seconds below sum the verbose reporter’s per-test durations for each file on the previously approved head 57b4fe69374; they exclude import/setup time and are not wall time.

File under extensions/ Standalone wall seconds CI test seconds
discord/src/actions/message-bodies.test.ts 24 0.448
discord/src/actions/runtime.test.ts 20 1.128
discord/src/internal/client.test.ts 20 0.272
discord/src/internal/interactions.test.ts 20 0.339
discord/src/monitor/listeners.thread-update.test.ts 25 0.484
discord/src/monitor/provider.startup.test.ts 19 0.016
discord/src/monitor/provider.test.ts 19 0.556
slack/src/actions.download-file.test.ts 20 0.001
slack/src/actions.read.test.ts 20 0.001
slack/src/channel-type.test.ts 2 0.014
slack/src/channel.outbound-preparation.test.ts 18 0.005
slack/src/channel.test.ts 16 0.098
slack/src/http/registry.test.ts 2 0.002
slack/src/monitor/allow-list.test.ts 2 0.000
slack/src/monitor/dm-auth.test.ts 16 0.003
slack/src/monitor/events/interactions.test.ts 18 0.466
slack/src/monitor/media.test.ts 17 0.165
slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts 23 2.862
slack/src/monitor/message-handler/prepare.test.ts 19 5.662
slack/src/monitor/provider.reconnect.test.ts 16 0.021
slack/src/monitor/relay-source.test.ts 18 2.634
slack/src/monitor/slash.test.ts 21 2.204
slack/src/monitor/thread-history.test.ts 1 0.003
slack/src/outbound-delivery.test.ts 20 0.793

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: slack Channel integration: slack size: XL labels Sep 25, 2026
@steipete
steipete marked this pull request as ready for review September 25, 2026 10:56
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 25, 2026, 11:23 AM ET / 15:23 UTC (Revision 5).

ClawSweeper review

What this changes

The branch consolidates Discord and Slack plugin messaging and interaction code, removes private forwarding helpers, and ties Slack webhook cleanup to the registration that created it.

Merge readiness

⛔ Blocked before merge - 3 items remain

Current main still has the Slack route-disposal defect, and the earlier merged cleanup PRs do not cover this second pass. The inspected changes show no actionable introduced defect.

Priority: P3
Reviewed head: 6108a3f3104a3554bdabbac429065fdbb2c72afe

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused route regression, broad reported boundary validation, and contract-preserving source changes support a good review rating.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The Repository State identifies a MEMBER author, so the external-contributor proof gate does not apply. The reported Testbox runs cover plugin paths and the registered Slack HTTP dispatch regression with synthetic clients; no live workspace result is claimed. No stored-data contract changes were found.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The Repository State identifies a MEMBER author, so the external-contributor proof gate does not apply. The reported Testbox runs cover plugin paths and the registered Slack HTTP dispatch regression with synthetic clients; no live workspace result is claimed. No stored-data contract changes were found.
Evidence reviewed 9 items Current-main gap: The disposer on current main deletes whichever handler occupies the path, so an older disposer can remove a replacement registration.
Introduced route repair: The proposed disposer is single-use and checks its captured registry and handler before deleting a route.
Regression boundary: The new regression registers a replacement with the same callback, invokes the older disposer again, and checks registered HTTP dispatch and normal removal.
Findings None None.
Security None None.

How this fits together

The Discord and Slack plugins turn platform events into authorized agent turns and deliver replies through each platform. Slack's HTTP route registry selects the webhook handler before an incoming event reaches the plugin.

flowchart LR
A[Slack webhook] --> B[Slack route registry]
B --> C[Plugin policy checks]
D[Discord event] --> C
C --> E[Agent turn]
E --> F[Plugin reply delivery]
F --> G[Platform API]
Loading

Before merge

  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

None.

Stored data model

Persistent data-model change detected: unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep the channel responsibilities in their existing plugins and retain the registration-specific Slack route cleanup with its dispatch-level regression.

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

Yes. Current-main source shows that an older Slack route disposer can delete a replacement, and the PR adds a registered-dispatch regression for that sequence; I did not execute it in this read-only checkout.

Is this the best way to solve the issue?

Yes. Capturing the registration and making its disposer single-use repairs the route lifecycle at its owner, while direct SDK exports remove forwarding without changing the inspected contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 25d74027a95d.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is primarily a behavior-preserving plugin cleanup with one bounded route-lifecycle repair.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The Repository State identifies a MEMBER author, so the external-contributor proof gate does not apply. The reported Testbox runs cover plugin paths and the registered Slack HTTP dispatch regression with synthetic clients; no live workspace result is claimed. No stored-data contract changes were found.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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 (4 earlier review cycles)
  • reviewed 2026-09-25T11:05:09.549Z sha b74c94b :: blocked before merge. :: none
  • reviewed 2026-09-25T11:56:12.091Z sha 9406d6e :: blocked before merge. :: none
  • reviewed 2026-09-25T13:39:42.711Z sha 57b4fe6 :: blocked before merge. :: none
  • reviewed 2026-09-25T14:04:47.864Z sha 57b4fe6 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 25, 2026
@steipete
steipete force-pushed the deslop/l45-discord-slack-second-pass branch from 9406d6e to 57b4fe6 Compare September 25, 2026 13:31
Consolidate transport preparation, result projection, interaction handling,
and private SDK helper ownership after #156579 and #156773. Preserve
channel authorization, registration payloads, credentials, public exports,
and persisted state.

Fix stale Slack HTTP route disposal so repeated cleanup cannot unregister
a replacement handler. Keep a boundary regression for same-callback
re-registration and preserve transport assertions through fixture cutovers.
Move RequestData to its serializer owner and import it directly from private
consumers. Give voice listeners a leaf contract implemented by the manager,
removing both type-import cycles reported by the architecture CI gate.

Preserve request fields, listener method signatures, and runtime behavior.
@steipete
steipete force-pushed the deslop/l45-discord-slack-second-pass branch from 57b4fe6 to 6108a3f Compare September 25, 2026 15:15
@steipete
steipete merged commit 38c0f85 into main Sep 25, 2026
198 checks passed
@steipete
steipete deleted the deslop/l45-discord-slack-second-pass branch September 25, 2026 15:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…8085)

* refactor(channels): deslop discord and slack second pass

Consolidate transport preparation, result projection, interaction handling,
and private SDK helper ownership after openclaw#156579 and openclaw#156773. Preserve
channel authorization, registration payloads, credentials, public exports,
and persisted state.

Fix stale Slack HTTP route disposal so repeated cleanup cannot unregister
a replacement handler. Keep a boundary regression for same-callback
re-registration and preserve transport assertions through fixture cutovers.

* fix(discord): keep shared transport contracts acyclic

Move RequestData to its serializer owner and import it directly from private
consumers. Give voice listeners a leaf contract implemented by the manager,
removing both type-import cycles reported by the architecture CI gate.

Preserve request fields, listener method signatures, and runtime behavior.
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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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