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.
Arguments
Section titled “Arguments”| 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 |
Result
Section titled “Result”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 |
Example
Section titled “Example”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":[]}Errors
Section titled “Errors”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.