From 8046bd25ca9181b5a6e31c099e6b5ed9d34591c3 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 15:47:23 +0000 Subject: [PATCH] Refresh architecture plan docs for runtime-core ownership Co-authored-by: Theo Browne --- .plans/01-shared-model-normalization.md | 6 ++--- .plans/02-typed-ipc-boundaries.md | 26 +++++++++---------- .plans/03-split-codex-app-server-manager.md | 4 +-- .plans/06-provider-logstream-lifecycle.md | 8 +++--- .../10-unify-process-session-abstraction.md | 4 +-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.plans/01-shared-model-normalization.md b/.plans/01-shared-model-normalization.md index e1e5f77db4..05423c3eb6 100644 --- a/.plans/01-shared-model-normalization.md +++ b/.plans/01-shared-model-normalization.md @@ -5,7 +5,7 @@ Move model alias/default normalization into `packages/contracts` so desktop and ## Motivation - Removes duplicated logic between: - - `apps/desktop/src/codexAppServerManager.ts` + - `packages/runtime-core/src/codexAppServerManager.ts` - `apps/renderer/src/model-logic.ts` - Prevents behavior drift when model aliases/defaults are updated. @@ -22,7 +22,7 @@ Move model alias/default normalization into `packages/contracts` so desktop and - `resolveModelSlug` - `DEFAULT_MODEL` 2. Export model utilities from `packages/contracts/src/index.ts`. -3. Update `apps/desktop/src/codexAppServerManager.ts` to replace local alias map/helper. +3. Update `packages/runtime-core/src/codexAppServerManager.ts` to replace local alias map/helper. 4. Update `apps/renderer/src/model-logic.ts` to wrap or re-export shared functions. 5. Update tests: - Move/duplicate normalization tests to contracts. @@ -38,5 +38,5 @@ Move model alias/default normalization into `packages/contracts` so desktop and - Manual check that model selection and session start still send expected model slug. ## Done Criteria -- No duplicated alias/default map in desktop and renderer. +- No duplicated alias/default map in runtime-core and renderer. - Shared model utilities are contract-tested. diff --git a/.plans/02-typed-ipc-boundaries.md b/.plans/02-typed-ipc-boundaries.md index 4e91004356..498a673e91 100644 --- a/.plans/02-typed-ipc-boundaries.md +++ b/.plans/02-typed-ipc-boundaries.md @@ -1,37 +1,37 @@ -# Plan: Strengthen Typed IPC Boundaries in Main Process +# Plan: Strengthen Typed WS RPC Boundaries in Runtime Server ## Summary -Replace loose payload casting in IPC handlers with strict schema parsing and typed helper wrappers. +Replace loose payload casting in runtime RPC handlers with strict schema parsing and typed helper wrappers. ## Motivation -- `apps/desktop/src/main.ts` currently uses casts like `payload as Parameters<...>`. +- `apps/t3/src/runtimeApiServer.ts` should avoid payload casts and parse all unknown input at the RPC boundary. - Casts can hide contract breakages until runtime. ## Scope -- Desktop main process IPC registration. -- Optional shared helper for handler registration. +- Runtime WebSocket RPC registration and method dispatch. +- Optional shared helper for method-level parse/dispatch registration. ## Proposed Changes -1. Add IPC helper utility (e.g. `apps/desktop/src/ipcHelpers.ts`) to: +1. Add RPC helper utility (e.g. `apps/t3/src/rpcHelpers.ts`) to: - Parse payload(s) with Zod schemas - Standardize typed handler signatures -2. Refactor provider IPC handlers in `apps/desktop/src/main.ts` to use: +2. Refactor provider RPC handlers in `apps/t3/src/runtimeApiServer.ts` to use: - `providerSessionStartInputSchema.parse` - `providerSendTurnInputSchema.parse` - `providerInterruptTurnInputSchema.parse` - `providerStopSessionInputSchema.parse` -3. Apply same pattern to agent/terminal handlers where possible. -4. Add tests for handler parsing failure paths (invalid payloads). +3. Apply same pattern to app/todo/agent/terminal/shell handlers where possible. +4. Add tests for parsing failure paths (invalid payloads). ## Risks -- Refactor can subtly change IPC error shape/messages. +- Refactor can subtly change RPC error shape/messages. - Helper abstraction should stay simple and not obscure control flow. ## Validation - `bun run test` - `bun run typecheck` -- Manual invalid payload check from renderer/devtools to confirm fast failure. +- Manual invalid payload check from websocket client/devtools to confirm fast failure. ## Done Criteria -- No provider handler uses `payload as Parameters<...>`. -- All IPC entrypoints parse unknown payloads at boundary. +- No runtime handler uses `payload as Parameters<...>`. +- All websocket RPC entrypoints parse unknown payloads at boundary. diff --git a/.plans/03-split-codex-app-server-manager.md b/.plans/03-split-codex-app-server-manager.md index e425a6ae7d..d759f53c8d 100644 --- a/.plans/03-split-codex-app-server-manager.md +++ b/.plans/03-split-codex-app-server-manager.md @@ -4,7 +4,7 @@ Split `CodexAppServerManager` into smaller modules with clear responsibilities. ## Motivation -- `apps/desktop/src/codexAppServerManager.ts` is large and mixes: +- `packages/runtime-core/src/codexAppServerManager.ts` is large and mixes: - Process lifecycle - JSON-RPC parsing/routing - Session state transitions @@ -12,7 +12,7 @@ Split `CodexAppServerManager` into smaller modules with clear responsibilities. - This increases regression risk and slows changes. ## Scope -- Desktop provider internals only. +- Runtime-core provider internals only. - Keep external behavior/API stable. ## Proposed Changes diff --git a/.plans/06-provider-logstream-lifecycle.md b/.plans/06-provider-logstream-lifecycle.md index 71d1cbd95b..585b9836bb 100644 --- a/.plans/06-provider-logstream-lifecycle.md +++ b/.plans/06-provider-logstream-lifecycle.md @@ -4,18 +4,18 @@ Ensure `ProviderManager` logging stream is initialized, rotated/structured, and closed safely. ## Motivation -- `apps/desktop/src/providerManager.ts` opens a write stream in constructor. +- `packages/runtime-core/src/providerManager.ts` opens a write stream in constructor. - Stream lifecycle is not explicit on shutdown. ## Scope -- Desktop provider logging behavior. -- App shutdown integration. +- Runtime-core provider logging behavior. +- Runtime server shutdown integration. ## Proposed Changes 1. Add explicit `dispose()` on `ProviderManager`: - Remove event listeners - End/close log stream -2. Call `providerManager.dispose()` from app shutdown path in `apps/desktop/src/main.ts`. +2. Call `providerManager.dispose()` from app shutdown path in `apps/t3/src/runtimeApiServer.ts` close flow. 3. Optional: change log format to JSON lines with stable fields. 4. Optional: per-session log files under `.logs/providers/`. diff --git a/.plans/10-unify-process-session-abstraction.md b/.plans/10-unify-process-session-abstraction.md index c3feec020f..cff212fecb 100644 --- a/.plans/10-unify-process-session-abstraction.md +++ b/.plans/10-unify-process-session-abstraction.md @@ -4,11 +4,11 @@ Refactor `ProcessManager` to use a single runtime-session interface for child-process and PTY modes. ## Motivation -- `apps/desktop/src/processManager.ts` maintains parallel maps and branch-heavy logic. +- `packages/runtime-core/src/processManager.ts` maintains parallel maps and branch-heavy logic. - New execution backends/providers will multiply complexity. ## Scope -- Desktop process execution internals. +- Runtime-core process execution internals. - Preserve public `ProcessManager` API. ## Proposed Changes