gunther876/openenv-schema-evolution-env
Schema Evolution Env
Schema Evolution Env is an OpenEnv-compatible FastAPI environment for training and evaluating agents that perform real SQLite schema migrations. Each episode starts from a seeded in-memory database and asks the agent to inspect the current schema, run migrations, validate integrity, recover with rollback when needed, and finally submit a completed migration for deterministic grading.
Why This Environment Matters
Database schema evolution is a real operational problem: teams need to change schemas without losing data, violating constraints, or breaking downstream consumers. This environment captures that workflow with three tasks that scale from a simple additive migration to a multi-step type migration with dependent objects.
Action Space
Observation Space
Reward Function
- Successful
run_migration:+0.05 - Successful
validate_constraints:+0.05 rollback:+0.0submit_final: replaces cumulative reward with the grader score- Max steps reached: episode ends with the current cumulative reward
All rewards are clamped to [0.0, 1.0].
Tasks
Quick Start
Reset an episode
curl -X POST http://localhost:7860/reset \
-H "Content-Type: application/json" \
-d '{"task_id":"task1_add_column"}'Take a step
curl -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{"action":{"type":"inspect_schema","params":{"table":"all"}}}'Read current state
curl http://localhost:7860/stateLocal Setup
Docker
docker build -t schema-env .
docker run -p 7860:7860 schema-envPython
python3 -m pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 7860Baseline Agent
inference.py implements a baseline agent that talks to the environment over HTTP and emits the required [START], [STEP], and [END] logs for automated evaluation.
Environment variables
Baseline scores
Baseline scores are not included yet because running inference.py requires a configured HF_TOKEN and a reachable OpenAI-compatible endpoint. Once those credentials are available, run:
HF_TOKEN=... API_BASE_URL=... MODEL_NAME=... python3 inference.pyTests
pytest tests/ -v