mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-26 22:22:13 +08:00
2.3 KiB
2.3 KiB
Backend Architecture Guardrails
These rules supplement the repository's root AGENTS.md.
- Keep configuration ownership in
config. Configuration writes must use its draft and persistence APIs. Patch orchestration must usefeat/effects.rsandfeat/executor.rs; refresh notifications must usecore::notify::announceafter successful persistence and commit. This keeps failed transactions from publishing state. Independent transactions retain their boundaries and announce viaafter_commit; runtime-only profile activation announces after successful application. Cross-layer operations must preserve these ownership and transaction boundaries. - Register every new
IVergefield. Register the field in the exhaustive effect registry, including an explicitNoEffectwhere appropriate, and preserve its platform attributes. Manual field-to-flag chains hide missing effects and are forbidden. - Use
utils::retryfor bounded retries. Do not introduce handwritten retry loops, includingloopplussleep; preserve attempt budgets, delays and terminal errors. Permanent watchers are the exception and must document their exit conditions. Traversal of distinct data or port candidates is not a retry policy. - Keep notifications typed. Send notice statuses through
NoticeStatusand useArc<str>for notice message payloads. Preserve the event names and status strings as a shared wire contract. Contract changes must keep frontend consumers and backend producers aligned. - Preserve lock order. The order is
config_writebeforeconfig_update_in_progressbeforelifecycle_lock. Patch callers must use the executor's guarded claim instead of independently combining these locks; this preserves Busy rejection and prevents inverted acquisition. Existing lifecycle and independent port transactions keep their established locking boundaries. A new lock requires registering its position in this rule before introducing acquisition sites. - Prefer reconciliation. Express new effects as idempotent
ensureoperations inEFFECT_ORDERso repeated application converges on the same state. A trigger chain is an exception only with a code comment explaining why the operation cannot be idempotent. Configuration rollback does not authorize reverse OS effects.