Skip to content

Commit 79ced86

Browse files
committed
feat(synthetic): add feature deletion tasks
1 parent 736ab53 commit 79ced86

20 files changed

Lines changed: 833 additions & 162 deletions

README.md

Lines changed: 50 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ swe-forge connects to [GH Archive](https://www.gharchive.org/) to discover recen
3333
| 📦 **Docker Verification** | Verifies tests in Docker before export |
3434
|**Full Parallelism** | GH Archive 8x, enrichment 20x, Docker 8x concurrent |
3535
| 🧠 **Smart Compaction** | 200k context limit with structured summary templates |
36-
| 📊 **Complete Export** | workspace.yaml + patch.diff + tests/ directory |
36+
| 📊 **Complete Export** | workspace.yaml + patch.diff + optional deletion_patch.diff + tests/ directory |
3737

3838
---
3939

@@ -71,40 +71,44 @@ export GITHUB_TOKEN="ghp_..." # GitHub PAT for PR enrichment
7171
export OPENROUTER_API_KEY="sk-or-v1-..." # OpenRouter API key for LLM
7272
```
7373

74-
### Mine Tasks from GH Archive
74+
### Mine PR Tasks
7575

7676
```bash
77-
# Mine 10 tasks with workspace export
7877
swe-forge mine mine \
79-
--limit 10 \
78+
--target 10 \
8079
--output ./tasks.jsonl \
8180
--output-folder ./tasks \
82-
--docker-username myuser \
8381
--parallel 8
84-
85-
# Mine with difficulty filter
86-
swe-forge mine mine \
87-
--limit 5 \
88-
--difficulty hard \
89-
--min-stars 100
90-
91-
# Mine specific repository
92-
swe-forge mine mine \
93-
--repo python/cpython \
94-
--limit 3
9582
```
9683

97-
### Complete Mining with Docker Verification
84+
### Verify One Pull Request End-to-End
9885

9986
```bash
100-
# Full A-Z pipeline with test verification
10187
swe-forge mine complete \
10288
--repo owner/repo \
10389
--pr 12345 \
10490
--output ./tasks.jsonl \
10591
--model openai/gpt-5.4
10692
```
10793

94+
### Generate a Synthetic Feature-Deletion Benchmark Task
95+
96+
```bash
97+
git clone https://github.com/owner/repo.git ./target-repo
98+
99+
swe-forge synthetic generate \
100+
--repo-path ./target-repo \
101+
--repo owner/repo \
102+
--source-file src/package/module.py \
103+
--symbol target_function \
104+
--fail-to-pass "pytest tests/test_target.py -v" \
105+
--pass-to-pass "pytest tests/ -v" \
106+
--install-command "pip install -e ." \
107+
--output-folder ./synthetic_tasks \
108+
--output-jsonl ./synthetic_tasks.jsonl \
109+
--overwrite
110+
```
111+
108112
---
109113

110114
## Output Structure
@@ -116,6 +120,7 @@ tasks/
116120
├── owner-repo-1234/
117121
│ ├── workspace.yaml # Complete task configuration
118122
│ ├── patch.diff # PR patch to apply
123+
│ ├── deletion_patch.diff # Synthetic mutation patch, when source_type is synthetic
119124
│ ├── test_patch.diff # Test file changes
120125
│ └── tests/ # Extracted test files
121126
│ ├── test_feature.py
@@ -148,52 +153,17 @@ tests:
148153
- pytest tests/test_another.py::test_case -v
149154
pass_to_pass:
150155
- pytest tests/ -v --ignore=tests/test_feature.py
156+
synthetic:
157+
source_type: synthetic_feature_deletion
158+
deletion_patch_file: deletion_patch.diff
159+
strategy: feature_deletion
151160
docker:
152161
image: myuser/swe-forge-tasks:owner-repo-1234
153162
build: true
154163
```
155164
156165
---
157166
158-
## CLI Reference
159-
160-
### `swe-forge mine mine` - Mine from GH Archive
161-
162-
```bash
163-
swe-forge mine mine [OPTIONS]
164-
```
165-
166-
| Option | Short | Default | Description |
167-
|--------|-------|---------|-------------|
168-
| `--repo` | `-r` | All | Target repository (owner/repo format) |
169-
| `--limit` | `-l` | 10 | Maximum tasks to mine |
170-
| `--output` | `-o` | ./tasks.jsonl | Output JSONL file |
171-
| `--output-folder` | `-O` | None | Output folder for workspace format |
172-
| `--docker-username` | `-D` | None | Docker Hub username for image names |
173-
| `--parallel` | `-p` | 8 | Concurrent Docker containers |
174-
| `--difficulty` | `-d` | All | Filter: easy, medium, hard |
175-
| `--model` | `-m` | moonshotai/kimi-k2.5 | LLM model for classification |
176-
| `--min-stars` | | 100 | Minimum repository stars |
177-
| `--language` | | python | Filter by language |
178-
| `--filter` | `-f` | {"easy":10,"medium":10,"hard":10} | JSON max tasks per difficulty |
179-
| `--verbose` | `-v` | False | Enable verbose logging |
180-
181-
### `swe-forge mine complete` - Full Pipeline with Verification
182-
183-
```bash
184-
swe-forge mine complete [OPTIONS]
185-
```
186-
187-
| Option | Short | Default | Description |
188-
|--------|-------|---------|-------------|
189-
| `--repo` | `-r` | Required | Target repository (owner/repo) |
190-
| `--pr` | `-p` | Required | Pull request number |
191-
| `--output` | `-o` | ./tasks.jsonl | Output file |
192-
| `--model` | `-m` | openai/gpt-5.4 | LLM model |
193-
| `--verbose` | `-v` | False | Verbose logging |
194-
195-
---
196-
197167
## Architecture
198168
199169
### Pipeline Flow
@@ -342,39 +312,23 @@ This preserves critical context across long agentic sessions.
342312
### Setup
343313

344314
```bash
345-
# Clone and install dev dependencies
346315
git clone https://github.com/CortexLM/swe-forge.git
347316
cd swe-forge
348317
pip install -e ".[dev]"
349-
350-
# Install pre-commit hooks
351-
pre-commit install
352318
```
353319

354320
### Testing
355321

356322
```bash
357-
# Run all tests
358323
pytest tests/ -v
359-
360-
# Run specific test module
361-
pytest tests/test_swe/test_pipeline.py -v
362-
363-
# Run with coverage
364-
pytest tests/ --cov=src/swe_forge --cov-report=html
365324
```
366325

367326
### Code Quality
368327

369328
```bash
370-
# Format
371-
ruff format src/
372-
373-
# Lint
374-
ruff check src/
375-
376-
# Type check
377-
pyright src/
329+
ruff format src/ tests/
330+
ruff check src/ tests/
331+
mypy src/
378332
```
379333

380334
---
@@ -473,23 +427,7 @@ The published dataset `CortexLM/swe-forge` on HuggingFace contains task instance
473427
#### CLI Usage
474428

475429
```bash
476-
# Test a specific task by ID
477-
python scripts/test_task.py --task-id pydantic-pydantic-12985
478-
479-
# Test 5 random tasks
480-
python scripts/test_task.py --random 5
481-
482-
# Test all tasks and save results
483-
python scripts/test_task.py --all --output results.json
484-
485-
# With verbose output
486-
python scripts/test_task.py --task-id pydantic-pydantic-12985 -v
487-
```
488-
489-
Or use the shell wrapper:
490-
491-
```bash
492-
./scripts/test_task.sh --random 5
430+
python scripts/test_task.py --task-id pydantic-pydantic-12985 --output results.json -v
493431
```
494432

495433
#### Docker Sandbox
@@ -527,20 +465,16 @@ SWE-Forge provides a Docker-based evaluation harness for benchmarking model-gene
527465
### Installation
528466

529467
```bash
530-
pip install datasets # For HuggingFace dataset loading
468+
pip install datasets
531469
```
532470

533471
### Quick Start
534472

535473
```bash
536-
# Evaluate gold patches (ground truth) on a specific task
537-
python3 scripts/run_evaluation.py --predictions_path gold --instance_ids pydantic-pydantic-12985
538-
539-
# Evaluate on 5 random tasks
540-
python3 scripts/run_evaluation.py --predictions_path gold --random 5
541-
542-
# Evaluate all tasks
543-
python3 scripts/run_evaluation.py --predictions_path gold --max_workers 8
474+
python3 scripts/run_evaluation.py \
475+
--predictions_path gold \
476+
--instance_ids pydantic-pydantic-12985 \
477+
--max_workers 4
544478
```
545479

546480
### Prediction Format
@@ -555,7 +489,9 @@ Create a JSONL file with model predictions:
555489
Then evaluate:
556490

557491
```bash
558-
python3 scripts/run_evaluation.py --predictions_path predictions.jsonl --max_workers 4
492+
python3 scripts/run_evaluation.py \
493+
--predictions_path predictions.jsonl \
494+
--max_workers 4
559495
```
560496

561497
### Evaluation Flow
@@ -677,41 +613,24 @@ Each task is verified in an isolated Docker container:
677613
### CLI Options
678614
679615
```bash
680-
# Mining with quality control (default)
681-
swe-forge mine mine --limit 100
682-
683-
# Adjust minimum complexity
684-
swe-forge mine mine --min-complexity 0.30
685-
686-
# Skip Docker verification (faster, less reliable)
687-
swe-forge mine mine --no-verify
688-
689-
# Skip complexity check (faster, accepts trivial tasks)
690-
swe-forge mine mine --skip-complexity
691-
692-
# Use different model for evaluation
693-
swe-forge mine mine --complexity-model openai/gpt-4
616+
swe-forge mine mine \
617+
--target 100 \
618+
--min-complexity 0.30 \
619+
--complexity-model openai/gpt-4 \
620+
--output ./tasks.jsonl \
621+
--output-folder ./tasks
694622
```
695623

696624
### Revalidation Script
697625

698626
Revalidate existing tasks to filter out invalid ones:
699627

700628
```bash
701-
# Revalidate all tasks
702-
python scripts/revalidate_tasks.py --tasks-dir ./tasks
703-
704-
# Skip Docker verification (complexity only)
705-
python scripts/revalidate_tasks.py --tasks-dir ./tasks --no-verification
706-
707-
# Limit to N tasks
708-
python scripts/revalidate_tasks.py --tasks-dir ./tasks --limit 10
709-
710-
# Custom threshold
711-
python scripts/revalidate_tasks.py --tasks-dir ./tasks --min-complexity 0.30
712-
713-
# Output report
714-
python scripts/revalidate_tasks.py --tasks-dir ./tasks --report report.json
629+
python scripts/revalidate_tasks.py \
630+
--tasks-dir ./tasks \
631+
--limit 10 \
632+
--min-complexity 0.30 \
633+
--report report.json
715634
```
716635

717636
### Expected Results

src/swe_forge/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from swe_forge.cli.export import app as export_app
77
from swe_forge.cli.benchmark import benchmark
88
from swe_forge.cli.publish import publish
9+
from swe_forge.cli.synthetic import app as synthetic_app
910

1011
app = typer.Typer(name="swe-forge", help="SWE-bench dataset generator")
1112

@@ -23,6 +24,7 @@ def version():
2324
app.add_typer(mine_app, name="mine")
2425
app.add_typer(validate_app, name="validate")
2526
app.add_typer(export_app, name="export")
27+
app.add_typer(synthetic_app, name="synthetic")
2628

2729

2830
def main():

0 commit comments

Comments
 (0)