> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Dead Code Wiring Execution Plan

> Phased plan to wire up spec-complete or in-progress code clusters that dead-code analysis flags as unwired — restore, stabilize, then reconnect each cluster.

Last updated: 2026-05-07
Owner: platform engineering
Scope: spec-complete or implementation-in-progress clusters that currently appear unwired in dead-code analysis.

## Phased execution order

* **P0 - Restore and stabilize build:** Restore risky deletions, run build/typecheck/dead-code scan, freeze delete actions.
* **P1 - Already-routed imports:** For routes that already exist, wire missing leaf components/hooks into existing page containers.
* **P2 - Page-level wiring:** Connect feature components to page-level tabs/cards/dialog triggers and permissions.
* **P3 - New routes if needed:** Add routes only where specs require distinct navigation surface and no existing page can host the feature.
* **P4 - Selective pruning:** After wiring validation and spec checks, prune truly dead files in small reviewed batches.

## CL (Clinical)

### Cluster: AI documentation controls

* **Target route/page/component:** `/cl/ambient-review`, `/cl/electronic-consents`; `src/cores/cl/ai-documentation/components/*`
* **Current wiring state:** Core routes are present; multiple AI documentation UI controls exist but are not consistently referenced by active page modules.
* **Exact implementation tasks:** Attach missing controls to review/settings surfaces; reconnect matching hooks; validate permission gating.
* **Acceptance checks:** Route renders without missing import errors; controls visible behind expected permissions; build + dead-code scan no longer flags wired files.

### Cluster: Referral status subcomponents

* **Target route/page/component:** `/cl/referral-outcomes`; `src/cores/cl/components/referral-status/*`
* **Current wiring state:** Route is active; shared referral-status dialogs/tables were restored but are not all referenced.
* **Exact implementation tasks:** Reconnect detail sheet/history/update dialog into referral outcome workflows; ensure query/mutation hooks are consumed by container page.
* **Acceptance checks:** User can open referral status history/update from route UI; no unresolved imports; dead-code count reduced for this cluster.

## CE (Community Engagement)

### Cluster: Mobile CRM shell + SMS conversation UI

* **Target route/page/component:** `/ce/*` pages, `src/cores/ce/components/mobile/*`, `src/cores/ce/components/sms/SmsConversation*`
* **Current wiring state:** Core CE routes are present; mobile and conversation leaf components were restored after accidental deletion but remain weakly connected.
* **Exact implementation tasks:** Reattach mobile shell wrappers to CE page layouts; wire SMS conversation panel/bubbles into active SMS pages.
* **Acceptance checks:** CE pages compile on desktop/mobile breakpoints; SMS conversation flow renders end-to-end; no dead imports from restored SMS/mobile files.

### Cluster: Assignment queue web-form components

* **Target route/page/component:** `/ce/web-forms/:id` and related builder pages; `src/cores/ce/components/web-forms/AssignmentQueue*`
* **Current wiring state:** Web-form routes exist, assignment queue leaf components are not clearly reachable.
* **Exact implementation tasks:** Hook assignment queue panel/search/item into web-form builder/detail workflows.
* **Acceptance checks:** Queue configuration accessible in UI; saved assignment rules persist and rehydrate; components are referenced by route-driven pages.

## FW (Forms & Workflow)

### Cluster: Sandbox/testing panel

* **Target route/page/component:** `/fw/forms/edit`, `/fw/automations/:id/workflow`; `src/cores/fw/components/testing/*`
* **Current wiring state:** Editing routes exist; sandbox testing components are present but not consistently mounted.
* **Exact implementation tasks:** Add explicit sandbox tab/accordion entry points in editor/workflow pages; bind state and execution handlers.
* **Acceptance checks:** Sandbox opens, executes test scenarios, and writes to expected history/telemetry paths; no unresolved imports.

### Cluster: Template/marketplace/prefill adjunct components

* **Target route/page/component:** `/fw/templates/marketplace`, `/fw/wizards/marketplace`, form prefill surfaces.
* **Current wiring state:** Marketplace routes exist; several leaf UI components (cards/badges/version widgets/prefill indicators) remain disconnected.
* **Pre-step:** Run `npm run audit:component-duplication -- --head 20` and reuse existing shared widgets before adding new composition wrappers.
* **Exact implementation tasks:** Consolidate to one canonical marketplace composition path; wire only selected components used by active pages.
* **Acceptance checks:** Marketplace list/detail pages render complete cards/dialogs; dead-code findings for selected components drop after wiring.

## HR (Human Resources)

### Cluster: Compensation and analytics adjunct widgets

* **Target route/page/component:** `/hr/compensation/*`, `/hr/ats/analytics/*`, `src/cores/hr/analytics/*`
* **Current wiring state:** Compensation routes are active; additional analytics widgets/helpers are partially disconnected.
* **Exact implementation tasks:** Map each spec-complete widget to one owning page; remove duplicate adapters only after usage is confirmed.
* **Acceptance checks:** Compensation and analytics pages load target widgets; duplicate export warnings reduced; no missing route references.

## IT (IT Operations)

### Cluster: Asset assignment + license/procurement wizard leaf steps

* **Target route/page/component:** `/it/assets/*`, `/it/licenses/*`, `/it/procurement/*`; `src/cores/it/components/*`
* **Current wiring state:** Route coverage exists; several dialog/step components were restored and may not be mounted by current pages.
* **Exact implementation tasks:** Reconnect assignment dialog and procurement step components into create/edit flows; ensure barrel exports match page imports.
* **Acceptance checks:** Create/edit flows open all expected steps; forms submit successfully; dead-code findings for these steps decrease.

## GR (Governance & Risk)

### Cluster: AI assistive panels and hooks

* **Target route/page/component:** `/gr/ai/*`; `src/cores/gr/components/ai/*`, `src/cores/gr/hooks/index.ts`
* **Current wiring state:** GR AI routes exist; component/hook surface appears larger than currently composed pages.
* **Exact implementation tasks:** Audit page-by-page usage and mount only approved AI panels; align hook exports with actual route usage.
* **Acceptance checks:** Each `/gr/ai/*` route renders intended panel set; no orphaned route-level imports for AI cluster.

## PM (Practice Management)

### Cluster: Enrollment and site billing wizard steps

* **Target route/page/component:** `/pm/enrollment/new`, `/pm/site-billing`, wizard step folders under `src/cores/pm/components/wizards/*`
* **Current wiring state:** Top-level routes are active; step-level components were restored and need explicit composition checks.
* **Exact implementation tasks:** Verify each wizard step is referenced by the owning wizard controller; rewire missing step registrations.
* **Acceptance checks:** Wizard can navigate all steps, validate, and submit; dead-code no longer reports restored wizard step files as isolated.

### Cluster: Batch operation wizard

* **Target route/page/component:** batch operation workflows in PM revenue/claims tooling.
* **Current wiring state:** Batch history route exists; batch wizard step files were restored after deletion.
* **Exact implementation tasks:** Reconnect step sequence (scope -> impact -> confirm -> submit) to batch operation entry points.
* **Acceptance checks:** Batch flow reaches final confirmation and execution from UI; no runtime import failures.

## RH (Recovery Housing)

### Cluster: Admission wizard step pack

* **Target route/page/component:** `/rh/admissions/new`, `src/cores/rh/components/wizards/admission-steps/*`
* **Current wiring state:** Admission route exists; step components were restored and must be validated in step registry/wizard controller.
* **Exact implementation tasks:** Confirm step registry references each restored step; wire missing exports in admission-step index and wizard shell.
* **Acceptance checks:** Full admission wizard path (basic info -> program -> bed -> docs -> review) runs without missing-step errors.

### Cluster: Discharge/outcomes operational dialogs

* **Target route/page/component:** `/rh/discharge-plans`, `/rh/discharge-documents`, `/rh/outcomes/*`
* **Current wiring state:** Routes exist; several dialog/form leaf components were restored but not guaranteed reachable.
* **Exact implementation tasks:** Add explicit triggers from list/detail pages; bind forms to existing RH hooks and mutation handlers.
* **Acceptance checks:** Dialogs open from route pages and persist updates; unresolved imports eliminated for restored RH forms.

## Platform

### Cluster: Wizard analytics + marketplace + review components

* **Target route/page/component:** `/fw/wizards/:id/analytics`, `/fw/wizards/marketplace/*`, `src/platform/wizards/components/{analytics,marketplace,review}/*`
* **Current wiring state:** Routes are present; many specialized visualization/review leaf components were restored after broad deletion.
* **Exact implementation tasks:** Recompose page containers to consume restored chart/review components where spec requires; avoid duplicate component paths.
* **Acceptance checks:** Wizard analytics and marketplace pages render full cards/charts/review sections; dead-code findings narrow to truly unused leaves.

### Cluster: Platform AI widget set

* **Target route/page/component:** platform AI widget surfaces and dashboard embed points.
* **Current wiring state:** Widget barrel exists; individual widget files were restored and need intentional usage mapping.
* **Exact implementation tasks:** Define canonical host pages for each widget class (assistant, analyzer, summarizer); wire skeleton pairing where used.
* **Acceptance checks:** Widget hosts render and hydrate successfully; unused-file alerts drop for widgets intentionally retained.

## Execution safety gates (apply to every cluster)

1. Verify route reachability from `src/routes/**` and lazy page imports.
2. Verify spec state in module README + `IMPLEMENTATION_LOG` + deferred dashboard before any prune action.
3. Run `npm run audit:integration-contracts` before wiring cross-module surfaces.
4. Run `npm run typecheck` and `npm run build` after each cluster batch.
5. Run `npm run test:baseline` for end-to-end safety before deletion proposals.
6. Run `npm run deadcode` to confirm net reduction and avoid regressions.
7. Deletion actions require explicit human approval after showing exact file list and evidence.
