fix(tasks): cap tasks retained per caller and evict finished ones first #289
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 288 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.339
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #289"
general
weight: 0.35
rozzilla
Problem
MemoryTaskStoreonly refused new tasks when the whole store (1000 records) was full, and finished tasks stayed until their ttl expired. One caller creating fast tasks with a longttlcould fill the store, after which every other caller's task creation failed for up to an hour with a bare-32603 "Internal server error".RedisTaskStorehad no cap at all.Fix
taskMaxRetainedPerPrincipal(default 100): the most tasks one principal may keep stored, finished ones included. Without authorization all callers share one quota.RedisTaskStoreenforces the quota atomically in a Lua script with a per-owner sorted set (mcp:tasks:owner:<subject>/mcp:tasks:anonymous, scored by creation time). The script prunes ids whose task key has expired, evicts as needed, and stretches the index expiry so it outlives its tasks.-32029 "Task limit reached". Stores throwTaskLimitError, which is exported along withTASK_LIMIT_REACHEDso custom stores can use it.MemoryTaskStorenow also accepts{ maxTasks, maxTasksPerPrincipal }. The old numeric argument still works.Relation to #239
#239 (merged) added per-owner Redis sorted sets for
tasks/listpagination. This PR now shares that index: #239'sINDEX_ADD_SCRIPTis folded intoCREATE_SCRIPT, which prunes expired ids, evicts, stores the task and adds it to the same per-owner set (same key, score and member, same index-expiry rule) in one atomic step. There is no globalmcp:tasksindex.Breaking change
Strictly speaking, yes. A single caller (or all callers together when authorization is off) can now keep at most 100 tasks by default. Older finished tasks beyond that are evicted before their ttl expires, and a 101st concurrently running task is refused. Raise
taskMaxRetainedPerPrincipalif you need more.Fixes #249
🤖 Generated with Claude Code
https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM