Skip to content

perf(discord): avoid duplicate inbound binding lookup - #128264

Merged
steipete merged 1 commit into
mainfrom
codex/perf-discord-binding-current
Aug 23, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-discord-binding-current

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves avoidable work on every accepted ordinary Discord guild message. Human guild traffic looked up the same thread binding before route resolution and again in the canonical conversation-binding route, even though only bot and webhook traffic can use the early result for self-loop rejection.

Why This Change Was Made

The Discord preflight owner now performs the pre-routing binding lookup only for bot or webhook traffic. Ordinary human messages reach the single authoritative conversation-binding route lookup. This adds no cache and does not change DMs, group DMs, thread routing, bound webhook/bot filtering, PluralKit handling, authentication, privacy, ordering, media, mentions, or durable admission.

User Impact

Ordinary Discord guild messages avoid one redundant thread-binding lookup while retaining identical routing and delivery behavior.

Evidence

  • Frozen base: cd86b59a35a5ed1eafa4a9a9155b608cc201d23b; exact candidate: 646aea9a1d5e057d0ca1584bdc605373314f4cc4.
  • Current-base regression proof failed for the intended reason: an accepted human guild message called the real manager's getByThreadId twice instead of once. The candidate passes with one canonical lookup.
  • Full owner preflight suite: 63/63 tests passed.
  • Transport/context/media/mention/room-event siblings: 126/126 tests passed across seven files.
  • Complete Discord extension: 227 files / 2,868 tests passed.
  • node scripts/check-changed.mjs -- extensions/discord/src/monitor/message-handler.preflight.ts extensions/discord/src/monitor/message-handler.preflight.test.ts
  • pnpm build
  • git diff --check
  • Authenticated Codex gpt-5.6-sol/high autoreview: clean, patch correct (0.95), no accepted/actionable P0/P1 findings; TruffleHog preflight clean.
  • Latest origin/main advanced to 20cdebb23dacb7f9ae21f28dd07a9ef8d837fe88 without touching either changed file; the patch applies cleanly there, so the proven commit was not rebased solely for drift.
  • Provenance: the duplicate early lookup was introduced by commit 95079949c3a2dab3380efe7593b34f02a416153f on 2026-04-05, authored and committed by Gustavo Madeira Santana. No associated PR is traceable from GitHub, so no PR attribution is inferred.

@clawsweeper

clawsweeper Bot commented Aug 23, 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: XS maintainer Maintainer-authored PR labels Aug 23, 2026
@steipete
steipete marked this pull request as ready for review August 23, 2026 16:01

Copy link
Copy Markdown
Contributor Author

Land-ready review complete for exact head 646aea9a1d5e057d0ca1584bdc605373314f4cc4.

The current-base regression failed for the intended reason (getByThreadId called twice for one accepted ordinary human guild message) and passes with one canonical lookup. Native review found no blocking findings; executable production delta is +1/-1 (net 0), plus two invariant-comment lines, with +38 test lines.

Verified locally:

  • focused regression red/green
  • full preflight owner: 63/63
  • hydration/context/ingress-recovery/room-event/media/mention/gateway siblings: 126/126
  • complete Discord extension: 227 files / 2,868 tests
  • node scripts/check-changed.mjs -- extensions/discord/src/monitor/message-handler.preflight.ts extensions/discord/src/monitor/message-handler.preflight.test.ts
  • pnpm build
  • git diff --check
  • Codex gpt-5.6-sol/high autoreview: clean, no actionable P0/P1 findings; TruffleHog preflight clean

Exact-head hosted CI is green: run 32650382638. Repository-native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 128264 completed in hosted_exact_or_recent_parent mode and verified the remote PR tree matches the prepared tree.

Proof gap: no live Discord channel run was performed. This is a behavior-neutral internal lookup reduction; full owner/sibling/extension coverage preserves bot/webhook filtering, canonical route/touch behavior, DMs/group DMs, PluralKit, media, mentions, room events, auth, privacy, and durable ordering.

@steipete
steipete merged commit 3d75c27 into main Aug 23, 2026
167 checks passed
@steipete
steipete deleted the codex/perf-discord-binding-current branch August 23, 2026 16:13

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants