Skip to content

refactor: simplify channel reply context handling - #157185

Merged
steipete merged 3 commits into
mainfrom
codex/channel-context-deslop
Sep 25, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/channel-context-deslop

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Related: #157091

What Problem This Solves

Removes obsolete Discord message adaptation and duplicate inbound-context scaffolding around Discord, Slack, and shared reply handling.

User Impact

No intended behavior change. Bot-message defaults, reply-parent context, access filtering, history limits, and cancellation/retry behavior remain intact. No configuration or data migration is required.

Why This Change Was Made

Discord hydration uses its native API payload instead of reconstructing fields through legacy casts and fallbacks. The in-memory queue carries prepared context directly; durable raw-message persistence remains with ingress. Slack thread preparation owns its single-caller bot-root and filtering decisions.

Tests construct typed native Discord messages, reuse preflight fixtures, and assert literal context/media contracts instead of duplicating production normalization. Public SDK compatibility paths remain intact. Net reduction: 1,269 lines (370 production, 897 tests/support, and two obsolete assertion-baseline entries).

Evidence

Current refresh 0267ba4e incorporates main 9fdb24bb, including the owning ratchet-test fix. It preserves the newer legacy-MediaUrl attachment regressions and main’s delivery-format-prompt test ownership while retaining the original cleanup. CI 36140986758 passed on this exact revision. Fresh ClawSweeper review reported no findings, and the native workflow verified the squash merge as 8518d391. The separately recorded boundary-run evidence below belongs to the incoming head.

  • Incoming-head boundary run: 273 passing cases across 13 files. Covers Discord preflight, queue cancellation, ACP bindings, route ownership, reply-parent context and history; Slack monitor-to-dispatcher delivery, bot admission and history policy; core quote visibility and conversation labels. These are isolated synthetic transport/dispatcher proofs, not live Discord or Slack observations.
  • Initial focused run: 306 passing cases across nine files, with the three ingress failures described below. Core context, metadata and media suites, Slack thread context, and Discord hydration all passed.
  • Independent Codex review completed. Its actionable mention-fixture fidelity finding was corrected and re-reviewed clean. The initial provider-coverage concern was rejected after inspecting the actual helper: those cases never called provider adapters or asserted routing fields; literal core expectations and real adapter boundary suites retain the contracts.
  • Fresh independent Codex review covered the complete refreshed candidate. Its proposed preservation of a Message.channel descriptor was rejected after tracing the production entry point: raw MESSAGE_CREATE payloads pass through durable ingress, whose mapper constructs a native Message without that property. The exported handler uses the same raw-payload path; the private preflight fallback does not establish a producer. The original review finding and the source-based disposition are retained; no unsupported compatibility shim was added.
  • CI on the initial revision found incomplete API test fixtures, a map/spread lint violation, and stale assertion allowances. The fixtures now retain supplied usernames and use typed attachment defaults; the two allowances are removed. On the corrected head, those static checks passed. The remaining CI failure is the unchanged ratchet CLI test described below.

Bounded ingress-failure assessment

The complete ingress file ran in its original order: 10 cases passed; both stale-route replacement variants timed out at 120 seconds, and the later ACP exhaustion case completed unexpectedly on its third disposition. The changed skipped-queue recovery case and the started-job cancellation cases passed. A fresh process running only the first failing replacement/ACP case passed without source changes (175.84 s wrapper wall, including transformation).

The failing matrix itself is unchanged. It runs real dispatch under fake timers, awaits dispositions without driving timers, does not pass cancellation into that dispatch, and reuses target session keys across replacement/exhaustion cases. Timed-out asynchronous work can therefore affect later cases. Source comparison confirms the queue refactor preserves every fixture-consumed message, route, config, lifecycle, and signal value. The isolated pass does not prove a fix or establish the exact cause; the full-file failure remains an unresolved test-reliability concern. No assertions, timeouts, or expected outcomes were weakened.

Measured changed-test cost

Incoming-head measurements with the supported repository runner, one file per invocation and --maxWorkers=1 (equivalent to pnpm test <file> --maxWorkers=1). Wall times include this host's cold transforms and worker-generation verification; several runs spent 86–97% of worker duration transforming modules. The final grouped boundary run took 507.18 s across four routed shards.

Changed suite Local wrapper wall Result
Discord hydration 714.74 s passed
Discord ingress recovery 468.40 s 10 passed; 3 failed
Discord preflight 260.76 s passed
Discord queue 273.14 s passed
Slack bot identity 19.52 s passed
Slack thread context 322.13 s passed
Core inbound context 656.21 s passed
Core inbound metadata 250.76 s passed
Core inbound media 17.94 s passed

Initial CI run: https://github.com/openclaw/openclaw/actions/runs/35983089503. It exposed the three static-check failures above; its passing jobs do not establish that the locally failing ingress matrix passed. The incoming-head CI run is https://github.com/openclaw/openclaw/actions/runs/35988263678. Its sole non-aggregate failure was checks-node-compact-small-43: the unchanged check-max-lines-ratchet worktree CLI test received context canceled on stderr despite status 0. That shard passed 1,497 other cases; its test phase took 153.71 s. The owning fix #157200 (809808b7) has since landed on main and is included in this refresh. It narrowly handles the known standalone compiler shutdown diagnostic while preserving other failures. No dependency or vendor patch is introduced here, and no required check has been bypassed. The refreshed exact-head CI completed successfully.

@clawsweeper

clawsweeper Bot commented Sep 24, 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 channel: discord Channel integration: discord channel: slack Channel integration: slack size: XL labels Sep 24, 2026
@steipete
steipete marked this pull request as ready for review September 24, 2026 09:44
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 25, 2026, 9:35 AM ET / 13:35 UTC (Revision 4).

ClawSweeper review

What this changes

The branch removes Discord's inbound-job adapter, hydrates replies from native message payloads, moves Slack bot-root history decisions into its thread preparer, and consolidates related tests.

Merge readiness

✅ Ready for maintainer review

Current main retains the adapter and queue split this PR removes, so the cleanup remains useful. The pinned diff shows no confirmed blocking defect, and the prior completed ClawSweeper review reported no findings.

Priority: P3
Reviewed head: 0267ba4ee3db761e1640eba469691260ca89893d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The cleanup is coherent and has substantial boundary coverage, with no confirmed patch defect; the available runs are synthetic rather than live-channel observations.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This repository-admin-authored internal refactor changes Discord context carried from ingress through the queue and Slack thread-history preparation; the recorded 273 synthetic boundary cases cover those paths, while live transport behavior was not observed on this head. No stored-data contract changes: Discord's durable raw-message ingress remains the persistence owner.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This repository-admin-authored internal refactor changes Discord context carried from ingress through the queue and Slack thread-history preparation; the recorded 273 synthetic boundary cases cover those paths, while live transport behavior was not observed on this head. No stored-data contract changes: Discord's durable raw-message ingress remains the persistence owner.
Evidence reviewed 8 items Pinned PR change: Discord now passes prepared preflight context directly to the run queue, while retaining ingress settlement and cancellation handling.
Production Discord entrypoint: Durable ingress maps raw MESSAGE_CREATE data to a native Message before dispatch; the exported handler also enters through ingress.
Slack policy cutover: The Slack thread preparer retains the bot-root insertion, MPIM history exception, sender filtering, and omission count in its caller.
Findings None None.
Security None None.

How this fits together

Discord and Slack monitors turn platform messages into inbound context before OpenClaw dispatches an agent turn and sends a reply. This change shapes reply-parent and thread-history context between admission and dispatch.

flowchart LR
 A[Discord and Slack messages] --> B[Channel admission]
 B --> C[Reply and thread context]
 C --> D[Channel run queue]
 D --> E[Agent turn]
 E --> F[Channel reply]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -370, Tests -897, Other -2. Total -1269 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 6 69 439 -370
Tests 11 577 1474 -897
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 2 -2
Total 18 646 1915 -1269

Review metrics

None.

Technical review

Best possible solution:

Keep channel-specific context decisions with the Discord and Slack owners, with handler-boundary coverage for reply context, filtering, and cancellation.

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

Not applicable: this refactor reports no user-facing defect to reproduce. The PR records focused synthetic boundary checks, but no live-channel observation on this head.

Is this the best way to solve the issue?

Yes: removing the private adapter and keeping Slack's thread decisions in its existing caller is a narrow simplification; the inspected settlement and filtering paths preserve their prior decisions.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is an internal simplification with no intended user-visible behavior change.
  • merge-risk: 🚨 message-delivery: Discord queue and hydration changes sit directly on the reply path, where semantic drift could affect delivery even when static checks pass.
  • 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: This repository-admin-authored internal refactor changes Discord context carried from ingress through the queue and Slack thread-history preparation; the recorded 273 synthetic boundary cases cover those paths, while live transport behavior was not observed on this head. No stored-data contract changes: Discord's durable raw-message ingress remains the persistence owner.

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)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • harjothkhara: 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 (3 earlier review cycles)
  • reviewed 2026-09-24T09:53:38.425Z sha eb3969b :: blocked before merge. :: none
  • reviewed 2026-09-24T10:44:39.600Z sha 65aad72 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-24T11:25:34.962Z sha 65aad72 :: needs maintainer review 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 24, 2026
@steipete steipete self-assigned this Sep 25, 2026
Integrate current main while retaining the legacy MediaUrl slot regressions
and the delivery-format prompt owner cutover in the core metadata tests.
Keep the original channel cleanup and author history intact.
@steipete
steipete merged commit 8518d39 into main Sep 25, 2026
192 checks passed
@steipete
steipete deleted the codex/channel-context-deslop branch September 25, 2026 14:13
@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
* refactor: simplify channel reply context handling

* test: preserve native Discord fixture contracts
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 merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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