Skip to content

fix(nextcloud-talk): keep the room-kind cache window on elapsed time - #193082

Closed
wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/nextcloud-talk-room-info-elapsed
Closed

wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/nextcloud-talk-room-info-elapsed

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

resolveNextcloudTalkRoomKind keeps a process-local per-account room-kind cache
for ROOM_CACHE_TTL_MS (5 minutes). Both the cache write and the freshness check
compare the wall clock (Date.now()). When the host clock is adjusted
backward while the process keeps running, Date.now() moves back with it, so
Date.now() < expiresAt stays true and the cached room kind (direct/group) is
served 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(); #190894
and #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 clock
corrections. 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:

  • "refreshes the cached room kind on elapsed time even when the wall clock is
    stepped back"
    : Date.now() is stepped back 10 minutes while
    performance.now() advances past the 5-minute window; the cached kind expires
    and 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.
  • "serves the cached room kind within the window regardless of the wall clock":
    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) → real
fetchWithSsrFGuard re-exported from openclaw/plugin-sdk/ssrf-runtime via the
extension's runtime-api.ts (module not mocked) → globalThis.fetch (the
only stub, which counts real room requests). Only the process-local clocks are
offset (Date.now = base - 10min, performance.now unchanged), matching the
runtime catalog sweep's method.

  • BASE (this branch reverted to Date.now): after the backward wall-clock
    step, the room request count stays 1 — the wall-clock comparison keeps the
    stale room kind alive. RED: AssertionError: expected 1 to be 2.
  • HEAD (this branch): after the same step, the room request count reaches
    2 and the room kind is re-looked-up. GREEN: Tests 2 passed (2).

Recorded trace (synthetic account/room token, no credentials):

[probe] resolveNextcloudTalkRoomKind(account=probe-account, roomToken=probe-room)
[probe] fetchWithSsrFGuard -> GET https://cloud.example.com/ocs/v2.php/apps/spreed/api/v4/room/probe-room  (count=1)
[probe] wall clock stepped back 600s; elapsed advanced 600s
[probe] fetchWithSsrFGuard -> GET https://cloud.example.com/ocs/v2.php/apps/spreed/api/v4/room/probe-room  (count=2)  <-- refetch on elapsed expiry

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.mjs entry and real module
chain locally.

Precedent: #192469, #190894, #192700, #193066

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.
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: nextcloud-talk Channel integration: nextcloud-talk size: XS labels Nov 5, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This 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.

  • Before: The five-minute cache can remain valid for 15 elapsed minutes, delaying discovery of a changed room kind.
  • After: The cache expires after five elapsed minutes regardless of the clock correction.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and source-correct with distinct regressions and successful exact-head checks, but supplied execution remains mocked transport proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Host clock corrections can keep stale direct/group classification beyond the documented cache window or force premature lookups.
Reason: The change restores an existing duration contract with no new option, public API, persistence, or competing owner.

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
Reviewed head: 61e29e17bebcc78856b92abcd0814015aca08f6b

Before merge

  • Add real behavior proof - The added probe exercises the production room-info and SSRF modules under Vitest but stubs globalThis.fetch, so its request counts do not clear the previous running-Gateway proof request. Please provide terminal output, logs, or a recording from the shipped Gateway path showing actual lookup refresh after backward correction and reuse within the elapsed window after forward correction; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Missing running-Gateway evidence showing actual room-info HTTP refresh after backward clock correction and cache reuse during a forward correction within the elapsed window.
Agent review details

How this fits together

Nextcloud 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]
Loading

Technical review

Best 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

  • Room-info expiry representation and transient-error handling keeps the original intent (39dfbc8: The merged retry repair stored expiry directly while leaving transient lookup failures to durable ingress.)
  • Credential-scoped cache lookup keeps the original intent (e8df190: The merged cache-scope repair prevents classification reuse across server, credential, and network-policy contexts.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e8df190 adds extensions/nextcloud-talk/src/room-info.ts:57 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e8df190f4617; files: extensions/nextcloud-talk/src/room-info.ts)
  • Alix-007: Raw commit 936136a adds extensions/nextcloud-talk/src/room-info.ts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 936136a707ad; files: extensions/nextcloud-talk/src/room-info.ts)

PR surface

Source 0, Tests +45. Total +45 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 2 0
Tests 1 45 0 +45
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 47 2 +45

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Clock corrections can extend stale room classification and affect Nextcloud Talk routing, with a limited channel-specific blast radius.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Supply the real-behavior evidence described above to clear the external-PR proof gate.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-05T00:51:59.986Z sha f3ea817 :: needs real behavior proof before merge. :: none

Reviewed November 4, 2026, 8:25 PM ET / November 5, 2026, 01:25 UTC (Revision 2).

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 5, 2026
obviyus added a commit that referenced this pull request Nov 5, 2026
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]>
@obviyus

obviyus commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Thanks @wangmiao0668000666. Your commit landed as part of sweep #193147 (2f183b3), which fixes the same elapsed-time cache bug. Closing this one as included.

@obviyus obviyus closed this Nov 5, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…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]>
@wangmiao0668000666
wangmiao0668000666 deleted the fix/nextcloud-talk-room-info-elapsed branch November 5, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: nextcloud-talk Channel integration: nextcloud-talk P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants