ML-169.3: performed pubsub audit

This commit is contained in:
Claudio Ortolina
2026-05-19 08:20:11 +01:00
parent c7f194cf6c
commit 2d4b82e7bb
2 changed files with 325 additions and 8 deletions
@@ -1,10 +1,10 @@
---
id: ML-169.3
title: "Phase 2: PubSub subscription lifecycle audit"
status: To Do
status: In Progress
assignee: []
created_date: "2026-05-08 08:59"
updated_date: "2026-05-11 06:46"
updated_date: "2026-05-19 07:16"
labels:
- audit
- ready
@@ -13,6 +13,10 @@ references:
- lib/music_library/records.ex
- lib/music_library/listening_stats.ex
- lib/music_library_web/live_helpers/record_actions.ex
modified_files:
- >-
docs/audits/phase2-pubsub-lifecycle/doc-25 -
Audit-Report-PubSub-Subscription-Lifecycle-Phase-2.md
parent_task_id: ML-169
priority: medium
---
@@ -31,10 +35,24 @@ Pre-flagged concern: ListeningStats.subscribe() is called in mount by StatsLive.
<!-- 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
- [x] #1 Records.subscribe/1 and Records.unsubscribe/1 call sites audited — confirmed only called via manage_subscription/2 in Show LiveViews
- [x] #2 manage_subscription/2 verified correct across all navigation paths (direct URL, browser back/forward, push_navigate, push_patch)
- [x] #3 ListeningStats.subscribe() double-subscription risk on reconnect evaluated — either confirmed safe by PID monitoring or flagged with fix
- [x] #4 Termination cleanup verified: Phoenix.PubSub auto-cleans on PID death confirmed; any manual unsubscribe gaps documented
- [x] #5 Records.notify_update/1 broadcast sites audited against intended behavior (coordinates with Phase 3 worker audit)
- [x] #6 Findings report written as a Backlog.md document with file:line references, severity ratings, and fix recommendations
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Audit complete. Report written at docs/audits/phase2-pubsub-lifecycle/doc-25.
Key findings:
- 27 call sites across subscribe, unsubscribe, broadcast, and consumer handle_info verified
- All 8 subscribe sites have cleanup coverage (explicit unsubscribe or PID-death auto-clean)
- Pre-flagged ListeningStats.subscribe() double-subscription risk is a false positive: Phoenix.PubSub MapSet deduplicates per PID, and LiveView reconnect reuses the same PID within grace period
- No code changes required
<!-- SECTION:NOTES:END -->