Skip to content

fix(discord): restore session resets for sender aliases - #140637

Merged
steipete merged 1 commit into
mainfrom
codex/discord-new-reset
Sep 7, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/discord-new-reset

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Related: #140535

What Problem This Solves

Fixes an issue where Discord users invoking /new or /reset receive “No reply was generated” and retain their conversation context when the command allowlist uses the documented user:<id> form. The same normalization gap affects existing discord: and pk: aliases and Discord mentions. This reproduces the symptom reported by @chrismanderson in #140535; the report does not include its exact allowlist configuration.

Why This Change Was Made

Discord's native command authorizer recognizes sender prefixes, but the shared Discord config adapter only lowercased the entries. Core reset authorization therefore compared a prefixed allowlist entry with the bare sender ID and rejected an already admitted command (extensions/discord/src/shared.ts:93, src/auto-reply/command-auth.ts:359, src/auto-reply/reply/commands-reset.ts:44). Normalize the existing aliases and mentions in the owning adapter, using the same SDK formatter option already used by Telegram. Preserve the existing Doctor-only migration of retired bundled-channel owner entries in the canonical core owner parser, without changing third-party native identities.

The reset target is already carried correctly, so changing slash-session routing or adding a retry/fallback would not repair this failure. #137313 is not the introduction: its merge commit is not an ancestor of the 2026.9.2 release commit. The adjacent group-system-prompt helper now returns its single trimmed value directly instead of constructing, filtering, and joining a one-element array.

User Impact

Authorized Discord reset commands clear the routed channel context and return their normal acknowledgement. Durable session IDs remain stable; the lifecycle revision and reset event prove the context reset. Explicit denial still prevents reset. Retired global-owner entries still require openclaw doctor --fix, and native third-party owner identities remain supported. The command documentation now names the supported user-ID aliases.

Evidence

Head: 5f4815f

  • Baseline synthetic native interaction: bare sender ID passes; user:, discord:, and pk: each return the generic fallback with the original lifecycle revision unchanged.
  • Fixed regression executes the real Discord native handler, channel dispatch, shared authorization/reset owner, SQLite session store, and reply pipeline. Only the interaction transport is synthetic. It checks both /new and /reset, durable reset events, normal acknowledgements, a mismatched sender, and an empty allowlist.
  • OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/auto-reply/command-control.test.ts extensions/discord/src/monitor/native-command.reset.test.ts extensions/discord/src/monitor/native-command.commands-allowfrom.test.ts extensions/discord/src/monitor/inbound-context.test.ts extensions/discord/src/shared.test.ts: 112 passed across five files (52 core authorization tests and 60 Discord tests).
  • pnpm check:changed: passed.
  • git diff --check: clean.
  • Independent Codex review at P0–P2: scoped-clean; no accepted/actionable findings.
  • Production: +23/-25, net -2. Tests: +145/-0. Docs: +2/-1.
  • CI: run 34075676397 passed on the exact head. ClawSweeper reviewed the same head with no actionable findings or security concerns.

No live Discord or full mock Gateway socket proof is claimed. There is no existing Discord native reset socket harness; this covers the handler-to-durable-reset boundary with isolated state. Guild-wide command authorization and generic denial-message wording are separate observed gaps and are not fixed here. No new configuration options, schema, SDK, protocol, dependency, or changelog changes.

Thanks to @chrismanderson for the report.

Normalize documented command sender aliases and mentions before shared authorization so native reset commands clear channel context and acknowledge success. Preserve the existing Doctor migration boundary for global owner entries and third-party native identities.

Related: #140535. Reported by @chrismanderson. Verified with 112 focused tests, check:changed, and independent review.
@clawsweeper

clawsweeper Bot commented Sep 7, 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 size: S maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 02:15
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 10:46 PM ET / September 7, 2026, 02:46 UTC.

ClawSweeper review

What this changes

Normalizes Discord sender aliases so authorized session resets succeed, preserves legacy owner migration rules, adds regression coverage and documentation, and simplifies a prompt helper.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and v2026.9.2 retain the sender-alias mismatch. No actionable introduced defect was found, consistent with the previous review of this head. The linked report’s exact cause remains unconfirmed.

Priority: P1
Reviewed head: 5f4815fe901108ca489c1826c60019b0320672a0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful durable-state regression coverage and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER classification exempts this PR from the ordinary external-contributor proof gate. Reported tests exercise the production native handler through durable reset and denial outcomes with synthetic interaction transport; live Discord delivery is not claimed, and no unresolved introduced authority violation requires additional final-effect proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER classification exempts this PR from the ordinary external-contributor proof gate. Reported tests exercise the production native handler through durable reset and denial outcomes with synthetic interaction transport; live Discord delivery is not claimed, and no unresolved introduced authority violation requires additional final-effect proof.
Evidence reviewed 8 items Current main still needs the repair: The fetched main revision still only lowercases Discord allowlist entries. Native authorization accepts sender prefixes, while shared command authorization compares formatted entries against the bare sender ID.
Latest release retains the mismatch: The v2026.9.2 adapter also only lowercases entries; the proposed normalization is not present in that release.
Existing Discord identity contract: Native command authorization already recognizes discord:, user:, and pk: entries and Discord mentions. The patch supplies equivalent normalization through the existing SDK formatter to shared authorization.
Findings None None.
Security None None.

How this fits together

Discord’s native command handler passes sender identity and command access into OpenClaw’s shared reply pipeline. Shared authorization determines whether the routed conversation can reset and receive an acknowledgement.

flowchart TD
  A[Discord reset command] --> B[Channel access checks]
  C[Configured sender aliases] --> D[Discord identity normalization]
  B --> E[Shared command authorization]
  D --> E
  E -->|Allowed| F[Reset routed session and acknowledge]
  E -->|Denied| G[Preserve session]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -2, Tests +145, Docs +1. Total +144 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 23 25 -2
Tests 2 145 0 +145
Docs 1 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 170 26 +144

Review metrics

Metric Value Why it matters
Reset authorization coverage 12 allowed cases; 4 denied cases Both reset commands check durable session effects across six sender forms and two explicit denial conditions.

Technical review

Best possible solution:

Keep Discord identity normalization in its existing config adapter so native and shared authorization agree without changing session routing, stored settings, or reset policy.

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

Yes, source establishes a concrete path: configure commands.allowFrom.discord with user:<id>, then invoke native /new or /reset; native admission accepts it while current shared authorization mismatches the bare sender ID. This review did not execute tests, and the linked reporter’s exact configuration remains unknown.

Is this the best way to solve the issue?

Yes, this repairs the normalization owner using an existing SDK option and preserves the documented Doctor migration boundary; routing changes or retries would not address the mismatch.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The mismatch breaks documented Discord session reset commands for operators using supported sender aliases.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 supplied MEMBER classification exempts this PR from the ordinary external-contributor proof gate. Reported tests exercise the production native handler through durable reset and denial outcomes with synthetic interaction transport; live Discord delivery is not claimed, and no unresolved introduced authority violation requires additional final-effect proof.

Evidence

What I checked:

  • Current main still needs the repair: The fetched main revision still only lowercases Discord allowlist entries. Native authorization accepts sender prefixes, while shared command authorization compares formatted entries against the bare sender ID. (extensions/discord/src/shared.ts:93, e13c0c6c44da)
  • Latest release retains the mismatch: The v2026.9.2 adapter also only lowercases entries; the proposed normalization is not present in that release. (extensions/discord/src/shared.ts:93, 3928bad9badf)
  • Existing Discord identity contract: Native command authorization already recognizes discord:, user:, and pk: entries and Discord mentions. The patch supplies equivalent normalization through the existing SDK formatter to shared authorization. (extensions/discord/src/monitor/native-command-auth.ts:53, 5f4815fe9011)
  • Allowed and denied durable outcomes: The new tests invoke the production native handler and inspect session lifecycle revisions, durable reset events, and acknowledgements for both commands. Different-user and empty-list cases assert no reset. Interaction transport is mocked; the captured PR body reports 112 focused tests passing and expressly disclaims live Discord or Gateway socket proof. (extensions/discord/src/monitor/native-command.reset.test.ts:95, 5f4815fe9011)
  • Existing upgrade boundary preserved: Doctor already rewrites recognized channel:user:id owner entries into channel:id. Existing documentation requires that migration, and persistence coverage checks canonical output and repeat-run stability. The introduced parser guard matches that existing migration envelope while preserving third-party native identities. (src/commands/doctor-command-owner.ts:12, 5f4815fe9011)
  • Introduced changes survive the verified merge: The supplied test merge has the pinned base and original head as its ordered parents. Comparing its result with that base confirms the normalization and owner-parser changes without attributing unrelated base drift to this PR. (src/auto-reply/command-auth.ts:235, 96e5309e9f12)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • chelsealong: 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-07T02:23:29.182Z sha 5f4815f :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 93562ca into main Sep 7, 2026
256 checks passed
@steipete
steipete deleted the codex/discord-new-reset branch September 7, 2026 02:57
@steipete

steipete commented Sep 7, 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 7, 2026
)

Normalize documented command sender aliases and mentions before shared authorization so native reset commands clear channel context and acknowledge success. Preserve the existing Doctor migration boundary for global owner entries and third-party native identities.

Related: openclaw#140535. Reported by @chrismanderson. Verified with 112 focused tests, check:changed, and independent review.
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

1 participant