Repository navigation
fix(discord): cache unavailable thread starters - #128653
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 26, 2026, 8:02 AM ET / 12:02 UTC. ClawSweeper reviewWhat this changesThe PR adds account-scoped positive and short-lived negative caching plus concurrent lookup coalescing for Discord thread-starter resolution. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until stronger real behavior proof is added - 4 items remain Keep open. Current main still retries null and failed Discord thread-starter lookups without caching them, and this branch’s owner-boundary repair is coherent; however, the claimed real-behavior proof is for an older head and its referenced harness is absent from the current head. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherDiscord inbound thread messages resolve their starter before constructing agent context. The Discord plugin either returns a bounded in-memory cache result or requests the starter through its REST client, then passes starter text or an intentional absence downstream. flowchart LR
A[Discord thread message] --> B[Context builder]
B --> C[Starter resolver]
C --> D{Cached or in flight?}
D -->|yes| E[Starter or no starter]
D -->|no| F[Discord REST client]
F --> G[Account-scoped cache]
G --> E
E --> H[Agent context]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +48, Tests +228. Total +276 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the resolver-owned cache design and publish redacted current-head Gateway/REST evidence showing stable 403/404 misses are cached while transient failures remain retryable. Do we have a high-confidence way to reproduce the issue? Yes, from current source: a null starter or caught REST error returns without a cache write, so the same thread reaches the REST client again on subsequent messages. Is this the best way to solve the issue? Yes for the code shape: cache ownership remains in the Discord resolver, account and route scope prevent cross-context reuse, and retryable failures remain uncached; exact-head real behavior proof is still required. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 710c4ea98320. 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
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
|
Merged via squash.
|
|
Postmerge verification addendum for 1e6844b: the missing connected Gateway/REST proof from the latest completed ClawSweeper review has now been run successfully. This evidence was obtained after merge, not before it. The actual flow was native Discord Redacted verdict from the completed run: {
"verdict": "PASS",
"build": "a95d5bc4a164b8539bc57ffd7af44b1f4ee24944",
"mergedCommit": "1e6844b71aa2299c082d23cf66dce38ff00b2211",
"modelRequests": 9,
"deliveredMessages": 9,
"unknownParentIncludedInProvider": true,
"accountBStarterIncludedInProvider": true
}
Every inbound case was correlated to exactly one provider request and one reply to the expected account/thread. Native thread metadata and all eight starter GETs were captured; an empty starter trace fails the proof. Owned processes shut down cleanly and the command exited 0. Runtime provenance: existing successful CI run 32965828319, Scope: this is a configured-proxy loopback protocol proof, not authenticated external Discord or default direct-network/DNS/SSRF/TLS proof. It does not add a pre-fix runtime baseline, TTL-expiry, LRU, or parallel-singleflight claim. Forum/transient recovery proves REST route/status recovery; established-session context intentionally does not reinject starter text. Earlier harness setup attempts were rejected as proof until the real owner REST path was observed. |
* fix(discord): cache unavailable thread starters * test(discord): prove thread starter cache over rest api * test(discord): satisfy proof lint guards * fix(discord): coalesce thread starter lookups * fix(discord): avoid coalescing incomplete metadata * test(discord): keep proof inside plugin boundary * test(discord): keep proof runner responsive * fix(discord): retry starters when parent type is unknown * fix(discord): preserve thread starter route ownership --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes repeated Discord REST lookups for deleted, inaccessible, or empty thread starters. Previously every inbound message in the same thread retried the unavailable starter, increasing rate-limit pressure and delaying normal message processing.
Fixes #128532.
Why This Change Was Made
The Discord thread-starter owner now caches authoritative successful and unavailable outcomes separately. Successful entries retain the existing five-minute bounded LRU; confirmed missing starters and typed Discord 403/404 responses use a 30-second negative cache. Transient transport errors, server errors, and rate limits remain retryable.
Both cached outcomes and concurrent in-flight lookups are owned by the complete
(account ID, thread ID, effective Discord message-channel ID)identity. This prevents one account's permissions from suppressing another account, while ensuring that an unavailable provisional parent-channel route cannot poison a subsequently discovered forum-thread route. Missing parent metadata does not suppress an existing valid parent-channel lookup, and a truly unavailable route is neither cached nor entered into single-flight.The previous standalone proof script was removed because it imported another plugin across its package boundary and was an unreferenced production-tree file. Its coverage now lives in the existing Discord owner and full message-processing suites instead of weakening architecture or dead-code checks.
User Impact
Busy Discord threads stop repeatedly fetching deleted or inaccessible starter messages. Valid starter text remains visible when optional parent-channel type metadata is absent, and forum threads recover correctly when their effective Discord API route becomes known. Account permissions remain isolated; no operator configuration, authentication, persistence, or public API changes are required.
Evidence
321ff5a34e3df5817f69b941224a6ba6f7ccf317.processDiscordMessageregression again exercises a valid thread starter without requiring optional parent-type metadata.openclaw/ci-gate.