# Generate coding tasks. Prove the grader can catch a believable mistake.

> Source: <https://dev.to/harishkotra/generate-coding-tasks-prove-the-grader-can-catch-a-believable-mistake-3bmd>
> Published: 2026-12-06 18:09:07+00:00

**Key takeaway:** A grader is only trustworthy if the reference passes all checks, unchanged code fails, and a swapped-in plausible implementation loses exactly one specific check (11/11 versus 10/11 in the Click alias task).

Coding Task Lab builds reproducible coding challenges from real repositories. Each challenge has a feature request, a reference implementation, and a grader. Before using a task to evaluate a coding agent, the lab checks that the reference passes, unchanged code fails the new requirements, and plausible wrong implementations fail a specific check.

Both alias tasks receive `--mode DEPLOY`, but the alias points to a different choice than the canonical `deploy` value:

| Contract | Expected behavior | What happens if you swap in the other reference? | 
|---|---|---|
| Canonical choice wins | Return `deploy` | The collision check fails | 
| Reject a conflicting alias | Exit with code `2` | The collision check fails | 

The two tasks share the same inputs. Each reference passes **11/11** checks on its own contract and **10/11** on the other. The swapped implementation still earns partial credit, but it does not solve the task. The grader tells you which rule it missed.

Use **Python 3.12+** and **Git**. The first run needs GitHub access to fetch Click unless you already have a verified checkout or snapshot. The local verifier does not require Docker or a model API key.

```
python3.12 -m venv .venv
.venv/bin/python -m pip install pytest==8.4.2
.venv/bin/python workspace.py
```

Open [http://127.0.0.1:8765](http://127.0.0.1:8765) for the showcase. Choose **Run the lab → New run → Local verifier → Start evaluation**. Open a task and select **Evidence** to see what the wrong implementations got wrong. **Export run** downloads the task packages and the evidence for a completed run.

A source-only Git checkout starts without saved runs. The distributed submission archive includes the recorded sample. `workspace.py --snapshot /path/to/click-source` lets you use an offline source snapshot that matches the checked-in [blob manifest](//evidence/click-baseline-blobs.json).

```
# Pin the upstream checkout and generate the five tasks.
.venv/bin/python factory.py baseline
.venv/bin/python factory.py generate --out repro --run-log repro-run.json

# Run the packaged grader with the upstream pytest suite.
.venv/bin/python verify.py --dataset repro

# Test deliberate wrong patches and replay both alias policies.
.venv/bin/python factory.py audit --dataset repro --click-source .upstream/click/src/click
.venv/bin/python replay_alias.py --dataset repro
```

To show reproducibility, generate again into `repro-repeat` and run `diff -r repro repro-repeat`. With identical inputs, the package files should match. To see a behavioral change, generate `--seed 43 --out fresh`: the unique-prefix contract requires **one** normalized character instead of the **three** required by seed `42`.

```
.venv/bin/python factory.py generate --seed 43 --out fresh
diff -u repro/pallets__click-prefix-choice-42/instruction.md \
  fresh/pallets__click-prefix-choice-43/instruction.md
```

Use a fresh output directory or a new seed when generating again. For the **Docker** version, start Docker with Compose and install Harbor in the same virtual environment:

```
.venv/bin/python -m pip install harbor==0.25.0
.venv/bin/python harbor_check.py --dataset repro
```

Harbor builds the task images and runs the `oracle` (reference) and `nop` (unchanged) baselines. The job directories and aggregate `baselines.json` are saved under `jobs/`. The builds require access to GitHub, the base image registry, and Python package repositories.

``` php
flowchart LR
    A["Clean checkout at a pinned Git commit"] --> B["Task generator"]
    C["Task rules or repository recipe + seed"] --> B
    B --> D["Harbor package: instructions, patches, tests, Dockerfile"]
    D --> E["Local pytest or Harbor in Docker"]
    D --> F["Deliberate wrong patches"]
    E --> G["Grading details and regression results"]
    F --> G
    G --> H["CLI reports, local workspace, and exports"]
```

| Layer | What it uses | 
|---|---|
| Generation | **Python** standard library (`argparse` ,`tomllib` ,`difflib` ,`random` ) and**Git** for commit checks and unified patches | 
| Grading | **pytest 8.4.2** , a test-result plugin, and explicit feature and regression test IDs | 
| Container trials | **Harbor 0.25.0** ,**Docker/Compose** , and lightweight**Bash** entry points | 
| Workspace | Python `ThreadingHTTPServer` bound to localhost, with**plain HTML, CSS, and JavaScript** ; no Node build step | 
| Automation | **GitHub Actions** regenerates the tasks twice, compares the output, and runs the Docker baselines | 
| Optional benchmark | Harbor **Terminus-2** with a configured model provider; not used to generate the tasks or reported as a model solve rate | 

The Click factory checks the checkout’s origin, exact commit, and clean status before it generates patches. The Docker build checks out the same [Click 8.3.1 commit](https://github.com/pallets/click/commit/1d038f270701498433cb432f54db89f95f07a845). A representative package looks like this:

```
pallets__click-alias-reject-conflict-42/
├── instruction.md
├── task.toml
├── environment/Dockerfile
├── solution/
│   ├── patch.diff
│   └── solve.sh
└── tests/
    ├── fail_to_pass.json       # new requirements
    ├── pass_to_pass.json       # existing behaviors to preserve
    ├── test_patch.diff
    ├── test.sh
    ├── grade.py
    ├── run_script.sh
    └── parser.py
```

The grader applies the test patch and runs pytest. A failed regression check yields zero. Otherwise the reward is the fraction of passing feature checks; only `1.0` counts as solved. The focused wrong-patch audit is separate from the Docker baseline jobs. For the scoring internals, design choices, and trade-offs, see the [technical blog](//docs/technical-blog.md).

| Task | Rule | Mistake the tests catch | 
|---|---|---|
| Prefix choice | Accept unique normalized prefixes at the generated minimum length; exact matches win | Accept the first of two ambiguous matches | 
| Alias: canonical priority | Keep the canonical choice on a collision | Reject a valid canonical input | 
| Alias: reject conflicts | Reject collisions between different targets | Accept the conflicting input | 
| Config-first option | Prefer CLI → config → environment → default and report the actual source | Let the environment override a configured zero | 
| Fallback group | Send unknown words to a fallback without losing arguments or changing regular dispatch | Override a command that resolves after normalization | 

**Recorded results:** For each of the two tested seeds, all five references scored `1.0`, all five unchanged baselines scored `0.0`, and all listed regressions passed in Docker. A separate focused audit caught **15/15 deliberate wrong patches per seed**. These figures measure validator behavior on the tested tasks, not model performance or coverage of all possible mistakes. Raw results and videos are local submission artifacts, excluded from Git; the commands above regenerate the evidence.

Start with the MarkupSafe example:

```
.venv/bin/python portable.py recipes/markupsafe \
  --check output/portable/markupsafe-replay.json
reference        5/5 checks   reward=1.00
no-change        0/5 checks   reward=0.00
believable-error 4/5 checks   reward=0.80
```

The last implementation incorrectly escapes an already formatted value. You can see the behavior test in [`recipes/markupsafe/checks.py`](//recipes/markupsafe/checks.py). To create another recipe:

`owner/repo`, full commit SHA, task slug, and upstream license in `recipe.toml`.` instruction.md` and `checks.py`. In the recipe, list the new pytest node IDs and the existing node IDs that must keep passing.`reference.py` and an insertion anchor, or a `solution.diff` for a multi-file change. Describe one plausible wrong edit in `[wrong_patch]`.` portable.py` against a trusted recipe. Use a custom `Dockerfile` and `run_script.sh` if the project needs a different setup from `src/` imports and pytest under `tests/`. The runner must load the bundled parser and record the configured pytest IDs.
The current adapter targets **Python/pytest GitHub repositories**. A recipe author supplies the feature and expected behavior. The tooling packages changes and checks them against the repository; it does not discover requirements from a GitHub URL. Other languages need a verifier adapter.

```
   git clone https://github.com/YOUR_HANDLE/YOUR_FORK.git coding-task-lab
   cd coding-task-lab
   git switch -c feature/new-task-recipe
```

`factory.py` and `templates/` for Click task changes or `recipes/` for adding a repository.

Code & more: [https://www.dailybuild.xyz/project/336-coding-task-lab](https://www.dailybuild.xyz/project/336-coding-task-lab)
