burtenshaw's picture
burtenshaw HF Staff
Publish procedural SQL investigation tasks and reproducible environment source
2ce79be verified
|
Raw History Blame Contribute Delete
3.87 kB
# OpenEnv SQL Investigation
A procedural SQL lab for learning to inspect unfamiliar data and compute exact answers. Ten families cover sales, inventory, reliability, invoices, experiments, cohorts, inspection coverage, latency changes, delivery streaks, and currency conversion. All data are synthetic.
Every reset builds a fresh, isolated, in-memory SQLite database. An explicit seed reproduces an episode; an unseeded reset samples a new instance. The initial observation contains the question and database schema. The policy can inspect the data with `{"op":"query","sql":"SELECT ..."}` and submit a result with `{"op":"submit","sql":"SELECT ..."}`. A correct complete result earns **1**, otherwise **0**. Answers are computed independently in Python. Comparison ignores row order but preserves duplicates and column order; numeric absolute tolerance is 0.0001. There is no partial credit or speed bonus.
Episodes end on submission, `{"op":"finish"}`, or after 12 actions. Finish and action-budget exhaustion score zero. SQL errors consume an action. Query results display at most 40 rows, 300 characters per string, and approximately 12,000 characters total. SQL execution is read-only, uses an allowlist of functions, and is limited to 500,000 VM operations or one second. No SQL file access, extensions, database attachment, writes, or network tools are exposed.
## Run locally
```sh
uv venv --python 3.12
uv pip install -r requirements.lock pytest
.venv/bin/python -m pytest -q
.venv/bin/uvicorn server.app:app --host 0.0.0.0 --port 8000
```
In another terminal:
```sh
.venv/bin/openenv validate --url http://127.0.0.1:8000
.venv/bin/python scripts/test_server.py --url http://127.0.0.1:8000
```
Use WebSocket `/ws` for episodes: send `{"type":"reset","data":{"task_id":"sales_net_revenue","seed":42}}`, then `{"type":"step","data":{"op":"query","sql":"SELECT 1"}}`. The pinned OpenEnv HTTP endpoints instantiate independent environments, so a sequence of HTTP reset/step calls does not preserve an episode.
## Container and publication
OpenEnv is pinned to Arena revision `86a180ede21e044f7929b9a7783ad83aa67d83a3`; other Python runtime dependencies are recorded in `requirements.lock`. The image uses Python 3.12 on Debian slim, runs as a non-root user, exposes port 8000, and needs no injected environment variables, secrets, files, volumes, GPU, or outbound network access.
```sh
DOCKER_DEFAULT_PLATFORM=linux/amd64 .venv/bin/openenv build -t ghcr.io/burtenshaw/openenv-sql-investigation:v1
docker run --rm -p 8000:8000 ghcr.io/burtenshaw/openenv-sql-investigation:v1
```
The publication workflow tests the exact built image before pushing it. The separate anonymous-pull workflow verifies public access and reruns endpoint validation and every task's examples against an immutable digest on a fresh runner with empty Docker credentials. Evidence is saved as workflow artifacts.
The common admission example queries `SELECT 1 AS ready` then finishes for reward 0. This is a contract smoke test, not a claim of task-solving performance. The test suite separately solves each task with reference SQL for reward 1 and checks incorrect answers for reward 0. The reference solutions are for maintainers; they are not exposed in policy observations or SQL tables.
The public Hugging Face dataset contains task descriptions, reproducible seed-42 examples, source, and reward documentation. These tasks train one policy; they are not replicas of Arena's private evaluation tasks. No improvement in private evaluation performance is claimed before training and evaluation.
No workflow submits to Arena. `submission.json` is prepared from the tested server's schema and public image digest, then requires explicit human approval before its POST. See the [Arena guide](https://openenvarena-arena.hf.space/AGENTS.md) for the rolling 24-hour submission limit.