mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
3.9 KiB
3.9 KiB
Phase 0 Baseline – Architecture Survey (September 20, 2025)
This note captures the current layout of the code-rs workspace before any
phase-one refactors. It should help us reason about the execution pipeline and
identify the modules that will be split up in later phases.
Workspace Layout
- Core execution
codex-core: orchestration crate exposingCodex, conversation management, exec tooling, confirm-guard policy, safety wrappers, and project/plan utilities. Most business logic lives here today.codex-exec: headsless CLI that streams protocol events to stdout/human or JSON renderers.codex-cli: thin binary that wires auth/config to the TUI.
- UI / presentation
codex-tui: Ratatui-based interface; owns chat widget, history cells, bottom pane, onboarding, streaming controller, and layout logic.
- Shared utilities
codex-common: shared config summaries, presets, timers, CLI argument parsing helpers.codex-ansi-escape,codex-browser,codex-file-search,codex-login,codex-apply-patch, etc. provide specialized services re-exported bycodex-core.
- Model/control plane
codex-mcp-*: client/server/test fixtures for Model Context Protocol.codex-protocol,codex-protocol-ts: protocol definitions consumed by Rust and TypeScript surfaces.
- Ancillary crates
- Tooling (
codex-ollama,codex-linux-sandbox,codex-browser), smoke tests, and TS bindings (codex-browser,codex-arg0, etc.).
- Tooling (
Core Command Pipeline (Today)
- Conversation spawn (
codex-core::ConversationManager)- Creates
CodexviaCodex::spawn, yielding an async event stream. - Produces
SessionConfiguredEventand registers the conversation in a sharedRwLock<HashMap<ConversationId, Arc<CodexConversation>>>.
- Creates
- Event loop (
codex-core::Codex&CodexConversation)Codex::next_eventpolls the MCP transport and channel fan-out to yieldEventMsgvalues.codex-core/src/codex.rsmanages confirm guards, tool dispatch, browser snapshots, streaming output buffers, and local command execution.
- Frontend consumption
codex-tui::chatwidgetsubscribes throughAppEventSenderand mutates aHistoryRenderStatealongside UI layout caches. Rendering merges state with Ratatui widgets inhistory_cell,diff_render, and friends.codex-execconsumes the same events for non-interactive sessions.
Identified Monoliths
codex-core/src/codex.rs(~3k LOC) interleaves policy checks, tool invocation, browser hooks, and response assembly. Later phases will split it into smaller services (ConfirmGuard,ToolBroker,ResponseAssembler, etc.).codex-tui/src/chatwidget.rs(~3k LOC) couples event wiring, command state, rendering hints, and approval flows. Target is a reducer-styleChatStateplus feature-specific controllers.codex-tui/src/history_cell.rsimplements a trait object hierarchy with manual downcasts. Moving to a typed enum model will simplify rendering and caching.
Current Testing & Tooling Gaps
- No lightweight integration test ensures event ordering invariants for the strict TUI history stream (per the TUI contract).
./build-fast.shis the single required check; results are not currently captured in documentation for regression comparison.
Baseline Metrics
./build-fast.sh(dev-fast) completed successfully on September 20, 2025 in 14.87s producingtarget/dev-fast/code(hash4162f125c8a0afb8f513e6e6a98ba57035aa2fb39959295c2567ec4699f0e965).
Next Actions for Phase 0
- Record baseline
./build-fast.shduration and success in this folder. - Introduce a smoke test under
codex-core/tests/that drives a short mock conversation and asserts strictly orderedEventMsgIDs. - Evaluate adding a TUI snapshot test harness once the chat state reducer is available (tracked for later phases).