$npx -y skills add Borda/AI-Rig --skill fortifySystematic ablation study runner. After research:run finds improvements, fortify identifies component candidates from git diff + diary, creates isolated git worktrees per ablation (main repo never modified), runs metric+guard in each worktree, ranks component importance, and opti
| 1 | <objective> |
| 2 | |
| 3 | Ablation study runner — after `/research:run` finds improvements, fortify identifies which components contributed, generates ablation variants (remove one component at a time), runs each in **isolated git worktrees** (main repo never modified), ranks component importance, optionally generates reviewer Q&A calibrated to venue. |
| 4 | |
| 5 | NOT for: initial optimization loop (use `/research:run`); methodology validation (use `/research:judge`); paper-vs-code consistency (use `/research:verify`); hypothesis generation (use `research:scientist` directly). Fortify runs ablation studies on completed runs only. |
| 6 | |
| 7 | </objective> |
| 8 | |
| 9 | <constants> |
| 10 | |
| 11 | ```yaml |
| 12 | MAX_ABLATION_CANDIDATES: 8 (ceiling — scientist produces 3–8; --max-ablations caps further) |
| 13 | METRIC_TIMEOUT_MS: 360000 (6 min — same as run SKILL.md) |
| 14 | GUARD_TIMEOUT_MS: 360000 |
| 15 | GIT_OP_TIMEOUT_MS: 15000 |
| 16 | SANITY_DIVERGENCE_PCT: 2.0 (full-variant vs best_metric mismatch threshold) |
| 17 | IMPORTANCE_CLASS_CRITICAL: 50.0 (% of full metric lost) |
| 18 | IMPORTANCE_CLASS_SIGNIFICANT: 10.0 |
| 19 | FORTIFY_DIR_BASE: .experiments |
| 20 | STATE_DIR_BASE: .experiments/state |
| 21 | METRIC_CMD_SOURCE: state.json .config.metric_cmd (campaign's real metric — no fail-open default; env METRIC_CMD overrides) |
| 22 | GUARD_CMD_SOURCE: state.json .config.guard_cmd (campaign's real guard — no fail-open default; env GUARD_CMD overrides) |
| 23 | ``` |
| 24 | |
| 25 | </constants> |
| 26 | |
| 27 | **Environment overrides** — set these before invoking the skill to override per-variant defaults: |
| 28 | |
| 29 | - `METRIC_CMD` — command run inside each variant worktree to measure the ablation metric (override; default sourced from source-run `state.json` `.config.metric_cmd`) |
| 30 | - `GUARD_CMD` — command run inside each variant worktree to detect regressions (override; default sourced from source-run `state.json` `.config.guard_cmd`) |
| 31 | - `STATE_DIR_BASE` — base directory for source-run state lookups (default: `.experiments/state`) |
| 32 | - `FORTIFY_DIR_BASE` — base directory for per-run fortify artifacts (default: `.experiments`) |
| 33 | |
| 34 | The constants block defaults above are YAML-only — bash blocks read environment variables (with `${VAR:-default}` fallback) and never source values directly from YAML. |
| 35 | |
| 36 | <compaction> |
| 37 | |
| 38 | Key boundaries: end of F2 — ablation candidates identified by scientist; end of F4 — all ablation variant worktrees completed. |
| 39 | Preserve at F2: FORTIFY_DIR (TMPDIR key), RUN_ID (TMPDIR key), ablation-candidates.jsonl path, best_metric from source run. |
| 40 | Preserve at F4: FORTIFY_DIR, RUN_ID, results.jsonl path — ready for F5 importance ranking. |
| 41 | F4 loop is resume-safe: 4a-guard skips variants already terminal (non-timeout) in results.jsonl, so a mid-loop compaction resumes at the first pending variant — never re-runs a completed ablation; a timed-out variant still retries. |
| 42 | Clear at F1 start (stale prior run) and at start of F8 terminal summary. |
| 43 | |
| 44 | </compaction> |
| 45 | |
| 46 | <workflow> |
| 47 | |
| 48 | <!-- Agent resolution: see _RESEARCH_SHARED/agent-resolution.md --> |
| 49 | |
| 50 | ## Agent Resolution |
| 51 | |
| 52 | **Agent resolution**: load and follow the protocol below. Contains foundry check + fallback table. If foundry not installed: use table to substitute each `foundry:X` with `general-purpose`. Agent this skill dispatches: `research:scientist` (same plugin — no fallback if research plugin installed). |
| 53 | ```bash |
| 54 | # loads: compaction-contract.md |
| 55 | _RESEARCH_SHARED=$(python "${CLAUDE_PLUGIN_ROOT:-plugins/cc_research}/bin/resolve_shared.py" 2>/dev/null) # timeout: 5000 |
| 56 | [ -z "$_RESEARCH_SHARED" ] && { echo "! Plugin path resolution failed — ensure research plugin installed and CLAUDE_PLUGIN_ROOT set, or invoke /research:fortify from project root."; exit 1; } |
| 57 | cat "$_RESEARCH_SHARED/agent-resolution.md" |
| 58 | ``` |
| 59 | |
| 60 | | Agent | Fallback if absent | |
| 61 | | --- | --- | |
| 62 | | `research:scientist` | `general-purpose` (ablation candidate identification and reviewer Q&A quality reduced — **⚠ general-purpose agent may not emit the JSON envelope this skill parses; surface partial output and surface ⚠ in F7 report**) | |
| 63 | |
| 64 | ## CRITICAL: Worktree-based isolation |
| 65 | |
| 66 | **Do NOT use `git checkout -b <branch>` for ablations** — dirties main working tree, corrupts concurrent tool calls. Each ablation gets own git worktree under `$FORTIFY_DIR/worktrees/<variant>`, created from `best_commit`. Main working tree NEVER modified. Cleanup: `git worktree remove --force` per variant; `git worktree prune` on interrupt. |
| 67 | |
| 68 | ## F |