apply_repository
Materialize a simulated repository plan as a diff, local commit, or pull request to implement the approved changes.
Instructions
Materialize a simulated repository decision in one of three modes. patch_only just returns the validated patch diff with applied=false and writes nothing. local_branch commits the patch to a new branch (default algenta/) in the engine-side checkout and returns commit_sha and local_checkout_path. remote_pr additionally pushes the branch and opens a pull request, returning pull_request_url. Both write modes are hard-gated: the simulation must satisfy policy thresholds (otherwise repository_apply_gate_failed) and write_permission=true must be passed explicitly (otherwise repository_write_permission_required). Use patch_only to review the diff before writing anything, and run_repository_fix to chain the whole flow. Requires decision_plan_id and simulation_id from simulate_repository.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | patch_only returns the diff; local_branch commits it; remote_pr pushes and opens a PR. | |
| base_branch | No | Branch the patch applies onto and the PR targets; defaults to the connector's default branch. | |
| branch_name | No | Branch to create; defaults to algenta/<plan-suffix>. | |
| snapshot_id | No | Snapshot id; resolved from the decision plan when omitted. | |
| repository_id | Yes | Saved repository connector id from list_connectors. | |
| simulation_id | Yes | Simulation id from simulate_repository. | |
| commit_message | No | Commit message; a default naming the plan id is used otherwise. | |
| decision_plan_id | Yes | Plan id from create_repository_decision_plan. | |
| write_permission | No | Must be true for local_branch and remote_pr; ignored for patch_only. | |
| pull_request_body | No | PR body for remote_pr mode. | |
| pull_request_title | No | PR title for remote_pr mode. |