Skip to content

API Reference parrot.e2e.targets.base

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.e2e.targets.base

View source

Target adapter protocol and launch contract (FEAT-581, M4).

This module defines the two pieces spec §3 "M4: Target registry and fixture entry points" fixes as a normative contract, independent of both the M3 supervisor and every concrete target module:

  • :class:LaunchSpec — the nonpersisted, secret-safe description of one child-process launch (argv/env/cwd/stdio), always meant to be executed via direct argv invocation (shell=False), never a shell string. Its env is redacted from repr/str (hence any self.logger call) and from model_dump()/model_dump_json().
  • :class:TargetAdapter — the typing.Protocol every target kind's concrete adapter implements: prepare() returns a validated :class:LaunchSpec (or raises :class:parrot.e2e.errors. E2EPrerequisiteError before any subprocess is spawned), ready() verifies the configured protocol endpoint and child identity.

Nothing here imports parrot.e2e.supervisor (M3) or any concrete target module (parrot.e2e.targets.mcp/botmanager/ui/browser/ redis, M4's own later deliverables) — only the M2 schema surface (:class:parrot.e2e.models.TargetConfig, :class:parrot.e2e.models.RunState) that both sides already depend on. This resolves the M3/M4 cycle spec §3 calls out: the supervisor depends on this protocol, this protocol never depends back on the supervisor or on any one adapter's implementation.

Class LaunchSpec

One validated, secret-safe child-process launch (spec §3 "M4").

Always intended for direct argv execution (e.g. asyncio.create_subprocess_exec(*argv, ...) or subprocess.run(argv, shell=False, ...)) — never a shell string, so no argument is ever subject to shell metacharacter expansion.

Fields:

Field Type Default Description
argv list[str] The literal command and its arguments, in execution order. Never empty; every element is a nonempty string token — the structural shape a shell-less exec call requires (a single "space-joined command" string is rejected, since it would only make sense to a shell).
env dict[str, str] Environment variables to set for the child process, merged by the caller over (or in place of) the parent environment. Never included verbatim in repr()/str() (so an accidental self.logger.info(str(spec)) cannot leak a secret) nor in :meth:model_dump/:meth:model_dump_json — every value is replaced by a fixed redaction marker; only key names survive.
cwd Path Working directory the child process is started in.
stdio bool False Whether the supervisor retains persistent stdio pipes to this child (spec §2 "Process Lifecycle": stdio targets are mediated through a private Unix control socket, never a raw pipe/PID file). False for targets that are only polled over HTTP.

Class TargetAdapter

Target-specific launch, readiness and identity checks (spec §3 "M4").

Every concrete adapter (mcp-toolkit/mcp-stdio/mcp-agent/ botmanager/ui/browser) implements this protocol; the M3 supervisor only ever calls through it, never a concrete class directly.

Method TargetAdapter.prepare

Return validated argv/env/cwd for this target; never spawns anything.

prepare(config: TargetConfig, *, run_id: str, worktree: Path) -> LaunchSpec

Parameter Type Default Description
config TargetConfig The target's own :class:TargetConfig (kind/profile/ timeouts/options); options keys are validated by the concrete adapter, not by this protocol.
run_id str The stable ID of the run this launch belongs to.
worktree Path The canonical worktree root the child must be started relative to (never an arbitrary filesystem path).

Returns: LaunchSpec — A validated :class:LaunchSpec, ready for direct argv execution (shell=False).

Raises:

  • parrot.e2e.errors.E2EPrerequisiteError — If a required external binary, installed extra or service is unavailable — raised before any subprocess is spawned.
  • parrot.e2e.errors.E2EConfigError — If config.options contains an unsupported key/value for this target kind.

Method TargetAdapter.ready

Verify the configured protocol endpoint and child identity.

ready(state: RunState) -> bool

Parameter Type Default Description
state RunState The current :class:RunState for the launched target, including its verified :class:parrot.e2e.models. ProcessIdentity and (once known) endpoint.

Returns: bool — True once the target's own protocol readiness check (spec §2 "Target and Authentication Design" — HTTP polling, stdio handshake, etc.) succeeds; False while still starting.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally