Skip to content

fix(channels): prevent metadata caches from growing without bound#101650

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
Alix-007:alix/discord-channel-info-cache-cap
Jul 7, 2026
Merged

fix(channels): prevent metadata caches from growing without bound#101650
vincentkoc merged 2 commits into
openclaw:mainfrom
Alix-007:alix/discord-channel-info-cache-cap

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Related: #101662

What Problem This Solves

Fixes an issue where long-lived Discord and Nextcloud Talk processes could retain
one metadata-cache entry for every unique channel or room they observed, allowing
those process-local Maps to grow without a fixed upper bound.

Why This Change Was Made

Each channel owner now caps its existing metadata cache at 1000 entries through
the shared pruneMapToMaxSize plugin SDK helper. Existing TTL, negative-cache,
request, error, and SSRF-policy behavior remains unchanged.

The related same-author Nextcloud Talk fragment from #101662 was consolidated
here so the two small fixes land as one focused review unit, as encouraged by
VISION.md.

User Impact

Long-running channel processes keep these metadata caches bounded while retaining
the newest entries. An evicted entry is fetched normally when it is needed again.

Evidence

  • Discord message-utils.test.ts: 49/49 passed.
  • Nextcloud Talk room-info.test.ts: 8/8 passed.
  • oxfmt --check and git diff --check: passed.
  • Fresh structured autoreview: clean, confidence 0.88.
  • Testbox-through-Crabbox tbx_01kwybm52cwzvxb4qb6w7hsvar:
    pnpm check:changed passed on the byte-identical rebased repair tree.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: XS labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 9:40 AM ET / 13:40 UTC.

Summary
The branch caps Discord channel-info and Nextcloud Talk room-info process-local caches at 1000 entries using pruneMapToMaxSize and adds focused eviction coverage.

PR surface: Source +13, Tests +59. Total +72 across 4 files.

Reproducibility: yes. Source inspection shows current main can grow both module-level metadata Maps with distinct channel or room keys, and the PR's focused tests exercise the over-cap eviction path.

Review metrics: 1 noteworthy metric.

  • Process cache bounds: 2 added caps at 1000 entries. Both affected channel metadata caches move from unbounded process Maps to fixed-size process-local caches without config, persistence, or public API changes.

Stored data model
Persistent data-model change detected: persistent cache schema: extensions/nextcloud-talk/src/room-info.test.ts, vector/embedding metadata: extensions/discord/src/monitor/message-channel-info.ts, vector/embedding metadata: extensions/nextcloud-talk/src/room-info.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #101650
Summary: This PR is the consolidated open landing candidate for the Discord and Nextcloud Talk metadata-cache cap work; the separate Nextcloud Talk PR overlaps and the merged Slack PR is a sibling same-root-cause precedent.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • [P2] No repair lane is needed because the PR is a focused implementation with sufficient proof and no actionable reviewer finding.

Security
Cleared: The diff only changes bounded in-memory cache bookkeeping and focused tests; it does not touch dependencies, workflows, secrets, package metadata, auth, downloads, or code-execution surfaces.

Review details

Best possible solution:

Land the consolidated bounded-cache fix after exact-head CI and maintainer gates, keeping the cap owner-local and using the shared collection-runtime helper.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows current main can grow both module-level metadata Maps with distinct channel or room keys, and the PR's focused tests exercise the over-cap eviction path.

Is this the best way to solve the issue?

Yes. The fix stays inside the owning channel plugin modules, reuses the existing public SDK collection helper, and avoids adding config, persistence, or a new plugin API.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b95b9e448794.

Label changes

Label justifications:

  • P2: This is a normal-priority resource-bounding bugfix for two channel plugins with limited blast radius and no evidence of an active crash loop or blocked setup path.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR and related visible review context include after-fix terminal/Testbox evidence for the bounded-cache behavior, so no contributor proof action is needed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR and related visible review context include after-fix terminal/Testbox evidence for the bounded-cache behavior, so no contributor proof action is needed.
Evidence reviewed

PR surface:

Source +13, Tests +59. Total +72 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 16 3 +13
Tests 2 59 0 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 75 3 +72

What I checked:

Likely related people:

  • steipete: Recent GitHub path history shows repeated maintenance on the Discord channel-info cache, Nextcloud Talk room-info parsing, and the shared map-size helper used by this PR. (role: recent area contributor; confidence: high; commits: d33d6bfafa22, ed59629ccd82, 6e25112aad71; files: extensions/discord/src/monitor/message-channel-info.ts, extensions/nextcloud-talk/src/room-info.ts, src/infra/map-size.ts)
  • vincentkoc: The PR is currently assigned to vincentkoc, the consolidation commit is authored by them, and prior Nextcloud Talk room-info/private-network history includes their commits. (role: current assignee and feature-history contributor; confidence: high; commits: 4c79e1cce682, 376a79210060, c863ee1b86c1; files: extensions/nextcloud-talk/src/room-info.ts, extensions/nextcloud-talk/src/inbound.ts)
  • zhangguiping-xydt: They authored the merged Slack conversation-info cache cap that is the closest sibling implementation pattern for bounded channel metadata caches. (role: adjacent cache-cap contributor; confidence: medium; commits: 4e29b2f5ab4b; files: extensions/slack/src/channel-type.ts)
  • joshavant: Recent Nextcloud Talk bot-response work touched the same room-info/send behavior area and is useful routing context for this plugin surface. (role: adjacent Nextcloud Talk contributor; confidence: medium; commits: 024528c9379d; files: extensions/nextcloud-talk/src/room-info.ts, extensions/nextcloud-talk/src/send.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-07T12:56:12.155Z sha e70523c :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@vincentkoc
vincentkoc force-pushed the alix/discord-channel-info-cache-cap branch from e70523c to 6f5879c Compare July 7, 2026 13:24
@openclaw-barnacle openclaw-barnacle Bot added channel: nextcloud-talk Channel integration: nextcloud-talk size: S and removed size: XS labels Jul 7, 2026
@vincentkoc vincentkoc self-assigned this Jul 7, 2026
@vincentkoc vincentkoc changed the title fix(discord): cap channel info cache size fix(channels): prevent metadata caches from growing without bound Jul 7, 2026
@vincentkoc
vincentkoc force-pushed the alix/discord-channel-info-cache-cap branch from 6f5879c to 4c79e1c Compare July 7, 2026 13:34
@vincentkoc

Copy link
Copy Markdown
Member

Maintainer repair and landing proof are complete for exact head
4c79e1cce68231551f3c503d7fc9e3a21602d64e.

What changed:

  • Consolidated the same-author Nextcloud Talk cache-cap fragment from fix(nextcloud-talk): cap room info cache size #101662.
  • Replaced both bespoke eviction loops with the shared
    openclaw/plugin-sdk/collection-runtime pruning helper.
  • Kept both cache limits private; no production barrel or public API expansion.
  • Preserved existing TTL, negative-cache, request, error, and SSRF-policy behavior.

Validation:

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-discord.config.ts extensions/discord/src/monitor/message-utils.test.ts
    • 49/49 passed.
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-messaging.config.ts extensions/nextcloud-talk/src/room-info.test.ts
    • 8/8 passed.
  • oxfmt --check on all four changed files: passed.
  • git diff --check: passed.
  • Fresh structured autoreview: clean, no actionable findings, confidence 0.88.
  • Testbox-through-Crabbox tbx_01kwybm52cwzvxb4qb6w7hsvar:
    pnpm check:changed passed on the rebased repaired patch.
  • Exact-head hosted CI run 28870314607: completed successfully; all relevant
    checks are green.

The first hosted run exposed an unrelated stale native-i18n sentinel already
fixed on main by #101689. Rebasing onto that fix removed the failure without
changing this PR's four touched files.

Known gap: no live Discord gateway or Nextcloud Talk server was required for
this process-local Map eviction change; focused behavioral tests cover oldest
eviction and newest-entry retention on both owners.

Land-ready.

@vincentkoc
vincentkoc merged commit 936136a into openclaw:main Jul 7, 2026
94 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 8, 2026
…enclaw#101650)

* fix(discord): cap channel info cache size

* fix(channels): consolidate bounded metadata caches

---------

Co-authored-by: Vincent Koc <[email protected]>
sunlit-deng added a commit to sunlit-deng/openclaw that referenced this pull request Jul 8, 2026
The teamGroupIdCache Map had TTL-based expiry but no size cap.
A large Teams workspace with many distinct team IDs could accumulate
entries faster than the 10-minute TTL window, allowing unbounded growth.

Add a 500-entry cap via pruneMapToMaxSize, matching the pattern from
openclaw#101650 (Alix-007). This is a safety net — normal TTL expiry handles
most eviction; the cap prevents runaway growth under heavy usage.
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
…enclaw#101650)

* fix(discord): cap channel info cache size

* fix(channels): consolidate bounded metadata caches

---------

Co-authored-by: Vincent Koc <[email protected]>
@Alix-007

Alix-007 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @vincentkoc, appreciate the repair and landing pass here.

Consolidating the sibling cache-cap fragment and moving both paths onto the shared pruning helper makes sense. I’ll prefer that shared helper for similar metadata cache caps going forward.

Respect to OpenClaw’s chief architect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: nextcloud-talk Channel integration: nextcloud-talk P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants