# ALPHA STABILIZATION-003
## Workspace Session Context

You are implementing Alpha Stabilization-003 for the INVEETAIRE platform.

This is an architecture refinement.

This is NOT a new feature.

This patch prepares the platform for future multi-workspace support while preserving the current single-workspace Alpha experience.

Do NOT implement Workspace Users yet.

Do NOT redesign permissions.

---

Current Status

✅ Sprint 0

✅ Sprint 1

✅ Sprint 2

✅ Sprint 3

✅ Pilot-001

✅ Pilot-002

✅ Pilot-003

✅ Pilot-004

✅ Pilot-005

✅ Pilot-006

✅ Pilot-007

✅ Alpha Patch-001

✅ Alpha Patch-002

✅ DEV PATCH-001

✅ DEV PATCH-002

✅ Alpha Stabilization-001

✅ Alpha Stabilization-002

---

Objective

Introduce the concept of an Active Workspace Session.

Currently every Couple user owns exactly one workspace.

This patch establishes the architecture so future versions can support multiple workspaces without changing business modules.

---

Current Behaviour

User logs in.

↓

Redirects to dashboard.

Business modules independently retrieve workspace context.

---

Target Behaviour

User logs in.

↓

Workspace Context Resolver

↓

Session.active_workspace_id

Session.active_workspace_slug

Session.active_workspace_name

↓

Dashboard

↓

All modules consume workspace context from session.

---

Requirements

Create a Workspace Context abstraction.

The active workspace must be established immediately after successful authentication.

The workspace context becomes the single source of truth.

No module should need to resolve workspace ownership repeatedly.

---

Workspace Context

Store in session:

active_workspace_id

active_workspace_slug

active_workspace_name

active_workspace_status

For Super Admin:

workspace context remains NULL.

No workspace selected yet.

---

Authentication Flow

Platform Login

↓

Admin

↓

No active workspace.

Workspace Login

↓

Couple / Crew

↓

Resolve workspace.

↓

Store active workspace.

↓

Redirect to dashboard.

---

Services

Reuse existing WorkspaceService where appropriate.

Do NOT duplicate workspace lookup logic.

If a WorkspaceContext helper/service is beneficial,

create one.

Keep responsibilities clean.

---

Routing

Do NOT expose workspace_slug in internal panel URLs.

Internal URLs remain:

/app/dashboard

/app/invitation

/app/guests

/app/messages

/app/checkin

/app/reports

Workspace is inferred entirely from session.

Public invitation URLs remain unchanged.

---

Constraints

Do NOT:

Implement workspace selector

Implement workspace switching

Implement workspace users

Implement permission redesign

Modify public invitation URLs

Modify QR URLs

Modify messaging URLs

Modify database schema

Modify Sprint 3 tenant isolation

---

Verification

Verify:

Couple login creates active workspace session.

Crew login (current implementation) creates active workspace session.

Admin login does not create workspace session.

Dashboard reads workspace from session.

Guest module reads workspace from session.

Invitation module reads workspace from session.

Operation module reads workspace from session.

Workspace isolation remains intact.

Session survives page refresh.

Logout clears workspace context.

PHP syntax passes.

---

Acceptance Criteria

PASS only if:

Workspace context exists.

Session becomes single source of truth.

Internal URLs contain no workspace slug.

No database changes.

No duplicated workspace lookup.

Authentication continues working.

PHP syntax passes.

---

Output

Provide:

1. Files created.

2. Files modified.

3. Workspace session architecture.

4. Authentication workflow.

5. Session lifecycle.

6. Verification results.

7. Acceptance checklist.

8. PHP syntax results.

Stop after implementation.

Wait for Human Approval.