# Broadcast Configuration Fallback Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Prevent incomplete Pusher credentials from causing 500 responses across sale and transaction modal requests.

**Architecture:** Validate the selected broadcast connection in `BroadcastServiceProvider` before channel registration. Switch only an incomplete Pusher connection to the existing `null` driver, leaving valid Pusher and every other driver unchanged.

**Tech Stack:** PHP, Laravel service providers/configuration, PHPUnit.

## Global Constraints

- Do not edit `.env` or add a database migration.
- Preserve Pusher behavior whenever key, secret, and application ID are all present.
- Keep the fallback limited to application startup.

---

### Task 1: Add broadcast fallback and regression coverage

**Files:**
- Modify: `app/Providers/BroadcastServiceProvider.php`
- Create: `tests/Unit/BroadcastServiceProviderTest.php`

**Interfaces:**
- Consumes: Laravel's `config()` repository and `Broadcast::routes()` registration.
- Produces: `BroadcastServiceProvider::useSafeDefaultConnection(): void`, called before broadcast route/channel registration.

- [ ] **Step 1: Write the failing test**

Add tests that invoke the provider's fallback method through reflection. Assert that incomplete Pusher configuration changes `broadcasting.default` to `null`, and complete Pusher configuration remains `pusher`.

- [ ] **Step 2: Run the focused test to verify it fails**

Run: `php artisan test tests/Unit/BroadcastServiceProviderTest.php`

Expected: FAIL because the fallback method does not exist.

- [ ] **Step 3: Implement the minimal fallback**

Add a private provider method that checks `broadcasting.default`, reads the selected Pusher connection, and sets `broadcasting.default` to `null` when `key`, `secret`, or `app_id` is blank. Call it at the start of `boot()`.

- [ ] **Step 4: Run focused and full verification**

Run: `php artisan test tests/Unit/BroadcastServiceProviderTest.php`

Run: `php artisan config:cache && php artisan view:cache && php artisan test --compact`

Expected: all commands exit successfully with no failing tests.
