Module Map
Layer-level ownership map for the workspace crates and the agentty application layers.
This guide maps the workspace crates and the agentty application layers to their responsibilities so contributors can quickly choose the correct module when implementing changes. For file-level detail, read the module docstrings directly.
Workspace Crates🔗
| Crate | Responsibility |
|---|---|
ag-clipboard | Host clipboard reads |
ag-contracts | Transport-independent execution types and interfaces |
ag-runtime | Adapter composition and dispatch |
ag-scheduler | Shared session admission |
ag-worker | Scheduling, cancellation, heartbeats, recovery, execution policy |
ag-agent | CLI, app-server, and native harness adapters; policy enforcement |
ag-forge | GitHub/GitLab review requests and comments |
ag-git | Worktrees, captured diff parsing, sync, rebase, merge, lease push |
ag-harness | Native model loop, tools, durable sessions |
ag-harness-cli | Companion harness CLI |
ag-noise | Noise handshakes and encrypted sessions for remote control |
ag-protocol | Response schemas, parsing, prompt envelopes |
ag-relay | Embeddable remote-control relay: device streams and admission |
ag-remote | Remote-control protocol, pairing, and the relay link |
ag-router | Structured chat routing and provider transports |
ag-session | Session models, policies, catalog, lifecycle API |
ag-sqlite | Shared SQLite open, locked migration, and transaction helpers |
ag-store | Persistence contracts, SQLite adapters, migrations |
ag-telemetry | Content-free spans, async trace context, and opt-in OTLP export |
ag-tui-text | Markdown, forge HTML, terminal diagrams and text layout |
agentty | Application composition and TUI |
testty | PTY assertions and visual recordings |
ag-release | Release planning, archives, installers, notes, and the workflow |
ag-xtask | Workspace maintenance checks |
All crates live under crates/. See ag-harness Design for its component contracts. ag-worker also re-exports dispatch_sandbox_helper, which a host enabling harness sessions calls first in main so its executable serves as the native sandbox helper; see the Execution Boundary. It also re-exports ag-agent's TrustedCargoCache: Agentty's infra/ refreshes a project's Cargo cache through it outside the sandbox, app/ decides when, and, under the cache root the host passes to RuntimeConfig::with_trusted_cargo_cache, ag-agent copies from it into each sandboxed session's CARGO_HOME.
Application Layers (crates/agentty/src/)🔗
| Layer | Owns |
|---|---|
main.rs / lib.rs | Bootstrap and composition |
app/ | Workflows, state transitions, event reduction, service adapters |
domain/ | Pure Agentty entities and interaction policies |
infra/ | External integrations behind injectable traits |
runtime/ | Terminal and headless event loops, input dispatch |
presentation/ | Shared interaction, selection, editor, and viewport state |
ui/ | Snapshot projection, layout, and rendering |
Layer Rules🔗
- Keep workflow changes and shared command admission in
app/, with external effects behindinfra/traits. The command gateway owns admission; the worker owns execution ordering and settlement. - Keep frontend-neutral session, task, Env, and workflow role contracts in
ag-sessionand persistence inag-store. Task attempts project execution state from worker-owned operations; task completion is explicit outcome acceptance. ag-sessionowns portable agent definitions and bundled defaults; the injected infrastructure catalog overlays repository definitions. Execution consumes captured definitions independently of their IDs.- Execution graph ownership is split:
ag-protocolowns model-authored proposals,ag-sessionpure validation, resolution, and result bindings,ag-storeversions, evidence, and atomic admission, andag-workerdispatch and resource leases. Agentty owns proposal approval, explicit launch, wakeups, and adapters into session workers; focused review owns its own graph construction. See Graph Machinery for how the pieces connect. - Runtime converts presentation state into typed app requests and applies returned navigation effects.
app/does not import runtime handlers or mutateAppMode. App::view_snapshot()supplies an immutable frontend view. UI projection cannot access concrete application services; runtime owns render caches and table viewports.- Resolve the injected clock once per frame. Persist activity timestamps explicitly and apply the clock's UTC offset when grouping events, avoiding host-timezone dependence.
- Share semantic interaction calculations in
domain/orpresentation/; keep these independent of Ratatui rendering.
For example, resource accounting puts host sampling in infra/, scheduling and cache invalidation in app/, totals in domain/, and display formatting in ui/. A platform's Sync puts its HTTP routes in infra/platform.rs, what a request may say in domain/platform_sync.rs, the start gate and task lifecycle in app/platform_sync.rs, the Sync project each project names, and the picker that chooses it, in app/sync_project.rs, the credential-free remote host/path in ag-forge, the held task in ag-store, and the fenced milestone block of session turns in ag-agent. It is unrelated to project sync in app/sync.rs. Node worktree publishing keeps its check per session and what it found in app/node_pull_request.rs, reads a session's remote, decision, worktrees, and bases in app/session/workflow/node_publish.rs, pushes a worktree that may be published in app/session/workflow/node_push.rs, opens, adopts, or reads its pull request in app/session/workflow/node_forge.rs, polls its state, checks, and conflicts beside the review-request pass in app/node_pull_request_sync.rs, plans what to do about failed or passed checks in app/node_follow_up.rs, adds fixer nodes or asks for reruns in app/node_check_follow_up.rs, marks green drafts ready for review in app/node_mark_ready.rs, links chains of them into stacks in app/session/workflow/node_stack.rs, restacks their branches, and hands a restack's conflicts to a fixer node, in app/session/workflow/node_restack.rs and app/session/workflow/node_restack_fix.rs, frees the worktree of a merged one in app/session/workflow/task_worktree_integration.rs, and decides through the stages and steps in ag-session.
See Testability Boundaries for external ports and Change Recipes for contribution paths.
Worker-owned model execution🔗
Application workflows submit session turns through SessionRunClient and isolated utilities through RunClient; applications configure workers rather than construct adapters. See Execution for the dependency rule and execution contract.