# Dispatch Spot v241

## Summary
- Added live browser token issuance backend wiring for the Twilio token contract.
- Expanded CORI’s Quotes so operators can see real live-token readiness posture and issue a controlled token when the workspace is actually ready.
- Preserved staged rollout gating so the app does not pretend live calling is active when provider or workspace posture is incomplete.

## What changed
1. Live token contract helper added
   - Added `src/modules/voice/twilio-token.contract.ts`
   - Introduced workspace-gated readiness checks for:
     - required Twilio env mapping
     - staged rollout enablement
     - credential readiness
     - browser token posture
     - dispatcher voice-assist policy
     - provider-ready token service posture
   - Added signed JWT issuance using Node crypto when all required conditions are satisfied.

2. Token backend route upgraded
   - Updated `app/api/voice/twilio/token/route.ts`
   - The route now supports two behaviors:
     - readiness/foundation response
     - controlled live-token issuance mode
   - Added explicit blocked-reason output when live issuance cannot proceed.

3. CORI’s Quotes token section expanded
   - Updated `app/(dashboard)/cori/quotes/page.tsx`
   - Added provider-posture visibility.
   - Added a new action:
     - `Issue live token`
   - Added live-token readiness signals for:
     - provider ready
     - voice assist allowed
     - live token ready

4. Token issuance result visibility added
   - When a token is issued, the section now surfaces:
     - token preview
     - expiry time
     - voice region
     - optional full-token disclosure panel
   - When issuance is blocked, the section now surfaces the exact blocked reason.

5. Canonical documentation updated
   - Updated:
     - `CHANGELOG.md`
   - Added:
     - `dispatchspot_next_phase_handoff_v241.md`
     - `dispatchspot_next_phase_handoff_v241.html`

## What's Visible
When you log in and open CORI’s Quotes, this is what you will see and where you will see it:

1. In the existing Twilio token service backend foundation section
   - You will now see two action buttons at the top-right:
     - `Check token foundation`
     - `Issue live token`

2. Inside the summary cards in that same section
   - You will now also see provider posture visibility.

3. In the foundation contract results block
   - You will now see extra live-readiness lines for:
     - live token ready
     - provider ready
     - voice assist

4. After clicking `Issue live token`
   - If the workspace is fully ready, you will now see a success panel showing:
     - live browser token issued
     - token preview
     - expiry time
     - voice region
     - a disclosure row to reveal the full token

5. If issuance is not ready
   - You will now see a blocked-state panel showing the exact reason, such as:
     - missing Twilio env vars
     - provider posture pending
     - rollout disabled
     - voice assist blocked

## Important note
- There are no Prisma schema changes in v241.
- This build adds real backend token issuance wiring logic, but it still depends on valid Twilio environment variables and workspace/provider posture being set correctly on the deployed server before live issuance can succeed.
- I could not run a full dependency-aware Next.js build in this sandbox because installed project dependencies are not present here.

## Next
- This sets up the natural next step for controlled browser token consumption and dialer-side live token handling.
