Skip to content

Cluster-ablation splicer for leave-one-cluster-out#5

Merged
hmworsham merged 1 commit into
mainfrom
feat/ablate-monolith
Jun 30, 2026
Merged

Cluster-ablation splicer for leave-one-cluster-out#5
hmworsham merged 1 commit into
mainfrom
feat/ablate-monolith

Conversation

@cmungall

Copy link
Copy Markdown
Collaborator

Cluster-ablation splicer for leave-one-cluster-out

Implements the splicer designed in #4. Given a hold-out set of datasets, it
produces an executable copy of the expert monolith
(data/gold/expert_code/harmonize_ess-dive_soilmoisture_data.py) with those
datasets' blocks removed, so the held-out cluster is absent from the agent's
exemplar context and any regenerated exemplar outputs.

How it works

The monolith is a series of # %% cells; the 19 per-dataset blocks are each
exactly one cell anchored by a single idx = N. The splice drops whole cells
whose idx is held out and keeps everything else verbatim (config, shared
helpers, the REF_IDX = 0 reference reads, and the location-dedup footer), so
the result stays runnable.

  • Input: --holdout accepts integer indices or dataset_identifiers
    (resolved via the gold mapping JSON). No coupling to cv_folds.yaml.
  • Safety by construction: requiring each hold-out to correspond to a real
    block automatically rejects REF_IDX (0) and the excluded datasets
    (11–14, 19–22), which carry no block — a clear ValueError otherwise.
  • Output: the ablated .py to --output (or stdout).

Example

python -m src.folds.ablate_monolith --holdout 1,2,3,6,16,27 -o ablated_c1.py
# wrote ablated_c1.py (removed blocks [1, 2, 3, 6, 16, 27]; 13 blocks remain)

Tests

  • 14 pytest cases + 2 doctests, all green. A synthetic mini-monolith fixture
    keeps the suite independent of the full corpus; additional cases run against
    the real gold file when present (19 blocks; cluster ablation stays
    ast.parse-able with REF_IDX/footer preserved; rejects 0/11/19).

Deferred

Per the discussion in #4, verifying the ablated script runs end-to-end is
gated on staging the raw inputs (separate work). This PR validates the splice
(correct blocks removed, output parses, scaffold preserved); the run-to-verify
step follows once ~/ess-dive_wfsfa_soil_datasets/ is populated.

Refs #4

🤖 Generated with Claude Code

Splices per-dataset blocks out of the expert harmonization monolith,
producing an executable copy that harmonizes only the remaining datasets.
Cells are keyed on `idx = N`; requiring each hold-out to map to a real
block auto-rejects REF_IDX (0) and the excluded datasets, no coupling to
cv_folds.yaml. Includes pytest + doctests with a synthetic fixture.

Refs #4

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cmungall
cmungall requested a review from hmworsham June 30, 2026 19:19
@hmworsham
hmworsham merged commit da8e480 into main Jun 30, 2026
@cmungall
cmungall deleted the feat/ablate-monolith branch June 30, 2026 19:21
cmungall added a commit that referenced this pull request Jun 30, 2026
- Fix repo_root default-arg bug: Option default None, resolve in body (was
  Path.cwd() evaluated at import time) [#6]
- Audit the LS tool (path) [#8]; check Grep/Glob 'glob'/'pattern' for
  path-bearing patterns [#7]
- Flag 'cd' into an answer location (answer key / real gold/processed), so a
  single-component read after it isn't missed [#1]
- Remove dead '&& ||' token guard [#3]
- --show-bash prints full multi-line commands instead of just the first line [#5]
- Tests: LS, Grep glob, cd-into-answer-key, multi-cd chain, ~ expansion

53 tests green; real fold_ds07 trace still CLEAN.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants