Skip to content

fix(mattermost): cap outbound and monitor resource caches - #101740

Merged
steipete merged 1 commit into
openclaw:mainfrom
hugenshen:fix/mattermost-cap-process-caches
Jul 10, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
hugenshen:fix/mattermost-cap-process-caches

Conversation

@hugenshen

@hugenshen hugenshen commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Mattermost kept six process-local resource caches without cardinality bounds:

  • per-monitor channel and user lookups;
  • outbound bot identity, username, channel-name, and DM-channel lookups.

Long-lived gateways that encounter many distinct servers, credentials, channels, or users could therefore retain those entries indefinitely. The opaque-target classifier is no longer part of this PR because #103258 already landed its canonical cap on main.

Why This Change Was Made

The remaining cache owners now use the shared pruneMapToMaxSize plugin SDK helper after successful writes:

Cache Maximum entries
Monitor channel 1,000
Monitor user 1,000
Outbound bot identity 64
Outbound username 1,024
Outbound channel name 1,024
Outbound DM channel 1,024

Reads intentionally do not refresh insertion order. A newly resolved write moves that key to the newest position before pruning, which also gives deterministic behavior when concurrent misses resolve out of order. Existing five-minute channel and ten-minute user TTL behavior is unchanged.

User Impact

Mattermost gateways now keep these lookup caches within fixed memory bounds. Eviction is transparent: a later lookup follows the existing API-resolution path and repopulates the entry. Configuration, routing, send behavior, and public plugin APIs are unchanged.

Evidence

  • Exact repaired head: 4486068b493f2c7289b2b8015ade713d349415f9.

  • Deterministic regressions fill every cache to its cap, prove the oldest entry is evicted, and prove the newest entry remains cached.

  • Monitor tests cover both channel and user caches and the exact TTL boundary.

  • Fresh post-rebase Codex autoreview: no accepted or actionable findings, confidence 0.90.

  • Hosted CI run 29072789577: 43 jobs succeeded and 12 conditional jobs skipped, with no failures.

  • CodeQL Critical Quality run 29072789602: the selected channel-runtime boundary passed.

  • Blacksmith Testbox-through-Crabbox run 29073327959 (tbx_01kx5am65jxqh2wswd42ms2cwe): both touched files passed, 2 files / 48 tests.

  • AI-assisted

  • I understand what the code does

  • Change is focused and does not mix unrelated concerns

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

clawsweeper Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 8, 2026, 2:33 AM ET / 06:33 UTC.

Summary
The branch adds max-entry pruning to Mattermost monitor, outbound send, and opaque-target in-process caches, plus monitor and opaque-target eviction regression tests.

PR surface: Source +61, Tests +50. Total +111 across 5 files.

Reproducibility: yes. source-reproducible: current main and v2026.6.11 store Mattermost cache entries in Maps without max-entry pruning. I did not establish a live high-cardinality Mattermost gateway run.

Review metrics: 1 noteworthy metric.

  • Mattermost process cache caps: 7 added. The diff changes process-memory behavior across monitor lookup, outbound send, and opaque-target caches, so maintainers should review the cap table before merge.

Stored data model
Persistent data-model change detected: persistent cache schema: extensions/mattermost/src/mattermost/monitor-resources.test.ts, persistent cache schema: extensions/mattermost/src/mattermost/monitor-resources.ts, persistent cache schema: extensions/mattermost/src/mattermost/send.ts, persistent cache schema: extensions/mattermost/src/mattermost/target-resolution.test.ts, vector/embedding metadata: extensions/mattermost/src/mattermost/monitor-resources.ts, vector/embedding metadata: extensions/mattermost/src/mattermost/send.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body provides exact-SHA Vitest output and mocked regression flows, but it explicitly lacks redacted live Mattermost/gateway logs or a real setup transcript; screenshots, terminal output, copied live output, recordings, or redacted logs from a real run would satisfy the gate if private details are redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

Maintainer options:

  1. Reconcile the overlapping outbound cache path (recommended)
    Before merge, align this PR with fix(mattermost): cap outbound target caches to prevent unbounded memory growth #101800 on cap values and outbound regression coverage so one branch owns the final behavior.
  2. Land the broader branch after proof
    Maintainers may accept this PR as canonical once redacted real Mattermost/gateway proof shows bounded behavior and the outbound-only PR is closed or superseded.
  3. Pause or close duplicate cache-cap work
    If maintainers do not want the broader scope, pause this PR and keep the narrower outbound-only path as the candidate.

Next step before merge

  • [P1] No automated repair is appropriate because the remaining blockers are contributor-supplied real behavior proof and maintainer coordination with the overlapping outbound-only PR.

Maintainer decision needed

  • Question: Should maintainers use this broader Mattermost cache-cap PR as the canonical landing path, or prefer the narrower outbound-only PR plus separate monitor/opaque work?
  • Rationale: Both open PRs touch the Mattermost outbound cache behavior with different cap tables, and green CI does not decide which user-facing resource mitigation should become the durable owner path.
  • Likely owner: mukhtharcm — CONTRIBUTING.md lists this person for Mattermost and the relevant earlier Mattermost PRs were merged by them.
  • Options:
    • Use the broader cache-cap path (recommended): Make this PR canonical after real Mattermost/gateway proof and outbound cap/test reconciliation, then close or supersede the outbound-only PR.
    • Prefer the outbound-only PR first: Land fix(mattermost): cap outbound target caches to prevent unbounded memory growth #101800 after proof and ask for monitor/opaque cache caps in a separate focused PR.
    • Pause both cache-cap branches: Hold both PRs until a Mattermost owner chooses the cap table and proof bar.

Security
Cleared: No concrete security or supply-chain concern found; the diff only changes Mattermost plugin TypeScript/tests and imports an existing SDK helper.

Review details

Best possible solution:

Land one coordinated Mattermost cache-cap change that keeps the broad monitor/outbound/opaque coverage, reconciles outbound cap values and tests with #101800, and includes redacted real Mattermost or gateway proof.

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

Yes, source-reproducible: current main and v2026.6.11 store Mattermost cache entries in Maps without max-entry pruning. I did not establish a live high-cardinality Mattermost gateway run.

Is this the best way to solve the issue?

Unclear as a landing path: bounding the plugin-local caches with the shared helper is the right code shape, but this branch should reconcile proof, cap values, and outbound tests with the overlapping PR before merge.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a normal-priority resource-growth fix for one bundled channel plugin with limited blast radius and no evidence of an active outage.
  • merge-risk: 🚨 other: A second open PR changes the same Mattermost outbound cache surface with different cap values, so merge order and canonical ownership need maintainer coordination.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides exact-SHA Vitest output and mocked regression flows, but it explicitly lacks redacted live Mattermost/gateway logs or a real setup transcript; screenshots, terminal output, copied live output, recordings, or redacted logs from a real run would satisfy the gate if private details are redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +61, Tests +50. Total +111 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 73 12 +61
Tests 2 50 0 +50
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 123 12 +111

What I checked:

Likely related people:

  • mukhtharcm: CONTRIBUTING.md lists Muhammed Mukhthar for Mattermost, and he merged the adjacent Mattermost user-first DM and buttons PRs. (role: listed Mattermost area owner and prior merger; confidence: high; commits: 6d0547dc2eab, 136ca87f7bb2; files: CONTRIBUTING.md, extensions/mattermost/src/mattermost/send.ts, extensions/mattermost/src/mattermost/target-resolution.ts)
  • vincentkoc: Recent current-main Mattermost refactors touched the exact cache-bearing files, and the overlapping outbound-only PR is assigned to this person. (role: recent area contributor; confidence: high; commits: eb5d8f85c458, ba7af3630673; files: extensions/mattermost/src/mattermost/send.ts, extensions/mattermost/src/mattermost/monitor-resources.ts, extensions/mattermost/src/mattermost/target-resolution.ts)
  • teconomix: The user-first Mattermost DM and opaque-target resolution path being capped here traces to their merged PR. (role: feature-history contributor; confidence: high; commits: 6d0547dc2eab; files: extensions/mattermost/src/mattermost/send.ts, extensions/mattermost/src/mattermost/target-resolution.ts)
  • Peter Steinberger: The monitor resource helper split that now owns the per-monitor channel/user caches was introduced in a broad monitor runtime refactor. (role: monitor runtime refactor contributor; confidence: medium; commits: b86bc9de95d0; files: extensions/mattermost/src/mattermost/monitor-resources.ts, extensions/mattermost/src/mattermost/monitor.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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-07T15:32:41.066Z sha 38066dda38b506d236c47dc999deff4c2f6614ac :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T15:52:06.101Z sha 44b772b0a8a4825e2b5f62cbaad79a689136524b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T15:59:16.903Z sha 44b772b0a8a4825e2b5f62cbaad79a689136524b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T02:26:13.504Z sha b32fac5444b5ba46391ec8b59234d45e3af4b04a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T02:33:19.952Z sha b32fac5444b5ba46391ec8b59234d45e3af4b04a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T03:55:14.422Z sha b32fac5444b5ba46391ec8b59234d45e3af4b04a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T04:20:51.421Z sha 95aeb011951b297918f45efcccff3b93dbd97c9b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T04:23:17.182Z sha 95aeb011951b297918f45efcccff3b93dbd97c9b :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M and removed size: S labels Jul 7, 2026
@hugenshen
hugenshen force-pushed the fix/mattermost-cap-process-caches branch from ca7f7eb to 44b772b Compare July 7, 2026 15:43
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed scripts Repository scripts size: M labels Jul 7, 2026
@hugenshen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — branch rebased to single commit on latest main, proof scripts removed from repo, PR body updated with Real behavior proof (Vitest regression output).

@clawsweeper

clawsweeper Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@hugenshen
hugenshen force-pushed the fix/mattermost-cap-process-caches branch from 44b772b to b32fac5 Compare July 8, 2026 02:15
@hugenshen

Copy link
Copy Markdown
Contributor Author

Squashed to a single commit and rebased on latest main. Behavior proof is covered by colocated regression tests (no scripts/proof-*.mjs).

Test run

pnpm test extensions/mattermost/src/mattermost/monitor-resources.test.ts — 8 passed; target-resolution.test.ts — 5 passed

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@hugenshen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Jul 8, 2026
@steipete
steipete force-pushed the fix/mattermost-cap-process-caches branch from 95aeb01 to 4486068 Compare July 10, 2026 06:02
@steipete steipete changed the title fix(mattermost): cap opaque, outbound, and monitor resource caches fix(mattermost): cap outbound and monitor resource caches Jul 10, 2026
@steipete

Copy link
Copy Markdown
Contributor

Maintainer repair complete; this is land-ready.

What changed:

  • Removed the opaque-classifier overlap because fix(mattermost): cap opaque target cache #103258 already landed its canonical cap.
  • Bounded the two monitor caches at 1,000 entries while preserving their existing TTLs.
  • Bounded outbound bot identity at 64 entries and username, channel-name, and DM-channel caches at 1,024.
  • Added deterministic coverage for every remaining cache, oldest eviction, newest retention, and exact monitor TTL expiry.

Evidence:

Known proof gaps: none blocking. The release-prep changelog owns the central Mattermost memory-bound entry and contributor credit. A live Mattermost server run adds little to this deterministic in-memory bound; eviction returns to the already-tested API-resolution path.

Thanks @hugenshen for finding and fixing the remaining Mattermost cache-retention surfaces.

@steipete
steipete merged commit 514829f into openclaw:main Jul 10, 2026
108 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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