Expand description
Narrow workspace-state surface the workers MCP Tool impls
consume. Trait + mock for unit-testing the Tool impls without
spinning up a real Workspace. Mirrors crate::mcp::peers::facade.
The production impl is ProdWorkerFacade (below).
Re-exports§
use std::sync::Arc;🔒use std::sync::Weak;🔒use forge_agent::client::SpawnFailureKind;🔒use forge_primitives::WorkerStatus;🔒use crate::SessionSlot;🔒use crate::mcp::peers::types::WrappedPrompt;🔒use crate::protocol::Command;🔒use crate::protocol::SessionChoice;🔒use crate::protocol::WorkerSpawnReply;🔒use crate::workspace::ResumeTarget;🔒use crate::workspace::Workspace;🔒
Structs§
- Caller
Project - Caller’s project + lead-or-not flag. Returned by
WorkerFacade::caller_project. - Mock
Worker Facade - Mock for unit-testing the four Tool impls. Captures every dispatched call into a Vec so tests can assert “tool X dispatched spawn with these args” without spinning up a real Workspace.
- Prod
Worker Facade - Production impl. Holds a
Weak<Workspace>so construction doesn’t close a strong cycle through the Workspace -> bridge -> MCP -> Tool -> facade -> Workspace path. Every method starts withupgrade()and short-circuits when the workspace has been dropped (only possible during shutdown). - Recorded
Project Delivery - One captured
deliver_worker_prompt_to_projectcall: the address it was given, and the prompt it carried. - Worker
Capacity - Point-in-time worker-capacity read for the caller’s project: the
cap the spawn path enforces, how many workers are live under it,
and where the cap came from. Produced by
WorkerFacade::capacity.
Enums§
- Despawn
Outcome - Synchronous outcome of
despawn_worker- the success-shaped half of aCommand::DespawnWorker. Gating + dispatch errors are theErrarm of the result; these two variants are what theagents__despawnTool renders asstatus: "despawned" | "blocked". - Worker
CapSource - Whether a project’s worker cap came from its
[[orgs.projects]]max_workersoverride or the built-in default. - Worker
Deliver Error - Error from
deliver_worker_prompt. A prompt not yet taken is not one: a worker that never finishes connecting leaves a parked message thatWorkspace::expire_parked_for_slotacknowledges back to its sender. - Worker
Despawn Error - Synchronous error from
despawn_worker. Gating (lead-only, non-empty label) happens before dispatch;UnknownLabelis surfaced from the handler’sNotFound, andDispatchFailedfrom itsFailed. - Worker
Lead Deliver Error - Error from
deliver_prompt_to_lead. The caller wants to send a prompt back to its lead via the reserved"lead"addressing keyword. - Worker
Spawn Error - Synchronous error from
spawn_worker. All gating happens before the workspace dispatch is even issued. - Worker
Target Status - A delivery’s own answer, and it has one shape: the prompt was accepted (handed to the target’s session queue, held for its turn end, or parked for its connect). A prompt that reached no session is an error instead, so “accepted” is the whole of what this claims.
- Worker
Update Error - Synchronous error from
update_worker. Gating (lead-only, non-empty label, at least one supplied field) happens in the tool before the call, so these are the outcomes only the store can decide.
Constants§
- LEAD_
LABEL - The label reserved for a project’s own agent. A caller addresses it
as the
labelof anagents__send_messagetarget;agents__spawnrejects the label so no live worker can shadow the keyword. Reserved label for a project’s own agent, addressed as thelabelof anagents__send_messagetarget.agents__spawnrejects it so no live worker can shadow the keyword.
Traits§
- Worker
Facade - The narrow workspace-state surface workers MCP Tool impls depend on.
Functions§
- await_
delivery 🔒 - Await a delivery’s acceptance answer, mapping it to the caller’s
ack. The handler answers
Ok(())once the prompt was accepted andErr(reason)when nothing could take it, so this is the one place the ack is decided. - classify_
worker_ spawn_ failure - Heuristic mapping from a raw spawn-error message + the worker’s
is_git_repo_at_spawnflag to a typedWorkerSpawnError. - discard_
refused_ 🔒worktree - Undo the worktree a refused spawn’s
ensure_worker_worktreestep created, so a refusal strands neither worktree nor branch.ensuredisNonewhen this spawn never touched a worktree. - refused_
delivery 🔒 - The refusal for a label that cannot take a delivery:
Nonewhen a live worker matches, else the error naming which absence this is - a label that is not in the project’s pool at all, or a row kept because the worker crashed. The two read very differently to the sender: one says “check the label”, the other “respawn it”. - validate_
worker_ 🔒label - The label rules a spawn must pass wherever it enters: empty, the
reserved
lead, and a slash. Shared by the tool’s validation and the spawn handler so the MCP tool, the command bus and the socket cannot disagree about which labels mint a worker. - validate_
worker_ 🔒spawn - Validation chain shared by the production and mock
spawn_workerimpls so tests exercise the real rules rather than a hand-copied duplicate.is_leadis the resolved caller role.
Type Aliases§
- Recorded
Spawn 🔒Call - A captured
MockWorkerFacade::spawn_workercall:(caller, label, resolved charter, kick, resume_kick, interactive, resume_session, mcp_families, cwd). - Recorded
Update 🔒Call - A captured
MockWorkerFacade::update_workercall:(caller, label, charter, kick, resume_kick).