用于将已批准的改进候选应用到目标文件、回滚之前的更改或预览更改效果。支持四种操作(append/replace/insert_before/update_yaml),每次更改前自动备份。不用于打分(使用 improvement‑discriminator)或门禁验证(使用 improvemen...)
Applies accepted candidates with automatic backup and rollback.
--dry-run 预览变更improvement-discriminatorimprovement-gateimprovement-orchestratorbash
# Apply a candidate (requires ranking artifact + candidate ID)
python3 scripts/execute.py \
--input ranking.json \ # REQUIRED: ranking artifact from discriminator
--candidate-id cand-01-docs \ # REQUIRED: which candidate to execute
--state-root /path/to/state \ # default: lib/state_machine.DEFAULT_STATE_ROOT
--output result.json \ # default: {state-root}/executions/{run-id}-{candidate-id}.json
--force # execute even if recommendation != accept_for_execution
# Rollback a previous change
python3 scripts/rollback.py --receipt receipt.json [--dry-run]
ParamDefaultWhen to change--input(required)Always: path to ranking artifact JSON from discriminator--candidate-id(required)Always: the id field of the candidate to execute--forcefalseUse to execute candidates with recommendation=hold (bypasses critic check)--outputautoSet for custom output location
ActionTriggerBehaviorappend_markdown_section``execution_plan.actionAppends heading + bulleted content lines at EOF. No-op if heading already existsreplace_markdown_section``execution_plan.actionFinds section by heading match, replaces all lines until next same-or-higher-level headinginsert_before_section``execution_plan.actionInserts content lines before a matched headingupdate_yaml_frontmatter``execution_plan.actionMerges frontmatter_updates dict into YAML frontmatter (requires PyYAML)
Every execution creates a backup at {state-root}/executions/backups/{run-id}/{candidate-id}-{filename} BEFORE modifying the target. The backup path is stored in result.rollback_pointer.backup_path for gate-driven rollback.
recommendation != accept_for_execution (use --force to override)EXECUTOR_SUPPORTED_CATEGORIES (docs, reference, guardrail) are auto-executable; others return status=unsupportedexecution_trace dict with action, status, diff_summary for GEPA feedback loop正确: 执行一个 docs 类候选 $ python3 scripts/execute.py --input ranking.json --candidate-id cand-01-docs --state-root ./state → Backup: ./state/executions/backups/run001/cand-01-docs-README.md → Appended "## Operator Notes" section → stdout: ./state/executions/run001-cand-01-docs.json
错误: 跳过 discriminator 直接执行 medium-risk candidate $ python3 scripts/execute.py --input ranking.json --candidate-id cand-04-prompt --force → category=prompt 不在 EXECUTOR_SUPPORTED_CATEGORIES → status=unsupported → medium/high risk 必须经 gate 走 pending_promote → 人工审批
json
{"stage": "executed", "status": "success", "candidate_id": "cand-01-docs",
"result": {"status": "success", "modified": true, "diff": "--- a/...",
"backup_path": "...", "rollback_pointer": {"method": "restore_backup_file",
"backup_path": "...", "target_path": "..."}},
"execution_trace": {"type": "execution_trace", "action": "append_markdown_section", ...},
"next_step": "apply_gate", "next_owner": "gate"}
accept_for_execution onesrollback_pointer