Files
music_library/backlog/tasks/ml-169.3 - Phase-2-PubSub-subscription-lifecycle-audit.md
T
2026-05-11 07:49:40 +01:00

41 lines
1.7 KiB
Markdown

---
id: ML-169.3
title: "Phase 2: PubSub subscription lifecycle audit"
status: To Do
assignee: []
created_date: "2026-05-08 08:59"
updated_date: "2026-05-11 06:46"
labels:
- audit
- ready
dependencies: []
references:
- lib/music_library/records.ex
- lib/music_library/listening_stats.ex
- lib/music_library_web/live_helpers/record_actions.ex
parent_task_id: ML-169
priority: medium
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Audit all PubSub subscribe/unsubscribe pairs for correctness. Verify no stale subscriptions or double-subscription risks.
Pre-flagged concern: ListeningStats.subscribe() is called in mount by StatsLive.Index and ScrobbledTracksLive.Index but never unsubscribed. Phoenix.PubSub monitors PID for auto-cleanup, but double-subscription on LiveView reconnect is possible and needs verification.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Records.subscribe/1 and Records.unsubscribe/1 call sites audited — confirmed only called via manage_subscription/2 in Show LiveViews
- [ ] #2 manage_subscription/2 verified correct across all navigation paths (direct URL, browser back/forward, push_navigate, push_patch)
- [ ] #3 ListeningStats.subscribe() double-subscription risk on reconnect evaluated — either confirmed safe by PID monitoring or flagged with fix
- [ ] #4 Termination cleanup verified: Phoenix.PubSub auto-cleans on PID death confirmed; any manual unsubscribe gaps documented
- [ ] #5 Records.notify_update/1 broadcast sites audited against intended behavior (coordinates with Phase 3 worker audit)
- [ ] #6 Findings report written as a Backlog.md document with file:line references, severity ratings, and fix recommendations
<!-- AC:END -->