# E2E Spec: Runtime Auto-Detection

## Overview
Test runtime PATH scanning, normalization, and periodic re-detection.
Covers `internal/profile/runtimes.go`.

## Test Cases

### Detection
- Detect scans PATH for known runtime binaries
- Returns found/not-found for each runtime type
- Runtime names normalized via agent.NormalizeRuntime
- Invalid binary names are skipped
- Runtimes sorted by priority

### Builtin OpenCode runtime values
- `builtin` is the AgentTeam-managed OpenCode runtime bundled with Desktop
- `opencode` is an external OpenCode binary resolved from PATH or manual config
- Detection reports `builtin` and external `opencode` as separate runtimes
- Launch preserves the `builtin` identity so managed OpenCode is used
- Detached recovery for OpenCode/builtin uses the session-revert adapter; LAN E2E verifies managed and external OpenCode behavior before release

### Get
- Returns runtime by name (case-insensitive)
- Returns false for unknown runtime

### Start/Stop Detect
- StartDetect begins background scanning every 60s
- Double StartDetect is idempotent
- StopDetect stops background goroutine
- StopDetect when not started is no-op

### Runtime Provider Reload
- Detection triggers runtime provider reload
- Auto-detected providers marked as read-only
