Repository navigation
fix(discord): keep REST entity cache entries on elapsed time - #190997
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR makes Discord REST entity-cache expiry follow elapsed time instead of wall-clock corrections. Example: The wall clock moves backward 60 seconds after emoji-list caches clock_v1, then 31 real seconds pass.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR provides a focused, proven fix for a cache-expiry bug still present on current main; no actionable defects were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Discord plugin's private Client caches REST-fetched entities for connected Gateway consumers, returning cached values until expiry or Gateway-event invalidation. flowchart LR
A[Message tool emoji-list] --> B[Discord action handler]
B --> C[Account Gateway plugin]
C --> D[Client entity cache]
D --> E[Discord REST client]
E --> F[Normalized emoji result]
D --> F
Technical reviewBest possible solution: Merge the existing one-line clock repair with its consolidated regression and documentation after required checks pass. Do we have a high-confidence way to reproduce the issue? Current-main source directly exposes both clock-step failures, and the supplied built-Gateway traces independently demonstrate them; this read-only review ran no target code. Is this the best way to solve the issue? Yes: changing the existing private owner's single clock sample fixes every entity-cache consumer without adding state, APIs, configuration, or a parallel timing path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e571cd1495c1. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests -1, Docs +5. Total +4 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 2, 2026, 6:11 AM ET / 11:11 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Bundled-Gateway cache proofFinal head: Final exact-head gates: CI and Both full builds succeeded in secretless The operator invokes the actual Gateway HTTP endpoint with its real task-owned bearer credential: {
"tool": "message",
"args": {
"action": "emoji-list",
"channel": "discord",
"guildId": "223456789012345678"
},
"sessionKey": "agent:main:entity-cache"
}The native client makes real Observed twice on each artifact
All operator calls returned HTTP 200 with the actual message-tool result payload. The REST counts come from received native wire requests, not a mocked method. Every run observed exactly one Discord IDENTIFY for its entire sequence, and its config bytes remained unchanged; no restart or reconnect cleared the cache between reads. The harness steps only the Gateway child's Focused regression and simplificationThe existing emoji-cache test now covers zero, forward, and backward wall steps. All independent 5,000-entry cap, late-response sweep, guild-emoji invalidation, and member/user invalidation cases remain. Source delta against frozen main: +1/−1. Tests: +4/−5 (net −1). Docs: +5. No test allocation remains, no SDK export is added, and no public/persisted epoch or configuration contract changes. Retained receiptsProof directory: Successful
Each includes actual tool payloads, native request paths/counts/timing, Gateway wire opcodes, isolation paths, and config checks; accompanying |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 1306cc5. Thanks @wangmiao0668000666. The Discord entity cache now ages correctly across clock changes. |
…w#190997) fix(discord): measure entity cache age with the monotonic clock The Discord entity cache measured entry age with the wall clock. When the clock moved forward, entries expired too early; when it moved back, stale entries were served past their lifetime. The cache now measures age with `performance.now()`. Behavior without a clock change is unchanged. Evidence: bundled built Gateway with the Discord plugin in secretless Node 24.22.1 Docker, through the real `message` tool's `emoji-list` action, stepping only the process wall clock (`Date.now`). On main, entries expired early after a forward step and stale results were served after a backward step plus 31 real seconds, twice each; with this change both cases were correct twice. No-step controls matched. Details: openclaw#190997 (comment). Thanks @wangmiao0668000666. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes Discord entity data expiring too early or remaining stale too long when the wall clock is corrected while the Gateway stays connected.
User Impact
Discord's existing 30-second REST entity-cache window follows elapsed time rather than clock corrections. This prevents unnecessary REST requests after a forward correction and stale user, member, guild, channel, or emoji reads after a backward correction. Normal no-step behavior is unchanged.
Why This Change Was Made
Retains @wangmiao0668000666's original fix: sample
performance.now()in the existing private cache owner. Lookup, expiry creation, and sweeping already use that single sample. No new owner, SDK export, setting, persistence, or public timestamp contract is introduced. The TTL, sweep interval, 5,000-entry cap, and event invalidation stay intact. The sweep origin remains zero; its first process-start sweep can therefore wait until the existing 30-second interval, while reads still check expiry on every access.The clock regression now extends the existing emoji-cache contract, with explicit Date/performance fake clocks. The independent capacity, late-response sweep, and event-invalidation cases remain. Removed the redundant standalone regression and its test-line allocation. Against frozen main
68a413a67ab14a569c4a82ff96bf8627e5163f51: source +1/−1, tests +4/−5 (net −1), docs +5.Evidence
Built both artifacts in secretless Docker on Node 24.22.1, then exercised the bundled built Gateway with the actual Discord plugin, not a manually constructed Client or transport. An authenticated operator called HTTP
/tools/invokewith the realmessagetool'semoji-listaction; the native Discord clients used a task-trusted TLS CONNECT protocol fixture at their normal authorities. The Discord Gateway connection remained alive throughout each run.Main twice, candidate twice, with fresh isolated profiles each time:
clock_v1while fresh; readsclock_v2after 31 real secondsclock_v2clock_v1clock_v1clock_v2clock_v2clock_v2The step changes only the Gateway process's
Date.now(), as in #190894. The system clock, native timers,performance.now(), public tool path, cache implementation, and its 30-second TTL are not replaced or accelerated. The fixture supplies protocol responses, not production credentials or live Discord delivery; all tool responses and actual REST requests are captured.The consolidated regression fails on main for the two intended clock-direction assertions (2 failed / 5 passed) and passes on the candidate (7/7). Focused formatting and changed-file lint passed. Detailed native-wire and returned-value receipts.
Merge danger: two-way door; reverting fully restores the previous process-local timing behavior, with no stored-data migration. Blast radius is the Discord Client's existing REST entity cache and its consumers; incorrect behavior could increase REST calls or prolong stale cached entities.