Architecture Decision Record
ADR-144: Offline Writes and Delta Reads (Client Write Queue, Server Change Feed with Tombstones)
Status
Accepted (2026-11-12). Released in MMCA.Common v1.289.0 (MMCA.Common/CHANGELOG.md:511); the reference adopter is MMCA.ADC. Revised 2026-11-23: the reference adopter's UI calls SetBookmarkedAsync directly, its BookmarkService wrapper being gone; anchors refreshed after v1.315.0.
Context
The framework already lets a client read while offline: ILocalCacheStore keeps JSON documents on the device, over localStorage in the browser (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DeviceStorage/BrowserLocalCacheStore.cs:6) and as files in an mmca-cache folder under the app data directory on MAUI (MMCA.Common/Source/Presentation/MMCA.Common.UI.Maui/Capabilities/DeviceStorage/MauiLocalCacheStore.cs:7). Writes had no such path. A client write is an HTTP call through HttpResultExecutor, which turns a request that never got an answer into an Http.TransportFailure or Http.Timeout failure (ADR-013); with the device offline, every write failed and the user's intent was lost. The reference adopter makes this concrete: an attendee in a conference hall with no signal taps the star on a session and the bookmark never reaches the server.
A client that keeps a local copy also needs to bring it up to date cheaply when it reconnects. The list endpoints answer "what exists now", which forces a full re-read and cannot report a row that was deleted, because the soft-delete query filter hides it (ADR-005).
Three existing decisions shape the answer. ADR-017 makes idempotency a per-action opt-in through [Idempotent] (MMCA.Common/Source/Presentation/MMCA.Common.API/Idempotency/IdempotentAttribute.cs:15-16): a request to such an action that carries a client-minted Idempotency-Key is answered from a replay cache kept 24 hours by default (MMCA.Common/Source/Presentation/MMCA.Common.API/Idempotency/IdempotencySettings.cs:16), so the same request sent twice runs once. ADR-035 round-trips a RowVersion as a weak ETag in If-Match, so a write based on stale data answers 412. ADR-136 puts a service worker in front of the installable web app and has it never cache a page or a response, because server-rendered pages carry the signed-in user's data.
Decision
MMCA.Common ships two opt-in pieces: a durable client-side write queue in MMCA.Common.UI, and a server change feed on EntityControllerBase that returns the rows changed since a point in time with soft-deleted rows as tombstones. Neither is wired by the framework itself (MMCA.Common/Source/Presentation/MMCA.Common.UI/DependencyInjection.cs:411, MMCA.Common/Source/Presentation/MMCA.Common.API/Pagination/SupportsChangeFeedAttribute.cs:7).
The client write queue
Registration.
AddOfflineWriteQueue(configure)registersIOfflineWriteQueueasOfflineWriteQueue, scoped, andTimeProvider.Systemunless one is registered (MMCA.Common/Source/Presentation/MMCA.Common.UI/DependencyInjection.cs:417-418). In the browser hosts the connectivity service and local store the queue reads are scoped too (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DependencyInjection.cs:113,:115); the MAUI head registers its local store as a singleton (MMCA.Common/Source/Presentation/MMCA.Common.UI.Maui/DependencyInjection.cs:63).AddOfflineWriteHandler<THandler>()adds one scopedIOfflineWriteHandlerper write kind, and registering the same type again adds nothing (MMCA.Common/Source/Presentation/MMCA.Common.UI/DependencyInjection.cs:438). The queue indexes handlers by an ordinal match onKind, the first registered for a kind winning (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:57,:98-101).Storage on each head. The whole queue is one
List<PendingWrite>underOfflineWriteQueueOptions.StorageKey, defaultmmca.offline-writes(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueueOptions.cs:7), kept in the device'sILocalCacheStore, and the queue is available wherever the host registered a device store: itsIsAvailableis the store's (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:113). Three cases follow from the registrations. With the defaultNullLocalCacheStore, whichAddUISharedregisters only when nothing else did (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DependencyInjection.cs:61),IsAvailableis false (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DeviceStorage/NullLocalCacheStore.cs:7) andEnqueueAsyncanswersOfflineWrites.Unavailable(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:130-134). A host that callsAddBrowserDeviceCapabilitiesgetsBrowserLocalCacheStore(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DependencyInjection.cs:115), whoseIsAvailableis true (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DeviceStorage/BrowserLocalCacheStore.cs:20): browserlocalStoragebehind themmca.localCache.key prefix (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DeviceStorage/BrowserLocalCacheStore.cs:12), reached through JS interop. The composed Blazor web-host call makes that call afterAddUIShared(MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/Hosting/BlazorWebHostExtensions.cs:107-109), so this case covers WebAssembly and a Blazor Server circuit alike: on a server circuit the writes are kept in the browser's storage, and the queue works only while the circuit is up, because every read and write crosses that circuit's JS interop and a disconnected one answers nothing (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/CapabilitiesJsModule.cs:41-44). On MAUI the store isMauiLocalCacheStore, a file under the app data directory (MMCA.Common/Source/Presentation/MMCA.Common.UI.Maui/Capabilities/DeviceStorage/MauiLocalCacheStore.cs:7,MMCA.Common/Source/Presentation/MMCA.Common.UI.Maui/DependencyInjection.cs:63). Every change re-reads, edits and writes the list back under oneSemaphoreSlimand raisesPendingChanged(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:449-473); the semaphore belongs to one queue instance (:62), so it serializes the callers of that instance only (see Trade-offs).The pending write.
PendingWritecarriesKind,IdempotencyKey,BasedOnRowVersion,PayloadJson(serialized withJsonSerializerOptions.Web),CoalesceKey,UserScope,EnqueuedOnandAttempts(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/PendingWrite.cs:15-40). The caller supplies the idempotency key, the row version and the coalesce key throughOfflineWriteOptions, all optional (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteOptions.cs:7-14); with no key the queue mints a GUID inNform (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:140). A row version is rendered as the ADR-035 weak ETag forIf-Match(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/PendingWrite.cs:47).Per-user scoping. Each write is stamped with the signed-in user's id, read afresh from the
AuthenticationStateProvider(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:144,:493-499). Listing, cancelling and replaying see only the current user's writes, oldest first (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:254-257). A local sign-out clears the whole local store, and with it every user's queued writes (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Auth/AuthUIService.cs:542,:599).The coalesce key.
CancelPendingAsync(coalesceKey)removes every queued write of the current user with that key (ordinal) and raises noWriteSettled(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/IOfflineWriteQueue.cs:40-44,MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:193-208).The cap.
MaxPendingWritesdefaults to 200 (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueueOptions.cs:17); an enqueue past it answersOfflineWrites.QueueFull(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:152-155,:173-176).MaxAgedefaults to 24 hours (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueueOptions.cs:10-14), the same as the server's default idempotency window (MMCA.Common/Source/Presentation/MMCA.Common.API/Idempotency/IdempotencySettings.cs:16); the two are separate settings. A pass removes asExpired, unsent, a write older thanMaxAgeat the start of the pass (item 8), which keeps a replay inside the server's window except at its edge (see Trade-offs).When it replays.
ReplayAsyncdoes nothing unless the store is available, the device is online and no other replay is running: a compare-exchange makes it single flight (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:213-216). A replay starts in three situations: the queue starts one, unawaited, whenever connectivity changes to online (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:501-520);OfflineWriteNotifierruns one on its first interactive render while online (MMCA.Common/Source/Presentation/MMCA.Common.UI/Components/Capabilities/OfflineWriteNotifier.razor:33-54), and Common'sMainLayoutalready hosts that component (MMCA.Common/Source/Presentation/MMCA.Common.UI/Layout/MainLayout.razor:85); and the queue retries by itself (item 9).What a handler returns and what each outcome does.
IOfflineWriteHandler.ReplayAsyncsends the write with its idempotency key (andIf-Matchwhen set) and returns the server's answer as aResult(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/IOfflineWriteHandler.cs:14-23). A pass walks the user's writes oldest first, and before it expires or sends one it re-checks under the semaphore that the write is still stored, skipping one that left the store since the pass read it (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:293-354,:307-310,:476-487):- older than
MaxAge: removed asExpiredwithout being sent (:312-317); - no handler for its kind in this app: skipped and kept (
:319-323); - success: removed as
Completed(:265-268); - a transport failure, a timeout, or an
Unexpected,TooManyRequestsorUnauthorizederror, or a handler that throws any exception other than a cancellation: kept withAttemptsincremented, and the pass stops (:280-283,:335-347); - a handler that throws
OperationCanceledException: rethrown, so the pass ends without counting an attempt (:330-333) and the next retry is still scheduled (:227-232,:365-369); - any other
Conflict: removed asConflict; any other failure: removed asRejected(:275-277).
The transient check runs before the conflict check (
:270before:275). A settled write leaves the store first, thenWriteSettledfires (:424-428), andOfflineWriteNotifierturns it into a toast: a warning forConflictandExpired, an error forRejected, and a success toast forCompletedonly whenShowCompletedis set (MMCA.Common/Source/Presentation/MMCA.Common.UI/Components/Capabilities/OfflineWriteNotifier.razor:30,:88-104). The outcomes are theOfflineWriteOutcomeenum (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteOutcome.cs:4-16).- older than
The self-retry while online. The queue holds at most one retry timer on the injected
TimeProvider(MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:383-394). It is set after a write with a registered handler is queued (:162-171) and after a pass that stopped on a transient failure or threw (:361-369). The first delay is 5 seconds (:50); it doubles after each pass that settled nothing, capped at 5 minutes (:53,:285-286), and returns to 5 seconds after a pass that settled a write (:367). A pass that leaves nothing to retry removes the timer, unless a replayable write was queued while it ran (:370-378). The timer is never created while the device reports offline (:385), and going offline removes it (:508-516), so an empty queue or an offline device holds none.
The server change feed
- Opt-in per controller.
EntityControllerBase.GetChangesAsyncservesGET {controller}/changes?since=&cursor=&pageSize=(MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:456-465). Its[OptInAction(typeof(SupportsChangeFeedAttribute))](:457) removes the action from the application model unless the controller carries[SupportsChangeFeed](MMCA.Common/Source/Presentation/MMCA.Common.API/Pagination/OptInActionAttribute.cs:24-33), so a controller that did not opt in has no route and an unchanged API document (MMCA.Common/Source/Presentation/MMCA.Common.API/Pagination/OptInActionAttribute.cs:11-13). The attribute is inherited, so declaring it on an abstract base controller opts in every derived one (MMCA.Common/Source/Presentation/MMCA.Common.API/Pagination/SupportsChangeFeedAttribute.cs:10,:13). - Paging.
pageSizedefaults to 100 and is clamped to the controller'sMaxPageSize(MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:464,:467). The query service reads one keyset page overLastModifiedOnascending throughGetPageByCursorAsync, withIdas the tie-break (MMCA.Common/Source/Core/MMCA.Common.Application/Services/EntityQueryService.cs:571-572,:584-591), and returns aKeysetCollectionResult<EntityChange<TEntityDTO, TIdentifierType>>with the next cursor (:610). - The
sincebound. The bound is inclusive:ChangeFeedSpecificationfiltersLastModifiedOn >= sinceand omits the bound whensinceis null (MMCA.Common/Source/Core/MMCA.Common.Application/Services/Query/ChangeFeedSpecification.cs:36-41). A local value is converted to UTC and an unspecified one taken as UTC (MMCA.Common/Source/Core/MMCA.Common.Application/Services/EntityQueryService.cs:614-620). A client pages with onesinceuntil the cursor is null, then keeps the largestchangedOnas its nextsince; boundary rows come again and are applied idempotently by id and row version (MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:448-450). - Tombstones. The specification lifts the soft-delete filter (
MMCA.Common/Source/Core/MMCA.Common.Application/Services/Query/ChangeFeedSpecification.cs:30). Each row becomes anEntityChangewithId,IsDeleted,ChangedOn(LastModifiedOn, elseCreatedOn) andItem; only live rows are mapped, so a tombstone carries no field of the deleted row (MMCA.Common/Source/Core/MMCA.Common.Application/Services/EntityQueryService.cs:597-608). - Scope stays in force. The rows are ANDed with the controller's
GetReadSpecificationAsyncscope (MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:469-471,MMCA.Common/Source/Core/MMCA.Common.Application/Services/Query/ChangeFeedSpecification.cs:44-54), and only the soft-delete filter is lifted, so the tenant filter and every other global filter stay in force (MMCA.Common/Source/Core/MMCA.Common.Application/Services/Query/ChangeFeedSpecification.cs:9-11). - A query service that predates it.
IEntityQueryService.GetChangesSinceAsynchas a default body that fails withQuery.ChangeFeedNotSupported(Unexpected, 500) (MMCA.Common/Source/Core/MMCA.Common.Application/Interfaces/Mapping/IEntityQueryService.cs:34,:198,:212-213), so a custom query service learns of the feed by answering 500 rather than returning wrong data.
Rationale
- The queue reuses the stores the client already has. Offline reads already put JSON documents in
ILocalCacheStoreon both heads, so the queue is one more document in the same store and works wherever offline reads do, with no second persistence stack on the device. - Idempotency keys make a replay safe without a sync protocol. A write that may already have reached the server is resent with the same key, and ADR-017 answers it from the replay cache instead of running it twice. The queue's
MaxAgeand the server's replay window are separate settings, both 24 hours by default, so a replay falls inside the window except in the narrow case under Trade-offs. A stale edit carries its row version and gets ADR-035's 412, which the queue reports asConflictinstead of overwriting. - The handler owns the meaning of a failure. Only the app knows that "already bookmarked" is a success for an add. The queue's classification covers the general case (transient keeps, conflict and refusal discard) and leaves domain equivalences to the handler.
- The change feed is a read over data the framework already stamps.
LastModifiedOnandIsDeletedexist on every auditable entity, so the feed needs no new column, no change log table and no migration, and it reuses keyset paging and the read scope that the list endpoints already enforce. - Opt-in on both sides. A consumer that registers nothing and declares no attribute sees no new service, no new route and no change to its API document.
Trade-offs
MaxPendingWritescounts every user's queued writes on the device, not the current user's: the cap check reads the whole list (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:152). A local sign-out wipes the whole store, every user's backlog with it (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Auth/AuthUIService.cs:542,:599), and that clear is best-effort (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Auth/AuthUIService.cs:590-605). Another user's writes therefore count against the cap only after a session that ended without that sign-out or whose clear failed; such a backlog can refuse the next user's enqueue, and since a pass reads only the current user's writes (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:296), it neither drains nor expires until its own user signs in again.- Only a transport failure falls back to the queue in the reference adopter. A timeout, a 429 or a 5xx on the online attempt is returned to the caller as a failure, not queued (
MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/SessionBookmarkUIService.cs:215-217), even though the queue would keep such an error on replay. Which errors queue is the adopter's choice; the framework does not decide it. - Both device stores are best-effort. On MAUI
MauiLocalCacheStore.SetAsyncswallows anIOExceptionor anUnauthorizedAccessException(MMCA.Common/Source/Presentation/MMCA.Common.UI.Maui/Capabilities/DeviceStorage/MauiLocalCacheStore.cs:27-34). In the browserstorageSetcatches a failedlocalStorage.setItem, a full quota included, and returns false (MMCA.Common/Source/Presentation/MMCA.Common.UI/wwwroot/capabilities-interop.js:141-148),BrowserLocalCacheStore.SetAsyncignores that result (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DeviceStorage/BrowserLocalCacheStore.cs:27-30), and the interop wrapper turns an unavailable interop, aJSDisconnectedExceptionor aJSExceptioninto a default answer (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/CapabilitiesJsModule.cs:36-48). Either way a failed write loses the queued write whileEnqueueAsyncstill reports success (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:149-176). The browser store is bounded bylocalStorage's quota of roughly 5 MB (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DeviceStorage/BrowserLocalCacheStore.cs:7-8). - The semaphore serializes the callers of one queue instance only (
MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:62,:452). Several browser tabs or circuits share one storage key with one queue instance each, so their read-modify-write cycles can overwrite each other and lose a write. And a read failure that a store swallows comes back as an empty list (MMCA.Common/Source/Presentation/MMCA.Common.UI.Maui/Capabilities/DeviceStorage/MauiLocalCacheStore.cs:53-64,MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DeviceStorage/BrowserLocalCacheStore.cs:50-53,MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:489-490), so the next change writes that list back (:455-459) and drops the rest of the queue. - Newest intent wins only over a write the pass has not started sending. A pass skips an entry that left the store after the pass read it (
MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:307-310), butCancelPendingAsyncdoes not wait for a running pass (:193-208), so a write cancelled while its own request is in flight still lands; the next intent, issued in full, is what corrects the server. - A replay can reach the server just after it forgot the key. The server stores its replay entry after the action runs, for
CacheExpirationHours(MMCA.Common/Source/Presentation/MMCA.Common.API/Idempotency/IdempotencyFilter.cs:442-450), the failed online attempt runs before the queued write'sEnqueuedOnis stamped (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:145), and a pass measures age once, at its start (:297). So with the two windows equal, a write near the edge ofMaxAgecan go out after the server evicted its key and run again unless the action refuses the duplicate itself, and a host that sets the server window (MMCA.Common/Source/Presentation/MMCA.Common.API/Idempotency/IdempotencySettings.cs:15-16) belowMaxAgewidens that gap. - A pass stops at the first transient failure, so one write that keeps failing transiently holds back every later write of the same user until it settles or reaches
MaxAge. - Rows with no last-modified time are invisible to a time-bounded feed.
LastModifiedOn >= sincenever matches a nullLastModifiedOn(MMCA.Common/Source/Core/MMCA.Common.Application/Services/Query/ChangeFeedSpecification.cs:41), so a row written before the framework stampedLastModifiedOnon insert appears only in a full read (sincenull), where itsChangedOnfalls back toCreatedOn(MMCA.Common/Source/Core/MMCA.Common.Application/Services/EntityQueryService.cs:605). - The
sincebound trusts the application clock.LastModifiedOnis stamped from the application's clock whenSaveChangesruns, not when the transaction commits (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Persistence/Interceptors/AuditSaveChangesInterceptor.cs:65,:83,:94). With the largestchangedOnas the nextsince, a row committed after a client read past its stamp, or stamped by a host whose clock runs behind, falls below that client'ssinceand is missed until its next full read. - A row that leaves the read scope without being deleted yields no tombstone (
MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:453). A client that cached it keeps it until its next full read. - A hard delete yields no tombstone. The audit interceptor stamps only added and modified rows and leaves an
EntityState.Deletedrow alone (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Persistence/Interceptors/AuditSaveChangesInterceptor.cs:101), and a row that is gone cannot match the feed, so only a soft delete is reported; a client that cached a hard-deleted row keeps it until its next full read. - The feed is time-based, not a log. It reports the latest state of each changed row, not each intermediate change, and depends on
LastModifiedOnbeing stamped by the save path; a write that bypasses the audit stamping is not reported. - Nothing here was exercised on a physical device. The queue, the notifier and the reference adopter are covered by tests and builds only; a device run (airplane mode on a phone, an installed web app going offline) has not been performed.
The rule an adopter must follow, learned in the reference adopter: the newest intent for a key wins over every queued write not yet in flight, and it is always issued in full. On every new intent the adopter cancels the pending writes under the coalesce key FIRST, then sends or queues the new intent as a complete write of its own; it never cancels the queued write and stops. Cancelling removes a queued write that a replay pass has not started sending (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:307-310), but a write whose own request is already in flight still lands, and a write queued after a transport failure may already have reached the server, so cancelling it locally does not undo it: the opposite intent must still reach the server (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/SessionBookmarkUIService.cs:86-91). Two companion rules follow from the same fact: a queued create reuses the idempotency key of the failed online request it replaces, chosen before the online attempt (:93-96, :202), and a device that already reports offline queues at once rather than spending the retry budget on a request that cannot leave it (:98-103). A queued delete carries no key of its own (:204-208): the queue mints one (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:140) that the delete handler does not send, and neither the online nor the replayed delete sends a key (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/BookmarkApiClient.cs:84, MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/BookmarkDeleteReplayHandler.cs:57); a repeated delete is safe because a bookmark the server no longer has counts as done (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/BookmarkDeleteReplayHandler.cs:58, MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/SessionBookmarkUIService.cs:181).
Alternatives rejected
- An embedded SQLite store on the device (weighed 2026-11-12). It would give the queue transactions and queries, but it is a second persistence stack on the client beside
ILocalCacheStore, with its own native dependency on MAUI and a WebAssembly build of its own in the browser, for a queue that holds at most a few hundred small documents. Revisit when a consumer needs offline writes that must query or join locally queued data, or when the queue outgrows the browser'slocalStoragequota. - Letting the service worker queue requests (Background Sync style, weighed 2026-11-12). ADR-136 keeps the worker to GET navigations and has it never cache a page or a response; a worker that stores request bodies carrying the user's data and replays them outside the app would break that rule, would exist only in the browser (the MAUI head has no worker), and could not attach a fresh bearer token or classify a
Result. Revisit if ADR-136 is superseded by a worker that is allowed to hold user data. - Free-form replay without idempotency keys (weighed 2026-11-12). A write that died in transit may have reached the server, so resending it without a key can run it twice (a duplicate create, a double toggle). The key is what makes "resend until answered" safe. Revisit never for non-idempotent writes; a handler whose write is naturally idempotent (a PUT of a full state) may still pass any key.
- A full sync protocol (client-side change tracking, server-side conflict resolution and merge, weighed 2026-11-12). It solves conflicts the framework does not have: the queue holds short-lived user intents, a conflict is reported through ADR-035's 412 rather than merged, and the change feed covers the read side. Revisit when a consumer needs multi-device offline editing of the same record with automatic merge.
Consequences
An adopter adds, using ADC's bookmark toggle as the worked example:
- Register the queue and one handler per write kind. ADC's Engagement UI calls
AddOfflineWriteQueue()andAddOfflineWriteHandler<>()forBookmarkCreateReplayHandlerandBookmarkDeleteReplayHandler(MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/DependencyInjection.cs:42-44). - Name versioned kinds and a coalesce key.
Engagement.Bookmark.Create.v1andEngagement.Bookmark.Delete.v1are versioned because a queued write can outlive an app update, and the coalesce keybookmark:{userId}:{sessionId}pairs one user's toggles of one session (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/BookmarkOfflineWrites.cs:13,:16,:22-23). - Route every write through one place that applies the newest-intent rule.
SessionBookmarkUIService.SetBookmarkedAsynccancels the pending writes for the key, mints the create's key before the online attempt, queues at once when offline, and otherwise falls back to the queue only on a transport failure (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/SessionBookmarkUIService.cs:79-135). The Conference UI calls that toggle directly for both writes (MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.UI/Pages/Public/Sessions/PublicSessionListView.razor.cs:164,:186,MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.UI/Pages/Public/Sessions/SessionBookmarkButton.razor.cs:122), so every new intent first removes each queued write of the same user and session that a replay pass has not started sending; one already in flight still lands (see Trade-offs). The same interface also exposesDeleteBookmarkAsync(MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.Shared/UserSessionBookmarks/ISessionBookmarkUIService.cs:32), which deletes online without cancelling queued writes (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/SessionBookmarkUIService.cs:63-76); its only caller is the toggle's own remove path (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/SessionBookmarkUIService.cs:180), so a caller that went around the toggle would skip the newest-intent rule. A write the queue refuses is returned as a failure, never as queued (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/SessionBookmarkUIService.cs:210-212). - Write each handler to map domain equivalences to success. The create handler resends with the queued key and treats
UserSessionBookmark.Duplicateas done, since the star already exists (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/BookmarkCreateReplayHandler.cs:45-52). The delete handler resolves a missing bookmark id through the session-ids read and counts a bookmark the server does not have, or a 404, as done (MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/BookmarkDeleteReplayHandler.cs:40-65). Both return every other failure unchanged so the queue classifies it. - Expose a change feed scoped to the caller.
BookmarksControllerderives fromApiControllerBase, notEntityControllerBase, so it serves its ownGET bookmarks/changes(MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.API/Controllers/BookmarksController.cs:37,:120,:125): behind theOwnerOrAdminFilter(:121), with a requireduserId(:126), a page clamped to 500 (:46,:135), and a scope of that user's rows passed to the sameGetChangesSinceAsync(:132,:136). AnEntityControllerBasecontroller gets the same feed by declaring[SupportsChangeFeed].
What to watch: the cross-user cap on shared devices, a write held back behind a transient failure until MaxAge, rows with no LastModifiedOn in a time-bounded feed, and the first physical-device run of the offline path.
Revision (2026-11-23)
Re-verified against current source. The decision is unchanged: the client write queue, its registration, storage, scoping, coalescing, cap, replay triggers, outcome classification and self-retry, and the server change feed with its paging, inclusive since bound, tombstones and read scope all hold as written. What moved is the reference adopter's UI, and the line numbers in most cited files.
- The adopter's
BookmarkServicewrapper is gone. The Conference UI callsISessionBookmarkUIService.SetBookmarkedAsyncdirectly for both the add and the remove (MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.UI/Pages/Public/Sessions/PublicSessionListView.razor.cs:164,:186,MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.UI/Pages/Public/Sessions/SessionBookmarkButton.razor.cs:122), so Consequences item 3 now cites those call sites. The interface still exposesDeleteBookmarkAsync(MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.Shared/UserSessionBookmarks/ISessionBookmarkUIService.cs:32), which deletes online without callingCancelPendingAsync(MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/SessionBookmarkUIService.cs:63-76); its only caller is the toggle's remove path (:180), and item 3 now says so. - Anchors re-verified against current source:
MMCA.Common/CHANGELOG.md:511(the v1.289.0 entry);MMCA.Common/Source/Presentation/MMCA.Common.UI/DependencyInjection.cs:411,:417-418,:438;MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DependencyInjection.cs:61,:113,:115;MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/Hosting/BlazorWebHostExtensions.cs:107-109;MMCA.Common/Source/Presentation/MMCA.Common.UI.Maui/DependencyInjection.cs:63;MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/OfflineWriteQueue.cs:50,:53,:57,:62,:98-101,:113,:130-134,:140,:144,:145,:149-176,:152-155,:162-171,:173-176,:193-208,:213-216,:227-232,:254-257,:265-268,:270,:275-277,:280-283,:285-286,:293-354,:296,:297,:307-310,:312-317,:319-323,:330-333,:335-347,:361-369,:367,:370-378,:383-394,:385,:424-428,:449-473,:452,:455-459,:476-487,:489-490,:493-499,:501-520,:508-516;MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Offline/IOfflineWriteQueue.cs:40-44;MMCA.Common/Source/Presentation/MMCA.Common.UI/Layout/MainLayout.razor:85;MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Auth/AuthUIService.cs:542,:590-605,:599;MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/EntityControllerBase.cs:448-450,:453,:456-465,:457,:464,:467,:469-471;MMCA.Common/Source/Core/MMCA.Common.Application/Services/EntityQueryService.cs:571-572,:584-591,:597-608,:605,:610,:614-620;MMCA.Common/Source/Core/MMCA.Common.Application/Interfaces/Mapping/IEntityQueryService.cs:198,:212-213;MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/DependencyInjection.cs:42-44;MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.UI/Services/Bookmarks/BookmarkCreateReplayHandler.cs:45-52;MMCA.ADC/Source/Modules/Engagement/MMCA.ADC.Engagement.API/Controllers/BookmarksController.cs:37,:46,:120,:121,:125,:126,:132,:135,:136.