diff --git a/CLAUDE.md b/CLAUDE.md index c7fd4ac4..b9fb0b5e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -200,10 +200,14 @@ Apply before finalizing any multi-phase plan. Trust-but-verify between scout → 10. **Context key style convention** — check existing `context.go` pattern before introducing new key types. Mixed = code smell. 11. **Alias/shim coverage** — enumerate ALL exported symbols via `go doc `. Add compile-time signature guards. 12. **Verify pass MANDATORY after rewrite** — spawn fresh Explore/grep to audit planner output. Don't trust self-validation. +13. **No fabricated Go identifiers** — every type/function/package referenced in plan must be grep-verified to exist (`grep -rn '^func \|^type ' `). Plausible-sounding APIs (`Keyring`, `StartSpan`, `Validator`, `security.SSRF`) are RED FLAGS — conventions differ per codebase. Rule of thumb: if you can't cite `file_path:line_number` for a symbol, you're fabricating. Apply especially when planner says "reuse existing X" — re-verify X exists before writing into plan. +14. **Plausible-but-wrong API families** — watch for: OTel-style `StartSpan/EndSpan` (codebase may be emit-based); wrapper types like `Keyring/Vault/Manager` (codebase may use free functions); `internal/security` or `internal/auth` packages (often scattered instead of centralized). When unsure, `go doc ` lists actual exported surface. **Pattern to avoid:** user asks → planner writes → report "done". **Safer pattern:** user asks → scout → planner writes → audit-verify → report. +**Concrete red-team practice:** After planner completes, run `code-reviewer`/`brainstormer` agent in audit mode with explicit instruction "spot-check 15+ factual claims against live codebase". Caught fabricated `internal/security/`, `crypto.Keyring`, `tracing.StartSpan` in Agent Hooks plan (see `plans/260414-2229-agent-hooks-system/reports/audit-260414-2310-plan-review.md`). + ## Post-Implementation Checklist After implementing or modifying Go code, run these checks: diff --git a/docs/00-architecture-overview.md b/docs/00-architecture-overview.md index ea0c75a3..6faa71db 100644 --- a/docs/00-architecture-overview.md +++ b/docs/00-architecture-overview.md @@ -475,6 +475,29 @@ Six distinct workspace scenarios: - **L0 Auto-Injection**: Top-K vault entries injected into system prompt as "relevant context from vault" - **Filesystem Sync**: Vault entries exported as `.md` files for manual editing, re-imported with change tracking +### Audio & Voice System (ElevenLabs + Streaming TTS) + +**Provider architecture** (`internal/audio/`): +- **`Manager`**: Central orchestrator dispatching TTS/STT/Music/SFX requests to pluggable providers +- **`TTSProvider` interface**: Core text-to-speech contract (blocking, buffered response) +- **`StreamingTTSProvider` interface**: Optional interface for ElevenLabs `/stream` endpoint (chunked audio via `io.ReadCloser`) +- **Implementations**: ElevenLabs, OpenAI, Edge, MiniMax (phase-gated; STT/Music/SFX partial) + +**Voice discovery & caching**: +- **Voice cache** (`internal/audio/voice_cache.go`): In-memory LRU (cap 1000 tenants, TTL 1h) shared by HTTP `/v1/voices` + WS `voices.list` handlers. Thread-safe with `sync.Mutex` (LRU updates require write lock) +- **Cache miss recovery**: HTTP handler auto-fetches from ElevenLabs; WS handler requires prior cache warm (provider resolution deferred to Phase 3) +- **Agent audio context** (`store.WithAgentAudio` / `AgentAudioFromCtx`): Immutable snapshot bundle (AgentID + OtherConfig JSONB) injected by dispatcher before tool dispatch; consumed by `TtsTool.Execute` for voice/model resolution + +**Agent-level configuration** (`agents.other_config` JSONB): +- `tts_voice_id`: ElevenLabs voice ID (e.g., "pMsXgVXv3BLzUgSXRplE") +- `tts_model_id`: Model choice (eleven_v3, eleven_flash_v2_5, eleven_multilingual_v2, eleven_turbo_v2_5) +- Resolution precedence: CLI args → agent config → tenant override → provider default + +**Web UI voice picker** (`ui/web/src/components/voice-picker.tsx`): +- Combobox with BM25 search, preview playback button (HTML `