Change Recipes
Use these recipes to route changes through the correct modules without crossing layer boundaries.
Add or Modify a Session Workflow🔗
- Update orchestration in
crates/agentty/src/app/session/(lifecycle.rs,worker.rs,task.rs, etc.). - Keep persistence in
crates/agentty/src/infra/db/domain modules and keepcrates/agentty/src/infra/db.rslimited to pool wiring plus repository composition. - Keep git operations behind
GitClientincrates/agentty/src/infra/git/client.rs(re-exported fromcrates/agentty/src/infra/git.rs). - Preserve the session-branch invariant: one evolving commit per session branch, with the first file-changing turn creating it and later file-changing turns updating it by amending
HEAD. - Update docs when lifecycle/status behavior changes:
docs/site/content/docs/usage/workflow.md.
Add a New Agent Backend or Model🔗
- Update domain model declarations in
crates/agentty/src/domain/agent.rs. - Add backend behavior in
crates/agentty/src/infra/agent/and register it inprovider.rs. - If app-server-based, implement
app_server_client()in the concrete backend so the provider owns its runtime wiring. - Register any shared parsing, prompt-transport, streaming, or thought-policy changes in
crates/agentty/src/infra/agent/provider.rs. - The channel layer (
infra/channel.rs) routes automatically based on the backend-owned transport mode - no change needed there unless the runtime contract itself changes. - Update
docs/site/content/docs/agents/backends.mdwith backend/model documentation.
Add a Keybinding or Mode Interaction🔗
- Update the handler in
crates/agentty/src/runtime/mode/, or incrates/agentty/src/runtime/key_handler.rswhen the interaction is a cross-mode overlay dispatch. - If a new mode/state is needed, extend
crates/agentty/src/ui/state/app_mode.rs. - If help content changes, update
crates/agentty/src/ui/state/help_action.rsas needed. - Update
docs/site/content/docs/usage/keybindings.md.
Add or Change Database Schema🔗
- Add a new migration file in
crates/agentty/migrations/(NNN_description.sql). - Never modify existing migration files.
- Keep query changes in the matching
crates/agentty/src/infra/db/*.rsdomain module instead of expandingcrates/agentty/src/infra/db.rs. - Ensure any status/model behavior changes are reflected in docs pages affected by user-facing behavior.
Add a New UI Page or Component🔗
- Add the page in
crates/agentty/src/ui/page/or component incrates/agentty/src/ui/component/. - Wire the page into
crates/agentty/src/ui/router.rs. - If a new
AppModeis needed, extendcrates/agentty/src/ui/state/app_mode.rsand add a key handler incrates/agentty/src/runtime/mode/.
Contributor Checklist for Architecture-Safe Changes🔗
- Keep workflow/state transitions in
app/, not in UI rendering modules. - Keep external integrations in
infra/behind traits. - Keep business entities and enums in
domain/. - In
app/andruntime/orchestration, avoid directCommand::new,Instant::now,SystemTime::now, and direct filesystem/process calls unless they run behind trait boundaries. - For helpers that need timestamps in
app/orruntime/, reuse the sharedapp/session/core.rsClockboundary instead of adding directInstant::now()orSystemTime::now()calls. - New external boundaries should get a trait with
#[cfg_attr(test, mockall::automock)]. - Update docs in
docs/site/content/docs/whenever user-facing behavior changes. - Update
docs/site/content/docs/architecture/module-map.md,docs/site/content/docs/architecture/runtime-flow.md, anddocs/site/content/docs/architecture/testability-boundaries.mdwhen architecture responsibilities change. - Keep the nearest semantic
AGENTS.mdguides aligned when a major module's purpose, invariants, or change-routing guidance changes. - Treat render-time helpers as hot paths: avoid per-frame cloning of large render inputs, and make line-count/layout helpers reuse the same cached derived data as the final paint path.
- When adding/removing files in
runtime/mode/, update the runtime-mode file list indocs/site/content/docs/architecture/module-map.md. - When changing
TurnRequest/TurnEvent/TurnResultshapes incrates/agentty/src/infra/channel/contract.rs(re-exported bycrates/agentty/src/infra/channel.rs), update the key-types table indocs/site/content/docs/architecture/runtime-flow.md. - When adding/removing
#[cfg_attr(test, mockall::automock)]external-boundary traits, updatedocs/site/content/docs/architecture/testability-boundaries.md. - Run quality gates from
AGENTS.mdbefore opening a PR.