#1856
Architecture cleanup: finish extracting legacy route/UI/store behavior into domain services
Theme
Recent PRs have been moving Codex Autorunner toward a cleaner architecture: backend-owned state, typed read models, unified automation jobs, thin route/UI surfaces, and clean terminology migrations without long-lived compatibility shims. There are still several high-ROI follow-up refactors that fit that same direction.
Relevant recent PRs
- #1855 - Add unified automation plane
- #1853 - Rename lifecycle archive actions to retire
- #1848 - Improve chat transcript efficiency
- #1846 - Add chat architecture goal function
- #1843 - Make PMA chat genesis explicit
- #1842 - Extract PMA chat architecture goal
- #1830 - Move Web Chat toward turn-structured detail projection
- #1827 - Chat archive lifecycle authority + newt surface semantics
Highest-ROI cleanup areas
- Split
src/codex_autorunner/core/pma_automation_store.pyinto PMA compatibility persistence, domain translation/reducer glue, unified automation mirror/backfill, and a thin facade. This is the largest remaining pre-unified-plane boundary leak. - Move chat transcript/queue/optimistic reconciliation ownership out of
src/codex_autorunner/web_frontend/src/routes/chats/[[chatId]]/+page.svelteand into read-model/application modules, keeping the Svelte page as a binding layer. - Retire or isolate legacy PMA transcript file-path fallbacks in
src/codex_autorunner/core/pma_transcripts.pyonce mirror coverage is explicit. - Extract PMA managed-thread route helper/application logic out of route modules and remove reverse dependencies from web services into routes.
- Consolidate repeated Web read-model page scaffolding and small duplicated loaders after the main state-ownership cuts are done.
Target architecture
- Core/domain modules own state transitions, compatibility migration, and durable writes.
- Web routes expose typed read models and dispatch commands; they do not become business-logic owners.
- Frontend pages subscribe to screen-shaped read models and delegate normalization/reconciliation to application/view-model modules.
- Compatibility paths are either removed after migration coverage or isolated behind explicit one-time migration/backfill code.
Suggested CAR ticket flow
Create tickets for the first three high-ROI cuts now: PMA automation store split, chat detail read-model ownership, and PMA transcript legacy retirement. Follow with managed-thread route/service dependency cleanup if the first three land cleanly.
Progress report from mini CAR review sweep:
The implementation work for this cleanup is materially real, not just planning artifacts. The completed queue currently has:
TICKET-001done: PMA automation store split and transcript legacy fallback review.TICKET-002done: chat detail display/read-model ownership moved further into application modules.TICKET-003done: managed-thread route business logic moved into PMA service modules.TICKET-004open: remaining read-model scaffolding and hotspot overage cleanup.Follow-up review fixes made during the sweep:
src/codex_autorunner/surfaces/web/routes/pma_routes/managed_thread_route_helpers.pycompatibility shim after confirming no production/test imports remained.src/codex_autorunner/surfaces/web/services/pma/managed_thread_automation.py; automation store failures should now surface instead of masquerading as valid empty state.TICKET-004so the remaining quality bar is durable for the next run.Validation from the review:
Closure judgment: I would not close this issue yet under the stricter maintainability bar.
tests/test_hotspot_budgets.py::test_hotspot_file_budgetsstill fails on issue-relevant read-model/page files:src/codex_autorunner/surfaces/web/services/pma/managed_thread_read_models.pysrc/codex_autorunner/surfaces/web/services/chat_read_models.pysrc/codex_autorunner/web_frontend/src/lib/application/pmaChatArchitecture.tssrc/codex_autorunner/web_frontend/src/routes/chats/[[chatId]]/+page.svelteThe remaining close bar is: complete
TICKET-004by consolidating real duplicated read-model/page scaffolding and reducing those hotspot overages without just raising caps to bless the current shape. After that passes, this issue should be close-ready unless the final review finds another material boundary leak or unrealistic fallback path.