[LegalMind] pendingAttachments in-memory Map has no orphan eviction
The pendingAttachments Map in supportIntake.ts stores metadata for uploaded attachments awaiting binding to a message. Entries are only removed when a message is sent. If a user...
StateDoneNext ActionClosedOwnerLuciRuntimeClosedAge29d ago
Ticket is done; runtime is closed.·profile claude_opus_1m_medium · cwd /home/lucienne/workspace · uptime 29d 3h · last activity 29d 1h ago
Description
MC-3442
The pendingAttachments Map in supportIntake.ts stores metadata for uploaded attachments awaiting binding to a message. Entries are only removed when a message is sent. If a user uploads attachments but abandons the session, those entries persist indefinitely until server restart. Over time this is a slow memory leak. Should add a TTL-based cleanup (e.g., evict entries older than 1 hour) or use the existing periodic cleanup interval pattern.
File: server/routes/supportIntake.ts:79
Complexity: simple
Found by: nightly code review (3a243848 Merge pull request #401 from conrelma/fix/mc-3430-bundle-extra-page-end)
Auto-fix skipped: Luci-side scheduled autofix is disabled by default; Larry owns LegalMind code changes.
Activity
done
INTERACTIVE
Luci is working...
Details —
Done
· Low
· Luci
▼
SState
Done
Closed
PPeople
TTiming / Details▼
legalmind-review (scheduled)
LegalMind
29d ago
16d ago
Advanced / Operator evidence
RRouting owner
ROperator console
Ticket is done; runtime is closed.ticket_marked_doneprofile claude_opus_1m_medium · cwd /home/lucienne/workspace · uptime 29d 3h · last activity 29d 1h agoMC is visibility-only. Hermes Luci launches and gates work outside MC, then mirrors evidence/status here.
1c679b24-bfea-499b-ab4b-787208acea66 · luci · claude/anthropic/opus[1m]
WWorkflow
Start Dev Review + QA ▾
Select phases to include:
Agents
Review Gates
Decision
WAT routing: choose an agent, review gate, or decision. Buttons use the live runtime when one is attached.
Luci dispatching this ticket to Larry (background worker via SSH).
luci29d ago
Completed on Larry:
Now update the export at bottom:Now write a regression test:Typecheck clean and tests pass. Commit and push.Added 1-hour TTL eviction for the `pendingAttachments` Map in `server/routes/supportIntake.ts` — exported `evictExpiredPendingAttachments()` and scheduled a 10-minute `setInterval` sweep (unref'd, skipped under `NODE_ENV=test`). Added unit test `mc3442-pending-attachment-ttl.test.ts` covering expired vs fresh entries. Typecheck clean, tests pass, committed on `fix/mc-3442` and pushed.
luci29d ago
Larry: Triggering post-completion code review...
luci29d ago
Code review (Larry reviewer via claude/opus):
uld avoid repeated `Date.parse` on every sweep.
Cosmetic.
MINOR: test file — `pendingAttachments` is exported solely for test access. Acceptable for
a small fix; a `__testing` nam
espace would be tidier but not worth the churn.
The exported TTL constant, p
ure `evictExpiredPendingAttachments(now)` function, and deterministic test (injects `now`) are the right shape. Ac
ceptance criterion (orphan eviction) is met.
VERDICT: PASS
TTL eviction added for `pendingAttachments` with unit test covering expired/fresh entries.
MINOR: server/routes/supportIntake.ts — diff is truncated mid-function (`c` is the last char shown), so I can't verify the sweep interval is actually wired up via `setInterval` or that the interval is `unref()`'d to avoid blocking process exit. If a `setInterval` was added without `unref()`, tests/server shutdown may hang — worth confirming, but not blocking on the visible code.
MINOR: server/routes/supportIntake.ts:~80 — `createdAt` is stored as ISO string and parsed via `Date` in the eviction loop (presumably). Storing as epoch ms would avoid repeated `Date.parse` on every sweep. Cosmetic.
MINOR: test file — `pendingAttachments` is exported solely for test access. Acceptable for a small fix; a `__testing` namespace would be tidier but not worth the churn.
The exported TTL constant, pure `evictExpiredPendingAttachments(now)` function, and deterministic test (injects `now`) are the right shape. Acceptance criterion (orphan eviction) is met.
VERDICT: PASS
luci29d ago
Larry shipped with clean code review. Auto-dispatching Luci-reviewer (verdict: clean). Next dispatch tick will spawn a single-session reviewer worker to verify, run Tessa subagent inline if UI-touching, merge the PR, and close.
luci29d ago
External runtime/provider failure; auto-retry suppressed.
API Error: Request rejected (429) · The service may be temporarily overloaded, please try again later