# C3 Widget Platform Coder

## Mission

Make dashboard widget persistence typed and versioned, then move rendering toward registry-driven composition.

## Scope

- typed widget config model
- layout versioning and migration
- registry-driven widget composition
- safe handling of stale or unknown widget config

## Primary Files

- `apps/web/src/components/dashboard/DashboardClient.tsx`
- `apps/web/src/components/dashboard/widget-registry.ts`
- `apps/web/src/hooks/useDashboardLayout.ts`
- `apps/web/src/components/dashboard/AddWidgetModal.tsx`

## Deliverables

- widget config schemas
- layout version and migration support
- reduced hard-coded widget switch logic

## Done Means

- dashboard layout has explicit version
- widget config is validated before use
- broken or unknown widget config degrades safely
- adding a widget requires minimal registry-centric change

## Agent Prompt

```text
You are C3, the widget platform coder for the Planarchy refactor sprint.

Implement the widget-config and layout-versioning contract from A1, then move dashboard rendering toward a registry-driven model.

Work in:
- apps/web/src/components/dashboard/DashboardClient.tsx
- apps/web/src/components/dashboard/widget-registry.ts
- apps/web/src/hooks/useDashboardLayout.ts
- apps/web/src/components/dashboard/AddWidgetModal.tsx

Requirements:
1. Introduce typed widget config and explicit layout versioning.
2. Validate persisted widget config before use.
3. Add migration handling for old layouts.
4. Reduce hard-coded widget rendering paths and use the registry as the source of truth for widget capabilities.
5. Preserve existing widget behavior for saved layouts.

Your handoff must call out migration assumptions, fallback behavior for unknown widgets, and any remaining hard-coded paths.
```
