Skip to content

Component ablations

Measure one-component removal variants of a completed managed numeric campaign. Use the source campaign's exact metric, direction and guard; define bounded named removal patches and allowed paths before executing. This mode neither widens file scope nor authorizes paid/network execution, new dependencies, commits, force operations or destructive cleanup.

Before preparing worktrees, verify that the frozen metric and guard operate on the reconstructed working-tree bytes and cover the affected component paths. Record the inspected command behavior and coverage in hypothesis.md. Commands that depend on the index, branch name, omitted Git metadata or files outside the reproduced inputs are not portable under this mode. For example, bare pre-commit run selects staged files and can check nothing in a clean-index variant; a guard reading git show :file can use a different threshold. Do not change frozen commands silently or certify them by a self-authored marker. Explain unsupported input and start a separately authorized campaign with appropriate explicit worktree-based commands when needed. The parent verifies this semantic condition; receipt validation checks only its recorded declaration and consistency.

Reconstruct the reference

  1. Create a separate optimize result run. Validate the completed source campaign and retain its frozen configuration, best metric, source fingerprint and original evidence hashes. If the invoking source no longer matches its final best snapshot, recover a proved retained snapshot or report unavailable evidence; never substitute current HEAD.
  2. Freeze the actual best source into a retained bundle outside source. A dirty best source does not require a new commit.
  3. a. Retain the exact base HEAD, git diff --cached --binary --no-ext-diff HEAD -- for the index, and git diff --binary --no-ext-diff HEAD -- for the working tree.
  4. b. Inventory the union of paths in the HEAD tree, index, and configured scope using NUL-delimited Git path output. Include unchanged tracked files outside scope: Git checkout conversion can change their raw bytes too.
  5. c. Retain each regular file's exact bytes and executable mode, each leaf symlink's exact target without following it, and explicit absence for deletions. Reject ancestor symlinks or other unsupported source layouts rather than omitting paths.
  6. d. Verify that capturing the bundle did not change the original snapshot. The helper's snapshot --run-dir <run> --root <checkout-root> --config <config-file> returns the source fingerprint.
  7. Announce task-owned worktree locations. Use an ordinary detached git worktree add --detach <path> <base-head> for a reference and each variant, without switching the invoking checkout.
  8. a. Apply the retained index patch with git apply --cached --binary, then the retained HEAD-to-working-tree patch with git apply --binary; skip empty patches. The index operation leaves the working tree at HEAD for the second patch and preserves staged additions/deletions that affect Git diff semantics. If either patch cannot be applied, such as an unsupported unmerged index, preserve evidence and report reconstruction unavailable rather than bypassing a check.
  9. b. Restore the complete raw filesystem inventory, including unchanged tracked bytes, executable modes, leaf-link targets, and explicit deletions, only in the new task-owned worktree. Validate destination paths and refuse linked ancestors before writing; never follow a leaf link when replacing it. Git patches alone can lose line endings, ignored modes, or staged membership.
  10. c. Run snapshot with each worktree root and the frozen configuration; require its digest to equal the frozen source digest before measuring or applying a removal. Preserve the invoking checkout and index exactly. Do not assume HEAD equality implies source equality.
  11. d. Keep metric and guard commands independent of the index even after recreating staging: staged-only commands can ignore variant working-tree changes.
  12. Re-run the metric and guard on the reconstructed reference. Retain commands, working directory, exit codes and complete outputs. Record source fingerprints before and after; require equality with frozen source. A failed reference guard, failed/nonfinite metric, or mismatch with the source campaign's best metric outside an explicitly justified measurement tolerance stops contribution claims. Document noise rather than silently relaxing acceptance.

Measure variants

  1. Apply each named removal patch only to the allowed component paths in its isolated worktree. Retain the patch and its rationale; verify that the diff against the reconstructed reference changes only those paths. Never alter metric/guard scripts unless the original scope explicitly permits that measurement-integrity risk.
  2. Execute the exact same commands in that worktree and environment. Record its source before/after, frozen configuration identity, outputs and exit codes. A source change during measurement is invalid. A failed guard remains an excluded result, not an importance score; a failed metric cannot be ranked. The main checkout must remain byte-for-byte unchanged throughout.
  3. Write ablation-input.json with schema_version=1, measurement_basis=worktree, metric_direction, frozen_source (reference snapshot digest), frozen_config (canonical JSON SHA-256 of frozen configuration), one reference and nonempty variants. Each measurement has name, metric, source_before, source_after, frozen_config, integer metric_exit_code, integer guard_exit_code, and metric_output/guard_output objects with run-relative path and exact sha256. metric_output is the retained numeric stdout, not an edited summary; retain stderr separately. Every output stays within the result run. The reference source must equal frozen_source; commands and actual execution remain parent-verified evidence, not authenticated by a self-written hash.
  4. Run PLUGIN_ROOT/bin/python PLUGIN_ROOT/skills/optimize/campaign.py ablation --run-dir <run> --input <run>/ablation-input.json (native Windows: .cmd launcher). Save stdout as ablation-summary.json. Ranking uses signed loss versus the remeasured full reference, in metric units: positive loss means removing the component hurt. It excludes guard failures and validates every retained output hash, numeric stdout, source/config identity and exit code. Do not interpret one-at-a-time removals as interaction or significance estimates.

Complete and retain evidence

Write hypothesis.md with frozen-source reconstruction and component-removal rationale; comparison.md with baseline/reference, after/variant, delta/loss, guard, confidence, tolerance and limitations. After all measurements finish, create a new immutable derived experiments.jsonl exclusively once with the filesystem tool, naming each variant. This frozen report is derived from the digest-bound ablation input, not a growing campaign ledger; never append to it or edit the source campaign history. Corrections require a separate result run with retained original evidence.

Bind ablation-input.json in metadata.optimize_lifecycle with mode ablation; its receipts bind all numeric/guard outputs. Use existing final columns with exactly one row per variant in ablation-input.json order: Iteration is its name, Baseline the reference metric, After the variant metric, and Delta the signed loss in the configured direction. Guard is pass with Decision=ranked for a passing guard, otherwise fail with Decision=excluded; an excluded row's delta is still descriptive and does not rank its contribution. Admission reconciles every row with bound measurements. Complete the main skill's gates and result promotion. Check the invoking checkout against its pre-ablation snapshot. Retain dirty worktrees and their locations when evidence is needed; remove only proved clean task-owned worktrees with ordinary git worktree remove, never force cleanup or user-content deletion.