# ARISE Observability, Dashboard, Distributed Setup & Registry — Design Spec

## Feature 1: Evolution Reports + OpenTelemetry

### In-memory evolution history
- New dataclass `EvolutionReport` in `arise/types.py`:
  - `timestamp`, `gaps_detected: list[GapAnalysis]`, `tools_synthesized: list[str]`, `tools_promoted: list[str]`, `tools_rejected: list[dict]` (name + reason), `duration_ms: int`, `cost_usd: float`
- `ARISE` class gets `evolution_history: list[EvolutionReport]` and `last_evolution` property
- Populated during `evolve()` and worker `_evolve()`

### OTel integration (optional)
- New file `arise/telemetry.py`
- `pip install arise-ai[otel]` adds `opentelemetry-api`, `opentelemetry-sdk`
- Wraps evolution steps in spans: `arise.evolution`, `arise.gap_detection`, `arise.synthesis`, `arise.sandbox`, `arise.adversarial`, `arise.promotion`
- Each span has attributes: tool_name, success, duration, error
- If OTel not installed, no-op (graceful degradation)
- Config: `ARISEConfig(enable_telemetry=True)`

## Feature 2: Dashboard

### CLI TUI (`arise dashboard`)
- New file `arise/dashboard/tui.py`
- Uses `rich` library (optional dep: `pip install arise-ai[dashboard]`)
- Shows: skill library table, recent evolution history, success rate chart, cost summary
- Reads from local SQLite stores
- Arguments: `arise dashboard [skills_path] [trajectories_path]`

### Web UI (`arise dashboard --web`)
- New file `arise/dashboard/web.py`
- FastAPI app on localhost:8501
- Endpoints: GET /api/skills, GET /api/history, GET /api/stats
- Simple HTML page with tables (no React/build step — inline HTML template)
- Auto-opens browser

## Feature 3: Simpler Distributed Setup

### Setup helper
- New file `arise/distributed.py`
- `setup_distributed(region, bucket_name=None, queue_name=None)` → `ARISEConfig`
- Creates S3 bucket (with versioning enabled) + SQS queue (with DLQ)
- Returns configured `ARISEConfig` with all fields set
- Prints resource ARNs
- Requires: boto3, valid AWS credentials

### CLI command
- `arise setup-distributed --region us-west-2` — interactive, creates resources, writes config to `.arise.json`
- `arise setup-distributed --destroy` — deletes resources

## Feature 4: Skill Registry Improvements

### File-based import/export
- `arise registry export [skills_path] -o skills.json` — exports all active skills as JSON
- `arise registry import skills.json [skills_path]` — imports with validation
- Validation on import: sandbox + adversarial test each skill before promoting

### Better search
- Add `tags: list[str]` field to RegistryEntry
- `registry.search()` supports tag filtering: `registry.search(tags=["json", "parsing"])`
- Sort results by `avg_success_rate` descending

### Validation on pull
- `registry.pull()` gains `validate=True` param (default True)
- Runs sandbox test on pulled skill before returning
- If fails, raises `SkillValidationError` instead of silently returning broken skill

### CLI commands
- `arise registry search "csv parsing"` — search with output
- `arise registry publish <skill_id> --tags json,parsing` — publish to S3 registry
- `arise registry pull <name>` — pull + validate
