codefix-env 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {codefix_env-0.2.1/src/codefix_env.egg-info → codefix_env-0.2.2}/PKG-INFO +135 -299
  2. codefix_env-0.2.2/README.md +232 -0
  3. {codefix_env-0.2.1 → codefix_env-0.2.2}/pyproject.toml +1 -1
  4. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/__init__.py +1 -1
  5. {codefix_env-0.2.1 → codefix_env-0.2.2/src/codefix_env.egg-info}/PKG-INFO +135 -299
  6. codefix_env-0.2.1/README.md +0 -396
  7. {codefix_env-0.2.1 → codefix_env-0.2.2}/LICENSE +0 -0
  8. {codefix_env-0.2.1 → codefix_env-0.2.2}/MANIFEST.in +0 -0
  9. {codefix_env-0.2.1 → codefix_env-0.2.2}/SECURITY.md +0 -0
  10. {codefix_env-0.2.1 → codefix_env-0.2.2}/setup.cfg +0 -0
  11. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/cli.py +0 -0
  12. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/client.py +0 -0
  13. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/env.py +0 -0
  14. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/models.py +0 -0
  15. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/rewards.py +0 -0
  16. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/tasks/__init__.py +0 -0
  17. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/tasks/easy.py +0 -0
  18. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/tasks/hard.py +0 -0
  19. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/tasks/medium.py +0 -0
  20. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/utils/__init__.py +0 -0
  21. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/utils/metrics.py +0 -0
  22. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/utils/reward_model.py +0 -0
  23. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env/utils/sandbox.py +0 -0
  24. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env.egg-info/SOURCES.txt +0 -0
  25. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env.egg-info/dependency_links.txt +0 -0
  26. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env.egg-info/entry_points.txt +0 -0
  27. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env.egg-info/requires.txt +0 -0
  28. {codefix_env-0.2.1 → codefix_env-0.2.2}/src/codefix_env.egg-info/top_level.txt +0 -0
  29. {codefix_env-0.2.1 → codefix_env-0.2.2}/tests/test_env.py +0 -0
  30. {codefix_env-0.2.1 → codefix_env-0.2.2}/tests/test_rewards.py +0 -0
  31. {codefix_env-0.2.1 → codefix_env-0.2.2}/tests/test_tasks.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codefix-env
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A high-performance PyTorch-based RL environment for automated code debugging and LLM agent evaluation
5
5
  Author-email: Shailendra Dhakad <dhakarshailendra829@gmail.com>
6
6
  License: Apache License
@@ -267,244 +267,103 @@ Dynamic: license-file
267
267
 
268
268
  <div align="center">
269
269
 
270
- # CodeFix-Env
270
+ <h1>CodeFix-Env</h1>
271
271
 
272
- **A reinforcement learning environment for training LLM-driven agents to autonomously debug, localize, and repair code through sandboxed execution and feedback-driven learning.**
272
+ <p>A sandboxed reinforcement learning environment for training and evaluating LLM agents on automated code debugging, and the fast, verifiable feedback loop that kind of training requires.</p>
273
273
 
274
274
  <p align="center">
275
- <strong>Built for scalable agent evaluation on real-world software debugging tasks.</strong>
275
+ <a href="https://github.com/dhakarshailendra829/codefix-env/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/dhakarshailendra829/codefix-env/ci.yml?branch=main&style=for-the-badge" alt="CI status"></a>
276
+ <a href="https://pypi.org/project/codefix-env/"><img src="https://img.shields.io/pypi/v/codefix-env?style=for-the-badge&color=blue" alt="PyPI version"></a>
277
+ <a href="https://github.com/dhakarshailendra829/codefix-env/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge" alt="Apache 2.0 License"></a>
278
+ <a href="tests/"><img src="https://img.shields.io/badge/tests-197%20passing-brightgreen?style=for-the-badge" alt="Tests passing"></a>
276
279
  </p>
277
280
 
278
281
  <p align="center">
279
- <!-- Red -->
280
- <a href="https://pytorch.org/">
281
- <img src="https://img.shields.io/badge/PyTorch-EE4C2C?style=for-the-badge&logo=pytorch&logoColor=white" alt="PyTorch">
282
- </a>
283
-
284
- <!-- Orange -->
285
- <a href="https://vllm.ai/">
286
- <img src="https://img.shields.io/badge/vLLM-F97316?style=for-the-badge&logo=fastapi&logoColor=white" alt="vLLM">
287
- </a>
288
-
289
- <!-- Yellow -->
290
- <a href="https://huggingface.co/">
291
- <img src="https://img.shields.io/badge/HuggingFace-FFD21E?style=for-the-badge&logo=huggingface&logoColor=black" alt="HuggingFace">
292
- </a>
293
-
294
- <!-- Green -->
295
- <a href="https://fastapi.tiangolo.com/">
296
- <img src="https://img.shields.io/badge/FastAPI-009688?style=for-the-badge&logo=fastapi&logoColor=white" alt="FastAPI">
297
- </a>
298
-
299
- <!-- Blue -->
300
- <a href="https://www.docker.com/">
301
- <img src="https://img.shields.io/badge/Docker-2496ED?style=for-the-badge&logo=docker&logoColor=white" alt="Docker">
302
- </a>
303
-
304
- <!-- Indigo -->
305
- <a href="https://github.com/">
306
- <img src="https://img.shields.io/badge/CI/CD-181717?style=for-the-badge&logo=githubactions&logoColor=white" alt="CI/CD">
307
- </a>
308
-
309
- <!-- Violet -->
310
- <a href="https://ollama.com/">
311
- <img src="https://img.shields.io/badge/Ollama-7C3AED?style=for-the-badge&logo=llama&logoColor=white" alt="Ollama">
312
- </a>
282
+ <strong>
283
+ <a href="#quick-start">Quick Start</a> ·
284
+ <a href="ARCHITECTURE.md">Architecture</a> ·
285
+ <a href="SECURITY.md">Security</a> ·
286
+ <a href="CONTRIBUTING.md">Contributing</a>
287
+ </strong>
313
288
  </p>
314
289
 
315
-
316
- <p align="center">
317
- <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/Python-3.10%2B-3776ab?style=flat-square&logo=python&logoColor=white"></a>
318
- <a href="https://pytorch.org/"><img src="https://img.shields.io/badge/PyTorch-2.2%2B-ee4c2c?style=flat-square&logo=pytorch&logoColor=white"></a>
319
- <a href="https://fastapi.tiangolo.com/"><img src="https://img.shields.io/badge/FastAPI-0.110%2B-009688?style=flat-square&logo=fastapi&logoColor=white"></a>
320
- <a href="https://gymnasium.farama.org/"><img src="https://img.shields.io/badge/Gymnasium-Compatible-4B8BBE?style=flat-square"></a>
321
- <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-green?style=flat-square"></a>
322
- <a href="tests/"><img src="https://img.shields.io/badge/Tests-197%2F197%20Passing-brightgreen?style=flat-square"></a>
323
- <a href="https://github.com/dhakarshailendra829/codefix-env"><img src="https://img.shields.io/github/stars/dhakarshailendra829/codefix-env?style=flat-square"></a>
324
- </p>
290
+ </div>
325
291
 
326
292
  ---
327
293
 
328
- ### 📖 Overview
329
-
330
- CodeFix-Env is a **Gymnasium-compatible RL environment** that simulates real-world Python code debugging workflows. It enables researchers and engineers to:
294
+ > **Status: active development.** The environment, sandbox, reward pipeline, and task registry are stable and tested. A trained-policy result and a larger, mined task set are in progress — see [Roadmap](#roadmap).
331
295
 
296
+ ---
332
297
 
333
- | Goal | Description |
334
- | :--- | :--- |
335
- | **Train** | Large language models (LLMs) on code repair tasks. |
336
- | **Evaluate** | AI agents on real debugging scenarios. |
337
- | **Benchmark** | Code generation and reasoning capabilities. |
338
- | **Build** | Automated debugging systems. |
339
-
340
- **Compatible with:** Qwen, Llama, CodeLlama, DeepSeek, and other leading LLMs.
298
+ ## Table of Contents
299
+
300
+ - [Why CodeFix-Env?](#why-codefix-env)
301
+ - [Install](#install)
302
+ - [Quick Start](#quick-start)
303
+ - [Deployment](#deployment)
304
+ - [How It Works](#how-it-works)
305
+ - [Benchmark](#benchmark)
306
+ - [Capabilities](#capabilities)
307
+ - [Roadmap](#roadmap)
308
+ - [Contributing](#contributing)
309
+ - [Security](#security)
310
+ - [License](#license)
311
+ - [Citations](#citations)
341
312
 
342
313
  ---
343
314
 
344
- </div>
315
+ ## Why CodeFix-Env?
345
316
 
346
- ---
317
+ Training a coding agent to debug software requires more than static examples of correct code. It requires a tight loop: propose a fix, execute it against a real test suite, and receive a signal that reflects genuine progress rather than superficial activity.
347
318
 
348
- ### 🔴 The Challenge
349
- Training Large Language Models (LLMs) for code generation and autonomous repair requires more than static data. Effective learning requires:
350
-
351
- * **Authentic Scenarios:** Moving beyond synthetic examples to real-world debugging.
352
- * **Tight Feedback Loops:** Providing immediate test results and error logs.
353
- * **Measurable Progress:** Quantifiable metrics based on test pass rates.
354
- * **Secure Execution:** Sandboxed environments to prevent unsafe code execution.
355
-
356
- ### 🟢 The Solution: CodeFix-Env
357
- CodeFix-Env is a specialized environment designed for RL agents and LLMs to master code repair through:
358
-
359
- * **Real-World Tasks:** 21 curated Python bugs ranging from logic errors to complex edge cases.
360
- * **Test-Driven Feedback:** Agents receive granular execution data after every action.
361
- * **Multi-Factor Rewards:** Reward signals based on test progress, code quality, and task completion.
362
- * **Isolated Execution:** Built-in sandboxing with timeout protection for safe evaluations.
363
- * **Structured Interaction:** Clean API for structured actions that LLMs can reliably generate.
364
-
365
- ### Workflow
366
- ```mermaid
367
- graph TD
368
- A[Agent receives buggy code] --> B[Analyze code & test failures]
369
- B --> C[Generate action: e.g., edit_line]
370
- C --> D[Environment executes action]
371
- D --> E[Environment provides feedback]
372
-
373
- subgraph Feedback Loop
374
- E --> F[Test results & pass/fail counts]
375
- E --> G[Code diff & change analysis]
376
- E --> H[Shaped reward signals]
377
- end
378
-
379
- F & G & H --> I{Solution found?}
380
- I -- No --> B
381
- I -- Yes --> J[Task Complete]
382
- ```
383
- ---
319
+ We do that because SWE-bench<sup>1</sup> gave coding agents a scalable, realistic evaluation standard, built on full repositories and real GitHub issues. What it does not give is a fast enough loop for on-policy reinforcement learning, where thousands of cheap episodes per training step are typically required.
384
320
 
385
- ## Key Features
386
-
387
- ** Task Library**
388
- - 21 carefully designed debugging tasks
389
- - 3 difficulty levels: Easy (8), Medium (8), Hard (5)
390
- - Each task includes buggy code, solution, test cases, and hints
391
- - Covers real Python patterns: loops, recursion, algorithms, decorators
392
-
393
- ** LLM Integration**
394
- - Works with HuggingFace Transformers ecosystem
395
- - Compatible with training frameworks: SFT, DPO, GRPO, PPO
396
- - Pre-built support for Qwen, Llama, CodeLlama, DeepSeek models
397
- - Structured JSON action interface for LLM control
398
-
399
- ** Performance**
400
- - Multiprocessing-based sandbox with timeout enforcement
401
- - Per-test execution isolation
402
- - 197 unit tests with 83% code coverage
403
- - Automated CI/CD pipeline (Python 3.10, 3.11, 3.12)
404
-
405
- ** Developer Friendly**
406
- - Gymnasium standard interface
407
- - Async client for high-performance training
408
- - Sync wrapper for notebooks
409
- - FastAPI HTTP server for remote access
410
- - Complete type hints and documentation
321
+ Most environments used for this today sit at one of two extremes: repository-scale benchmarks that are realistic but slow to sandbox, or ad-hoc code execution with no meaningful isolation at all. CodeFix-Env is built for the space between them.
411
322
 
412
- ---
323
+ CodeFix-Env is building that middle layer:
413
324
 
414
- ## Installation
325
+ > a sandboxed, densely-rewarded reinforcement learning environment for single-function code repair, fast enough to serve as a rollout source, with a stated threat model rather than an assumed one
415
326
 
416
- ### Step 1: Clone Repository
327
+ We do that by:
417
328
 
418
- ```bash
419
- git clone https://github.com/dhakarshailendra829/codefix-env.git
420
- cd codefix-env
421
- ```
422
- ### Step 2: Create virual Environment
423
- ```bash
424
- python3.11 -m venv .venv
425
- source .venv/bin/activate (On mac)
426
- .venv/Scripts/activate (On Windows)
427
- ```
428
- ### Step 3: Intall Package
429
- #### For Basic Usage
430
- ```bash
431
- pip install -e .
432
- ```
433
- ---
434
- #### For Developement
435
- ```bash
436
- pip install -e ".[dev]"
437
- ```
438
- ---
439
- #### For LLM training (includes transformers, TRL, datasets)
440
- ```bash
441
- pip install -e ".[llm]"
442
- ```
443
- ---
444
- #### For everything
445
- ```bash
446
- pip install -e ".[dev,llm]"
447
- ```
448
- ### Step 4: Verify Installation
449
- ```bash
450
- python -c "from codefix_env import CodeFixEnvironment; print(' Installation successful!')"
451
- ```
452
- ---
453
- ## Usage & Development Guide
329
+ - executing every agent action inside a layered sandbox — static AST filtering, restricted builtins, and OS-level process isolation — documented in full in [SECURITY.md](SECURITY.md), including two hardening attempts that failed under load and were reverted rather than left unreported
330
+ - computing a dense, per-step reward from hidden test-pass-rate deltas, rather than a single pass/fail signal at episode end
331
+ - mining task candidates directly from real, merged bug-fix pull requests on GitHub, so tasks can be traced back to an actual historical defect (`scripts/mine_tasks.py`)
332
+ - publishing the environment as an installable, continuously tested package rather than a static research repository
454
333
 
455
- ### 1. Basic Environment Usage
456
- ```python
457
- python << 'EOF'
458
- from codefix_env import CodeFixEnvironment, CodeFixAction, ActionType
334
+ Our goal is to grow this into a task set and training result large enough to serve as a genuine benchmark and training ground for code-repair agents, in the same way SWE-bench did for repository-scale evaluation.
459
335
 
460
- # Create environment
461
- env = CodeFixEnvironment()
336
+ <sup>1</sup> https://arxiv.org/abs/2310.06770
462
337
 
463
- # Start episode with random easy task
464
- obs = env.reset(difficulty="easy")
465
- print(f"Task: {obs.task_id}")
466
- print(f"Current Code:\n{obs.current_code}")
338
+ ---
467
339
 
468
- # Run tests to see failures
469
- action = CodeFixAction(action_type=ActionType.RUN_TESTS)
470
- result = env.step(action)
471
- print(f"\nTest Results: {result.observation.tests_passed}/{result.observation.tests_total} passing")
472
- print(f"Output:\n{result.observation.test_output}")
340
+ ## Install
473
341
 
474
- print(f"\nReward: {result.reward:.3f}")
475
- print(f"Episode Done: {result.done}")
476
- EOF
342
+ ```bash
343
+ pip install codefix-env
477
344
  ```
478
345
 
479
- ### 2. Testing & Quality Assurance
480
- To run the full suite:
346
+ For development, or to use the training extras:
347
+
481
348
  ```bash
349
+ git clone https://github.com/dhakarshailendra829/codefix-env.git
482
350
  cd codefix-env
483
- PYTHONPATH=src pytest tests/ -v --timeout=60
351
+ python -m venv venv
352
+ source venv/bin/activate # Windows: venv\Scripts\activate
353
+ pip install -e ".[dev]" # add ",llm" for transformers/TRL/accelerate
484
354
  ```
485
355
 
486
- To run specific Test Suite
487
- ```bash
488
- PYTHONPATH=src pytest tests/test_tasks.py::TestSolutionCorrectness -v
489
- ```
356
+ Verify:
490
357
 
491
- To check code standards:
492
358
  ```bash
493
- ruff check src/ tests/ examples/
494
- black --check src/ tests/ examples/
495
- mypy src/codefix_env/ --ignore-missing-imports
359
+ codefix-server info
496
360
  ```
497
361
 
498
- ### 3. API Server Deployment
499
- ```bash
500
- cd codefix-env
501
- uvicorn src.codefix_env.server.app:app --reload --port 8000
502
- ```
503
362
  ---
504
- ## Usage Examples
505
363
 
506
- ### 1. Core Debugging Workflow
507
- A complete cycle from task initialization to final submission.
364
+ ## Quick Start
365
+
366
+ **Local environment** — run episodes directly in Python, no server required:
508
367
 
509
368
  ```python
510
369
  from codefix_env import CodeFixEnvironment, CodeFixAction, ActionType
@@ -512,152 +371,129 @@ from codefix_env import CodeFixEnvironment, CodeFixAction, ActionType
512
371
  env = CodeFixEnvironment()
513
372
  obs = env.reset(task_id="easy-001-missing-return")
514
373
 
515
- # 1. Run tests to identify failures
516
374
  result = env.step(CodeFixAction(action_type=ActionType.RUN_TESTS))
517
- print(f"Tests: {result.observation.tests_passed}/{result.observation.tests_total} passing")
375
+ print(f"{result.observation.tests_passed}/{result.observation.tests_total} tests passing")
518
376
 
519
- # 2. Apply a targeted fix
520
377
  result = env.step(CodeFixAction(
521
378
  action_type=ActionType.EDIT_LINE,
522
379
  line_number=3,
523
- new_content=" return result"
380
+ new_content=" return result",
524
381
  ))
525
382
 
526
- # 3. Final Verification & Submission
527
383
  result = env.step(CodeFixAction(action_type=ActionType.SUBMIT_FIX))
528
- print(f"Status: {'Solved' if result.observation.all_tests_pass else 'Failed'}")
529
- print(f"Final Reward: {result.reward:.3f}")
384
+ print("solved" if result.observation.all_tests_pass else "not solved", result.reward)
530
385
  ```
531
386
 
532
- ### 2. High-Level Task Management
533
- Programmatically interact with the task database.
387
+ **Server mode** — expose the environment over HTTP for remote or multi-language clients:
534
388
 
535
- ```python
536
- from codefix_env import list_tasks, Difficulty, task_count
389
+ ```bash
390
+ codefix-server serve --port 8000
391
+ ```
537
392
 
538
- # Get environment stats
539
- print(f"Total tasks by difficulty: {task_count()}")
393
+ **Task inspection** list and filter the task registry:
540
394
 
541
- # Bulk process specific difficulty levels
542
- easy_tasks = list_tasks(difficulty=Difficulty.EASY)
543
- for task in easy_tasks[:5]:
544
- print(f"Loading {task.id}: {task.title}")
395
+ ```bash
396
+ codefix-server tasks
397
+ ```
398
+
399
+ **Baseline evaluation** — run oracle and random policies across the full task set:
400
+
401
+ ```bash
402
+ python scripts/run_baseline_eval.py --episodes 3
545
403
  ```
546
404
 
547
405
  ---
548
406
 
549
- ## LLM Training & Integration
407
+ ## Deployment
550
408
 
551
- ### Server-Client Architecture
552
- Deploy the environment as a service to scale LLM evaluations across multiple agents.
409
+ The repository includes a `Dockerfile` for running the environment as a standalone service:
553
410
 
554
411
  ```bash
555
- # Start the API server
556
- uvicorn src.codefix_env.server.app:app --port 8000
412
+ docker build -t codefix-env .
413
+ docker run -p 8000:8000 codefix-env
557
414
  ```
558
415
 
559
- ### Building Training Datasets
560
- Export environment states into `.jsonl` formats for fine-tuning models like Llama or Qwen.
561
-
562
- ```python
563
- import json
564
- from codefix_env import CodeFixClient
565
-
566
- async def collect_trajectories():
567
- async with CodeFixClient("http://localhost:8000") as client:
568
- obs = await client.reset(difficulty="medium")
569
- dataset_entry = {
570
- "instruction": f"Fix the following code: {obs.current_code}",
571
- "context": obs.test_output,
572
- "metadata": {"task_id": obs.task_id}
573
- }
574
- # Append to training_data.jsonl....
575
- ```
416
+ Set `CODEFIX_REWARD_MODEL_PATH` if using a trained neural reward checkpoint (see [ARCHITECTURE.md](ARCHITECTURE.md)). No other environment variables are required for the default, rule-based reward configuration.
576
417
 
577
- ### Zero-Shot Inference (HuggingFace)
578
- Connect an LLM directly to the environment loop.
418
+ ---
579
419
 
580
- ```python
581
- from transformers import pipeline
582
- from codefix_env import CodeFixEnvironment
420
+ ## How It Works
583
421
 
584
- # Load a coding model
585
- fixer = pipeline("text-generation", model="Qwen/Qwen2.5-Coder-7B")
422
+ When an episode runs, CodeFix-Env:
586
423
 
587
- env = CodeFixEnvironment()
588
- obs = env.reset(difficulty="easy")
424
+ 1. **Loads** a task — a buggy function, a hidden test suite, and graduated hints
425
+ 2. **Receives** a structured action from the agent: run tests, edit a line, insert, delete, request a hint, view the code, or submit
426
+ 3. **Executes** any code-mutating action inside the sandbox, isolated from the host process
427
+ 4. **Computes** a unified diff against the original code and a dense, shaped reward from the test-pass-rate change
428
+ 5. **Returns** the updated observation, including test output and the diff, so the agent can decide its next action
429
+ 6. **Terminates** the episode on a full solve, an explicit submission, or the step budget running out
589
430
 
590
- # Generate a fix based on environment observation
591
- prompt = f"Fix this Python code based on these errors: {obs.test_output}\nCode:\n{obs.current_code}"
592
- suggestion = fixer(prompt)
593
- ```
431
+ Full design detail, including the reward formula and the sandbox's layered isolation model, is in [ARCHITECTURE.md](ARCHITECTURE.md).
594
432
 
595
433
  ---
596
434
 
597
- ## API Quick Reference
435
+ ## Benchmark
598
436
 
437
+ Regenerate these numbers with `python scripts/run_baseline_eval.py --episodes 3`.
599
438
 
600
- | Class / Method | Description |
601
- | :--- | :--- |
602
- | `CodeFixEnvironment` | Local execution engine for debugging tasks. |
603
- | `CodeFixClient` | Async client for interacting with a remote server. |
604
- | `env.step(action)` | Executes an `ActionType` (EDIT, RUN_TESTS, SUBMIT). |
605
- | `Difficulty` | Enum: `EASY`, `MEDIUM`, `HARD`. |
606
- | `BugCategory` | Categories: `SYNTAX`, `LOGIC`, `DATA_STRUCTURE`, `ALGORITHM`. |
439
+ <!-- BENCHMARK-START -->
607
440
 
608
- ---
441
+ Oracle policy (applies the known-correct fix) versus a random policy, across all 21 tasks:
609
442
 
610
- ## Development & CI/CD
611
- Standard commands for maintaining the environment.
443
+ | Policy | Easy | Medium | Hard |
444
+ |---|---|---|---|
445
+ | Oracle | 100% | 87.5% | 60% |
446
+ | Random | 0% | 0% | 20% |
612
447
 
613
- ```bash
614
- # Run full test suite with coverage
615
- pytest tests/ -v --cov=src/codefix_env
448
+ No trained-policy result yet — this compares two fixed baselines to confirm the reward signal discriminates genuine problem-solving from undirected action. A GRPO training result is in progress; see [Roadmap](#roadmap).
449
+
450
+ <!-- BENCHMARK-END -->
616
451
 
617
- # Static Analysis
618
- ruff check src/ # Linting
619
- black --check src/ # Formatting
620
- mypy src/ # Type Checking
621
- ```
622
452
  ---
623
453
 
624
- <div align="center">
454
+ ## Capabilities
625
455
 
626
- # LLM Ecosystem & Infrastructure
456
+ | | |
457
+ |---|---|
458
+ | **Sandboxed execution** | Static AST filtering, restricted builtins, and OS-level process isolation, with a documented threat model |
459
+ | **Dense reward shaping** | Per-step reward from test-pass-rate deltas, hint-usage and step-count penalties, and a solve bonus |
460
+ | **Graded task registry** | 21 tasks across easy, medium, and hard tiers, each with hidden tests and progressive hints |
461
+ | **Task mining pipeline** | Extracts candidate tasks from real, merged GitHub bug-fix pull requests for human review |
462
+ | **Server and async client** | FastAPI HTTP server with a session-scoped API, plus an async client for training loops |
463
+ | **Framework-compatible** | Gymnasium-style `reset()`/`step()`/`state()` interface; usable with SFT, DPO, GRPO, and PPO training code |
464
+ | **CI-gated** | 197 tests, linting, and type checking on every change, across Python 3.10 through 3.12 |
627
465
 
628
- ### LLM Models
466
+ ---
629
467
 
630
- | Model | Description |
631
- | :--- | :--- |
632
- | 🟢 **Qwen 1.5B, 7B, 14B** | Alibaba's instruction models |
633
- | 🟢 **Llama 2-7B-Chat** | Meta's foundation model |
634
- | 🟢 **CodeLlama 7B, 13B, 34B** | Specialized for code |
635
- | 🟢 **DeepSeek Coder 1.3B, 6.7B** | Chinese LLM for code |
636
- | 🟢 **Mistral 7B** | Open-source efficient model |
468
+ ## Roadmap
637
469
 
638
- <br/>
470
+ - Closed-loop RL training result: fine-tune a small open-weight code model against the environment and publish a measured pass-rate curve
471
+ - A trained checkpoint for the optional learned reward model, calibrated against oracle judgment
472
+ - Task registry expansion from 21 to several hundred tasks, mined and reviewed from real repositories
473
+ - Multi-file task support, extending beyond single-function scope
474
+ - Container-level sandbox isolation (namespace and capability restrictions, seccomp filtering)
475
+ - Support for a second programming language
476
+ - Horizontally scalable session handling for distributed rollout collection
477
+ - Listing on the OpenEnv Hub
639
478
 
640
- ### ⚙️ Training Frameworks
479
+ ---
641
480
 
642
- | Framework | Method |
643
- | :--- | :--- |
644
- | 🟢 **SFT** | Supervised fine-tuning |
645
- | 🟢 **DPO** | Direct preference optimization |
646
- | 🟢 **GRPO** | Group relative policy optimization |
647
- | 🟢 **PPO** | Proximal policy optimization |
481
+ ## Contributing
648
482
 
649
- <br/>
483
+ Issues and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for local setup, the task-authoring template, and the pull request workflow.
650
484
 
651
- ### 🏗️ Infrastructure
485
+ ---
652
486
 
653
- | Tool | Purpose |
654
- | :--- | :--- |
655
- | 🟢 **HuggingFace** | Model hub & training |
656
- | 🟢 **vLLM** | Fast LLM serving |
657
- | 🟢 **Ollama** | Local model deployment |
658
- | 🟢 **Docker** | Containerization |
659
- | 🟢 **GitHub Actions** | CI/CD |
487
+ ## Security
488
+
489
+ Execution isolation is treated as a first-class design concern, not an afterthought — including reporting what the current sandbox does not protect against. See [SECURITY.md](SECURITY.md) for the full threat model and for responsible disclosure of any suspected sandbox escape.
660
490
 
661
- </div>
662
491
  ---
663
- ## Note:- This is pure backend system not frontend, we are working on frontent very soon we will update.
492
+
493
+ ## License
494
+
495
+ Apache License 2.0 — see [LICENSE](LICENSE).
496
+
497
+ ## Citations
498
+ <sup>2</sup> Dhakad, S. CodeFix-Env: A Sandboxed Reinforcement Learning Environment for Automated Code Debugging. arXiv:2607.XXXXX, 2026.
499
+