File size: 3,895 Bytes
5dd1bb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9e64e71
 
5dd1bb4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Project Map (AGENTS.md)

This file is a navigation map for agents. Durable knowledge lives in `docs/`.

## Start Here

- Docs index: [docs/README.md](docs/README.md)
- Architecture: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
- Operations: [docs/RUNBOOK.md](docs/RUNBOOK.md)
- Test: `uv run pytest tests/ -v`

## System-of-Record Documents

| Category | Location | Type | Purpose |
|----------|----------|------|---------|
| Guides | [docs/guides/README.md](docs/guides/README.md) | how-to | Practical procedures |
| Design docs | [docs/design-docs/index.md](docs/design-docs/index.md) | explanation | Feature design, ADRs |
| References | [docs/references/README.md](docs/references/README.md) | reference | External docs |

## Project Structure

This project follows the [OpenEnv](https://github.com/meta-pytorch/OpenEnv) `openenv init` convention.
The project root **is** the environment package β€” no `envs/` nesting.

```
sql-env/                       # project root = environment package
β”œβ”€β”€ __init__.py                # exports SQLAction, SQLObservation, SQLEnvClient
β”œβ”€β”€ models.py                  # Pydantic models (action w/ tokens, observation w/ messages, state)
β”œβ”€β”€ client.py                  # SQLEnvClient(EnvClient) β€” WebSocket client w/ tensor serialization
β”œβ”€β”€ conftest.py                # pytest config (ignores __init__.py collection)
β”œβ”€β”€ openenv.yaml               # OpenEnv manifest
β”œβ”€β”€ pyproject.toml             # deps + package config (setuptools, torch, transformers)
β”œβ”€β”€ .python-version            # pins Python 3.12
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ databases/
β”‚   β”‚   └── models.py          # SQLAlchemy ORM models (student_assessment)
β”‚   └── questions/
β”‚       └── student_assessment.json  # 30+ Spider Q&A pairs with gold SQL
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ app.py                 # FastAPI app (tokenizer factory, MockTokenizer fallback)
β”‚   β”œβ”€β”€ sql_environment.py     # SQLEnvironment(Environment) β€” core logic + Ollama
β”‚   β”œβ”€β”€ test_sql_env.py        # MockTokenizer (char-code encoding for dev/test)
β”‚   β”œβ”€β”€ reward.py              # Reward computation (stub β€” Phase 3)
β”‚   β”œβ”€β”€ verifier.py            # Answer comparison (stub β€” Phase 3)
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── install_deps.sh        # Docker setup script
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ download_spider_data.py       # Download Spider questions from HuggingFace
β”‚   └── generate_models_from_schema.py # Auto-generate SQLAlchemy models
β”œβ”€β”€ tests/
β”‚   └── test_smoke.py          # 21 tests (models, env, actions, client, schema)
β”œβ”€β”€ docs/                      # Design docs, architecture
└── AGENTS.md
```

## Guardrails

- **Testing:** Use the package manager (`uv run pytest ...`), never bare `pytest`.
- **Git safety:** No destructive commands (`reset --hard`, `push --force`) unless explicit.
- **Secrets:** Never commit `.env` or credentials.

## Quick Commands

| Task | Command |
|------|---------|
| Install | `uv sync` |
| Lint | `uv run ruff check --fix .` |
| Format | `uv run ruff format .` |
| Test | `uv run pytest tests/ -v` |
| Run server | `uv run uvicorn server.app:app --reload` |
| Validate env | `uv run openenv validate --verbose` |
| Build Docker | `uv run openenv build` |
| Push to HF | `uv run openenv push` |

## Development Workflow

- Run via package manager (`uv run ...`), never bare commands.
- List existing files before creating new ones (avoid naming drift).
- Prefer vertical slices over horizontal refactors.
- No premature abstraction until multiple use-cases require it.

<!-- GUIDELINES-BEGIN -->

<!-- Managed by: opencode-ctx guidelines apply --packs python,testing,delivery-safety -->
<!-- Run the command above to populate this section -->

<!-- GUIDELINES-END -->