| 1 | # Agent fleet |
| 2 | |
| 3 | > Baca terjemahan bahasa Indonesia: [id/FLEET.md](id/FLEET.md) |
| 4 | |
| 5 | Agent fleet is the local-first roster and member-selection layer for durable |
| 6 | multi-worker runs. It does not execute or authorize work. After fleet resolves |
| 7 | who should participate, local native (`this_computer`) workers run in-process on |
| 8 | their own Runtime thread (`NativeFleetExecutor`), while SSH, Tailscale, and |
| 9 | external ACP/CLI workers launch a headless `codewhale exec` run and the Runtime |
| 10 | tracks them durably. See |
| 11 | [AGENT_RUNTIME.md](AGENT_RUNTIME.md) for how sub-agents, `exec`, and |
| 12 | fleet-backed workers converge on one runtime. In product language, a user may |
| 13 | still "open a sub-agent"; in architecture language, durable nested work uses a |
| 14 | fleet member identity with delegated runtime execution. |
| 15 | |
| 16 | ## Naming and compatibility boundary |
| 17 | |
| 18 | **Fleet** is the public product noun. The durable ledger, saved rosters, config |
| 19 | tables, and `--fleet` flag share that name: |
| 20 | |
| 21 | | Surface | Canonical | |
| 22 | | --- | --- | |
| 23 | | CLI | `codewhale fleet …` | |
| 24 | | Slash command | `/fleet …` | |
| 25 | |
| 26 | These shared names are load-bearing wherever changing them would break |
| 27 | existing workspaces, receipts, or scripts: |
| 28 | |
| 29 | - the durable ledger `.codewhale/fleet.jsonl` and the log directories |
| 30 | `.codewhale/fleet/` and `.codewhale/fleet-host/`; |
| 31 | - saved rosters `fleets/<name>.toml` and their `schema = "fleet"` header, under |
| 32 | `$CODEWHALE_HOME/` or the workspace's `.codewhale/` (checked-in rosters at the |
| 33 | workspace root's `fleets/` are still read); |
| 34 | - the `[fleet]` config table (named fleets live in `fleets/<name>.toml` files); |
| 35 | - the `codewhale workflow run --fleet <name>` flag; |
| 36 | - wire, receipt, and control-plane operation ids such as `fleet.status`. |
| 37 | |
| 38 | The rest of this document uses fleet as the public product noun and retains |
| 39 | these literal paths, keys, flags, and ids. |
| 40 | |
| 41 | Use a fleet roster rather than anonymous short-lived `agent` fanout whenever a |
| 42 | delegated run needs stable member identities across retries, sleep/restart, |
| 43 | remote execution, receipts, or a ledgered audit trail. The initial CLI surface |
| 44 | is: |
| 45 | |
| 46 | For a guided start-to-monitor walkthrough that combines fleet task specs with |
| 47 | Workflow authoring, see [fleet + Workflow Tutorial](FLEET_WORKFLOW_TUTORIAL.md). |
| 48 | |
| 49 | ```sh |
| 50 | codewhale fleet init |
| 51 | codewhale fleet run tasks.json --check # validate only; nothing is created or launched |
| 52 | codewhale fleet run tasks.json --max-workers 4 |
| 53 | codewhale fleet status |
| 54 | codewhale fleet inspect <worker-id> |
| 55 | codewhale fleet logs <worker-id> |
| 56 | codewhale fleet artifacts <worker-id> |
| 57 | codewhale fleet interrupt <worker-id> |
| 58 | codewhale fleet restart <worker-id> |
| 59 | codewhale fleet resume <run-id> |
| 60 | codewhale fleet stop --all |
| 61 | ``` |
| 62 | |
| 63 | `codewhale fleet resume <run-id>` is the restart-recovery verb: it replays the |
| 64 | ledger, reconciles any in-flight lease whose worker stopped heartbeating |
| 65 | (retrying within the task's budget, else failing and escalating per the alert |
| 66 | policy), and prints the post-resume status. It launches no new work and is |
| 67 | idempotent, so it is safe to run after a manager exit, laptop sleep, or runtime |
| 68 | restart. |
| 69 | |
| 70 | Coordinator state for fleet-backed runs is stored under the workspace in |
| 71 | `.codewhale/fleet.jsonl`. Worker logs and adapter logs are stored under |
| 72 | `.codewhale/fleet/` and `.codewhale/fleet-host/`. |
| 73 | |
| 74 | ## Project Coordinator and Shared Context |
| 75 | |
| 76 | Fleet supports local-first multi-agent project coordination alongside the |
| 77 | durable `.codewhale/fleet.jsonl` ledger, with no cloud dependency and full |
| 78 | local resume across sleep or restarts: |
| 79 | |
| 80 | - **Shared project notes (`.codewhale/context/*.md`):** markdown notes scoped |
| 81 | strictly to the workspace, enforced against symlink and path-traversal |
| 82 | escapes, size-bounded per file, and isolated from personal secrets or |
| 83 | credentials. |
| 84 | - **Shared task board (`.codewhale/context/board.json`):** atomic JSON task |
| 85 | board supporting `add`, `claim`, `done`, and `list` operations without |
| 86 | creating files on read-only inspection. |
| 87 | - **Untrusted peer/worker framing:** coordinator and host peer-message routing |
| 88 | wraps worker and peer output inside |
| 89 | `<untrusted_agent_message sender="...">...</untrusted_agent_message>` with |
| 90 | sanitized sender attributes and neutralized embedded tag sequences so peer |
| 91 | output can never impersonate owner instructions. |
| 92 | - **Slash commands:** `/fleet context [list|read <name>]` inspects shared |
| 93 | project notes, and `/fleet board [list|add <title>|claim <id> <owner>|done <id>]` manages the |
| 94 | shared task board. |
| 95 | |
| 96 | ## Public contract: identity, membership, and selection |
| 97 | |
| 98 | **Fleet** = the user's model inventory: who is in the roster and which member is selected. |
| 99 | |
| 100 | A public fleet identity consists only of: |
| 101 | |
| 102 | - a stable member id and an optional user-facing name; |
| 103 | - a semantic role, such as `explore`, `implement`, or `reviewer` (the legacy |
| 104 | spellings `worker`, `scout`, `builder`, `verifier`, `consultant`, and `oracle` |
| 105 | are still accepted on input and map to `general`, `explore`, `implement`, |
| 106 | `test`, and `advisor`); |
| 107 | - an exact provider/model identity, or an explicit inherited route; |
| 108 | - visible roster state or origin. |
| 109 | |
| 110 | Project or workspace trust, filesystem and network reach, secret access, |
| 111 | approval mode, sandboxing, tool authorization, and every other form of runtime |
| 112 | authority are separate delegated-coordination and Runtime policy inputs. They |
| 113 | are never fleet identity fields, and they never select or reroute a fleet |
| 114 | member. The Runtime applies and clamps those policies only after member |
| 115 | selection; if the selected member cannot run inside the effective envelope, |
| 116 | launch fails closed instead of choosing somebody else. |
| 117 | |
| 118 | Natural-language member selection is deterministic. A caller may name: |
| 119 | |
| 120 | - an exact member id, optionally as `member:<id>` or `id:<id>`; |
| 121 | - a unique user-facing member name, optionally as `name:<name>`; |
| 122 | - a unique semantic role, for example `explore` or `role:explore`; |
| 123 | - an exact pinned model id, for example `deepseek-v4-flash`, or its offline |
| 124 | display name, for example `DeepSeek V4 Flash`; or |
| 125 | - an exact `route:<provider>/<model>`. |
| 126 | |
| 127 | An unqualified exact member id wins. Every other match succeeds only when it |
| 128 | identifies one distinct roster member. Multiple matches produce an ambiguity |
| 129 | error that names the candidates and asks for `member:<id>`; Codewhale never |
| 130 | picks whichever match happened to be listed first. Users do not need to know |
| 131 | an internal role label such as `explore`: a unique member name, display model, or |
| 132 | exact model id is equally valid. Saved v2 fleets store that optional human name |
| 133 | as `display_name` (the input alias `name` is also accepted); it must be one |
| 134 | trimmed printable line of at most 80 characters. |
| 135 | |
| 136 | ### Your fleet as models |
| 137 | |
| 138 | The same fleet file answers a third question: **which models has this person |
| 139 | put in their fleet?** Every exact `provider` + `model` pin in the selected |
| 140 | fleet — the operator route, each pinned member, and each explicitly marked |
| 141 | shortlist row — is a fleet model. Executable member rows supply the roles it |
| 142 | fills; a shortlist row has no role. All remain in the same fleet file. Legacy |
| 143 | members that omit `role` still use their id as the role identity. |
| 144 | Shortlist rows carry only model choices; reasoning, instructions, and capability |
| 145 | requirements belong on executable role members and are refused on shortlist rows. |
| 146 | |
| 147 | - `/fleet models` prints the fleet: `provider/model · roles · price · context · |
| 148 | tools`, facts read from the model catalog. With no selected fleet the line |
| 149 | reads "Your fleet is the session model only". |
| 150 | - `/fleet add <provider> <model> [role…]` adds a model (one member row per |
| 151 | role, or one `shortlist = true` row for a role-less add). The provider must be one you configured |
| 152 | and, when the catalog knows the provider, must serve that exact id. |
| 153 | A role member asked to run the fleet's own operator route inherits it |
| 154 | instead of pinning — the role follows when the operator moves; a pin on |
| 155 | any other route is the deliberate opt-out. Files that already pin the |
| 156 | operator route are read as inheritance. |
| 157 | With no fleet selected, a user-global fleet named `My fleet` is created and |
| 158 | selected first. `/fleet remove <provider> <model>` drops every row that pins |
| 159 | the route; the operator route is changed with `/fleet save`, not removed. |
| 160 | - In `/model`, `⇧F` adds or removes an explicit shortlist row for that exact |
| 161 | route. It preserves saved role pins and the operator route; |
| 162 | fleet models are listed first, labelled `fleet · <roles>`, ahead of your |
| 163 | own `⇧P` pins and the provider lists. `/models` prints the fleet before the |
| 164 | provider's list. |
| 165 | |
| 166 | The operator model reads this list when it assigns sub-agents (design |
| 167 | `MODEL-ROUTING-CATALOG-20260901.md` §10, slice F2). |
| 168 | The model-facing roster resolves roles through the same route admission code |
| 169 | as a start. Explicit profiles and manual role pins remain authoritative; a |
| 170 | unique saved role pin also applies to a start naming only its role. Task model |
| 171 | choices are available for unpinned roles, constrained to the selected models |
| 172 | plus the session route. Shortlist model rows disclose their own exact route |
| 173 | independently of any role pin. |
| 174 | |
| 175 | ### Interactive and persistent status |
| 176 | |
| 177 | Open `/fleet` to select a mission and see its task states, receipts, and saved |
| 178 | session IDs where available. Press `r` to refresh the mission list or `b` to |
| 179 | read the latest 50 board events for the selected mission from the local Runtime. |
| 180 | Use |
| 181 | `/fleet members` for the saved roster, `/fleet teams` for named teams, and |
| 182 | `/agents` or `/whales` for saved specialist profiles. |
| 183 | |
| 184 | `/fleet status` and `codewhale fleet status` are the **same** command on two |
| 185 | surfaces. Both read the durable `.codewhale/fleet.jsonl` ledger for the |
| 186 | workspace, through one shared control-plane contract, and both report the same |
| 187 | verb id (`fleet.status`), read-vs-write authority, persistence scope, and |
| 188 | receipt. When the workspace has no ledger they say so with a typed reason |
| 189 | (`no_fleet_ledger`) instead of rendering an empty-looking "all clear" — and |
| 190 | neither creates the ledger as a side effect of reading it. |
| 191 | |
| 192 | The current interactive session's sub-agents are a **different set**, and now |
| 193 | have their own name: |
| 194 | |
| 195 | - `/fleet workers` (or `/subagents`, or Tab / `w` from `/fleet members`) |
| 196 | shows sub-agents attached to the current TUI session. It does not read the persistent ledger. |
| 197 | - `/fleet list|status|interrupt|resume` and `codewhale fleet |
| 198 | list|status|interrupt|resume` act on the durable ledger. |
| 199 | - `codewhale fleet restart <worker-id>` is CLI-only: it re-leases the task and |
| 200 | then drives the manager loop to completion. `/fleet restart` does not |
| 201 | silently do a smaller thing — it reports `surface_not_supported` and names |
| 202 | the CLI command. |
| 203 | |
| 204 | The contract behind this — descriptors, availability reasons, exact-identity |
| 205 | targets, receipts, typed unknowns, and bounds — is documented in |
| 206 | [`docs/COMMAND_CONTROL_PLANE.md`](COMMAND_CONTROL_PLANE.md). |
| 207 | |
| 208 | ## Saved agent profiles |
| 209 | |
| 210 | Use `/agents` or `/whales` to browse reusable profiles, and `/subagents` to inspect live children. The terminal equivalents are `codewhale agents` and `codewhale whales`. Use `show <id>` to inspect a saved profile or `route <id> <provider> <model>` to save a concrete route. Project profiles require workspace trust. A saved route can be edited in Markdown or TOML. Profiles loaded from plugins and Claude Code are read-only here. |
| 211 | |
| 212 | For a local Runtime mission, use a saved whale’s `fleet_member_selector` from `GET /v1/whales` as the task’s `worker.agent_profile` and its `fleet_role` as `worker.role`. Declare that role in the mission. Keep the selector opaque. The Runtime host token is required. The mission snapshots the saved profile when queued. Deleting and recreating the profile invalidates old selectors for new missions. If a whale is unavailable, `fleet_unavailable_reason` explains why. The general Fleet profile roster lists ordinary members, while saved whales are available from the whale endpoint. |
| 213 | |
| 214 | On a Runtime that advertises `fleet_worker_model_pool`, read or update the shared selection at `/v1/providers/{id}/worker-model-pool`, using the exact configured provider ID. An unset selection returns `null`. For a write, send `mode` (`all`, `selected`, or `none`), `models` in selected mode, the last `revision` as `expected_revision` (zero when unset), and the current `binding_id` from that provider’s model listing. On a revision conflict, reload the pool. On a binding or inventory change, refresh the inventory and ask the user to confirm the choice. |
| 215 | |
| 216 | ## Authoring agent profiles (`/fleet setup`) |
| 217 | |
| 218 | Agents: the durable artifact is the profile TOML described below; the |
| 219 | key-by-key walkthrough is the human interactive path. |
| 220 | |
| 221 | `/fleet setup` (also `/fleet setup edit` / `new`) opens an in-TUI wizard for |
| 222 | authoring a reusable agent-team profile. Bare `/fleet` and the |
| 223 | `roster`/`roles`/`profiles`/`party` aliases open the selected fleet's member |
| 224 | roster. `/fleet saved` opens the named saved-fleet picker. `/fleet workers` opens the |
| 225 | current-session worker view; `/subagents` is a |
| 226 | compatibility shortcut for that view. For durable run history, use |
| 227 | `/fleet status` or the shell command `codewhale fleet status` described above — |
| 228 | they are the same command. |
| 229 | |
| 230 | The wizard is progressive: you make one focused choice at a time — a **role**, |
| 231 | then a **model** (`inherit`, or a concrete model from *any configured |
| 232 | provider*, not only the one the parent session is currently using), then |
| 233 | **where the profile lives**, and finally a **review** of the member identity |
| 234 | and route. When the review also previews thinking, tools, approvals, or another |
| 235 | execution control, those rows summarize separate Runtime policy; they do not |
| 236 | become fleet identity or member selectors. The header shows "Saves to: …" on |
| 237 | every step — the choice you still have to make, or the exact resolved file |
| 238 | once you have made it. Nothing is written until you activate the save control |
| 239 | on the review step. |
| 240 | |
| 241 | The **Destination** step is a focused two-option list: |
| 242 | |
| 243 | - **This project** writes `<workspace>/.codewhale/agents/<role>.toml`. It |
| 244 | applies to this project only and takes precedence over a Personal profile |
| 245 | with the same id. When project profiles are disabled for the session |
| 246 | (`--no-project-config`) or the workspace folder is unavailable, the option is |
| 247 | shown disabled with that reason; the wizard never falls back to Personal on |
| 248 | its own. |
| 249 | - **Personal** writes `$CODEWHALE_HOME/agents/<role>.toml` and is available in |
| 250 | every project on this machine, except where a project has its own profile |
| 251 | with the same id. |
| 252 | |
| 253 | For the highlighted option the step shows the exact file, whether saving would |
| 254 | create a new file or **replace an existing one**, and the precedence |
| 255 | consequence for the roster. The review step repeats those facts under |
| 256 | "Saves to" and names the final action by its effect — **Save to this |
| 257 | project**, **Save as Personal profile**, or **Replace …**. Replacing an |
| 258 | existing file asks for a second confirmation on the save control. Reopening a |
| 259 | saved member from `/fleet` starts from what is on disk: its member identity, |
| 260 | route, and save scope. Thinking (`inherit`, `off`, `low`, `medium`, `high`, |
| 261 | `max`, or `auto`) is adjusted on the review step, but remains a route |
| 262 | execution setting rather than part of the member's fleet identity. |
| 263 | |
| 264 | Profile scope controls where a role definition is reusable; it does not widen |
| 265 | the authority of a running operation and is not a project-trust setting. To |
| 266 | coordinate several nearby repositories, start Codewhale from their shared |
| 267 | parent directory so that parent is the workspace. Project/workspace trust, |
| 268 | external paths, filesystem and network reach, secrets, approvals, sandboxing, |
| 269 | and tool authorization come from delegated-coordination and Runtime policy. |
| 270 | For nested delegation, Runtime intersects the requested child posture with the |
| 271 | live parent. For standalone `codewhale fleet` execution, Runtime instead uses |
| 272 | the bounded tool-authority envelope minted from the task's explicit write |
| 273 | scope together with live config, sandbox, and platform enforcement. Neither |
| 274 | path reads authority from the profile's storage scope or identity selector. |
| 275 | A worker whose envelope grants read-only shell access runs the same read-only |
| 276 | command grammar as an in-session read-only agent, including pipelines, chains |
| 277 | and a leading `cd` (see "Read-only shell commands" in `docs/SUBAGENTS.md`); |
| 278 | Admitted `gh` reads also need the envelope's network grant. `npm view` remains |
| 279 | outside the read-only grammar because npm configuration can select executable |
| 280 | helpers; a network grant does not authorize those helpers. |
| 281 | |
| 282 | Picking a concrete model pins its provider explicitly: the saved profile records both |
| 283 | `model` and `provider` fields, so the route it names doesn't depend on |
| 284 | whichever provider happens to be active when the profile is later loaded. |
| 285 | Pressing **Enter** ("start") on the review step previews the exact starter |
| 286 | profile TOML inline on that same screen; nothing is written until you save it. |
| 287 | The `provider` field may be a built-in provider id such as `openrouter` or a |
| 288 | user-named OpenAI-compatible provider configured under `[providers.<name>]` |
| 289 | such as `lm-studio`; the launch path preserves that id and fails closed if the |
| 290 | provider is not configured. |
| 291 | |
| 292 | Profiles are also how the model-facing `agent` tool selects a route: a child |
| 293 | either runs as a `profile` (whose saved route and thinking tier it uses |
| 294 | exactly) or inherits the operator's model. Per-task `model`, `model_strength`, |
| 295 | and `thinking` remain advertised for unpinned roles; saved profile and manual |
| 296 | role pins refuse overrides. See docs/SUBAGENTS.md for the advertised field |
| 297 | list and the parse-accepted compat list. |
| 298 | |
| 299 | When a provider is configured, the review step also offers model-assisted |
| 300 | drafting behind an explicit preview-before-save gate: |
| 301 | |
| 302 | - Press **`m`** to have your first configured model draft the profile. The |
| 303 | draft arrives sanitized and bounded. Separately, the Runtime keeps its |
| 304 | conservative execution floor (no shell or trust escalation and approval |
| 305 | required) regardless of what the model proposes. |
| 306 | - **Drafting is not saving.** The exact rendered TOML preview renders |
| 307 | inline on the review step (not in a separate scrollable viewer), so nothing |
| 308 | is saved until you press **`g`** or **Enter** to save (or press `m` again |
| 309 | to redraft). Saving writes the profile to the project or personal scope |
| 310 | shown in the preview. |
| 311 | |
| 312 | ## Naming: Modes, Workflow, and fleet |
| 313 | |
| 314 | These names describe different layers, not competing systems. Plan and Work are |
| 315 | the two modes; Operate was retired, and its orchestration guidance lives in |
| 316 | every conversation. Background Fleet agents take independent, parallel, |
| 317 | isolated, or long-running work in any mode, under the same approval, sandbox, shell, |
| 318 | ask-rule and repository protections as the parent, but no executable step |
| 319 | requires one. Workflow is an optional orchestration overlay |
| 320 | for work that needs ordering, gates, shared budgets, replay, or deterministic |
| 321 | fan-in. |
| 322 | |
| 323 | The short public vocabulary is: |
| 324 | |
| 325 | - **Fleet** is the durable roster and deterministic member-selection surface. |
| 326 | It records member ids and names, semantic roles, provider/model identities, |
| 327 | and roster state. Fleet is also the name used by storage and wire formats. |
| 328 | - **Workflow** = what order the work follows: phases, gates, budgets, replay, |
| 329 | and fan-in. |
| 330 | - **Lane** = one running Workflow instance and its live progress. |
| 331 | - **Runtime** = where, how, and with what authority selected work executes. |
| 332 | Runtime owns the local or remote process, provider route, project/workspace |
| 333 | trust, filesystem, network, secrets, approvals, sandbox, tools, and API |
| 334 | boundary. |
| 335 | |
| 336 | - **Workflow** is the repeatable plan and user-facing orchestration |
| 337 | overlay: a script/IR that decides which phases and agents run next, keeps |
| 338 | intermediate results out of the main conversation, and can be inspected or |
| 339 | rerun. A Workflow run should have a visible progress view and a clear active |
| 340 | header state instead of feeling like a hidden background task. |
| 341 | - **Fleet** is the durable roster and deterministic member-selection surface: |
| 342 | member ids and names, semantic roles, pinned or inherited provider/model |
| 343 | identities, and roster state. The delegated |
| 344 | coordinator and Runtime own launch concurrency, leases, heartbeats, logs, |
| 345 | receipts, tools, sandboxing, approvals, and authority. |
| 346 | - **High fan-out** is a behavior of a Workflow run, not a separate system: |
| 347 | when a phase needs many workers at once, Workflow dispatches them as a |
| 348 | fleet-backed run (durable workers, receipts, goal re-dispatch) rather than |
| 349 | reviving prompt-only sub-agent fanout. |
| 350 | - **Fan-in is explicit:** when the user needs one combined result, an owner |
| 351 | aggregates, verifies, and synthesizes the worker receipts. Independent tasks |
| 352 | may finish separately; dispatch is never presented as completion. |
| 353 | |
| 354 | UI guidance: keep the main transcript calm. A Workflow run should appear as a |
| 355 | compact progress card plus workbar rows (the strip under the composer, or |
| 356 | a side workbar) with phase names, worker counts, receipts, and nested |
| 357 | indentation for child workers. Use the whale mark sparingly as an active |
| 358 | header/status signal; avoid repeating emoji-heavy rows for every worker. |
| 359 | |
| 360 | ## Saved fleets and the Reasoning Router |
| 361 | |
| 362 | A selected v2 fleet freezes each selected member's id, semantic role, provider, |
| 363 | and model identity into the durable run before a Workflow starts. Save the |
| 364 | fleet as `fleets/<name>.toml` under the workspace's `.codewhale/` (where the |
| 365 | fleet editor saves folder fleets) or under `$CODEWHALE_HOME`; a checked-in |
| 366 | `fleets/<name>.toml` at the workspace root is also read. |
| 367 | Models cannot replace those identity or route assignments at runtime: |
| 368 | |
| 369 | ```toml |
| 370 | schema = "fleet" |
| 371 | schema_revision = 2 |
| 372 | name = "release" |
| 373 | |
| 374 | [operator] |
| 375 | provider = "deepseek" |
| 376 | model = "deepseek-v4-pro" |
| 377 | |
| 378 | [[members]] |
| 379 | id = "implementer" |
| 380 | display_name = "Release Builder" |
| 381 | role = "implement" |
| 382 | provider = "zai" |
| 383 | model = "glm-5.2" |
| 384 | |
| 385 | [[members]] |
| 386 | id = "advice" |
| 387 | role = "advisor" |
| 388 | provider = "openai" |
| 389 | model = "gpt-5.6" |
| 390 | ``` |
| 391 | |
| 392 | The workflow crate's older `schema = "exact"`, revision 1 files are migration |
| 393 | input only. Do not author revision-1 files; the selected roster and setup UI |
| 394 | read and write only `schema = "fleet"`, revision 2. |
| 395 | |
| 396 | `workflow(fleet: "release")` runs a saved Fleet without selecting it. At |
| 397 | Workflow start, a member with no pin takes the Fleet's `[operator]` route or, |
| 398 | without one, the session route and reasoning tier; that frozen route is what |
| 399 | runs and what receipts name, and editing the file mid-run changes only the next |
| 400 | Workflow. If a saved Fleet and an older exact/legacy file share a name, the |
| 401 | Workflow refuses to guess; qualify the saved one as `user/<name>` or |
| 402 | `folder/<name>`. Members with `instructions` or `requires` cannot run in a |
| 403 | Workflow yet. |
| 404 | |
| 405 | Reasoning is a separate route-execution decision, not fleet identity. The |
| 406 | optional Reasoning Router is a reusable Runtime service, not a fleet member. |
| 407 | Save one profile at `routers/<name>.toml` in any search root and reference it |
| 408 | from any number of fleets: |
| 409 | |
| 410 | ```toml |
| 411 | name = "luna-low" |
| 412 | schema = "reasoning_router" |
| 413 | schema_revision = 1 |
| 414 | provider = "openai" |
| 415 | model = "gpt-5.6-luna" |
| 416 | call_reasoning = "low" |
| 417 | ``` |
| 418 | |
| 419 | At runtime it may choose only the reasoning tier for an already-frozen worker |
| 420 | route. It cannot change the member, provider, model, or semantic role. The |
| 421 | Router call itself is capped at `off` or `low`; more expensive values are |
| 422 | rejected. A manually selected worker reasoning tier makes no Router call. Route |
| 423 | and reasoning receipts name the worker model and, when used, the Router's exact |
| 424 | provider/model so the operator can see which model did which job. If the same |
| 425 | bare Router or fleet name exists in more than one root, qualify it as |
| 426 | `codewhale_home/<name>`, `workspace/<name>` (the workspace's `.codewhale/`), or |
| 427 | `workspace_root/<name>` (the workspace root) instead of relying on shadowing. |
| 428 | |
| 429 | Compatibility schemas may serialize `reasoning`, `permissions`, tool hints, or |
| 430 | other execution settings beside a member. Those values are not fleet identity, |
| 431 | member selectors, or active authority. A valid legacy `schema = "exact"` roster snapshot |
| 432 | retains its old `permissions` bytes only while verifying and replaying that |
| 433 | snapshot's recorded content hash; a fresh capture emits the authority-free |
| 434 | member shape. New-run validation rejects legacy roster |
| 435 | `security_policy` and worker `trust_level` fields; configure execution authority |
| 436 | through Runtime policy. The delegated coordinator resolves and durably freezes |
| 437 | the member first. Runtime then applies either the delegating parent's effective |
| 438 | ceiling or, for standalone fleet CLI work, Runtime execution configuration plus |
| 439 | live sandbox/platform enforcement. That boundary may |
| 440 | reduce or refuse the selected worker's execution surface, but it must never |
| 441 | choose a different member or route. See |
| 442 | [`docs/MODES.md`](MODES.md), [`docs/SUBAGENTS.md`](SUBAGENTS.md), and |
| 443 | [`docs/AGENT_RUNTIME.md`](AGENT_RUNTIME.md) for the enforcement contract. |
| 444 | |
| 445 | Reasoning receipts record the requested tier *and* the tier the provider was |
| 446 | actually asked for. Those differ whenever a route cannot express the requested |
| 447 | one — Codewhale's route normalizer sends `high` for a requested `low` on most |
| 448 | routes, and Z.AI's GLM routes express only thinking on/off — so the receipt |
| 449 | reports the real request rather than the label that was selected. The value a |
| 450 | call actually carries is spelled by that route's own normalizer, not by the tier |
| 451 | label: an OpenAI Codex route is asked for `xhigh`, not `max`, and cannot be |
| 452 | asked for `off` at all. |
| 453 | |
| 454 | A durable fleet CLI receipt keeps the selected profile id in |
| 455 | `effective_permissions.profile_id`, the resolved semantic role in |
| 456 | `resolved_route.role`, and the effective Runtime surface in the permission, |
| 457 | shell, and tool-scope fields. An exact Workflow launch receipt records |
| 458 | `member_role` separately from an optional Runtime `posture_role`, plus the |
| 459 | fingerprint of the effective authority envelope checked at the spawn boundary. |
| 460 | A member named `auditor` can therefore retain that identity while Runtime |
| 461 | reports a `custom` posture and independently proves the narrower surface it |
| 462 | enforced. |
| 463 | |
| 464 | A Workflow start fails closed on anything decidable locally: an unresolvable |
| 465 | provider or model, a missing credential, a client that cannot be built for a |
| 466 | member's route, or an `auto` member with no usable Reasoning Router. Per-task |
| 467 | validation that the spawn boundary would refuse anyway — notably a write-capable |
| 468 | member with no declared `write_roots`/`exact_files`/`coordination_contracts` — |
| 469 | is checked before the Router is called, so an invalid task never spends a |
| 470 | routing request. If a spawn fails *after* a Router decision, the receipt is |
| 471 | still recorded: the tokens were spent, and any cross-provider disclosure already |
| 472 | happened. |
| 473 | |
| 474 | ## Manager-owned Workflow fan-in |
| 475 | |
| 476 | When parallel work must return one combined answer, prefer a manager-owned |
| 477 | Workflow over a flat `agent` fan-out. Default shape: |
| 478 | |
| 479 | 1. **Cast one manager** (operator or workflow orchestrator). |
| 480 | 2. **Fan out** child tasks through `workflow` (`task()`, `parallel()`, |
| 481 | `pipeline()`, `phase()`) or a single manager session that owns the children. |
| 482 | 3. **Wait** for child receipts or completion events. |
| 483 | 4. **Aggregate and verify** load-bearing claims before treating them as facts. |
| 484 | 5. **Synthesize** one result the operator can depend on. |
| 485 | |
| 486 | Raw `agent` fan-out fits independent work with no combined result. When |
| 487 | results must be merged, compared, or verified, route through `workflow` so |
| 488 | the manager owns fan-in — that is what the shape above is for, not a ban |
| 489 | on simpler patterns when nothing needs combining. |
| 490 | |
| 491 | ## Workflow on fleet |
| 492 | |
| 493 | The intended high-capability path is agent-authored. When the main agent |
| 494 | decides a task needs more durable coordination than turn-by-turn sub-agent |
| 495 | calls, it drafts a Workflow script/IR, presents the run plan according to the |
| 496 | active permission mode, and the runtime compiles it into typed fleet work. |
| 497 | |
| 498 | fleet remains the sub-agent roster and member-selection surface. It owns member |
| 499 | identity, membership, semantic roles, saved provider/model pins or inheritance, |
| 500 | and roster state. Workflow owns the orchestration plan: |
| 501 | branch, sequence, loop, expand, review, and reduce decisions. The delegated |
| 502 | coordinator and Runtime own slot admission, launch concurrency, the execution |
| 503 | ledger, and every authority decision. A workflow script receives no direct |
| 504 | shell, filesystem, network, provider-secret, cancellation, or TUI authority; |
| 505 | workers perform real work as `codewhale exec` processes under the effective |
| 506 | Runtime policy. |
| 507 | |
| 508 | Default Workflow-to-fleet validation is intentionally bounded: |
| 509 | |
| 510 | - 1,000 total worker agents per Workflow run; |
| 511 | - 64 live worker agents at once by default (`[workflow] max_concurrent`, at most 128); larger populations queue (block) on the host's |
| 512 | per-run concurrency gate until a live slot frees, then route through fleet; |
| 513 | - Workflow IR structural nesting no deeper than 5; |
| 514 | - Runtime child delegation defaults to 3 levels and has an opt-in hard ceiling |
| 515 | of 8, independently of the Workflow document's structural depth. |
| 516 | |
| 517 | These are delegated-coordination population limits, not fleet identity and not |
| 518 | a demand to launch everything at once. A 1,000-agent Workflow should still |
| 519 | drain through the configured Runtime worker pool. They are also not model-step |
| 520 | budgets: omitted or zero `max_steps` remains unbounded. An explicit positive |
| 521 | `max_steps` may cap that task, while wall-clock timeouts, cancellation, |
| 522 | provider safeguards, heartbeats, and admission controls remain independent. |
| 523 | |
| 524 | Recommended model layouts, such as a DeepSeek Pro orchestrator with Flash |
| 525 | workers in the first ring and cheaper workers farther out, are presets only. |
| 526 | Every slot can inherit the active model or carry an explicit model override. |
| 527 | Inheritance is literal: the model you select in `/model` is the **operator** |
| 528 | (the pinned first row in `/fleet roster`), and any worker whose task spec and |
| 529 | roster profile pin no model runs on that session model. Once a selected member |
| 530 | has an exact provider/model pin, the Runtime does not silently reroute that |
| 531 | identity because a policy input differs; it either runs that route inside the |
| 532 | effective envelope or fails closed. Route receipts record the requested and |
| 533 | resolved identity. |
| 534 | |
| 535 | The setup UI should render this as an expanding grid: an orchestrator plus a |
| 536 | small number of visible sub-agent slots, with Right/Enter drilling into a slot's |
| 537 | next recursive ring rather than trying to show the whole tree at once. |
| 538 | |
| 539 | ## Task Spec |
| 540 | |
| 541 | `codewhale fleet run` accepts JSON or TOML. `codewhale fleet run <spec> --check` |
| 542 | runs every validation a real run performs (spec shape, roster members, agent |
| 543 | profiles, model routes) and prints the same warnings, then stops: no ledger is |
| 544 | created, no run is written, no worker starts, and nothing is spent. A minimal |
| 545 | JSON spec: |
| 546 | |
| 547 | ```json |
| 548 | { |
| 549 | "name": "local smoke", |
| 550 | "tasks": [ |
| 551 | { |
| 552 | "id": "lint", |
| 553 | "name": "Lint", |
| 554 | "instructions": "Run the lint check and report failures.", |
| 555 | "expected_artifacts": ["log"] |
| 556 | } |
| 557 | ] |
| 558 | } |
| 559 | ``` |
| 560 | |
| 561 | Workers are optional. If omitted, Codewhale creates local worker slots up to |
| 562 | `--max-workers`. |
| 563 | |
| 564 | A spec file takes one of three shapes, chosen by its structure before any |
| 565 | field is read: |
| 566 | |
| 567 | - a **document** — an object with `tasks` (and optionally `name`, `labels`, |
| 568 | `workers`, `usage_ceiling`); |
| 569 | - a **task array** — a bare JSON array of task objects; |
| 570 | - a **single task** — one task object with `id` / `instructions` at the top |
| 571 | level (JSON or TOML; a TOML file is never a task array). |
| 572 | |
| 573 | Array and single-task files take their run name from the file name. Because |
| 574 | the shape is picked first, a malformed spec reports the real problem, for |
| 575 | example ``JSON spec document at tasks[1] (id "review"): missing field |
| 576 | `instructions` at line 7 column 5``. The checked-in |
| 577 | [`docs/examples/fleet-dogfood.toml`](examples/fleet-dogfood.toml) and the |
| 578 | tutorial's `tasks.json` are parsed by the test suite, so they stay valid. |
| 579 | |
| 580 | Task specs are typed in Rust and keep verification data separate from worker |
| 581 | transcripts. Only the `worker` member/role reference participates in fleet |
| 582 | identity selection. The remaining execution fields are delegated-coordination |
| 583 | or Runtime inputs applied after the member is resolved. A task can declare: |
| 584 | |
| 585 | - `id`, `name`, `description`, `objective`, and `instructions` |
| 586 | - `worker` role, tool profile, tools, and required capabilities |
| 587 | - `workspace` root, required files, writable paths, and environment allowlist |
| 588 | - `input_files`, extra `context`, `budget`, `timeout_seconds`, and `retry_policy` |
| 589 | - `expected_artifacts`, `scorer`, `tags`, and free-form `metadata` |
| 590 | |
| 591 | None of those execution-policy fields becomes part of a fleet identity or an |
| 592 | alternate member selector. Omitted or zero `max_steps` means no model-step |
| 593 | ceiling; Codewhale must not synthesize a default step budget. (This is the |
| 594 | fleet file task-spec convention; model-facing `agent` calls differ — the tool |
| 595 | parser rejects an explicit zero. See `docs/SUBAGENTS.md`.) Explicit positive |
| 596 | step limits, timeouts, cancellation, provider safeguards, heartbeats, and |
| 597 | admission control are enforced independently by the delegated coordinator and |
| 598 | Runtime. |
| 599 | |
| 600 | Workers write bounded artifact files under `.codewhale/fleet/` and ledger only |
| 601 | the artifact refs: kind, path, checksum, MIME type, and size. Receipts record |
| 602 | `pass`, `fail`, `partial`, `skip`, or `timeout`; failed receipts may also mark |
| 603 | the source as `transport`, `task`, or `verifier`. `codewhale fleet status` |
| 604 | surfaces those failure-source counts separately. |
| 605 | |
| 606 | Deterministic built-in scorers are `exit_code`, `file_exists`, `regex_match`, |
| 607 | and `json_path`. Specs may also declare `command`, |
| 608 | `code_whale_verifier_prompt`, or `manual`; those record a partial receipt until |
| 609 | an explicit verifier pass completes. |
| 610 | |
| 611 | ### Using Role Presets |
| 612 | |
| 613 | Tasks can reference a semantic role name to select one unique roster member. |
| 614 | Built-in role names (`smoke-runner`, `reviewer`, `builder`, `read-only`) remain |
| 615 | available for compatibility, and custom roles may be defined in |
| 616 | `[fleet.roles]`. |
| 617 | |
| 618 | ```json |
| 619 | { |
| 620 | "name": "smoke check", |
| 621 | "tasks": [ |
| 622 | { |
| 623 | "id": "lint", |
| 624 | "name": "Lint check", |
| 625 | "instructions": "Run lint and report failures.", |
| 626 | "worker": { "role": "smoke-runner" }, |
| 627 | "expected_artifacts": ["log"] |
| 628 | } |
| 629 | ] |
| 630 | } |
| 631 | ``` |
| 632 | |
| 633 | After identity resolution, compatibility role presets may provide tool, |
| 634 | timeout, or retry defaults to the delegated coordinator. Those defaults do not |
| 635 | grant authority, do not change which member was selected, and remain subject to |
| 636 | Runtime clamping. A task spec may request its execution settings explicitly: |
| 637 | |
| 638 | ```json |
| 639 | { |
| 640 | "id": "deep-review", |
| 641 | "name": "Deep review", |
| 642 | "instructions": "Review the entire crate for soundness issues.", |
| 643 | "worker": { |
| 644 | "role": "reviewer", |
| 645 | "tools": ["cargo", "rg", "git"], |
| 646 | "capabilities": ["rust"] |
| 647 | }, |
| 648 | "input_files": ["crates/**/*.rs"], |
| 649 | "budget": { "max_tokens": 32000 }, |
| 650 | "expected_artifacts": ["log", "report"], |
| 651 | "scorer": { "kind": "regex_match", "path": ".codewhale/fleet/report.md", "pattern": "finding|all clear" } |
| 652 | } |
| 653 | ``` |
| 654 | |
| 655 | ### Multi-Task Run Example |
| 656 | |
| 657 | A single fleet run can dispatch several independent tasks in parallel: |
| 658 | |
| 659 | ```json |
| 660 | { |
| 661 | "name": "CI gate", |
| 662 | "tasks": [ |
| 663 | { |
| 664 | "id": "check", |
| 665 | "name": "Compile check", |
| 666 | "instructions": "Run cargo check --workspace and report errors.", |
| 667 | "worker": { "role": "builder" }, |
| 668 | "expected_artifacts": ["log"], |
| 669 | "scorer": { "kind": "exit_code" } |
| 670 | }, |
| 671 | { |
| 672 | "id": "clippy", |
| 673 | "name": "Clippy lint", |
| 674 | "instructions": "Run cargo clippy --workspace and report warnings.", |
| 675 | "worker": { "role": "reviewer", "tools": ["cargo", "cargo-clippy"] }, |
| 676 | "expected_artifacts": ["log"], |
| 677 | "scorer": { "kind": "exit_code" } |
| 678 | }, |
| 679 | { |
| 680 | "id": "security", |
| 681 | "name": "Secret audit", |
| 682 | "instructions": "Search for plaintext secrets and report any matches.", |
| 683 | "worker": { "role": "read-only", "tools": ["rg"] }, |
| 684 | "input_files": ["crates/**/*.rs"], |
| 685 | "expected_artifacts": ["log", "report"], |
| 686 | "retry_policy": { "max_attempts": 1 } |
| 687 | } |
| 688 | ] |
| 689 | } |
| 690 | ``` |
| 691 | |
| 692 | ## Alerts |
| 693 | |
| 694 | fleet alerting is disabled by default. A caller must supply an enabled alert |
| 695 | config before anything is sent. Routes match typed fleet event classes, not log |
| 696 | strings: |
| 697 | |
| 698 | - `stale` |
| 699 | - `restart_exhausted` |
| 700 | - `needs_human` |
| 701 | - `budget_exceeded` |
| 702 | - `verifier_failed` |
| 703 | - `run_completed` |
| 704 | |
| 705 | Adapter config stores environment variable names, not secret values. Send-time |
| 706 | code resolves those names from the environment or a future secrets provider. |
| 707 | Ledger records store only audit labels such as `slack`, `webhook`, or |
| 708 | `pagerduty`; task specs persisted in the ledger redact webhook URLs and routing |
| 709 | keys. |
| 710 | |
| 711 | Example alert config shape: |
| 712 | |
| 713 | ```json |
| 714 | { |
| 715 | "enabled": true, |
| 716 | "dry_run": true, |
| 717 | "routes": [ |
| 718 | { |
| 719 | "events": ["stale", "restart_exhausted", "verifier_failed"], |
| 720 | "adapter": "ops-slack" |
| 721 | }, |
| 722 | { |
| 723 | "events": ["restart_exhausted"], |
| 724 | "adapter": "pager" |
| 725 | } |
| 726 | ], |
| 727 | "adapters": { |
| 728 | "ops-slack": { |
| 729 | "kind": "slack", |
| 730 | "webhook_env": "CODEWHALE_FLEET_SLACK_WEBHOOK", |
| 731 | "channel": "#codewhale-fleet" |
| 732 | }, |
| 733 | "pager": { |
| 734 | "kind": "pager_duty", |
| 735 | "routing_key_env": "CODEWHALE_FLEET_PAGERDUTY_ROUTING_KEY", |
| 736 | "severity": "critical" |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | ``` |
| 741 | |
| 742 | Use dry-run to inspect a redacted adapter payload without sending: |
| 743 | |
| 744 | ```sh |
| 745 | codewhale fleet alert-dry-run \ |
| 746 | --event stale \ |
| 747 | --run-id fleet-demo \ |
| 748 | --worker-id fleet-demo-local-1 \ |
| 749 | --task-id release-triage \ |
| 750 | --reason "worker heartbeat stale since 2026-06-13T02:00:00Z" \ |
| 751 | --adapter slack |
| 752 | ``` |
| 753 | |
| 754 | The payload includes the run id, worker id, task id, status, short reason, and |
| 755 | safe inspection commands such as `codewhale fleet status` and |
| 756 | `codewhale fleet inspect <worker-id>`. Endpoints, webhook secrets, and |
| 757 | PagerDuty routing keys are shown as `<redacted:env:...>`. |
| 758 | |
| 759 | ## Status Surfaces |
| 760 | |
| 761 | `codewhale fleet status` shows compact counts for queued, running, completed, |
| 762 | partial, failed, restarted, escalated, cancelled, stale, and verifier/transport |
| 763 | failure sources. `inspect` shows the worker state plus the current task |
| 764 | objective, role, host, heartbeat, latest event, artifact refs, latest error, and |
| 765 | alert state. `logs` prints bounded log artifact contents, and `artifacts` lists |
| 766 | artifact refs without embedding large payloads. |
| 767 | |
| 768 | The Runtime API exposes the same ledger-backed projection behind the existing |
| 769 | runtime auth middleware: |
| 770 | |
| 771 | ```text |
| 772 | GET /v1/fleet/runs |
| 773 | GET /v1/fleet/runs/{run_id} |
| 774 | GET /v1/fleet/runs/{run_id}/workers |
| 775 | GET /v1/fleet/workers/{worker_id} |
| 776 | PATCH /v1/fleet/workers/{worker_id} |
| 777 | POST /v1/fleet/workers/{worker_id}/interrupt |
| 778 | POST /v1/fleet/workers/{worker_id}/restart |
| 779 | POST /v1/fleet/workers/{worker_id}/revive |
| 780 | POST /v1/fleet/runs/{run_id}/stop |
| 781 | ``` |
| 782 | |
| 783 | Action endpoints call the same manager controls as the CLI and record their |
| 784 | decisions in the fleet ledger. For native local workers running on Runtime |
| 785 | threads (`fleet_worker_thread_executor`), `POST /v1/fleet/workers/{worker_id}/revive` |
| 786 | resumes from the worker's saved checkpoint while keeping the same `worker_id` |
| 787 | and `runtime_thread_id` (refusing retired or unprovable workers with `409`), |
| 788 | and `PATCH /v1/fleet/workers/{worker_id}` (`fleet_worker_model_hotswitch`) |
| 789 | hot-switches `model_provider` / `model` after validating `WorkerModelPool` |
| 790 | and route preflight, deferring mid-turn switches to the next turn boundary. |
| 791 | |
| 792 | ## Manager-Agent Runbook |
| 793 | |
| 794 | Manager agents should treat fleet operations as typed, ledgered control-plane |
| 795 | work. Start with `codewhale fleet status`, then inspect one run or worker with |
| 796 | `codewhale fleet inspect <worker-id>`, `logs`, and `artifacts`. Use direct |
| 797 | reads of `.codewhale/fleet.jsonl`, host logs, or remote files only when the |
| 798 | typed CLI/API surface cannot provide the required evidence. |
| 799 | |
| 800 | Classify the worker before taking action: |
| 801 | |
| 802 | - `transient failure`: stale heartbeat, host timeout, interrupted transport, |
| 803 | retryable provider/network error, or an adapter status that can plausibly |
| 804 | recover without changing the task. |
| 805 | - `task failure`: the worker completed but produced an incorrect result, |
| 806 | domain failure, missing required artifact, or explicit task-level error. |
| 807 | - `verifier failure`: the worker result exists, but the scorer/verifier failed, |
| 808 | timed out, or disagrees with the receipt. |
| 809 | - `needs-human`: missing authority, secret request, destructive operation, |
| 810 | repeated restart exhaustion, ambiguous product decision, or conflicting |
| 811 | evidence that the manager cannot resolve from typed artifacts. |
| 812 | - `not startable`: the issue or task has no `agent-ready` grant from a |
| 813 | maintainer; do not pick it up, implement it, or dispatch a worker against it. |
| 814 | |
| 815 | Choose one typed action: |
| 816 | |
| 817 | - Restart a worker only when the failure is transient, retry budget remains, |
| 818 | the task is idempotent or retry-safe, and no permission or secret boundary is |
| 819 | involved: `codewhale fleet restart <worker-id>`. |
| 820 | - Interrupt or stop only when the current task is unsafe to continue or the |
| 821 | operator explicitly asks for cancellation: `codewhale fleet interrupt |
| 822 | <worker-id>` or `codewhale fleet stop --all`. |
| 823 | - Do not restart pure task failures by default; preserve artifacts and hand the |
| 824 | receipt to the task owner unless the task spec says retrying can produce new |
| 825 | evidence. |
| 826 | - For verifier failures, inspect scorer inputs and artifact refs first. If the |
| 827 | verifier cannot be corrected through typed fleet actions, escalate for human |
| 828 | review. |
| 829 | - For `needs-human`, draft an escalation instead of sending it unless alert |
| 830 | config explicitly authorizes sending. |
| 831 | |
| 832 | Safe Slack or PagerDuty draft: |
| 833 | |
| 834 | ```text |
| 835 | Codewhale fleet needs attention |
| 836 | Run: <run-id> |
| 837 | Worker: <worker-id> |
| 838 | Task: <task-id or unknown> |
| 839 | Classification: <transient failure | task failure | verifier failure | needs-human> |
| 840 | Reason: <one sentence, no secrets> |
| 841 | Latest typed evidence: codewhale fleet inspect <worker-id>; codewhale fleet artifacts <worker-id> |
| 842 | Safe log excerpt: <3 lines max or "see artifact <ref>"> |
| 843 | Requested decision: <restart approval | verifier review | task owner review | permission decision> |
| 844 | ``` |
| 845 | |
| 846 | Post-run summaries should include the run id, workers checked, classification, |
| 847 | typed action taken or drafted, expected ledger effect, artifact refs reviewed, |
| 848 | and next owner. Keep summaries bounded; link artifact refs instead of copying |
| 849 | full logs or transcripts. |
| 850 | |
| 851 | The bundled `fleet-manager` skill mirrors this runbook for manager agents. It |
| 852 | is a first-party system skill and should be discoverable through the normal |
| 853 | skill registry after system skills are installed or refreshed. |
| 854 | |
| 855 | ## Host Adapters |
| 856 | |
| 857 | The Runtime host-adapter boundary supports local child processes and explicit |
| 858 | SSH workers. Host choice is Runtime placement on a worker spec, not fleet member |
| 859 | identity or a member selector. It does not authenticate the host or grant |
| 860 | access. Adapters expose the same operations: start, read status, read bounded |
| 861 | logs, interrupt, restart, stop, and cleanup. |
| 862 | |
| 863 | Local workers run as child processes with stdin closed and stdout/stderr written |
| 864 | to bounded host-adapter logs. They inherit only a small safe base environment |
| 865 | such as `PATH` and explicitly allowlisted variables. |
| 866 | |
| 867 | SSH workers run through the system `ssh` client with `BatchMode=yes` and a |
| 868 | bounded connect timeout. Remote environment variables are sent with OpenSSH |
| 869 | `SendEnv`; values are not embedded in the local ssh argv or fleet logs. |
| 870 | |
| 871 | Host keys must already be trusted: connections use `StrictHostKeyChecking=yes` |
| 872 | and never accept a new key automatically. An explicit `known_hosts` file limits |
| 873 | trust to that file; when it is omitted, OpenSSH uses its normal known-host stores. |
| 874 | Verify the host key before adding it to either store. The legacy |
| 875 | `host_key_fingerprint` field is unsupported and is rejected; migrate it to a |
| 876 | verified `known_hosts` entry. The `identity` file selects the client login key; |
| 877 | it does not verify the remote host. |
| 878 | |
| 879 | Example SSH worker spec: |
| 880 | |
| 881 | ```json |
| 882 | { |
| 883 | "id": "builder-1", |
| 884 | "name": "Builder 1", |
| 885 | "host": { |
| 886 | "kind": "ssh", |
| 887 | "host": "builder.example.com", |
| 888 | "user": "codewhale", |
| 889 | "port": 22, |
| 890 | "identity": "~/.ssh/codewhale_fleet", |
| 891 | "known_hosts": "~/.ssh/codewhale_fleet_known_hosts", |
| 892 | "working_directory": "/srv/codewhale/work", |
| 893 | "env_allowlist": ["CODEWHALE_PROFILE"], |
| 894 | "codewhale_binary": "/usr/local/bin/codewhale" |
| 895 | }, |
| 896 | "capabilities": ["local", "linux", "tests"], |
| 897 | "max_concurrent_tasks": 1 |
| 898 | } |
| 899 | ``` |
| 900 | |
| 901 | Defaults are intentionally conservative: |
| 902 | |
| 903 | - no hosted control plane or cloud provisioning is enabled; |
| 904 | - SSH requires an explicit host, working directory, and Codewhale binary path; |
| 905 | - secret-like environment names such as `TOKEN`, `SECRET`, `PASSWORD`, |
| 906 | `API_KEY`, and `PRIVATE_KEY` are rejected from adapter allowlists; |
| 907 | - secrets should remain in Codewhale config providers or remote host config, |
| 908 | not in task instructions, argv, or fleet logs. |
| 909 | |
| 910 | ## Runtime policy and authority are not fleet identity |
| 911 | |
| 912 | fleet does not define a project/workspace trust level, filesystem or network |
| 913 | reach, secret access, approval mode, sandbox, tool set, or execution authority. |
| 914 | Those belong to delegated-coordination and Runtime policy. This separation is |
| 915 | load-bearing: |
| 916 | |
| 917 | - member resolution considers only member id/name, semantic role, |
| 918 | provider/model identity, and roster state; |
| 919 | - the selected identity is frozen before any authority policy is evaluated; |
| 920 | - the Runtime applies the live parent ceiling when one exists; standalone |
| 921 | fleet CLI launches instead carry an explicit bounded authority envelope, |
| 922 | and both paths remain subject to live sandbox and platform enforcement; |
| 923 | - no trust, permission, capability, secret, sandbox, approval, or tool-policy |
| 924 | value may select another member or silently change its provider/model route; |
| 925 | and |
| 926 | - receipts report requested and effective Runtime posture separately from the |
| 927 | fleet member identity. |
| 928 | |
| 929 | Older persisted configuration and protocol shapes may still contain fields such as |
| 930 | `security_policy`, `trust_level`, `permissions`, `capability_grants`, secret |
| 931 | references, host authentication, environment allowlists, or tool profiles. |
| 932 | They remain deserializable for ledger replay, but new fleet run creation rejects |
| 933 | `security_policy` and worker `trust_level` rather than pretending they grant |
| 934 | authority. Their presence in old data does not make them fleet variables or |
| 935 | grants. The active Runtime remains the final authority and fails closed when a |
| 936 | requested operation cannot be enforced. |
| 937 | |
| 938 | For current enforcement behavior, use [Modes](MODES.md), |
| 939 | [Sub-agents](SUBAGENTS.md), [Agent Runtime](AGENT_RUNTIME.md), and the |
| 940 | [Command Control Plane](COMMAND_CONTROL_PLANE.md). Keep secret values out of |
| 941 | task instructions, arguments, logs, and receipts; adapter and Runtime layers |
| 942 | must continue to redact or reject them independently of fleet selection. |
| 943 | |
| 944 | ## Child grants and follow-up rework (#6298) |
| 945 | |
| 946 | A child's authority is one grant object, `ChildGrant` |
| 947 | (`crates/agent-contract/src/worker_profile.rs`). It has `files` (none / read / write), `shell` (none / inspect / |
| 948 | verify / full), `network`, `desktop`, a tool `surface`, the caller's explicit |
| 949 | `scope`, and `spawn`. Roles are presets over it (`ChildGrant::for_role`), and |
| 950 | `ChildGrant::resolve` intersects the preset with the parent-derived profile |
| 951 | and the caller's scope. The child's tool catalog, its dispatch refusals, and |
| 952 | its capability envelope all read the same grant, so a tool the child can see |
| 953 | is a tool it can call. `desktop` is in no preset. |
| 954 | |
| 955 | `ShellGrant::Verify` gives the Verifier preset the |
| 956 | bounded built-in verification surface (default workspace checks, pure test |
| 957 | selection, bounded Git fetch and merge-tree) instead of a shell grammar. |
| 958 | |
| 959 | Additional grant invariants: |
| 960 | |
| 961 | - Children never inherit desktop or computer-control tools (b5e48cd31, #6296). |
| 962 | - A bounded verify surface for Git: `fetch` against a configured remote name |
| 963 | and a read-only `merge_tree` (b89349286). |
| 964 | - Refusals name the sanctioned alternative and tell a child to report a |
| 965 | blocked probe to its parent instead of working around it (23747acea). |
| 966 | - One reasoning vocabulary (c2bc1244d). Token budgets are tracked but never |
| 967 | enforced (a7a8bdb33). |
| 968 | |
| 969 | **Planned follow-up.** #6298 tracks the remaining rework below: |
| 970 | |
| 971 | **0.11 remainder** (one slice at a time): |
| 972 | |
| 973 | 1. **A `verify` shell mode for builds.** `cargo test`/`check` run under an |
| 974 | explicit, bounded write scope (`target/`, refs), so a verifier can run the |
| 975 | builds it is handed without a full shell. |
| 976 | 2. **Classified tool families that fail closed.** MCP and desktop tools form a |
| 977 | labeled family. A child gets that family only when the spawn grants it with |
| 978 | a reason, and an unclassified tool is not granted. |
| 979 | 3. **Legible grants.** The role picker, roster, and receipts show the effective |
| 980 | grant, model, and thinking tier in plain words. |
| 981 | |
| 982 | Related work is tracked in #6015, #5633, #6194, and #6232. |
| 983 |