# Refactoring map — v100.0.29-consistency-architecture-quality-foundation-wip

## Layer map

| Legacy surface | New canonical owner | Compatibility strategy | Status |
|---|---|---|---|
| Release/site constants and variables | `ReleaseIdentity`, `ConfigRepository`, `config/*.php` | `includes/config.php` variables and defined constants | Migrated |
| JSON reads and path resolution | `JsonRepository` | legacy `readJsonFile()` and `publicFilePath()` helpers | Migrated |
| Curated/personality catalogs | `PersonaCatalog` | legacy persona helpers | Migrated |
| Starter Pack behavior | `StarterPackCatalog` | 16 legacy functions | Migrated |
| Public API catalog | `ApiCatalog` | 10 legacy functions and constants | Migrated |
| Page aliases, dev dynamic routes, representation fallbacks | `RouteRegistry` | existing route scripts unchanged | Migrated |
| Script dependencies | `AssetRegistry` | historical page flags accepted as inputs | Migrated |
| Page metadata/security/representation context | `PageContext`, `PageSecurity`, `RepresentationService` | `includes/header.php` adapter | Migrated |
| Public API request/response behavior | `AgentApiRuntime`, `RequestContext`, `ResponseEmitter` | `includes/agent-api.php` facade | Migrated |
| Shared header/footer markup | `views/layout/header.php`, `views/layout/footer.php` | include adapters | Migrated |
| Persona generation | future `src/Domain/Persona/*` | characterize then facade extraction | Planned P0 |
| Psychosis character state | future `src/Domain/Psychosis/*` | evidence-layer extraction first | Planned P0 |
| Espionage persona state | future `src/Domain/Espionage/*` | chronology extraction first | Planned P0 |
| Adult creator controllers | future `src/Application/AdultCreator/*` | migrate one read-only endpoint first | Planned P1 |
| Release scripts | `tools/release_core/*` | thin v100.0.29 wrappers; historical scripts retained | In progress |

## Dependency direction

```text
views / endpoint scripts
        -> compatibility facades
        -> Application
        -> domain and core services
        -> repositories/configuration

Repositories and domain services never depend on views or endpoint scripts.
```

## Incremental extraction sequence

1. Freeze golden fixtures for each generator family.
2. Extract pure normalization functions into typed value objects.
3. Extract deterministic selectors and seeded randomness.
4. Extract chronology and relationship graph construction.
5. Extract output projections for page/API/export separately.
6. Move transport validation into request DTOs.
7. Replace direct emission with typed controllers.
8. Remove a facade only when no call sites remain.

## Compatibility promise

Public routes, documented JSON keys, legacy function names, adult-consent requirements, epistemic boundaries, and the exact UAIX/three-part packaging invariants remain stable during migration.
