Skip to content

fix_apply_plan tool

Apply answered fix plans atomically through the libcst validator and rollback journal. Pass the plan_id, params, and optional file_sha256 guard returned by fix_plan.

fix_apply_plan(answers, paths=null, rules=null)
  • May change files
  • May overwrite what is there
  • A second call may do more
  • Runs code that may reach outside the project

Tags: fix, plan.

Argument Type Required Default Description
answers list of object yes List of PlanAnswer entries filling holes returned by fix_plan.
paths list of string or null no null Python files or directories inside the project root (defaults to .).
rules list of string or null no null Optional rule or package selectors passed via --rule.
Field Type Required Default Description
answers[].plan_id string yes
answers[].params object yes
answers[].file_sha256 string or null no null

Output of xpd fix --apply-plan - --format json.

Field Type Required Default Description
applied integer yes
files_changed integer yes
moved list of list of any no

Submitting an empty answer batch for samples/pipeline/leaky.py leaves the file unchanged and returns zero applied edits.

{"answers":[],"paths":["samples/pipeline/leaky.py"]}
{"applied":0,"files_changed":0,"moved":[]}

If any target file changed since file_sha256 was recorded, or if an answer fails libcst validation, the entire batch rolls back and no files are modified.