Remote / foldkit-remote-domain

Handle a View that lags behind its write

After a command commits, mutate reads the View at the command's receipt:

OutcomeWhat Remote receives
Command committed, View caught upMutationSucceeded with the View's current row
Command committed, View still behindMutationSucceeded with written(reply, input) and after receipt token
Rejection mapped with refuseRemoteMutationError carrying the mutation's Refusal
Rejection mapped with forbid / unauthenticated / failRemoteForbidden, RemoteUnauthenticated, or RemoteMutationError
Middleware errorRemoteUnauthenticated or RemoteForbidden (via denied)
Transport failure or dropped responseRemoteUnreachable; Remote retries with the same operation id

A committed write is never reported as failed, and an older View row never overwrites it. Remote stores active floors in its Model (surviving persistence restores) and surfaces waiting rows under Data.inspect(model).floors with reason ReadAfter.

Idempotency and derived command ids

Each Remote write carries a stable operation id across retries. The adapter derives Domain's commandId as ${mutation}:${operation}:${digest}, where digest hashes [principal, target, keys, input]:

ScenarioSQLite ledgered writerRaw DomainThrough foldkit-remote-domain
Retry with same input and principalReturns recorded replyReturns first receiptReturns first receipt
Same operation, different inputRefusedSilently returns first receiptNew command, decided independently
Same operation, different principalDecided in new scopeSkips decide, returns first receiptNew command, decided afresh

Requests without an operation id fail with RemoteMutationError (Data.mutate always generates one). Lowered writes (Lower.write) enforce the full ledger rule on the aggregate side.