Context: You are working on a Hexagonal Architecture project (Python Backend Daemon). Objective: Maintain "State of the Art 2026" code quality standards. High cohesion, low coupling, zero technical debt.
- Source of Truth: Technical documentation lives in docs/docs/es/. mkdocs.yml defines the site structure.
- Detailed Instructions: Specialized documentation rules for agents are in docs/AGENTS.md.
- Sync: Any PR that changes functionality (code) MUST include the corresponding update in the documentation.
- README:
README.md(English) andLEEME.md(Spanish) must stay synchronized and point to the detailed documentation.
- Accessibility (WCAG 2.2+):
- Use descriptive
alt textfor all images. - Maintain strict heading hierarchy (H1 > H2 > H3).
- Minimum target size of 24x24px for interactive instructions.
- Use descriptive
- Structure:
- Tutorials: Learning-oriented.
- How-to Guides: Task-oriented.
- Reference: Information-oriented (API/CLI).
- Explanation: Understanding-oriented (Concepts/ADRs).
- Language:
- Detailed documentation (
docs/): Native Latin American Spanish. - Code comments: Native Latin American Spanish.
- Commits: English (Conventional Commits).
- Detailed documentation (
- Local-First (SOTA 2026): User privacy is absolute. Audio capture and speech recognition (ASR) are strictly local.
- Rust/Python Hybrid: High-performance audio engine in Rust (
v2m_engine) with Zero-Copy throughput to Python. - Modular Hexagonal: Domain logic is isolated. Infrastructure (Audio, LLM, API) is swappable.
- Async-Everything: Non-blocking I/O via FastAPI, WebSockets, and
uvloop.
- Serve locally:
mkdocs serve
- Core:
asyncio,uvloop,pydantic(v2). - ML/AI:
faster-whisper(Local ASR),silero-vad(ONNX), Google GenAI/Ollama. - Engine: Rust
v2m_engine+ Zero-Copy Shared Memory (/dev/shm). - Run:
python -m v2m.main(Starts FastAPI + WebSockets) - Test:
pytest tests/(Unit:tests/unit, Integration:tests/integration) - Lint:
ruff check src/ --fix(Strict rules enabled) - Format:
ruff format src/
- Install:
./apps/daemon/backend/scripts/setup/install.sh(Idempotent) - Verify:
python apps/daemon/backend/scripts/diagnostics/health_check.py
apps/daemon/backend/src/v2m/
├── api/ # FastAPI (app, routes, schemas)
├── shared/ # Foundation (config, errors, interfaces)
├── orchestration/ # Business Workflows (Recording, LLM)
└── features/ # Domain logic and specialized adapters (audio, llm, transcription)
- Interfaces in Domain/Application: Use
typing.Protocolwith@runtime_checkable. - No "God Classes": Divide responsibilities (e.g.,
AudioRecordervsTranscriptionService). - Type Hints: 100% coverage required.
- AsyncIO: Core is async. Offload blocking CPU/GPU tasks to executors.
- Unit Tests: Mock all infrastructure. Test logic in
application/. - Integration Tests: Test real infrastructure (GPU, Audio) in isolated scripts or
tests/integration/. - Golden Rule: If you fix a bug, add a test that reproduces it.
- Hardcoded Paths: NEVER use absolute paths. Use
v2m.utils.paths. - Blocking the Loop: Do not use
time.sleep(). Useawait asyncio.sleep(). - Secrets: No API keys in code. Use environment variables.
- Git Commits: Use Conventional Commits (
feat:,fix:,refactor:).
When generating code:
- Python: Pydantic V2, robust
ApplicationErrorhierarchy. - API: FastAPI + WebSockets (replaces legacy IPC sockets).
- Rust Bridge: Ensure
v2m_enginebinary is utilized for high-perf audio paths. - Hardware: Assume CUDA 12 context for GPU operations.
- Language: All documentation and comments must be in Native Latin American Spanish.