feat(CORE-001D1): harden unit-aware workspace persistence

This commit is contained in:
Bu5hm4nn
2026-03-25 13:19:33 +01:00
parent cfb6abd842
commit 132aaed512
13 changed files with 464 additions and 87 deletions

View File

@@ -26,7 +26,14 @@ class WorkspaceRepository:
def workspace_exists(self, workspace_id: str) -> bool:
if not self.is_valid_workspace_id(workspace_id):
return False
return self._portfolio_path(workspace_id).exists()
portfolio_path = self._portfolio_path(workspace_id)
if not portfolio_path.exists():
return False
try:
PortfolioRepository(portfolio_path).load()
except (ValueError, TypeError, FileNotFoundError):
return False
return True
def create_workspace(self, workspace_id: str | None = None) -> PortfolioConfig:
resolved_workspace_id = workspace_id or str(uuid4())