Files
clash-verge-rev/src-tauri/AGENTS.md
T
Tunglies 7b43bac198 docs(agents): define Rust backend architecture boundaries
Document which layer owns Rust capabilities, fallible inputs, background work, and crate validation.
2026-11-30 18:13:47 +08:00

27 lines
1.6 KiB
Markdown

# Backend Architecture Guardrails
Follow [Workspace Crate Architecture](../crates/AGENTS.md) when changing
backend capability boundaries, reusable orchestration, or background task
ownership.
- **Tauri adapter.** Commands validate transport input, delegate to application
use cases, and map results and errors to IPC. Tauri wires dependencies and
owns desktop lifecycle, window and tray integration, and event delivery.
Keep domain validation and reusable orchestration independent of command
handlers and framework state.
- **Configuration and effects.** `config` owns source configuration, drafts, and
persistence coordination. Persistence adapters perform storage and recovery.
The effects layer classifies every Verge patch field, including
fields without effects and platform-specific fields, and reconciles requested
state in dependency order. Publish rollbackable state after persistence and
commit. On failure, preserve already applied runtime effects, independently
committed state, their notifications, and the error.
- **Wire contract.** Use typed notifications and preserve event names, status
values, and payload compatibility with frontend consumers.
- **Lock order.** Acquire configuration-write, configuration-update, Core
lifecycle, and DNS ownership in that order when needed. Preserve independent
transaction boundaries and release synchronous guards before suspension.
- **Retries.** Reuse the backend retry policy and preserve attempts, delays, and
terminal errors. Keep monitor lifetime, condition waits, and candidate fallback
under their own contracts.