# Phase 3 — Deferred Admin UIs

> These items are explicitly deferred from v1. Each references the Phase 1/2 infrastructure already in place.
> Implement in any order — they are independent.

---

## 3.1 WorkflowEngine Admin UI

**What:** CRUD interface for `workflow_rules`. Drag-and-drop action builder.
**Prereqs:** `workflow_rules` table (Phase 1), `WorkflowDispatcher` (Phase 1).
**Note:** Rules added via UI must set `is_system = false` so they survive re-seeding.

---

## 3.2 EntityEngine Admin UI

**What:** CRUD for `entity_types` and `entity_relationships`. Manage capabilities per entity.
**Prereqs:** `entity_types`, `entity_relationships` tables (Phase 1), `EntityRegistry` (Phase 1).

---

## 3.3 Pipeline Management UI

**What:** Drag-and-drop stage ordering, color picker, add/remove stages, create new pipelines.
**Prereqs:** `pipelines`, `pipeline_stages` tables (Phase 1), `PipelineService` (Phase 1).
**Note:** User-created stages have `is_system = false` — seeder will not overwrite them.

---

## 3.4 Proposal UI

**What:** Template builder, proposal editor, approval workflow, PDF export.
**Prereqs:** `proposal_templates`, `proposals`, `proposal_approvals` tables (Phase 1),
`ProposalService` stub (Phase 1).

---

## 3.5 Contact Segments

**What:** Saved filter sets on contacts — tag-based or criteria-based grouping.
**Prereqs:** Existing `contacts` table, `contact_tags` (already in DB).
**Note:** No new tables needed if using tags + filter. May need `contact_segments` table for saved criteria.

---

## 3.6 Feature Pack Import/Export

**What:** Admin UI to upload a custom pack JSON, preview changes, apply/rollback.
**Prereqs:** `FeaturePackSeeder` (Phase 1). Additive-only constraint still applies.

---

## 3.7 Stub Profile Content Refinement

**What:** Review and improve the 5 feature pack JSONs based on real user feedback.
Adjust field labels, stage names, add new workflow rules.
**Prereqs:** Phase 2 user journeys completed and feedback collected.
**How:** Edit the JSON files + bump `version` in each pack + re-run `setup:crm`.

---

## 3.8 AI Pipeline (LLM Integration)

**What:** Replace `NullAiHook` with a real LLM-backed `AiHook` implementation.
Score leads based on custom field values. Suggest next action.
**Prereqs:** `AiHookInterface` (Phase 1), `score` column in `leads` (Phase 1),
`ComputeScore` action in WorkflowEngine (Phase 1).
**How:** Create `OpenAiHook implements AiHookInterface`, rebind in `CoreAppServiceProvider`.
No other code changes needed.

---

## 3.9 Admin Observability Panel

**What:** Dashboard showing: recent `workflow_runs` (pass/fail), `pipeline_stage_transitions`
heatmap, round-robin assignment distribution, feature pack version per tenant.
**Prereqs:** `workflow_runs` (Phase 1), `pipeline_stage_transitions` (Phase 1),
`activity_logs` (Phase 1), `settings` rows (Phase 1).
**Note:** Raw DB inspection is sufficient before go-live. This panel is v2 quality-of-life.
