From 50ddb84f19c60b36da6eed9fc81d4878ff73c167 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Sat, 28 Nov 2026 20:51:41 +0800 Subject: [PATCH] docs(backend): define background task ownership --- src-tauri/AGENTS.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src-tauri/AGENTS.md b/src-tauri/AGENTS.md index a9356e9fc..133b828b5 100644 --- a/src-tauri/AGENTS.md +++ b/src-tauri/AGENTS.md @@ -18,6 +18,14 @@ These rules supplement the repository's root `AGENTS.md`. When both are held, the lifecycle lock precedes the DNS lock. Independent transactions retain their ownership boundaries; asynchronous work does not hold synchronous data guards across suspension. +- **Task ownership.** Prefer a single task to own the state and resources of a + background operation whose start, replacement, and cleanup must be ordered. + Use typed inputs and coalesce requests only when intermediate requests may + be skipped. When callers depend on completion, reply with the actual outcome. + Cancel work only at cancellation-safe boundaries. Keep issued side effects + owned through completion or explicit reconciliation. Preserve shared + transaction boundaries and ensure a task can reply without acquiring a lock + held by the waiting caller. - **Retry ownership.** Bounded retries share backend policy while preserving attempts, delays and terminal errors. Background monitors own their lifetime and cancellation separately; waiting for a condition or traversing distinct