Repository navigation
fix(nextcloud-talk): keep the room-kind cache window on elapsed time - #193082
wangmiao0668000666 wants to merge 2 commits into
Conversation
The per-account room-kind cache used the wall clock, so a backward host clock correction kept expiresAt fresh and stopped room kind lookups from ever refreshing. Use performance.now() for the process-local window.
|
🦞👀 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 real behavior proof before merge. What this changesThis PR makes Nextcloud Talk room-kind cache expiry use monotonic elapsed time instead of the wall clock. Example: A direct-room classification is cached, then the wall clock moves backward 10 minutes.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR provides a minimal fix for a cache-expiry defect still present on current main; no introduced code defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherNextcloud Talk inbound handling resolves a room token through the credential-scoped room-info cache and guarded HTTP lookup, then uses the resulting direct/group classification for access checks and session routing. flowchart LR
A[Talk webhook] --> B[Inbound handler]
B --> C[Room info cache]
C --> D[Guarded Talk API lookup]
D --> C
C --> E[Access checks]
E --> F[Agent session routing]
Technical reviewBest possible solution: Keep the existing room-info owner and use the same monotonic clock for writing and checking its process-local expiry. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the clock-step failure, and the contributor reports red-on-base/green-on-head regressions; no target code was executed during this read-only review. Is this the best way to solve the issue? The two clock substitutions are the smallest complete fix and preserve cache scope, TTLs, retries, and policy; a fixed backward step delays expiry rather than making it permanent, and timezone changes alone do not change epoch time. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4671dd463e04. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests +45. Total +45 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 HistoryReview history (1 earlier review cycle)
Reviewed November 4, 2026, 8:25 PM ET / November 5, 2026, 01:25 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
fix: use elapsed time for Mantle discovery and Nextcloud Talk room caches The Mantle model discovery cache and the Nextcloud Talk room-kind cache measured expiry with the wall clock. A backward clock step kept stale entries past their TTL: Mantle kept serving an old catalog, and Nextcloud Talk kept classifying a room with its old kind, so the room's current group policy was not applied. Both caches now use elapsed time. TTLs, cached data and existing guards are unchanged. Sweep of #193066 and #193082; contributor commits are kept. #193070 is related but not included. Evidence: built Gateway, stepping only the process-local `Date`, after real TTLs (one hour for Mantle, five minutes for Nextcloud Talk). Main kept serving stale data; with this change both caches refresh, and Nextcloud Talk applies the existing group policy. No-step controls are unchanged. Details: #193147 (comment) and #193147 (comment). Thanks @wangmiao0668000666 and @wangmiao0668000666. Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @wangmiao0668000666. Your commit landed as part of sweep #193147 (2f183b3), which fixes the same elapsed-time cache bug. Closing this one as included. |
…law#193147) fix: use elapsed time for Mantle discovery and Nextcloud Talk room caches The Mantle model discovery cache and the Nextcloud Talk room-kind cache measured expiry with the wall clock. A backward clock step kept stale entries past their TTL: Mantle kept serving an old catalog, and Nextcloud Talk kept classifying a room with its old kind, so the room's current group policy was not applied. Both caches now use elapsed time. TTLs, cached data and existing guards are unchanged. Sweep of openclaw#193066 and openclaw#193082; contributor commits are kept. openclaw#193070 is related but not included. Evidence: built Gateway, stepping only the process-local `Date`, after real TTLs (one hour for Mantle, five minutes for Nextcloud Talk). Main kept serving stale data; with this change both caches refresh, and Nextcloud Talk applies the existing group policy. No-step controls are unchanged. Details: openclaw#193147 (comment) and openclaw#193147 (comment). Thanks @wangmiao0668000666 and @wangmiao0668000666. Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
resolveNextcloudTalkRoomKindkeeps a process-local per-account room-kind cachefor
ROOM_CACHE_TTL_MS(5 minutes). Both the cache write and the freshness checkcompare the wall clock (
Date.now()). When the host clock is adjustedbackward while the process keeps running,
Date.now()moves back with it, soDate.now() < expiresAtstays true and the cached room kind (direct/group) isserved forever — a room that changed type stays misclassified until the process
restarts, and inbound messages are routed with the stale kind.
This is the same elapsed-time cache-window shape the runtime clock sweep keeps on
the monotonic clock (precedent: #192469 moved the browser extension-relay owner
capture expiry and Feishu probe/reply windows onto
performance.now(); #190894and #192700 move process-local cache/chat-recovery windows the same way; #193066
does the same for the Amazon Bedrock Mantle discovery cache).
Why This Change Was Made
The process-local room-kind window measures an interval, not a point on the
wall clock.
performance.now()is monotonic and immune to host clockcorrections. The cache is keyed by account, base URL, room token, and credentials,
so switching to elapsed time does not change the cache scope.
User Impact
Without the fix, a backward clock step (NTP correction, manual change, DST-style
adjustment, timezone switch) can pin the Nextcloud Talk room kind for a given
room to whatever was first observed for the rest of the process lifetime —
direct/group misrouting persists until restart. With the fix, the room kind
refreshes after the 5-minute elapsed window regardless of wall-clock movement.
Evidence
Two regression tests in
extensions/nextcloud-talk/src/room-info.test.ts:stepped back":
Date.now()is stepped back 10 minutes whileperformance.now()advances past the 5-minute window; the cached kind expiresand the room is looked up again (fetch count 1 → 2, kind direct → group).
Before (base): RED on the new assertion — the wall-clock comparison keeps
the stale cache alive. After (this branch): GREEN.
wall clock jumps forward 10 minutes but elapsed time stays within the window;
the cache still serves (fetch count stays 1) — proves no over-refresh on a
forward clock jump.
Full suite:
node scripts/run-vitest.mjs run extensions/nextcloud-talk/src/room-info.test.ts→ 16 passed (1 file). Red on base, green with the fix.
Behavior-preserving for the normal path: within the 5-minute window the cache
still serves; only the clock source for the window boundary changed.
Shipped-entry-point proof (process-local wall-clock step)
A temporary probe (run via the repository vitest runtime and deleted after
running; it does not ship in this PR) exercises the real shipped chain:
resolveNextcloudTalkRoomKind(the inbound-message room-kind owner) → realfetchWithSsrFGuardre-exported fromopenclaw/plugin-sdk/ssrf-runtimevia theextension's
runtime-api.ts(module not mocked) →globalThis.fetch(theonly stub, which counts real room requests). Only the process-local clocks are
offset (
Date.now = base - 10min,performance.nowunchanged), matching theruntime catalog sweep's method.
Date.now): after the backward wall-clockstep, the room request count stays 1 — the wall-clock comparison keeps the
stale room kind alive. RED:
AssertionError: expected 1 to be 2.2 and the room kind is re-looked-up. GREEN:
Tests 2 passed (2).Recorded trace (synthetic account/room token, no credentials):
Control: with only the wall clock jumped forward (elapsed still in-window), the
cache serves and the count stays 1 — no over-refresh on a forward clock jump.
Not tested
Remote-run reproduction on the shared test server was blocked by a pre-existing
environment issue unrelated to this change (the extension vitest config loads
the Control UI Solid plugin, which fails to resolve under the remote
docker/node ESM loader — an unchanged file fails identically, same as #193066).
Proof above uses the repository's real
run-vitest.mjsentry and real modulechain locally.
Precedent: #192469, #190894, #192700, #193066