# Implement Experiment {{exp_id}}

## CLI Reference

Run all abreka commands with `uv run abreka <command>`. Examples:
- `uv run abreka exp show {{exp_id}}`
- `uv run abreka exp update {{exp_id}} --metric val:accuracy=0.99`
- `uv run abreka wiki list` — list project wiki pages
- `uv run abreka wiki show <slug>` — read a wiki page (durable knowledge across experiments)
- `uv run abreka wiki search "<query>"` — search the wiki

{{wiki_index}}

## Research Goal

{{goal}}

## Experiment Details

- **ID**: {{exp_id}}
- **Hypothesis**: {{hypothesis}}
- **Method**: {{method}}
- **Parent experiments**: {{parents}}

## Working Directory

Your working directory is the **project root**. All paths below are relative to it. Do NOT use `..` to navigate to a parent directory.

## Project Structure

- Shared library: `src/{{lib_name}}/`
- Experiment directory: `abreka/experiments/{{exp_id}}/`
- Experiment entry point: `abreka/experiments/{{exp_id}}/run.py`
- Experiment-specific code: `abreka/experiments/{{exp_id}}/code/`

## Prior Experiments

{{experiment_context}}

## Your Task

Implement the experiment described above. **Your job is to write code, not to run it.** The pipeline has a separate run step that will execute `run.py` end-to-end after you finish. Do not execute training loops, cross-validation sweeps, hyperparameter searches, or any other part of the experiment from inside this step.

1. **Read the wiki** for any page relevant to this experiment (data quirks, prior implementation pitfalls, methodology rules) before writing code.
2. **Write `run.py`** as the experiment entry point. It will be executed via `uv run abreka/experiments/{{exp_id}}/run.py`.
3. **Write experiment-specific modules** in `abreka/experiments/{{exp_id}}/code/` as needed.
4. **Import shared code** from `{{lib_name}}` (the user's library in `src/`).
5. **You may add new code** to `src/{{lib_name}}/` to grow the shared library.
6. **You may modify existing code** in `src/{{lib_name}}/` only if all existing tests still pass. If modifications would break tests, copy the code to `abreka/experiments/{{exp_id}}/code/` instead.
7. **Write tests** for any new code you add to the shared library.

### Do NOT

- **Do not execute the experiment** from this step. No `python run.py`, no inline `python - <<'PY' ... PY` heredocs that train models, fit estimators, run CV folds, or sweep hyperparameters. The runner will invoke `run.py` once, in a clean subprocess, after you return.
- Small sanity checks are fine (e.g. `python -c "import {{lib_name}}"` to confirm an import works, or reading a few rows of a CSV to verify column names). Anything that takes more than a second of compute belongs inside `run.py`.
- If you feel the urge to "just try it and see," resist — write the code, commit to it, and trust the run step.

### Metrics Output

Your `run.py` must print metrics to stdout using this format:
```
METRIC:train:loss=0.005
METRIC:train:accuracy=0.9985
METRIC:val:loss=0.028
METRIC:val:accuracy=0.9934
```

### Artifacts

Save checkpoints to `abreka/experiments/{{exp_id}}/artifacts/checkpoints/` and plots to `abreka/experiments/{{exp_id}}/artifacts/plots/`.
