def45dd0c6
_ensure_legacy_workspace creates the nil-UUID anchor (slug=legacy) owned by the platform admin (or oldest user as fallback). Raises a clear error if the DB has no users at all so we never silently create an orphaned workspace. Step 3 UPDATEs each table's remaining workspace_id IS NULL rows to LEGACY_WORKSPACE_ID. Orchestrator wires ensure-then-loop between Step 2 and Step 3. 3 new tests: orphan fan-out, no-users error, end-to-end orchestrator with mixed owned + orphan rows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>