Skip to content

fix(discord): classify announcement threads consistently - #128568

Merged
steipete merged 2 commits into
mainfrom
codex/cleanup-lane2-20260823
Aug 24, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/cleanup-lane2-20260823

Conversation

@steipete

@steipete steipete commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Discord thread recognition was independently implemented across message delivery, authorization, permission checks, thread bindings, incoming-message handling, interactive components, and channel-name resolution. One inconsistent copy omitted announcement threads, causing setup and allowlist resolution to choose an identically named announcement thread over the actual channel.

Why This Change Was Made

Use one lightweight, Discord-plugin-private thread classifier for announcement, public, and private threads. Move every existing caller to that owner, including read authorization and channel-match ranking; delete duplicate predicates and replace deprecated Discord enum aliases with their identical current values. No public plugin or SDK contract changes, and authorization retains the existing closed numeric-channel-type boundary.

User Impact

Discord setup and allowlist resolution now consistently prefer an actual channel over an announcement, public, or private thread with the same name. Existing thread routing, bindings, interactive context, guild actions, and private-thread authorization retain their behavior with less production code and cleaner ownership.

Evidence

  • Maintainer-requested, AI-assisted owner-boundary cleanup and announcement-thread resolution repair; production remains net-negative.
  • Before the production fix, the existing channel-resolution behavior test was extended across announcement/public/private threads and failed only for announcement threads: expected regular channel c1, received thread-1. The repaired owner now passes all three cases.
  • Focused Discord regression coverage includes channel allowlist resolution, provider setup, private-thread authorization, guild/messaging actions, thread bindings, inbound preflight, component interactions, thread starters, and outbound delivery.
  • Direct runtime probe confirms announcement/public/private threads and all three deprecated enum aliases remain accepted while text channels, forums, strings, null, and undefined are rejected.
  • Independent source review verified the upstream Discord enum aliases share exact values 10/11/12, thread-classification owners use the private leaf, and authorization/private-thread membership checks retain their security boundary.
  • Eleven changed-file guard and formatting steps passed. The first full local gate stopped when nested Vitest attempted to write through shared read-only dependencies; its owner suites then passed after redirecting Vite's temporary files (two files, five tests). Broader local typecheck is blocked by independently reproduced stale mixed-checkout dependency errors unrelated to this change, so exact-head hosted CI and the native Testbox prepare gate provide the authoritative clean-environment full verification.
  • Structured pre-commit autoreview passed cleanly with no actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 24, 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 channel: discord Channel integration: discord size: S maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 06:32
@steipete
steipete force-pushed the codex/cleanup-lane2-20260823 branch from f22dce2 to dccef04 Compare August 24, 2026 06:48
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 24, 2026
@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 3:17 AM ET / 07:17 UTC.

ClawSweeper review

What this changes

The PR centralizes Discord thread-type recognition so announcement, public, and private threads are handled consistently when resolving channels and related Discord operations.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. This maintainer-authored, maintainer-labeled PR has no blocking source finding, but it remains behind current main and this environment could not independently inspect current-main or the pinned Discord enum source.

Priority: P3
Reviewed head: 86ceabdcd25b00c20c42b81d62f722089042313c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, net-negative, and backed by a behavior-level regression test, with normal exact-head validation still pending.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body documents focused regression evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body documents focused regression evidence.
Evidence reviewed 6 items Source defect and repair: The prior resolver classified only numeric types 11 and 12; the PR delegates ranking to the shared classifier, which includes announcement threads as well.
Behavioral regression coverage: The table-driven resolver test puts each thread kind before an identically named normal channel and requires the normal channel to win; the old 11/12 predicate would leave announcement threads tied with the normal channel.
Sibling authorization boundary: Permission resolution still maps recognized thread channels to their parent, while private-thread membership remains a separate closed check.
Findings None None.
Security None None.

Live Verification

Command: pnpm test extensions/discord/src/resolve-channels.test.ts --reporter=verbose

Result: FAIL (partial) — step 2 expect_output prefers a matching guild channel over an announcement thread: expected terminal output was not visible within 30 seconds: "prefers a matching guild channel over an announcement thread"

pnpm test extensions/discord/src/resolve-channels.test.ts --reporter=verbose
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128568-N4Vwz2/target$ pnpm test extensions/discord/src/resolve-channels.test.ts --reporter=verbose
$ node --import tsx scripts/test-projects.mts extensions/discord/src/resolve-channels.test.ts --reporter=verbose
pnpm test extensions/discord/src/resolve-channels.test.ts --reporter=verbose
[test] starting test/vitest/vitest.extension-discord.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128568-N4Vwz2/target

 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › prefers a matching guild channel over a announcement t
hread 36ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › prefers a matching guild channel over a public thread
1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › prefers a matching guild channel over a private thread
 1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › resolves channel id to guild 1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › resolves guildId/channelId entries via channel lookup
2ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › reports unresolved when channel id belongs to a differ
ent guild 1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › resolves numeric channel id when guild is specified by
 name 1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › marks invalid numeric channelId as unresolved without
aborting batch 6ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › treats 403 channel lookup as unresolved without aborti
ng batch 1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › falls back to name matching when numeric channel name
is not a valid ID 1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › does not fall back to name matching when channel looku
p returns 403 1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › does not fall back to name matching when channel paylo
ad is malformed 1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › resolves guild: prefixed id as guild (not channel) 1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › bare numeric guild id is misrouted as channel id (regr
ession) 1ms

 Test Files  1 passed (1)
      Tests  14 passed (14)
   Start at  07:18:46
   Duration  7.90s (transform 6.14s, setup 963ms, import 6.52s, tests 58ms, environment 0ms)

[test] passed 1 Vitest shard in 13.87s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128568-N4Vwz2/target$ pnpm test extensions/discord/src/resolve-channels.test.ts --reporter=verbose
$ node --import tsx scripts/test-projects.mts extensions/discord/src/resolve-channels.test.ts --reporter=verbose
[test] starting test/vitest/vitest.extension-discord.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128568-N4Vwz2/target

 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › prefers a matching guild channel over a announcement t
hread 28ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › prefers a matching guild channel over a public thread
1ms
 ✓  extension-discord  extensions/discord/src/resolve-channels.test.ts › resolveDiscordChannelAllowlist › prefers a ma
… output truncated …

Assertions:

  • FAIL expect_output: prefers a matching guild channel over an announcement thread

How this fits together

The bundled Discord plugin turns Discord channel metadata into channel selection, permission, binding, and delivery decisions. A shared thread classifier feeds those decisions so threads are treated consistently across the plugin.

flowchart LR
  A[Discord API channel data] --> B[Discord thread classifier]
  B --> C[Channel-name resolution]
  B --> D[Permission and binding logic]
  C --> E[Selected Discord channel]
  D --> E
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports this head as cleanly mergeable but behind current main; refresh the merge result and complete exact-head checks before merging.
  • Resolve merge risk (P1) - Direct confirmation that discord-api-types 0.38.52 maps the replacement enum names to the former aliases is unavailable in this review environment.
Agent review details

Security

None.

PR surface

Source -39, Tests +6. Total -33 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 12 35 74 -39
Tests 1 7 1 +6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 42 75 -33

Review metrics

Metric Value Why it matters
Production versus test LOC production +35/-74 (net -39); tests +7/-1 The repair removes repeated production predicates while adding one table-driven behavior regression.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the plugin-private classifier, refresh it against current main, and confirm the pinned Discord enum alias contract before merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the plugin-private classifier, refresh it against current main, and confirm the pinned Discord enum alias contract before merge.

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

Yes, from source: an announcement thread preceding an identically named normal channel takes the old equal-score path, while the added table test specifies the corrected selection.

Is this the best way to solve the issue?

Yes, subject to direct enum-contract confirmation: one plugin-private classifier removes the inconsistent duplicate predicates rather than patching only resolver ranking.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a narrow Discord channel-name resolution edge case with limited blast radius.
  • 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: This maintainer-authored PR is exempt from the external-contributor proof gate; its body documents focused regression evidence.

Evidence

What I checked:

  • Source defect and repair: The prior resolver classified only numeric types 11 and 12; the PR delegates ranking to the shared classifier, which includes announcement threads as well. (extensions/discord/src/resolve-channels.ts:149, 86ceabdcd25b)
  • Behavioral regression coverage: The table-driven resolver test puts each thread kind before an identically named normal channel and requires the normal channel to win; the old 11/12 predicate would leave announcement threads tied with the normal channel. (extensions/discord/src/resolve-channels.test.ts:71, 86ceabdcd25b)
  • Sibling authorization boundary: Permission resolution still maps recognized thread channels to their parent, while private-thread membership remains a separate closed check. (extensions/discord/src/send.permissions.ts:142, 86ceabdcd25b)
  • Feature provenance: Blame attributes the original resolver ranking predicate to chelsealong; the source line used the incomplete 11/12 predicate before this PR. (extensions/discord/src/resolve-channels.ts:148, d2e62c6b8206)
  • Exact-head validation state: Provided PR checks show build, production types, lint, dependency, extension-boundary, and security checks passing; the channel-runtime quality job remains in progress and CodeQL remains queued. (86ceabdcd25b)
  • Inspection limitation: The checkout has no node_modules and is a partial clone; GitHub DNS was unavailable, so direct inspection of discord-api-types 0.38.52 and current main could not complete. (extensions/discord/package.json:13, 86ceabdcd25b)

Likely related people:

  • chelsealong: Git blame identifies this author on the pre-PR channel-ranking code and adjacent permission implementation. (role: source author of the existing ranking predicate; confidence: medium; commits: d2e62c6b8206; files: extensions/discord/src/resolve-channels.ts, extensions/discord/src/send.permissions.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the merge result on current main and let the remaining exact-head checks finish.
  • Confirm the pinned Discord enum aliases directly before merge.

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-08-24T06:55:07.444Z sha dccef04 :: needs maintainer review before merge. :: none

@steipete steipete changed the title refactor(discord): deduplicate thread channel classification fix(discord): classify announcement threads consistently Aug 24, 2026
@steipete
steipete merged commit 23df579 into main Aug 24, 2026
105 checks passed
@steipete
steipete deleted the codex/cleanup-lane2-20260823 branch August 24, 2026 08:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 25, 2026
…8568)

* refactor(discord): deduplicate thread channel classification

* fix(discord): classify announcement threads during channel resolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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