360 Secure SkillHub
360 安全技能中心

Improvement Executor

核心功能:支持4种文档/YAML变更操作,执行前自动备份,含推荐校验、类别校验等安全防护;可回滚历史变更,支持--dry-run预览。典型场景:应用已批准的文档类改进候选、回滚变更、预览变更影响。输入需提供discriminator生成的ranking文件和候选ID等,输出含执行状态、备份路径的JSON artifact,不用于打分或门禁验证。

lanyasheng
lanyasheng
热度 39.11
最近更新 2026-05-11 17:40:25
分类:自动化依赖:代码执行 / 读写文件应用场景:自动化脚本 / 工作流 / 任务管理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add auto-improvement-executor
Metadata
name
improvement-executor
category
tool
description
当需要把已批准的改进候选应用到目标文件、回滚之前的变更、或预览变更效果时使用。支持 4 种 action(append/replace/insert_before/update_yaml),每次变更前自动备份。不用于打分(用 improvement-discriminator)或门禁验证(用 improvement-gate)。
license
MIT
triggers
["apply improvement","execute candidate","rollback change","执行变更","回滚"]
version
0.1.0
author
OpenClaw Team

Improvement Executor

Applies accepted candidates with automatic backup and rollback.

When to Use

  • 把已批准的改进候选应用到目标文件
  • 回滚之前的变更(通过 receipt)
  • 用 --dry-run 预览变更

When NOT to Use

  • 给候选打分 → use improvement-discriminator
  • 门禁验证 → use improvement-gate
  • 全流程编排 → use improvement-orchestrator

CLI

# 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]
Param Default When to change
--input (required) Always: path to ranking artifact JSON from discriminator
--candidate-id (required) Always: the id field of the candidate to execute
--force false Use to execute candidates with recommendation=hold (bypasses critic check)
--output auto Set for custom output location

4 Action Types

Action Trigger Behavior
append_markdown_section execution_plan.action Appends heading + bulleted content lines at EOF. No-op if heading already exists
replace_markdown_section execution_plan.action Finds section by heading match, replaces all lines until next same-or-higher-level heading
insert_before_section execution_plan.action Inserts content lines before a matched heading
update_yaml_frontmatter execution_plan.action Merges frontmatter_updates dict into YAML frontmatter (requires PyYAML)

Backup Mechanism

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.

Safety Guards

  1. Recommendation check: refuses to execute if recommendation != accept_for_execution (use --force to override)
  2. Category check: only EXECUTOR_SUPPORTED_CATEGORIES (docs, reference, guardrail) are auto-executable; others return status=unsupported
  3. File existence: target file must exist, otherwise SystemExit
  4. Execution trace: every run captures a structured execution_trace dict with action, status, diff_summary for GEPA feedback loop

Output Artifact

{"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"}

Related Skills

  • improvement-discriminator: Scores candidates → executor only runs accept_for_execution ones
  • improvement-gate: Validates execution results → may trigger rollback via rollback_pointer
  • improvement-orchestrator: Calls executor as stage 4, passes ranking artifact + candidate ID