Spaces:
Running
Running
File size: 13,968 Bytes
707377e | 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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | # SentinelOps Arena β Complete Setup Guide
## 1. Local Dev Environment
### Python Version
- **Required:** Python 3.14 (system) or 3.12+ (venv)
- **Current venv:** Python 3.14.2 in `hackathon_env/.venv/` (created by uv)
- **Root venv:** Python 3.12.12 in `.venv/` (created by uv)
- **OpenEnv 0.2.1** requires `>=3.10`, works fine on 3.14
- **Tool manager:** `uv` 0.9.26 (installed at `/Users/nihalnihalani/.local/bin/uv`)
### Existing Environment State
The `hackathon_env/` directory already has a working OpenEnv echo environment with:
- `openenv-core==0.2.1` installed in `hackathon_env/.venv/`
- Working `Environment` subclass pattern (see `server/hackathon_env_environment.py`)
- Working `create_app()` HTTP server (see `server/app.py`)
- Working `EnvClient` subclass with `_step_payload()` and `_parse_result()` (see `client.py`)
- Working Dockerfile for HF Spaces deployment
- `openenv.yaml` spec file
### CRITICAL: The venv has a broken interpreter path
The `hackathon_env/.venv/bin/openenv` script points to `/Users/nihalnihalani/Desktop/Github/openev/hackathon_env/.venv/bin/python` (note `openev` not `NexusEnv`). This means the venv was created in a different directory and moved. The Python binary itself works fine, but CLI entry points are broken.
**Fix:** Recreate the venv from `hackathon_env/`:
```bash
cd /Users/nihalnihalani/Desktop/Github/NexusEnv/hackathon_env
uv venv .venv --python 3.14
uv sync
```
### Dependencies β pyproject.toml for SentinelOps
The project needs a **root-level** `pyproject.toml` for the SentinelOps Arena package. The `hackathon_env/pyproject.toml` only covers the echo env template.
```toml
[build-system]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "sentinelops-arena"
version = "0.1.0"
description = "Multi-agent self-play training environment for enterprise AI security"
requires-python = ">=3.10"
dependencies = [
# Core OpenEnv runtime
"openenv-core[core]>=0.2.1",
# MCP tool server
"mcp>=1.26.0",
"fastmcp>=2.14.5",
# HTTP server
"fastapi>=0.115.0",
"uvicorn>=0.24.0",
# MCP-X gateway dependencies
"PyJWT>=2.0",
"toml>=0.10.2",
"httpx>=0.27",
# Gradio for HF Spaces demo UI
"gradio>=5.0.0",
# Data handling
"pydantic>=2.0",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-cov>=4.0.0",
]
training = [
# These are for local training only, NOT for HF Spaces
"trl>=0.15.0",
"transformers>=4.40.0",
"torch>=2.0.0",
"accelerate>=0.30.0",
"datasets>=2.18.0",
"peft>=0.10.0",
]
[project.scripts]
server = "sentinelops_arena.server:main"
[tool.setuptools]
include-package-data = true
packages = ["sentinelops_arena", "sentinelops_arena.systems"]
```
### Pinned Dependency Versions (from envbeats reference)
| Package | Min Version | Source |
|---------|-------------|--------|
| openenv-core | 0.2.1 | hackathon_env/pyproject.toml |
| mcp | 1.26.0 | eb_assessor/pyproject.toml |
| fastmcp | 2.14.5 | mcp-x/pyproject.toml |
| fastapi | 0.128.6+ | mcp-x/pyproject.toml |
| PyJWT | 2.0+ | mcp-x/pyproject.toml |
| toml | 0.10.2+ | mcp-x/pyproject.toml |
| httpx | 0.27+ | mcp-x/pyproject.toml |
| uvicorn | 0.24.0+ | hackathon_env/server/requirements.txt |
| pydantic | 2.0+ | transitive via openenv-core |
| gradio | 5.0+ | for HF Spaces demo UI |
---
## 2. Infrastructure Setup
### Northflank H100
- Each team gets H100 GPU access via Northflank
- Used for **training only** (not deployment)
- Request at hackathon check-in or via organizer Slack
- Configure: SSH access, install Python 3.10+, CUDA drivers
- **Not required for MVP** β can use Colab free tier for training demo
### HuggingFace
- **Account:** Already have (nihalnihalani)
- **Join openenv-community:** Required for $30 compute credits β join org at huggingface.co
- **Create Space:** `nihalnihalani/sentinelops-arena`
- SDK: Docker (custom Dockerfile) or Gradio
- Hardware: CPU Basic (free) or CPU Upgrade ($0.03/hr from credits)
- **Push command:** `openenv push --space nihalnihalani/sentinelops-arena` OR manual git push to HF repo
### Google Colab
- Training notebook: `training/colab_training.ipynb`
- Runtime: T4 GPU (free tier) or A100 if credits available
- Key concern: Colab runs Python 3.10-3.11, but openenv-core requires >=3.10 (should work)
- **Fallback:** Bundle standalone env code in notebook without openenv import (for Python compat)
### YouTube
- Account for demo video upload
- Video length: **1 minute** (per spec, NOT 3-5 minutes as in the build plan)
- Screen record: Gradio demo + training signal
- Upload as unlisted, share link in submission
---
## 3. Repository Structure
### Target File Tree
```
NexusEnv/
βββ .git/
βββ .gitignore
βββ .venv/ # Root venv (Python 3.12)
βββ CLAUDE.md # Claude Code rules
βββ README.md # Project README (update for submission)
βββ SENTINELOPS_ARENA.md # Full spec document
βββ SETUP.md # This file
βββ pyproject.toml # Root project config (NEW)
βββ app.py # HF Spaces entry point β Gradio app (NEW)
βββ sentinelops_arena/ # Core package (NEW)
β βββ __init__.py
β βββ models.py # Pydantic models: Action, Observation, State, data models
β βββ systems/
β β βββ __init__.py
β β βββ crm.py # CRM simulator
β β βββ billing.py # Billing simulator
β β βββ ticketing.py # Ticketing simulator
β βββ attacks.py # Attack mechanics (4 types)
β βββ rewards.py # Reward functions (3 agents)
β βββ task_generator.py # Customer task generation
β βββ environment.py # SentinelOpsArena(Environment)
β βββ mcp_tools.py # FastMCP tool definitions
β βββ server.py # create_app() HTTP server
β βββ demo.py # Demo script with heuristic agents
βββ mcp_x/ # MCP-X gateway (adapted from envbeats) (NEW)
β βββ mcp_x.py # Gateway server (copy+adapt)
β βββ config.toml # Per-agent tool ACLs
βββ training/ # Training deliverables (NEW)
β βββ colab_training.ipynb # REQUIRED Colab notebook
β βββ rollout.py # rollout_func for GRPOTrainer
βββ envbeats/ # Reference implementation (existing, read-only)
β βββ eb_assessor/
β βββ eb_assessee_gym/
β βββ mcp-x/
βββ hackathon_env/ # Original echo env template (existing, reference)
β βββ ...
β βββ server/
β βββ Dockerfile # Reference Dockerfile
β βββ app.py # Reference create_app() usage
βββ train.py # Existing training script (update or replace)
```
### Key Files to Create (in build order)
1. `pyproject.toml` β root project config
2. `sentinelops_arena/__init__.py`
3. `sentinelops_arena/models.py` β all Pydantic models
4. `sentinelops_arena/systems/__init__.py`
5. `sentinelops_arena/systems/crm.py`
6. `sentinelops_arena/systems/billing.py`
7. `sentinelops_arena/systems/ticketing.py`
8. `sentinelops_arena/attacks.py`
9. `sentinelops_arena/rewards.py`
10. `sentinelops_arena/task_generator.py`
11. `sentinelops_arena/environment.py`
12. `sentinelops_arena/mcp_tools.py`
13. `sentinelops_arena/server.py`
14. `sentinelops_arena/demo.py`
15. `app.py` β Gradio HF Spaces entry point
16. `mcp_x/mcp_x.py` + `mcp_x/config.toml`
17. `training/colab_training.ipynb`
---
## 4. Deployment Config
### HuggingFace Spaces β Two Options
#### Option A: Gradio SDK (Simpler, Recommended)
HF Spaces README.md header:
```yaml
---
title: SentinelOps Arena
emoji: π‘οΈ
colorFrom: red
colorTo: blue
sdk: gradio
sdk_version: 5.12.0
app_file: app.py
pinned: false
license: mit
---
```
No Dockerfile needed. HF auto-installs from `requirements.txt`:
**requirements.txt** (for HF Spaces):
```
openenv-core[core]>=0.2.1
mcp>=1.26.0
fastmcp>=2.14.5
fastapi>=0.115.0
uvicorn>=0.24.0
PyJWT>=2.0
toml>=0.10.2
httpx>=0.27
gradio>=5.0.0
pydantic>=2.0
```
#### Option B: Docker (If Gradio SDK fails)
Use adapted Dockerfile from `hackathon_env/server/Dockerfile`.
HF Spaces README.md header:
```yaml
---
title: SentinelOps Arena
emoji: π‘οΈ
colorFrom: red
colorTo: blue
sdk: docker
pinned: false
license: mit
---
```
**Dockerfile:**
```dockerfile
FROM python:3.14-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
# Gradio uses port 7860 on HF Spaces
EXPOSE 7860
CMD ["python", "app.py"]
```
### Deployment Commands
```bash
# Option 1: Using openenv CLI
cd sentinelops_arena
openenv push --space nihalnihalani/sentinelops-arena
# Option 2: Manual HF push
# Create space on huggingface.co first, then:
git remote add hf https://huggingface.co/spaces/nihalnihalani/sentinelops-arena
git push hf main
# Option 3: Using huggingface_hub Python API
from huggingface_hub import HfApi
api = HfApi()
api.upload_folder(folder_path=".", repo_id="nihalnihalani/sentinelops-arena", repo_type="space")
```
---
## 5. Submission Checklist
Every field required in the submission form:
| Field | Value | Status |
|-------|-------|--------|
| **Team Name** | TBD (e.g., "NexusEnv" or "SentinelOps") | Need to decide |
| **Project Description** | Multi-agent self-play RL environment where 3 AI agents (Attacker, Worker, Oversight) interact with simulated enterprise systems. Through adversarial dynamics, agents learn to attack, defend, and audit enterprise operations. | Draft ready |
| **HuggingFace Spaces Link** | `https://huggingface.co/spaces/nihalnihalani/sentinelops-arena` | Need to create |
| **Demo Video (YouTube)** | 1-minute screencast of Gradio demo + training | Need to record |
| **Minimal Training Script** | Colab notebook link (`training/colab_training.ipynb`) | Need to build |
| **Partner Tracks** | Fleet AI (Scalable Oversight), Patronus AI (Schema Drift) | Selected |
### Submission Deadline
**Sunday, March 8th, 2026 at 1:00 PM**
---
## 6. Pre-flight Checks
### Before Writing Any Code
- [x] Python 3.14 available (system)
- [x] `uv` installed and working
- [x] OpenEnv 0.2.1 installed in `hackathon_env/.venv/`
- [x] OpenEnv Environment/Action/Observation/State APIs understood
- [x] EnvBeats patterns analyzed (create_app, MCP-X, client patterns)
- [x] Git repo initialized, on `main` branch
- [ ] Create `nihal` branch (per CLAUDE.md push rules)
- [ ] Create root `pyproject.toml`
- [ ] Set up new venv with all dependencies: `uv venv .venv && uv sync`
- [ ] Verify imports: `python -c "from openenv.core.env_server.interfaces import Environment; print('OK')"`
- [ ] Create HF Space (can be empty placeholder)
- [ ] HuggingFace: Join openenv-community org for $30 credits
### Critical API Patterns (from hackathon_env reference)
**Environment class:**
```python
from openenv.core.env_server.interfaces import Environment
from openenv.core.env_server.types import Action, Observation, State
class MyEnv(Environment):
SUPPORTS_CONCURRENT_SESSIONS = True
def reset(self, seed=None, episode_id=None, **kwargs) -> MyObservation:
...
def step(self, action: MyAction, timeout_s=None, **kwargs) -> MyObservation:
...
@property
def state(self) -> State: # NOTE: property, not method
...
```
**Action class:**
```python
class MyAction(Action):
# extra='forbid' inherited from Action base
field: str = Field(..., description="...")
```
**Observation class:**
```python
class MyObservation(Observation):
# Inherits: done (bool), reward (float|None), metadata (dict)
my_field: str = Field(default="", description="...")
```
**HTTP Server:**
```python
from openenv.core.env_server.http_server import create_app
app = create_app(MyEnv, MyAction, MyObservation, env_name="my_env")
# Run: uvicorn module:app --host 0.0.0.0 --port 8000
```
**Client:**
```python
from openenv.core import EnvClient
class MyClient(EnvClient[MyAction, MyObservation]):
def _step_payload(self, action: MyAction) -> Dict:
return action.model_dump()
def _parse_result(self, payload: Dict) -> StepResult[MyObservation]:
...
```
### Known Gotchas
1. `Action` has `extra='forbid'` β SentinelAction must not have extra fields
2. `state` is a `@property` not a method β use `env.state` not `env.state()`
3. `create_app()` returns an ASGI app β use `uvicorn.run(app)` not `app.run()`
4. Observation `reward` field type is `bool | int | float | None` (allows bool)
5. The hackathon_env venv has broken CLI entry points (moved from different path)
6. CLAUDE.md says push to `nihal` branch, not `main`
7. Demo video must be **1 minute**, not 3-5 minutes (spec says 1 minute)
### OpenEnv Version Note
The spec says "OpenEnv 0.4" but OpenEnv 0.4 does NOT exist. The stable version is **0.2.1**. The SENTINELOPS_ARENA.md references "0.4" but the actual codebase and all dependencies use 0.2.1. Build against 0.2.1.
---
## 7. Quick Start Commands
```bash
# 1. Create nihal branch
cd /Users/nihalnihalani/Desktop/Github/NexusEnv
git checkout -b nihal
# 2. Create root pyproject.toml (see Section 1)
# 3. Set up venv
uv venv .venv --python 3.14
uv sync
# 4. Verify setup
.venv/bin/python -c "from openenv.core.env_server.interfaces import Environment; print('OpenEnv OK')"
.venv/bin/python -c "from mcp.server.fastmcp import FastMCP; print('FastMCP OK')"
.venv/bin/python -c "import gradio; print('Gradio OK')"
# 5. Start building sentinelops_arena/models.py
```
|