Skip to content

fix(discord): honor reply visibility for session-busy notices - #135444

Merged
steipete merged 1 commit into
mainfrom
codex/fix-discord-conflict-visibility-20260901
Sep 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-discord-conflict-visibility-20260901

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #135442

What Problem This Solves

Fixes an issue where operators using Discord ambient room events or message-tool visible replies could receive unsolicited session-busy warnings after session initialization exhausted its retries. The normal reply path respected the selected visibility policy, but the terminal conflict notice bypassed it.

Why This Change Was Made

The existing Discord conflict-completion owner now consumes the prepared source reply mode and returns a delivered or suppressed outcome. Its caller records the exhausted conflict and outcome before the ingress owner settles the event. A failed allowed notice still throws so the existing ingress retry can recover it; downstream suppression is recorded accurately too.

This removes the one-use conflict-classification wrapper and replaces the old boolean completion assumption with an explicit outcome. Production changes are +21/-14 (net +7), covering the policy input and terminal outcome record; tests are +71/-6 and docs +2. The repair adds no configuration, schema, or retry policy.

User Impact

Ambient and message-tool-only turns remain quiet when their session stays busy, with an explicit failure and suppression record in Gateway logs. Automatic replies retain the existing visible session-busy warning. Both handled outcomes complete ingress processing, while an allowed notice that fails to send remains retryable.

Evidence

  • Pre-fix source probe: two automatic controls passed; ambient and configured message-tool-only groups each incorrectly posted one notice (two failures). The relevant production files were byte-identical at the implementation base.
  • Focused owner and sibling coverage: 47 distinct cases passed across abort/retry, room events, run-queue behavior, and durable ingress recovery. The corrected abort/retry file passed 11/11 with wrapper exit 0. Its original replay-history assertions remain intact, using a dispatch failure to release the quiet event.
  • Mock-Gateway channel proof: all five scenarios passed, wrapper exit 0 in 169.624s. An actual built ephemeral Gateway connected to Crabline's local Discord REST/WebSocket server and the QA mock provider. A test-only, hash-pinned Node load hook forced the existing session-initialization CAS conflict for named synthetic sessions; error creation, bounded retries, Discord delivery, and durable ingress stayed real. Both quiet cases completed with zero posts. The direct control posted once. Three injected HTTP 503s left the failed notice pending; the existing ingress retry then posted exactly once. A later normal provider turn replied successfully. All owned services stopped cleanly, and source hashes matched before and after.
  • Fixture isolation uses the existing joinIntro: false option to keep the separate fresh-guild welcome turn out of the provider-count assertion. Test-only endpoint adapters route Discord REST and the WebSocket handshake to loopback; the fixture rejects other TCP destinations. The production Gateway build is unchanged by the harness.
  • Canonical private QA runtime build passed: OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build sourcePerformance (exit 0). The reviewed working-tree patch was tested on base 91067e340a1811f94a3f119fae329542c3f23872; its diff SHA-256 is 5b2ce2bbc72d6b5124b5bbc072d878de091c639b21c51979e5c5e534c773b51e.
  • Canonical changed-code gate passed (exit 0): production/test extension types, focused lint and formatting, five Doctor-contract tests, plugin boundaries, unused exports, storage/media/sidecar guards, and zero runtime import cycles. Exact-head hosted CI passed at 86e273da9ddcbad764efb9eb89c5944844aae3dd.
  • Independent Codex review through P1: clean, no actionable findings.
{
  "kind": "discord-conflict-visibility-mock-gateway",
  "status": "pass",
  "gateway": "actual ephemeral built Gateway",
  "channel": { "driver": "crabline", "live": false },
  "provider": { "fixture": "mock-openai", "live": false },
  "cases": [
    { "name": "ambient-room-event", "casConflicts": 40, "messagePosts": 0, "outcome": "suppressed", "ingress": "completed" },
    { "name": "mentioned-message-tool-group", "casConflicts": 40, "messagePosts": 0, "outcome": "suppressed", "ingress": "completed" },
    { "name": "direct-automatic-notice", "casConflicts": 40, "messagePosts": 1, "outcome": "delivered", "ingress": "completed" },
    { "name": "failed-direct-notice-retry", "casConflicts": 80, "failedPosts": 3, "retryPendingObserved": true, "messagePosts": 1, "ingress": "completed" },
    { "name": "normal-provider-turn-after-conflicts", "providerRequests": 1, "reply": "DISCORD_CONFLICT_RECOVERED", "ingress": "completed" }
  ],
  "cleanup": "all owned services confirmed stopped",
  "sourceHashesUnchanged": true
}

Related work: #109902 addresses the shared conflict classifier; #121204 addresses stale ambient backlog ordering. Neither changes this terminal-notice visibility boundary.

Use the prepared reply mode when completing exhausted session conflicts,
recording delivered or suppressed outcomes before ingress settlement.
Preserve retryability when an allowed terminal notice fails to send.

Cover ambient, message-tool, direct, downstream suppression, and replay cases.
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord size: S maintainer Maintainer-authored PR labels Sep 1, 2026
@steipete
steipete marked this pull request as ready for review September 1, 2026 18:31
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 2:55 PM ET / 18:55 UTC.

ClawSweeper review

What this changes

The PR makes Discord’s exhausted session-busy notice follow the prepared reply-visibility policy and records whether it was delivered or intentionally suppressed.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review. The active PR repairs a current-main Discord reply-policy gap, has no actionable correctness finding, and carries sufficient Gateway-backed channel proof.

Priority: P2
Reviewed head: 86e273da9ddcbad764efb9eb89c5944844aae3dd

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A small owner-boundary correction with focused regression coverage, exact-head CI evidence, and Gateway-backed channel proof.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied PR-body verdict exercises the changed production Discord processor, retry, delivery, and durable-ingress path through an ephemeral Gateway with a local transport; its recorded post-fix results show quiet-policy suppression, a visible direct control, retry after a failed allowed send, and subsequent recovery.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied PR-body verdict exercises the changed production Discord processor, retry, delivery, and durable-ingress path through an ephemeral Gateway with a local transport; its recorded post-fix results show quiet-policy suppression, a visible direct control, retry after a failed allowed send, and subsequent recovery.
Evidence reviewed 8 items Current-main gap: The current main version of the conflict helper directly delivers the terminal payload and returns a boolean; it receives no prepared reply-delivery mode, so the reported quiet-policy boundary remains unfixed on main.
Owner-boundary repair: The introduced helper accepts the already prepared source reply mode, suppresses terminal notices for message-tool-only turns, and distinguishes delivery from downstream suppression.
Prepared-policy caller: The Discord processor resolves the reply mode once, passes it into the terminal conflict path, and records the resulting terminal outcome before returning.
Findings None None.
Security None None.

How this fits together

Discord’s inbound monitor prepares whether a turn may post automatic replies before dispatch. If session initialization exhausts its retries, the terminal conflict helper either sends a permitted notice or records a suppression before ingress settles the event.

flowchart LR
  A[Discord inbound turn] --> B[Prepare reply visibility]
  B --> C[Initialize and dispatch session]
  C --> D{Retries exhausted?}
  D -->|yes| E[Conflict completion]
  E --> F{Automatic reply allowed?}
  F -->|yes| G[Send final notice]
  F -->|no| H[Record suppression]
  G --> I[Settle ingress event]
  H --> I
Loading

Before merge

  • Resolve merge risk (P1) - Production code increases by net 7 lines for explicit terminal-outcome recording; the added state is justified by distinguishing delivery from intentional suppression, but should remain limited to this conflict owner.
  • Complete next step (P2) - This is an active maintainer-owned implementation PR with no identified mechanical repair finding.
Agent review details

Security

None.

PR surface

Source +7, Tests +65, Docs +2. Total +74 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 21 14 +7
Tests 1 71 6 +65
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 94 20 +74

Review metrics

Metric Value Why it matters
Production and test delta production +21/-14; tests +71/-6; docs +2/-0 The net-seven production increase carries the prepared policy and an explicit terminal outcome; most of the change is focused regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #135442
Summary: This PR is the candidate fix for the linked Discord quiet-reply-policy bug; the other referenced PRs concern different boundaries.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge the focused owner-boundary repair so all terminal conflict notices obey the already prepared reply policy while failed permitted notices remain retryable.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge the focused owner-boundary repair so all terminal conflict notices obey the already prepared reply policy while failed permitted notices remain retryable.

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

Yes: the supplied deterministic harness targets the exhausted session-conflict path, and source inspection confirms the current helper bypasses the prepared quiet-reply mode.

Is this the best way to solve the issue?

Yes: passing the already prepared delivery mode to the terminal conflict owner avoids policy recomputation and retains the existing failure retry behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs unsolicited Discord messages on a bounded, policy-controlled conflict path.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied PR-body verdict exercises the changed production Discord processor, retry, delivery, and durable-ingress path through an ephemeral Gateway with a local transport; its recorded post-fix results show quiet-policy suppression, a visible direct control, retry after a failed allowed send, and subsequent recovery.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied PR-body verdict exercises the changed production Discord processor, retry, delivery, and durable-ingress path through an ephemeral Gateway with a local transport; its recorded post-fix results show quiet-policy suppression, a visible direct control, retry after a failed allowed send, and subsequent recovery.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): 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 (1 earlier review cycle)
  • reviewed 2026-09-01T18:41:09.323Z sha 86e273d :: needs maintainer review before merge. :: none

@steipete
steipete merged commit f7e6297 into main Sep 1, 2026
273 checks passed
@steipete
steipete deleted the codex/fix-discord-conflict-visibility-20260901 branch September 1, 2026 18:56
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…aw#135444)

Use the prepared reply mode when completing exhausted session conflicts,
recording delivered or suppressed outcomes before ingress settlement.
Preserve retryability when an allowed terminal notice fails to send.

Cover ambient, message-tool, direct, downstream suppression, and replay cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Discord session-busy notices bypass quiet reply policy

1 participant