Appearance
0001. Library first: host roles in adam-host ​
Status: Accepted (2026-09-29). The owner answered the open questions the same day. Two questions stayed open: cross-process events (resolved 2026-09-29, see below), and the exact workspace placement enum (resolved 2026-09-29: decided in ADR 0002).
Status note 2026-10-01: built. The composition that ran the two halves by hand in adam-coder's serve.rs is now adam-service, shared by every agent binary: serve registers the components of a role on an adam_host::Host exactly as described here, over the store and the notifications, and a binary only hands it the agent it serves.
Context ​
adam-rs started as a framework with one binary, adam-coder. Its serve.rs runs two halves by hand: an A2A server and a run worker. It starts both, waits for a signal, and stops the server first and the worker second.
The owner decided on 2026-09-29:
- adam-rs is a library that any host app embeds. The comparison: eve.dev is a library, NestJS is the app.
- A host runs a control plane and workers, decoupled: one control plane and N workers, or more.
- The roles
control-plane,workerandallare an enum in adam-rs. It is the standard for every host. Another host, such as theanother-agentic-systemorchestrator, reuses it and only says which role a process runs.
The orchestrator already stops its two halves by hand in orchestrator/bin/orchestrator/src/boot.rs. The two hand-written versions are alike: the first half to end takes the process down, the front stops first, the worker stops second, and a bound decides when to give up (the orchestrator bounds both halves, adam-coder only the front). Verified 2026-09-29: read crates/adam-coder/src/serve.rs and boot.rs.
The name "control plane" also names the Next.js chat UI in another-agentic-system. The owner decided that the UI is renamed "web chat surface" there, and that "control plane" means the role. The rename is outside this repo.
Decision ​
adam-rs is library-first. A binary is a host that uses the library. Anything a host needs from every process goes into a library crate, not into one binary.
Rolelives in a new crate,adam-host. The crate has std,adam-errorandthiserrorby default, and it has no HTTP framework. It never reads the environment.Roleis closed.enum Role { All (default), ControlPlane, Worker }, with no#[non_exhaustive]. A new role must be a compile error in every host that matches on it (the same idea as ADR 0004 inanother-agentic-system: closed enums for protocols).runs_control_plane()andruns_workers()let a host avoid matching at all.The host supplies the variable name.
adam-hostgivesRole::from_optional(Option<&str>)and, with featureclap,ValueEnum.adam-coderwill readROLE. The orchestrator can readORCH_ROLE.Noneor blank meansall, which is today's behaviour.A small supervisor comes with it (feature
supervisor, on by default).Host::new(role).control_plane(name, f).worker(name, f).run(shutdown). It runs only the components that match the role. It stops the control plane first (bounded by a drain time), then the workers (bounded by a grace time), and it returns the first failure by component name. It exposesHealthas data only.What each role runs in
adam-coder(a later change, not part of this one):Role Runs control-planethe A2A front ( A2aServeroverRuntimeTaskBackend), and the runtime withoutrun_workerworkerrun_worker, and a health endpointallboth (today) The front then needs no model or GitHub secrets. The worker needs them. Config is checked per role.
Amended 2026-09-29 (implemented in
adam-coder): config is checked per role, but the control plane still needs the model and GitHub settings.Runtime::startlooks the agent up by name and calls itsinit, so the control plane registers the completeCoderAgent(its model client, workspaces and GitHub client are built, never called, and the workspace root is not created). OnlyA2A_BEARER_TOKENSandPUBLIC_URLare role-specific, and the worker does not need them. Removing the requirement needs agent starters (a control plane that can start a run without holding the agent), which is a later change. Verified 2026-09-29: readRuntime::startandnew_runincrates/adam-runtime/src/runtime.rs.Amended 2026-09-29 (agent starters implemented): the requirement above is gone. Starting a run needs only the agent's name and
init, soadam-runtimehasAgentStarter(the start-only half ofAgent) andRuntimeBuilder::starter. The runtime keeps a closed registry of agents and starters;start,start_with_idandagent_namescover both, whilerun_workerclaims only agents.adam-coderregisters aCoderStarterin the control plane (Coder::control_plane), so a control plane needsDATABASE_URL,A2A_BEARER_TOKENSandPUBLIC_URLand no model or GitHub variables; only the roles that run workers read them (Config::worker, aWorkerConfig, isSomeexactly then). This is a breaking change toadam-coder's publicConfigandworkspaces_for. Verified 2026-09-29:crates/adam-coder/tests/binary.rsstarts a control plane with none of the model, GitHub or workspace variables, and a separate worker process completes its task.The seam stays the store. The two roles talk only through the Postgres store: the run record with its version compare-and-swap, and leases. No new protocol between them.
Hosts may run adam agents in-process, tools and sandboxes included. The owner decided this for the
another-agentic-systemorchestrator: a worker there may host an adam agent in its own process, behind its own agent port and behind a Cargo feature of its own. That includes agents that run tools and sandboxes. It is the host's decision and the host's risk. For adam-rs it means the agent, runtime and store crates stay usable as libraries in another process. The host, not adam-rs, adds the adapter. Plain A2A stays the way to reach an agent in another process.Hosts consume adam-rs by git rev. The repository is public. A host pins a full commit sha and bumps it by pull request. adam-rs does not publish to crates.io for this. It keeps the workspace
repositoryfield and the pinned dependency versions correct, so a host can build from the sha alone.Workspace placement is chosen by the deployer (decided in principle). An agent with a filesystem, such as the coder, needs a workspace per run. The owner said every strategy must be possible: "A worker can do the work, it can own a folder, it can have an isolated pvc, it can use only a2a." adam-rs will offer a closed, deployer-selected placement policy. Candidate names:
Policy Meaning Sharedan RWX volume; any worker may resume any run Affinitya run is leased only by the worker that owns its folder Isolateda PVC per worker; implies affinity none A2A-only deployments need no workspace The exact enum and the mechanism are follow-up design work. The runtime has no run-to-worker affinity today: any worker may lease any run. Until affinity exists, a coder deployment runs one worker, or uses a shared volume.
Amended 2026-09-29: ADR 0002 closes this. The enum is
Placement { Shared, Affinity, Isolated, A2aOnly }inadam-host, and affinity is a store-level claim scope (ClaimScope::Pinned) over a run owner. The table above is the candidate list; ADR 0002 has the final one.
Consequences ​
- A host is a short composition: read the role, register components, call
run. The stop order stops being copied into each binary. - The orchestrator and
adam-codercan share one vocabulary, and one deployment can scale the two halves apart. Roleis a public, closed enum. Adding a role is a breaking change for hosts that match on it. That is the point, and it costs a major version.adam-coderis not refactored here. Until it is, it keeps its own hand-written stop logic. Amended 2026-09-29:adam-codernow readsROLEand runs its components throughHost; its hand-written stop logic andStoppedUnexpectedlyare gone, and a component that ends early is aHostError(exit code 70).Amended 2026-09-29: thecoderHelm chart can deploy the two halves separately (topology: split, a front Deployment and a worker StatefulSet). It stays at one worker until workspace placement exists; deploy-only, no binary changed.Amended 2026-09-29: the chart now sets the placement (workspace.placement, ADR 0002) and allowsreplicaCountabove 1 when it is set.- Hosting agents in-process (decision 8) is only safe as far as the host limits it. An agent that runs builds can starve the process it lives in. The host must give it its own pods and limits. adam-rs does not sandbox the host.
- Placement (decision 10) will add a second closed enum that deployments depend on.
- When the halves are separate processes, some things degrade until they are built: live events only reach subscribers in the same process, the worker wakes by polling instead of a wake signal, and a cancel reaches the worker by polling. Each has a planned fix (Postgres
NOTIFY), not part of this change. Amended 2026-09-29: built and wired intoadam-coder(see "Cross-process events" under Resolved questions); the degradation above is only what remains with polling alone. - The supervisor pulls
tokio,tokio-utilandtracingintoadam-host. A host that only wantsRoleturns the default feature off.
Alternatives considered ​
Roleinadam-runtime. The runtime is where workers live, so it looks natural. But a host with no runtime, such as the orchestrator today, would depend on the whole runtime for one enum. Rejected.Roleinadam-core. The crate is about the store and run types. A role is about a process, not about state. Rejected: wrong layer, and it would pull the host's concern into every crate that uses the store.- Separate binaries (
adam-coder-front,adam-coder-worker). No enum, no supervisor. But every host repeats the split, the config, and the stop logic, and "all" (one process for development) needs a third binary. Rejected. #[non_exhaustive]onRole. Hosts would keep compiling when a role is added, and would silently treat it as a default. That is the failure this decision wants to prevent. Rejected forRole.HostErrorand the other error enums stay#[non_exhaustive], following the repo rules, because a new error only needs a class.- A
runtimefeature inadam-hostnow. A ready-made worker component overadam-runtime. Useful, but not needed to fix the contract. Left as future work.
Resolved questions ​
- Local, in-process agents in hosts. Resolved 2026-09-29: yes, including agents that run tools and sandboxes, behind the host's agent port and a Cargo feature (decision 8).
- Where
Rolelives, and whether it is closed. Resolved:adam-host, closed (decisions 2 and 3). - How hosts depend on adam-rs. Resolved: git rev, public repository (decision 9).
- Cross-process events. Resolved 2026-09-29 as proposed: an event sink and a notifier over Postgres
LISTEN/NOTIFY, with polling staying on as the fallback and as the truth.adam-runtimehas theNotifierport (RuntimeBuilder::notifier),adam-notify-postgresthe adapter (PgNotify,PgEventSink,PgNotifier), andadam-coder'sservewires it in every role: onePgNotifyper process over the store's pool, run as the host componentnotify(a worker component inallandworker, stopped after theworkercomponent; a control-plane component incontrol-plane). So a worker wakes at once for a run another process started, a cancel reaches a step in another process at once, and a control plane's stream carries a worker'sProgressevents as they happen. Verified 2026-09-29: the payload limit is under 8000 bytes (a 7 999-byte payload is sent, an 8000-byte one is refused by PostgreSQL 16.13;crates/adam-notify-postgres/tests/conformance.rs), andcrates/adam-coder/tests/binary.rsruns a control plane and a worker as two processes and sees the worker's progress text in the control plane's stream. Postgres only: MongoDB keeps polling. No new environment variable.
Open questions ​
- The exact placement enum and mechanism (decision 10). Are
Shared,AffinityandIsolatedthe right names and the right set? How does a worker own a folder and claim only its runs (a lease with a worker id, or a routing key)? What happens to a run when its worker is gone for good underAffinityorIsolated? Needs its own design and ADR.