Repository navigation
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 10:35 PM ET / 02:35 UTC. Summary PR surface: Source +13, Tests +80. Total +93 across 2 files. Reproducibility: yes. by source inspection: current main declares process-wide Mattermost outbound Maps and writes them without max-size pruning. I did not establish a live high-cardinality Mattermost gateway run. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one proven Mattermost cache-cap path: this narrow outbound-only fix after real proof, or the broader #101740 if maintainers choose that as the canonical scope. Do we have a high-confidence way to reproduce the issue? Yes by source inspection: current main declares process-wide Mattermost outbound Maps and writes them without max-size pruning. I did not establish a live high-cardinality Mattermost gateway run. Is this the best way to solve the issue? Yes for the code shape: the patch stays inside the Mattermost plugin boundary, uses an existing SDK helper, and avoids new config or persistence. It is not merge-ready until real behavior proof is supplied and the overlapping PR path is coordinated. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fdc98242a1e5. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +13, Tests +80. Total +93 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (2 earlier review cycles)
|
a297bbe to
17c415a
Compare
|
Rebased onto latest Test run New regressions
Prior CI failure was unrelated ( @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Add outbound cache cap regressions. Co-authored-by: Cursor <[email protected]>
17c415a to
56f2411
Compare
|
Squashed to a single commit and rebased on latest Test run @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Closing as superseded by #101740, which landed as The landed canonical repair includes this PR's four outbound cache owners, with a 64-entry bot identity cap and 1,024-entry username, channel-name, and DM-channel caps. It also bounds the two monitor resource caches, while #103258 owns the already-landed opaque-target classifier cap. Focused Mattermost proof passed 2 files / 48 tests in Blacksmith Testbox run 29073327959, and hosted CI passed in run 29072789577. The landed commit preserves your authorship and co-authorship. Thanks @hugenshen for identifying and fixing these retention paths. |
What Problem This Solves
Fixes an issue where long-running Mattermost-connected OpenClaw processes gradually accumulate unbounded heap memory proportional to the number of unique users, channel names, and DM pairs they have ever addressed. On active servers with many distinct recipients the four module-level Maps in
send.ts—botUserCache,userByNameCache,channelByNameCache,dmChannelCache— grow without limit and are never evicted.Concrete example: An OpenClaw instance routing messages to 5 000 distinct Mattermost users over a week records 5 000 entries in
userByNameCacheand another 5 000 indmChannelCache. No TTL, no eviction, no bound — every unique(baseUrl, token, target)triple stays in memory for the life of the process.Why This Change Was Made
Added four named cap constants and one
pruneMapToMaxSizecall after each cache.set().pruneMapToMaxSize(fromopenclaw/plugin-sdk/collection-runtime) evicts the oldest insertion-order entry whenever the map exceeds its limit — the same LRU-like strategy used insrc/infra/map-size.ts.Cap values follow the existing Slack precedent (
SLACK_DM_CHANNEL_CACHE_MAX = 1024atextensions/slack/src/send.ts:49):botUserCacheuserByNameCachechannelByNameCachedmChannelCacheUser Impact
Before: Memory in the Mattermost send path grows linearly with the number of unique targets seen since process start. Operators on large servers must restart periodically to reclaim memory.
After: Each outbound cache is capped; the total overhead per cache is bounded and stable under sustained traffic.
Evidence
extensions/mattermost/src/mattermost/send.ts:70–73— four unboundedMapdeclarations, no cap or TTL before this PRextensions/slack/src/send.ts:49,572–578— direct Slack precedent withSLACK_DM_CHANNEL_CACHE_MAXsrc/infra/map-size.ts—pruneMapToMaxSizeimplementation;openclaw/plugin-sdk/collection-runtimere-exports itextensions/mattermost/src/mattermost/send.ts; call-site regressions added inextensions/mattermost/src/mattermost/send.test.tsBehavior proof
New regressions in
extensions/mattermost/src/mattermost/send.test.tsassert outbound caches stay bounded:evicts oldest DM channel cache entries after the configured cap— 1025 distinctuser:sends force a cache miss on the first entry after the 1024 cap.evicts oldest user-by-name cache entries after the configured cap— 513 distinct@usernamesends force a username re-lookup for the first entry after the 512 cap.This mirrors the Slack DM cache precedent and reuses the shared
pruneMapToMaxSizehelper contract fromsrc/infra/map-size.ts.Made with Cursor