Repository navigation
improve(discord): avoid repeated account resolution on sends - #128462
Conversation
Co-authored-by: Peter Steinberger <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 10:35 PM ET / August 24, 2026, 02:35 UTC. ClawSweeper reviewWhat this changesThe PR reuses a prepared Discord account across outbound message, component, structured, and voice sends to avoid repeated account resolution. Merge readinessKeep open for normal maintainer handling. Current main still resolves the Discord account separately in client creation, outbound projection, and channel-recipient resolution; this PR centralizes the prepared outbound account while keeping explicit-token retry lookup on the REST account. No actionable correctness or security defect was found, but the branch is behind main and exact-head checks remain in progress. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherDiscord outbound delivery prepares a REST client and retry policy, resolves a recipient and channel target, then sends a Discord payload. Per-account outbound settings flow through this path, while gateway-disconnect retry behavior remains tied to the REST client's account identity. flowchart LR
A[Outbound Discord request] --> B[Prepare REST client and account]
B --> C[Resolve recipient and channel]
B --> D[Bind retry to REST account]
C --> E[Build outbound payload]
D --> F[Dispatch Discord request]
E --> F
Decision needed
Why: The PR is maintainer-labeled and changes the shared outbound account-preparation path, so final landing remains an explicit maintainer choice. Before merge
Agent review detailsSecurityNone. PR surfaceSource -1, Tests +28. Total +27 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase this focused owner-boundary optimization onto current main and land it after exact-head Discord checks confirm preserved retry identity and outbound behavior. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main resolves account state in client construction, outbound projection, and channel-recipient resolution along the same configured-token send path. Is this the best way to solve the issue? Yes. Carrying the canonical prepared account from the client owner removes duplicate resolution while the separate REST account preserves existing explicit-token retry semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1ac7f0161c9e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Land-ready dispositionNo blocking findings. The root cause is three equivalent account resolutions on an ordinary configured-token Discord send: outbound projection, full-client construction, and channel recipient resolution. The canonical fix carries the full client's prepared configured account into projection and channel resolution while retaining the synthetic REST account solely for gateway-disconnect retry identity. Best-fix verdict: best owner-boundary fix. A cache would add invalidation state for process-stable configuration; changing REST-only clients would broaden unrelated semantics; leaving generic channel parsing in this path would retain the duplicate lookup. Production LOC is +42/-43 (net -1); tests are +28/-0. Behavior proof
Validation
ClawSweeper disposition: the exact-head review found no correctness or security defect and agreed this is the best solution. Its stale “checks in progress” item is resolved by the green exact-head run above. Its optional rebase rank-up is intentionally skipped: current Provenance: the duplicate preparation accumulated across the Discord move in #45660, full-client runtime-config preparation in Known proof gap: no credentialed/live Discord mutation was performed. This change does not alter the Discord API request boundary; mocked provider captures, retry-contract coverage, the full plugin suite, and exact-head CI are the available proof. ClawSweeper's unrelated Codex source hard gate was checked directly at |
|
Merged via squash.
|
Co-authored-by: Amp <[email protected]>
What Problem This Solves
Fixes an issue where ordinary Discord sends using a configured token repeatedly resolved the same account before provider dispatch. Projection, full-client creation, and channel target resolution each performed equivalent account preparation, adding avoidable CPU work to structured, component, edit, voice, and ordinary message paths.
Why This Change Was Made
The full Discord client now exposes its canonical prepared account so downstream outbound projection and channel resolution can reuse that fact. Generic REST-only client behavior remains unchanged, and explicit-token retry lookup deliberately stays bound to the synthetic REST account identity while outbound projection uses the configured account.
No cache, configuration, protocol, security, storage, media-staging, provider-payload, or retry-policy contract changes.
User Impact
Configured-token Discord outbound work performs one account resolution instead of three before dispatch. Provider requests and payloads remain unchanged.
Evidence
c18759dab3fef2e858a1694a980c2dac253a5b27be9ea3af0e2d48007ec0210afor both variants.opsaccount while gateway-disconnect retry extension remains bound to thedefaultREST account.node scripts/check-changed.mjs: passed all classified extension and extension-test gates (format, production/test typechecks, type-aware Oxlint 0/0, dead exports, boundaries, guards, import cycles 0). The classifier selected no build lane.git diff --check: clean.gpt-5.6-sol/ high autoreview: no actionable findings;patch is correctat 0.94 confidence.