---
url: /another-agentic-system/decisions/0015-control-plane-and-workers-on-adam-rs.md
---

# ADR 0015 — Control plane and workers on adam-rs, with in-process agents

* **Status:** accepted (2026-09-29). Amends [ADR 0001](0001-rust-state-machine-on-postgres.md)
  (the job ledger includes a local agent's journal) and
  [ADR 0007](0007-protocol-only-dependencies.md) (a worker may host adam agents in-process, behind a
  Cargo feature). Both carry a dated note that points here.
  *Amended (2026-11-19) by [ADR 0076](0076-the-orchestrator-as-a-library-in-an-application.md):* when the orchestrator
  is embedded as a library in an application, a local agent runs adam in process through `adam-engine` on adam's
  SQLite store, not `adam-store-postgres`, and its run state is adam's file, not `orch_agent_*` tables; in a server
  build decision 6 stands.

## Context

The owner decided the following on 2026-09-29.

* **adam-rs is a library, and any host app embeds it.** In the owner's words: "eve.dev is just a
  library, NestJS is the app." adam-rs must fit any backend structure. It also ships a convenience
  binary, `adam-coder`. adam-rs is [`vymalo/another-adam-rs`](https://github.com/vymalo/another-adam-rs).
  This repository is one of its hosts.
* **The control plane and the runtime workers are decoupled.** One control plane and N workers, or
  more, deployed apart.
* **The roles are an enum in adam-rs.** This repository reuses it and only says which role a
  process runs.
* **In-process ("local") adam agents in an orchestrator worker are wanted, including agents that run
  tools and sandboxes.** The owner chose this over the more conservative option (sandbox-free agents
  only).
* **Agents with a filesystem need a workspace.** Where it lives is the deployer's choice: "A worker
  can do the work, it can own a folder, it can have an isolated pvc, it can use only a2a."

What the code does today:

* `orchestrator/bin/orchestrator/src/boot.rs` starts the HTTP server and the dispatcher in one process
  and stops them by hand: it marks the process as shutting down, stops the server, then the
  dispatcher, each bounded by a grace time. The first half to end takes the process down.
* The two halves already talk only through Postgres: the outbox, the thread version
  compare-and-swap (CAS), and `LISTEN/NOTIFY` ([ADR 0001](0001-rust-state-machine-on-postgres.md)).
  Nothing else couples them.
* `AgentClient` in `orch-ports` is the only way the orchestrator talks to an agent. Its one
  implementation, `orch-agent-a2a`, speaks A2A.
* The word "control plane" already names the Next.js chat app in this repository's docs.
* [ADR 0014](0014-adam-coder-default-agent-over-a2a.md) makes `adam-coder` the default agent over
  plain A2A, with no crate dependency on adam-rs.
* [Lesson 1](../lessons-from-agent-canvas.md): one pod ran the UI, the API and every agent's builds.
  A single `cargo build` starved the API and the pod headed for a restart.

The adam-rs side of this decision is its own ADR 0001, "Library first: host roles in `adam-host`".
It is in that repository at `docs/decisions/0001-library-first-host-roles.md`.

## Decision

1. **adam-rs is a library that hosts embed.** This repository is a host. It uses adam-rs by
   git dependency and does not fork or vendor it.
2. **Two roles, decoupled.** A process is a control plane, a worker, or both. A deployment runs
   one control plane and N workers, or more of each. Nothing forces them onto one machine.
3. **The role is one closed enum, `Role`, owned by adam-rs.** It lives in the new `adam-host`
   crate: `All` (default), `ControlPlane`, `Worker`. `adam-host` also gives a role-aware supervisor,
   `Host`. This repository reuses both and adds no role of its own. It only provides which role a
   process runs: `ORCH_ROLE` or `--role`, default `all`.
4. **Git dependency, pinned to a full commit sha.** `Cargo.toml` names the adam-rs repository and
   a 40-character `rev`. A PR bumps it. Never a branch, never a tag. adam-rs is public, so CI and
   Docker need no token.
5. **What each orchestrator role runs.**

   | Role | Runs |
   |---|---|
   | `control-plane` | migrations, the axum server (health, resource API, the surfaces in `ORCH_SURFACES`), the transitions for user inputs, event streams, thread cards |
   | `worker` | migrations, the dispatcher (with the transition for agent updates), in-process adam agents, a health-only router |
   | `all` (default) | both: today's behaviour |

   **The seam is Postgres.** Outbox, thread version CAS and `LISTEN/NOTIFY` are already the only
   coupling. There is no new protocol between the roles. `transition` stays a pure function that
   both roles call; the CAS decides who wins.
6. **In-process ("local") adam agents are allowed in orchestrator workers, including agents that
   run tools and sandboxes.**
   * They sit behind the existing `AgentClient` port. The implementation is a separate crate,
     `orch-agent-adam`, behind the Cargo feature `agent-local`, **off by default**. It is the only
     crate that depends on adam agent and runtime crates.
   * **Remote agents stay plain A2A.** That includes the `adam-coder` default agent
     ([ADR 0014](0014-adam-coder-default-agent-over-a2a.md)).
   * **State.** A local agent's run state lives in the orchestrator's Postgres, in tables prefixed
     `orch_agent_*`. The job ledger now includes an agent's journal. This was the plan's
     recommended answer; the owner did not separately confirm it. Revisit it before the first local
     agent ships.
   * **This deliberately amends [ADR 0007](0007-protocol-only-dependencies.md).** See
     *What this amends*.
7. **Naming.** "Control plane" now means the orchestrator role. The Next.js app is the **web chat
   surface**. The docs are renamed in this change.
8. **Workspace placement is the deployer's choice (decided in principle).** An agent with a
   filesystem, such as the coder, needs a workspace for a run. adam-rs will offer a closed,
   deployer-selected placement policy. The candidate names are:

   * `Shared`: an RWX volume. Any worker may resume any run.
   * `Affinity`: a run is leased only by the worker that owns its folder.
   * `Isolated`: one PVC per worker. It implies affinity.
   * A2A-only deployments need none of these: the worker only calls remote agents.

   The exact enum and mechanism are follow-up design work in adam-rs, not decided here.
   **The runtime has no run-to-worker affinity today.** A run can be leased by any worker, so with
   per-worker volumes a run may land on a worker that does not have its worktree. Until affinity
   exists, a coder deployment runs one worker, or a shared volume.

### What this amends

**ADR 0007 (protocols only).** The rule was: no dependency on an agent host, gateway product or host
SDK. Two things change.

* `adam-host` is a hard dependency of the orchestrator binary. It is process plumbing (a role enum
  and a supervisor). It has no agent code. It still is a git dependency on a sibling repository.
* adam agents may run inside a worker, behind `agent-local`. That is a real exception: the
  orchestrator can host an agent in its own process. What stays true: a remote agent is an A2A
  agent-card URL, the port has no adam types, and with the feature off nothing from adam agents is
  linked.

**Lesson 1 (control plane and workers are separate).** The decision keeps the two apart, but it
also lets a worker run agent builds and tool calls. A local agent that runs `cargo build`
can starve the process it lives in. That is the failure Lesson 1 described, moved from the pod that
serves the UI to a worker pod. In the default role (`all`) it would still be the same pod as the API,
so `all` is for development. The mitigations:

* The feature is off by default.
* Worker pods are separate from control-plane pods, so a build starves only a worker.
* Resource limits on worker pods.
* Sandboxing is the agent's responsibility, not the orchestrator's.

**ADR 0001 (stateless processes, one event log).** Processes stay stateless. The rule "only the job
ledger and event log persist" now counts a local agent's journal as part of the job ledger. It is
stored in the same Postgres, in `orch_agent_*` tables. No second store.

ADR 0009 stands: `Role` and `Host` are not ports, because no one swaps them. `orch-agent-adam`
implements a port and puts no adam type in its signature.

## Diagrams

The topology. The web chat surface never talks to a worker. Workers never serve users.

```mermaid
flowchart LR
  you((You)) -- chat --> web["Web chat surface<br/>Next.js + assistant-ui"]
  web -- "AG-UI over HTTP + SSE" --> cp
  ext["Other systems · webhooks · MCP clients"] --> cp

  subgraph orch["Orchestrator (orch-* crates, one binary, --role)"]
    cp["Control plane × 1..n<br/>role control-plane<br/>API · surfaces · user-input transitions · event streams"]
    wk["Worker × 1..n<br/>role worker<br/>dispatcher · agent-update transitions"]
    local["Local adam agents<br/>feature agent-local, off by default<br/>behind the AgentClient port"]
    wk --> local
  end

  cp <-- "outbox · thread version CAS ·<br/>LISTEN/NOTIFY · event log" --> db[(Postgres<br/>job ledger · event log · orch_agent_* journal)]
  wk <-- "claim · commit" --> db

  wk -- "A2A (AgentClient)" --> remote["Remote agents<br/>adam-coder (default) · platform · kagent · any A2A"]
  local -. "workspace, deployer's choice" .-> ws[("Shared RWX volume ·<br/>per-worker PVC · none")]
  wk -- "MCP · OpenAI-compatible" --> tools["Tools · model endpoint"]
```

One chat turn across the seam. The two roles never call each other.

```mermaid
sequenceDiagram
  actor U as You
  participant W as Web chat surface
  participant C as Control plane
  participant DB as Postgres
  participant K as Worker
  participant A as Agent (remote A2A, or local behind the port)
  U->>W: message
  W->>C: AG-UI run request
  C->>DB: one transaction: append user event, thread version CAS, outbox row
  DB-->>K: NOTIFY (or the next poll)
  K->>DB: claim outbox row (SKIP LOCKED, lease)
  K->>A: AgentClient::send
  loop while the agent works
    A-->>K: status, message parts
    K->>DB: transition (pure), CAS, append events
    DB-->>C: NOTIFY (or the next poll)
    C-->>W: AG-UI events over SSE
  end
  A-->>K: completed
  K->>DB: transition to Done, CAS, append events
  DB-->>C: NOTIFY
  C-->>W: final events, run finished
```

The lifecycle of one process under the `adam-host` supervisor.

```mermaid
stateDiagram-v2
  [*] --> Running: components for the role started
  Running --> Stopping: shutdown signal
  Running --> Stopping: a component ended on its own
  Stopping --> DrainingControlPlane: mark shutting down, cancel control-plane components
  DrainingControlPlane --> DrainingWorkers: drained, or the drain time is up
  DrainingWorkers --> Stopped: workers done, or the grace time is up (abort)
  Stopped --> [*]: exit 0 after a signal
  Stopped --> Failed: first failure reported by component name
  Failed --> [*]: exit non-zero, restarted by the platform
```

A process that has no component for its role never starts: `Host::run` returns `NothingToRun`.

## Consequences

**Positive**

* The API and the workers scale apart: N control-plane pods for users, M worker pods for agent work.
  A build starves a worker, not the API.
* The hand-written stop logic in `boot.rs` goes away. One supervisor gives one stop order to every
  adam-rs host.
* The role vocabulary is shared with adam-coder. An operator learns `control-plane | worker | all`
  once.
* One process (`all`) still works for development and for small installs. No behaviour change by
  default.
* A local agent gets the orchestrator's durability: its journal is in the same Postgres and the
  same transactions.

**Negative**

* **A coupling to adam-rs.** A bump of the pinned sha is a PR here, and adam-rs changes can break
  the build. The two repositories share one owner today; that is what makes this cheap.
* **Lesson 1 is only mitigated.** A tool-running local agent can hurt the worker that hosts it.
  Nothing in the orchestrator sandboxes it.
* **The orchestrator is no longer a pure protocol layer when `agent-local` is on.** Its supply
  chain, build time and attack surface grow with that feature.
* **Split roles degrade until events cross processes.** Live events, worker wake-up and cancel
  between processes rely on polling until Postgres `NOTIFY` support lands in adam-rs. *Unverified:*
  the `NOTIFY` payload limit of 8000 bytes, from memory.
* **Coder scale-out is limited** (one worker, or a shared volume) until placement exists.
* More configuration to get right: a role per Deployment, secrets per role.

## Alternatives considered

* **A protocol seam between the roles (gRPC, HTTP).** Rejected. Postgres is already the only
  coupling and it is transactional. A new protocol adds a second source of truth, a versioned
  contract, and retry logic for what a CAS already settles.
* **adam-runtime as the orchestrator's engine.** Rejected. It would replace the pure `transition`
  and the job ledger ([ADR 0001](0001-rust-state-machine-on-postgres.md),
  [ADR 0004](0004-closed-enums-over-dyn-registry.md)) with another engine's run model. adam agents
  are hosted behind a port instead, so the orchestrator stays the owner of job state.
* **Separate binaries** (`orchestrator-control-plane`, `orchestrator-worker`). Rejected. Two
  binaries repeat the composition, and `all` for development would need a third. One enum and one
  binary keep it to one build and one image.
* **Sandbox-free local agents only.** Rejected by the owner. It is safer, and it would have kept
  Lesson 1 closed. The owner wants agents that run tools and sandboxes hosted in the worker.
  This ADR records the mitigations instead.
* **Never link adam-rs (A2A only, [ADR 0014](0014-adam-coder-default-agent-over-a2a.md)
  unchanged).** Rejected as the only path. It stays the default: remote agents, `adam-coder`
  included, are plain A2A, and the feature is off. But the role enum and the supervisor would be
  copied into this repository, and the roles would drift.

## Hard to reverse

* **`Role` is public and closed.** A new role breaks every host that matches on it. That is meant,
  and it costs a major version. A role cannot be removed without breaking deployments that set it.
* **`ORCH_ROLE` and `--role` values** (`all`, `control-plane`, `worker`) become part of every
  deployment's manifests.
* **`orch_agent_*` tables.** Once a local agent stores a journal there, the schema needs migrations
  and a retention rule. Moving to a separate database later is a data migration.
* **Hosting agents in a worker.** Once tool-running agents run in worker pods, deployments size
  their nodes and limits for them. Removing the feature is a breaking change for those users.
* **The placement enum**, once it ships in adam-rs, is closed like `Role`.

Easy to reverse: the pinned sha, the `agent-local` feature (off by default), and the split into
pods (`all` still works).

## Migration: PR order

1. **adam-rs:** `feat(adam-host)`: `Role` and the supervisor; its ADR 0001.
2. **This repository:** this ADR, the amendments, the rename to "web chat surface".
3. `refactor(orchestrator)`: `boot.rs` becomes shared setup plus two halves. No new dependency,
   no behaviour change.
4. **adam-rs:** `refactor(adam-coder)`: serve on `adam-host` with `ROLE`; a test with front and
   worker over one database completes a task.
5. **adam-rs:** pin the workspace, fix the `repository` field, move the tokio `test-util` feature
   of `adam-model-openai` to dev-dependencies (the orchestrator will link it).
6. `feat(orchestrator)`: `--role` / `ORCH_ROLE` through `adam-host` by git rev; a health-only
   router for the worker; an end-to-end test with 1 control plane and 2 workers, where a killed
   worker hands over and cancel reaches the agent.
7. Observability and scaling: role and instance log fields, queue metrics for KEDA, trace context,
   a compose `split` profile.
8. **adam-rs:** agent starters, so a control plane needs no model or GitHub secrets.
9. **adam-rs:** Postgres event sink and listener, and worker wake-up over `NOTIFY`.
10. **adam-rs:** deploy manifests: coder front Deployment and worker StatefulSet, one worker until
    affinity exists.
11. `feat(orchestrator)`: an `AgentClient` conformance testkit, a closed `AgentTransport` enum,
    a fence on commit.
12. `feat(orch-agent-adam)`: local agents behind `agent-local` (off), the `orch_agent_*` tables.
13. Later: an `AuthConfig::Custom` in `adam-a2a`; an A2A surface that reuses `adam-a2a`.

The placement policy in adam-rs is separate design work and has no slot here yet.

## Verified

* *Verified 2026-09-29* (adam-rs branch `wt-adam-host`, commit `1e54a5d`, crate `adam-host`): `Role`
  has `All`, `ControlPlane`, `Worker`, with `as_str`, `runs_control_plane`, `runs_workers` and
  `from_optional`. `Host::new(role).control_plane(name, f).worker(name, f)` with
  `control_plane_drain`, `worker_grace`, `health` and `run(shutdown)`. `HostError` names the
  component, and `NothingToRun` is returned when no component matches the role. Features:
  `clap`, `serde`, `supervisor` (default).
* *Verified 2026-09-29* (this repository, `orchestrator/bin/orchestrator/src/boot.rs`): the HTTP
  server and the dispatcher start in one process; the stop order and both grace bounds are written
  by hand there.
* *Verified 2026-09-29* (this repository, `orchestrator/crates/ports/src/agent.rs`): `AgentClient`
  is the one port to agents.
* *Unverified:* that adam-rs can be cloned anonymously by CI and Docker. The owner said the
  repository is public; no anonymous clone was run for this ADR.
* *Unverified:* the dependency and toolchain compatibility of the two workspaces (same major
  versions of `sqlx`, `axum`, `tokio` and the A2A crates; both Rust 1.94, edition 2024; both
  `MIT OR Apache-2.0`). It comes from the planning notes of 2026-09-29, not from a build. PR 6
  proves it.
* *Unverified:* that `NOTIFY` payloads are limited to 8000 bytes.

### Status note, 2026-09-29: migration step 6 built

`orchestrator` takes `--role` / `ORCH_ROLE` through `adam-host` and runs on `adam_host::Host`.

* *Verified 2026-09-29* (this repository, `cargo fetch --locked` with an empty `CARGO_HOME`): cargo
  fetches `adam-host` by git rev from `github.com/vymalo/another-adam-rs` with no credentials. The
  orchestrator toolchain (Rust 1.94.1) builds it. The lock file gains two packages, `adam-host` and
  `adam-error`, and `tokio-util` gains a `futures-io` edge from `adam-host`'s workspace features;
  nothing else moves, so the "same major versions" *unverified* item above holds for what the
  orchestrator links.
* *Verified 2026-09-29* (`orchestrator/bin/orchestrator/tests/smoke.rs`): `--role worker` serves
  only the probes; a `control-plane` process leaves a thread `queued` until a worker process starts;
  with one control plane and two workers, SIGKILL of the worker holding the delegation lets the other
  finish it exactly once.
* *Unverified:* the Docker build with the git dependency (`cargo chef prepare` and `cook`): there is no
  Docker daemon in the environment where this was built. CI's `image` job is the proof.
* `boot.rs` now uses `Host` for the stop order, with the two grace times both set to
  `SHUTDOWN_GRACE_SECS`, so the hand-written supervisor is gone. A cancel sent to the control plane
  reaching the agent through the worker that took a task over after a graceful stop is covered by
  `a_worker_stopped_with_a_running_task_hands_it_over_at_once`; the SIGKILL test with two workers
  finishes the task instead of cancelling it.

### Status note, 2026-09-29: migration step 7 built

Role and instance on every log line, queue metrics for autoscaling, and a compose `split` profile. Trace context
is **deferred**.

* Every log line carries `role` and `instance` (the lease owner): an event formatter adds them (a root span would
  not reach the dispatcher's spawned tasks), and each claimed outbox row runs inside an `outbox` span. The
  configuration is read before logging starts, so a line about an invalid configuration has neither.
* `ThreadStore::outbox_stats(now)` (a new port method with a conformance case, so the memory and Postgres stores
  agree) counts the open outbox rows as due, waiting and leased, with the age of the oldest due one. Every role
  serves it as Prometheus text on `GET /metrics`, without an identity. The counts are global, so an aggregation
  across replicas takes `max`, never `sum`. See `docs/orchestrator.md`, "Observability and scaling".
* The compose `split` profile runs a control plane beside two workers, and `dev/split-e2e.sh` kills the worker that
  holds a task and checks that the other finishes it; CI runs it at the end of the Coder E2E workflow.
* **Trace context is deferred**: carrying a W3C `traceparent` across the outbox needs a column (a migration) and an
  OpenTelemetry exporter, which is a design of its own; the `outbox` span, the request id and the thread id tie
  the lines together meanwhile. Open question 27.
* *Verified 2026-09-29* (this repository, `cargo test --workspace` against Postgres 16, and the binary's smoke
  tests): the `outbox_stats` conformance case passes on both stores; `/metrics` is served by the full router and
  the worker's health router without an identity; a control plane alone reports one due row until a worker starts,
  and every JSON log line of a worker carries `role` and `instance`; `docker compose config` accepts every
  combination of the `app` and `split` profiles.
* *Unverified:* the split profile running in containers (`dev/split-e2e.sh` in CI is its first run, with the
  workers having no healthcheck and `wget` in the caddy image assumed), and everything about KEDA: that a
  `prometheus` trigger over `max(due) + max(leased)` with `DISPATCHER_CONCURRENCY` as the threshold scales the
  workers, that a worker Deployment scales to zero on it while the control plane is scraped, and that the
  `postgresql` scaler with the count in `docs/orchestrator.md` does the same without Prometheus. These are from
  memory of the KEDA and Prometheus documentation; no cluster was involved.

### Status note, 2026-09-29: migration step 11 built

An `AgentClient` conformance testkit, a closed `AgentTransport` enum, and a fence on commit. Three commits.

* **Fence.** Every claim of an outbox row hands out a fencing token: `Lease { id, owner, attempt }`, where `attempt` is
  the row's `attempts` counter. The four outbox writes and `Commit.lease` match it, so a worker paused past its lease
  can no longer commit what its agent reported after another worker (or the same process, under the same owner name)
  claimed the row again: the store answers `CommitOutcome::Fenced`, `App::apply` reports `ApplyOutcome::Fenced`
  without retrying, and the worker logs that the late result was dropped. Expiry alone does not fence: a lapsed lease
  that nobody re-claimed still commits. No migration. The design, with its two diagrams, is in
  `docs/orchestrator.md`, "Fenced commits". The bug it closes was that the thread commit never looked at the
  lease, `give_up` committed `DeliveryFailed` before finishing the row, and the old test of a lost lease passed only
  because the heartbeat stopped the worker first.
* **Transport.** `AgentEndpoint { id, transport }` with `AgentTransport::A2a { card_url, bearer }`, in `orch-ports`.
  There is no `Local` variant yet: step 12 adds it with its implementation, and the compiler then lists the `match`
  sites. `AGENTS_FILE` takes an optional `transport: a2a` (ADR 0014 has the note). `AgentInfo.cardUrl` in the chat
  API stays required; step 12 makes it optional.
* **Testkit.** `agent_client_conformance!` with an `AgentFixture` trait, twelve cases, run against the A2A adapter
  (over real HTTP) and against `ScriptedAgent`. The scripted agent gained a `failed` script and `set_unreachable`.
* *Verified 2026-09-29* (this repository, `cargo test --workspace` against Postgres 16): the four fence cases
  (`stale_attempt_is_fenced`, `commit_after_another_owner_reclaims_is_fenced`, `commit_after_complete_is_fenced`,
  `expired_unclaimed_lease_still_commits`) pass on the memory and Postgres stores; two dispatcher tests, with a
  heartbeat that never fires, fail when the memory store's fence is removed and pass with it; a Postgres test that races
  commits against re-claims and `mark_sent` for 25 rounds neither deadlocks nor half-writes; the twelve testkit
  cases pass on both agents, three runs in a row for the A2A adapter.
* *Verified 2026-09-29* (the code): no statement takes a thread lock while holding an outbox row lock; the outbox
  statements touch only outbox and binding rows, and change no foreign key, so `thread, outbox row, binding` is the
  only lock order.
* *Unverified:* deadlock freedom under production load and on other Postgres versions: it rests on the lock-order
  argument above and the 25-round race test on one server, not on a proof. Also unverified: a process test that stops
  a worker with SIGSTOP past its lease and resumes it. It was not written, because `select!` in the worker polls the
  heartbeat and the stream in a random order, so the "late result was dropped" log line would only appear about
  half of the time, and the outcome without the fence is the same as with it (the replayed keys are duplicates).
  `skip_unsent_delegates` and `release_leases` are not fenced.

### Status note, 2026-09-29: migration step 12, first two changes built

Step 12 is split. These two come first, because they need no adam-rs dependency and the third builds on them.

* **The A2A-to-envelope mapping in its own crate.** `StreamMapper`, `snapshot` and the release-channels URI moved from
  `orch-agent-a2a` to the pure crate `orch-a2a-mapping` (no I/O, no async, no HTTP client). No behaviour change: the
  mapping's tests moved with it and pass unchanged. The point is that the in-process A2A host of the next change and
  the HTTP client share one set of idempotency keys.
* **`AgentTransport::Local { name }`**, `AgentEndpoint::local(id, name)`, in `orch-ports`, always compiled (the enum
  stays closed). The A2A adapter answers a local endpoint with `AgentError::Unsupported` on every operation, through
  one helper. `LocalAgentKind` (closed, `Echo` only) lives in the binary's `config.rs`, so the configuration names
  kinds without an adam crate. `AGENTS_FILE` takes `transport: local` with `agent: <kind>`; `cardUrl` is optional in
  the file (required for `a2a`, refused for `local`); `AgentInfo.card_url` is `Option` and `AgentInfo.cardUrl` is
  optional in `docs/api/chat-api.yaml` (`required: [id, name]`).
* **The Cargo feature `agent-local` is not defined yet.** A feature that enabled nothing would move the failure from
  startup to the first message, so `transport: local` is refused with `ConfigError::LocalAgentsNotCompiled { agent,
  feature: "agent-local" }` (exit 78) in every build, and `LocalAgentKind::compiled_in` is `false`. The change that
  adds `orch-agent-adam` defines the feature, turns `compiled_in` into `cfg!(feature = "agent-local")`, and replaces
  the message's "not available yet".
* *Verified 2026-09-29* (this repository): `cargo test --workspace` against Postgres 16 passes; the generated web types
  make `cardUrl` optional and `pnpm check`, `pnpm typecheck`, `pnpm test` and `pnpm build` in `web/` pass unchanged (no UI code
  reads `cardUrl`); `GET /api/agents` validates against the contract with an agent that has no card URL
  (`surface-chat-api`'s conformance test lists one from the scripted stack; since 2026-09-30 that test is `orch-api`'s `tests/contract.rs`).
* *Unverified:* a real deployment reading an agents file with a `local` entry; none can run until the next change.

### Status note, 2026-09-30: migration step 12 built

The third change of step 12: `orch-agent-adam`, the local agents behind the Cargo feature `agent-local`, with the
`Echo` kind only. The coder kind (an agent with tools and a workspace) is the next change.

* **The owner decided the journal's home on 2026-09-30.** A local agent keeps its journal in the *orchestrator's*
  Postgres, in tables prefixed `orch_agent_`. This settles the line in decision 6 that said the owner had not
  confirmed it, and closes "revisit it before the first local agent ships". A second database stays possible later
  (the store takes a pool), but it is a data migration ("Hard to reverse").
* **What was built.**
  * `orch-agent-adam` (`LocalAgents`, `LocalAgentClient`, the closed `LocalKind`) drives one `adam-runtime` `Runtime`
    per process through the `adam-a2a` `TaskBackend` seam (`adam-a2a-runtime`), and maps the results with
    `orch-a2a-mapping`, so its idempotency keys are the HTTP client's.
  * `orch-ports` gains `ByTransport<A, L>`, which routes each endpoint to its client by transport and holds no adam
    type.
  * The binary has the feature `agent-local`, **off by default**: `LocalAgentKind::compiled_in` is
    `cfg!(feature = "agent-local")` and the refusal of `transport: local` names the feature. It reads
    `AGENT_LOCAL_CONCURRENCY` (default 4) under the feature.
  * The Dockerfile takes the build argument `ORCH_FEATURES` (empty by default).
* **The pin moved** from `0e08fe07…` to `882e23901ea9964e4a6ed96ee1aed2f4dcea98eb` (adam-rs `main`). The seven adam
  crates the orchestrator uses share it (`adam-host`, `adam-core`, `adam-runtime`, `adam-a2a`, `adam-a2a-runtime`,
  `adam-store-postgres`, `adam-notify-postgres`). The bump is additive for `adam-host` (it gained `Placement`).
* **The TLS backend is kept single.** `adam-store-postgres` and `adam-notify-postgres` default to their feature
  `tls-rustls`, which selects sqlx's `tls-rustls-ring`; the orchestrator uses `tls-rustls-aws-lc-rs`. The workspace
  depends on both with `default-features = false`. *Verified 2026-09-30:* `cargo tree -p orchestrator -i ring` finds
  nothing with the feature on or off.
* **Where the journal lives at boot.** Every role that has a local agent configured builds a pool of its own from
  `DATABASE_URL`, sized `AGENT_LOCAL_CONCURRENCY + 4`, and migrates the journal after the orchestrator's own
  migrations (both are idempotent under their own advisory locks). The `worker` and `all` roles run the agents'
  worker and its notifier beside the dispatcher; the `control-plane` role runs neither and registers the agents'
  starters only. Each replica therefore holds `AGENT_LOCAL_CONCURRENCY + 4` more database connections, on top of
  `DATABASE_MAX_CONNECTIONS`.
* *Verified 2026-09-30* (adam-rs at `882e239`, read in `/home/user/another-adam-rs`):
  * `PgStore::with_table_prefix` accepts `[a-z0-9_]`, at most 40 characters, not starting with a digit
    (`crates/adam-store-postgres/src/lib.rs:84`); every table, index and constraint name derives from the prefix, and
    `Store::migrate` is `CREATE … IF NOT EXISTS` in one transaction under
    `pg_advisory_xact_lock(hashtext('adam-rs:migrate:<prefix>'))` (`lib.rs:421-422`); `SCHEMA_VERSION` is 2 (`lib.rs:50`).
    The tables are `orch_agent_runs`, `orch_agent_journal` and `orch_agent_meta`.
  * `PgNotify::with_channel_prefix` gives the channels `{prefix}events` and `{prefix}signals`
    (`crates/adam-notify-postgres/src/lib.rs:156`), here `orch_agent_events` and `orch_agent_signals`; the
    orchestrator's are `orch_thread`, `orch_outbox` and `orch_resync`, and its tables `threads`, `events`,
    `a2a_bindings` and `outbox`, so nothing collides.
  * **The `NOTIFY` payload limit is now verified:** nothing over `MAX_PAYLOAD_BYTES = 7_999` is sent
    (`crates/adam-notify-postgres/src/wire.rs:15`); an oversize status is cut on a character boundary and any other
    oversize event is dropped (its artifact is still in the durable run). This replaces the *unverified* item on the
    8000 bytes above.
  * `RuntimeTaskBackend` implements `TaskBackend` (`submit`, `get`, `cancel`, `subscribe`) with these properties:
    a task id that is not a UUID gives `Ok(None)` (`crates/adam-a2a-runtime/src/backend.rs:161`); one backend serves
    one agent name; a new task's id is `task_id_for(agent, subject, context, message_id)`
    (`crates/adam-a2a-runtime/src/ids.rs:50`), so resubmitting a message is idempotent; a cancel is committed as
    `Failed "cancelled: …"` and read back as `canceled` (`crates/adam-a2a-runtime/src/convert.rs:14`).
    `TaskEvent::ends_stream` and the loop that cuts a stream (`crates/adam-a2a/src/backend.rs:72`,
    `crates/adam-a2a/src/handler.rs:72`) are copied, since the loop is private there.
* *Verified 2026-09-30* (this repository, against Postgres 16): the `AgentClient` conformance suite passes on the
  local client over the in-memory journal and over Postgres; a task survives its worker dying mid-step (two
  processes on one schema, a 1 s lease: the second steps it to its end and a resubscribe shows the original keys);
  the tables and channels carry the prefix and no `adam_` table exists; the orchestrator's tables, adam's default
  prefix and ours coexist in one schema; the migration is idempotent under six concurrent replicas; through the
  dispatcher, an echo thread completes, a restart mid-task finishes with no gap and no duplicate, and a cancel
  reaches the local task; the binary answers a run through a local `echo` agent, and a control plane starts the run
  without stepping it until a worker starts. `cargo tree -p orchestrator -i adam-runtime` fails with the feature off,
  so the default binary links no adam runtime.
* *Unverified:* the Docker build with `--build-arg ORCH_FEATURES=agent-local` (`cargo chef cook` with `--features`;
  there is no Docker daemon here, and CI builds the default image only). *Unverified:* the SIGKILL process test of a
  local agent's worker: the durability test aborts the worker's future in-process, which drops its steps and stops its
  lease renewals without a process boundary. It comes with the coder kind, whose steps hold a workspace.
  *Unverified:* retention of the `orch_agent_*` tables: `Store::purge_finished` exists in adam-rs but nothing calls it
  yet (open question 28).
