fix(sync): guard archive actions by default

This commit is contained in:
Bohdan Triapitsyn
2026-08-02 16:48:02 +03:00
parent 4748c3362f
commit f95f1ab18f
3 changed files with 12 additions and 13 deletions
+4 -4
View File
@@ -217,15 +217,15 @@ Examples of global-store updates performed in `session-actions.ts`:
- `deleteSession()` -> waits for server confirmation or `404`, then removes the session and its persisted state
- `moveSessionToDirectory()` -> move the session between directory stores and update the global directory index
Archive callers whose confirmation spans asynchronous SDK calls may capture the
runtime key at operation start and pass it as `expectedRuntimeKey`. The guarded
action rechecks that key before every store reconciliation, so a response
Archive actions capture the active runtime key when they start and recheck it
before every store reconciliation, so a response
produced by the previous runtime is rejected instead of mutating the current
runtime's live or global session state. A guarded batch stops at the first
observed runtime change: sessions the server already confirmed remain archived
and stay in `archivedIds`, while every ID not confirmed on the captured runtime
is returned in `failedIds` so existing partial-failure feedback stays truthful.
Callers that pass no runtime key keep the previous unguarded behavior.
Callers whose confirmation can span a runtime switch may pass an
`expectedRuntimeKey` captured earlier; ordinary callers are guarded by default.
## The golden rule