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🔗

CrateResponsibility
ag-clipboardHost clipboard reads
ag-contractsTransport-independent execution types and interfaces
ag-runtimeAdapter composition and dispatch
ag-schedulerShared session admission
ag-workerScheduling, cancellation, heartbeats, recovery, execution policy
ag-agentCLI, app-server, and native harness adapters; policy enforcement
ag-forgeGitHub/GitLab review requests and comments
ag-gitWorktrees, captured diff parsing, sync, rebase, merge, lease push
ag-harnessNative model loop, tools, durable sessions
ag-harness-cliCompanion harness CLI
ag-noiseNoise handshakes and encrypted sessions for remote control
ag-protocolResponse schemas, parsing, prompt envelopes
ag-relayEmbeddable remote-control relay: device streams and admission
ag-remoteRemote-control protocol, pairing, and the relay link
ag-routerStructured chat routing and provider transports
ag-sessionSession models, policies, catalog, lifecycle API
ag-sqliteShared SQLite open, locked migration, and transaction helpers
ag-storePersistence contracts, SQLite adapters, migrations
ag-telemetryContent-free spans, async trace context, and opt-in OTLP export
ag-tui-textMarkdown, forge HTML, terminal diagrams and text layout
agenttyApplication composition and TUI
testtyPTY assertions and visual recordings
ag-releaseRelease planning, archives, installers, notes, and the workflow
ag-xtaskWorkspace 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/)🔗

LayerOwns
main.rs / lib.rsBootstrap 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 behind infra/ 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-session and persistence in ag-store. Task attempts project execution state from worker-owned operations; task completion is explicit outcome acceptance.
  • ag-session owns 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-protocol owns model-authored proposals, ag-session pure validation, resolution, and result bindings, ag-store versions, evidence, and atomic admission, and ag-worker dispatch 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 mutate AppMode.
  • 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/ or presentation/; 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.