Skip to content

API Reference parrot.tools.execution_plan.repair

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

parrot.tools.execution_plan.repair

View source

Runtime delta eligibility, merge and validation (FEAT-585 M5, goal D2).

A PlanDelta is deliberately not a standalone plan: a replacement node may depend on a successful node that is not itself part of the delta (finding R5). So the delta is merged into the original node set, the merged ExecutionPlan is validated with the frozen validate_with_allowlist (catalog.py:145), and the toolkit-specific invariants — eligibility, protected ids, identity preservation, key collisions and allowlist intersection — are checked on top, never patched into the frozen validator.

Function eligible_repair_nodes

Return the node ids a repair delta may replace.

Eligible ids are the explicit error refs (which project_run synthesizes for both recorded hard failures and never-dispatched nodes of a terminal run as status="error"), and only when the run itself is terminal-failed or terminal-partial. partial refs are never eligible (D2, spec §1 Non-Goals last bullet): a fan-out that partially succeeded is not reclassified as a failure.

eligible_repair_nodes(run: PlanRun) -> FrozenSet[str]

Parameter Type Default Description
run PlanRun The terminal run being repaired.

Returns: FrozenSet[str] — The frozen set of eligible node ids; empty for a running or completed run.

Function merge_delta

Merge a delta's replacement nodes into plan, in original order.

merge_delta(plan: ExecutionPlan, delta: PlanDelta) -> ExecutionPlan

Parameter Type Default Description
plan ExecutionPlan The plan the delta is being applied to.
delta PlanDelta Replacement nodes, keyed by their existing id.

Returns: ExecutionPlan — A new :class:ExecutionPlan with replaced nodes swapped in place; node order and plan-level name/objective/metadata are unchanged.

Raises:

  • ValueError — If delta names an id that is not in plan — a

Function protected_node_ids

Return every node id that must not be replaced or re-executed.

protected_node_ids(run: PlanRun) -> FrozenSet[str]

Parameter Type Default Description
run PlanRun The terminal run being repaired.

Returns: FrozenSet[str] — Every plan node id not returned by :func:eligible_repair_nodes (ok / skipped / partial nodes).

Function validate_delta

Validate a repair delta's toolkit invariants, then the merged plan.

validate_delta(delta: PlanDelta, *, run: PlanRun, tool_manager: Any, allowed_tools: Sequence[str], delegates: Optional[Sequence[Any]] = None, allow_delegate_side_effects: bool = False) -> ValidationReport

Parameter Type Default Description
delta PlanDelta Replacement nodes proposed for the repair.
run PlanRun The terminal run being repaired.
tool_manager Any Live manager forwarded to validate_with_allowlist.
allowed_tools Sequence[str] Current host policy allowlist. Intersected with run.metadata.allowed_tools — the effective allowlist is never widened relative to what the run was originally accepted with.
delegates Optional[Sequence[Any]] None Delegate chain forwarded to validate_with_allowlist.
allow_delegate_side_effects bool False Host delegate side-effect policy forwarded to validate_with_allowlist.

Returns: ValidationReport — class:ValidationReport. Toolkit-invariant errors short-circuit before the merge (a delta that fails identity/eligibility checks is never merged), otherwise the report from validate_with_allowlist(merged, tool_manager, effective_allowlist).

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