feat(core): introduce Turn domain type and CommandRegistry (#2895, #2896)#2912
Merged
feat(core): introduce Turn domain type and CommandRegistry (#2895, #2896)#2912
Conversation
) Turn domain type (Phase 1): - Add Turn struct in agent::turn with TurnId, TurnInput, TurnMetrics, cancel_token - TurnId is a per-conversation monotonic newtype (resets on /new) - TurnMetrics wraps TurnTimings only in Phase 1; token/cost deferred to Phase 2 - Agent gains begin_turn/end_turn lifecycle methods; process_user_message_inner now takes &mut Turn instead of individual (text, image_parts, iteration_index) - end_turn copies timings into pending_timings and flushes them CommandRegistry (Batch 1): - Add CommandHandler<C> trait (object-safe via Pin<Box<dyn Future>>) - Add CommandContext<'_, C> (lifetime-bound borrows of agent subsystems) - Add CommandOutput enum: Message / Silent / Exit / Continue - Add CommandRegistry<C> (Vec-backed, word-boundary dispatch via std::mem::take) - Migrate 8 commands to Batch 1 handlers: /exit, /quit, /clear, /reset, /clear-queue, /debug-dump, /dump-format, /log - Remove dead legacy branches from handle_builtin_command and dispatch_slash_command - Batch 2/3 migration deferred (remaining commands fall through to legacy path) Closes #2895, closes #2896
This was
linked to
issues
Apr 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#2895):Turnstruct inzeph-core::agent::turnwithTurnId(per-conversation monotonic newtype),TurnInput,TurnMetrics(Phase 1 wrapsTurnTimings), andbegin_turn/end_turnlifecycle methods inAgent. Sets the foundation for per-turn metrics, tracing, and future turn replay (Phase 2).#2896):CommandHandler<C>trait,CommandRegistry<C>(Vec-backed, word-boundary dispatch),CommandContext<'_, C>(lifetime-bound subsystem borrows),CommandOutputenum. Batch 1 (8 commands) migrated. Dead legacy branches removed.Wave 2 of architecture epic #2909
Depends on: #2897 (MemoryState decomposition, closed), #2899 (AgentBuilder consolidation, closed).
Enables: #2898 (run loop event handler — depends on
Turn).Changes
crates/zeph-core/src/agent/turn.rs— new filecrates/zeph-core/src/agent/command_registry.rs— new filecrates/zeph-core/src/agent/commands/— 7 new files (Batch 1 handlers + mod.rs)crates/zeph-core/src/agent/mod.rs— begin_turn/end_turn, command_registry field, run loop dispatchcrates/zeph-core/src/agent/slash_commands.rs— dead Batch 1 branches removedTest plan
cargo nextest run --workspace --features desktop,ide,server,chat,pdf,scheduler --lib --bins)cargo clippy --workspace --features desktop,ide,server,chat,pdf,scheduler -- -D warningscleancargo +nightly fmt --checkclean/exit,/clear,/debug-dump,/log debugbehave identically to pre-PR (see.local/testing/playbooks/turn-command-registry.md)/new,/compact,/model) unaffected