Guard production deletion against active sessions - #367
Conversation
The DELETE /production/:id endpoint deleted a production unconditionally, relying entirely on a client-side check for active participants before allowing the request. A direct API call bypassed that guard, so an in-use production could be removed while sessions were connected. Add ProductionManager.hasActiveSessions() to check for non-expired, active sessions on a production, and have the route return 409 Conflict instead of deleting when any are found. Closes #172 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Self-review (daily-backlog-pr Phase 3) — Verdict: Needs ChangesRecorded as a marker comment because this PR is self-authored by the automation account, and GitHub blocks state-bearing self-review. The board item (#172) is being moved back to Ready so the next implementation pass addresses the feedback below. The change is mechanically clean (409 wiring, schema updated, Blocking
Suggestions
|
Address self-review feedback on #172: keying the deletion guard on isActive:true under-blocked the ~40s window where a session is past the inactivity threshold (isActive:false) but not yet expired (isExpired:false) and a heartbeat would reactivate it. Match the isExpired-based "in use" definition used by getUsersForLine/checkUserStatus and add a regression test for the isActive:false/isExpired:false boundary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Self-review (daily-backlog-pr Phase 3) — Verdict: LGTMRecorded as a marker comment because this PR is self-authored by the automation account (GitHub blocks state-bearing self-review). Reviewed by a separate The prior Needs-Changes feedback was addressed: No blocking items. Merging with |
Summary
/production/:productionIdendpoint deleted a production unconditionally, relying entirely on a client-side check for active participants before the request was even made.ProductionManager.hasActiveSessions(productionId), which queries the db for non-expired sessions on the production that are still marked active.409 Conflict(without deleting) when active sessions exist, instead of silently removing an in-use production.Test plan
npm test)npm run typecheck)npm run lint)/production/:idreturns 409 and does not calldeleteProductionwhenhasActiveSessionsresolves true, and still deletes (200) when it resolves falseCloses #172
🤖 Generated with Claude Code