Skip to main content

Identity Service — Sync Contract

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: Service Template · 16 Offline & Sync

1. Scope

identity-service is a control-plane service. It is not an end-user offline aggregate. However, several aggregates interact with the offline protocol (device binding) and some read-only projections are replicated to the patient-chart offline bundle (e.g. cached provider profile for signing clinical notes).

2. Per-aggregate conflict policy

AggregateConflict policyRationale
Userserver_authoritativeCredentials, status, and email must never be client-driven. Clients cannot mutate User while offline.
Sessionserver_authoritativeSessions issued online only. Token refresh requires server.
Credentialserver_authoritativePassword hashes must not leave identity-service.
MFAFactorserver_authoritativeEnrollment requires online verification step.
Deviceserver_authoritative (with offline-emitted signals)Registration is online. Offline device emits usage beacons consumed when back online; conflicts resolved by most-recent-server-update-wins; beacons never override server state.
BindingCertificateserver_authoritative; append-only on clientClient holds signed cert; server can revoke. Client cache of revocation list uses LWW on revoked_at.
APIKeyserver_authoritativeSecrets only issued server-side.
ServiceAccountserver_authoritative
ExternalIdentityserver_authoritativeOIDC/SAML only meaningful online.
Moduleserver_authoritativeGlobal catalogue; read-only on clients.
LicenseAssignmentserver_authoritative; client reads cached effective setClient cannot mutate. Offline clients honour last-known effective set until absoluteExpiresAt of binding cert.
LicenseAssignmentHistoryappend_onlyNever mutated once written.

3. Client behaviour while offline

BehaviourRule
Token refreshImpossible offline. Access JWT continues to be accepted by offline-capable services until exp. Binding cert provides stronger offline proof.
Session revocationOffline revocation honoured via signed CRL-like delta shipped during next sync.
LicensingClient caches last-known effective set for (tenantId, providerId, nodeId). Cache lifetime ≤ binding cert expiry. On first online contact, client refreshes. If a module was revoked while offline, client shows license.pending-sync state and blocks new mutations on that module.
Device bindingClient cannot issue its own binding cert offline. Certificate carries expiry ≤ 30 days; offline-only workflow is guarded by this expiry.

4. Sync event consumption

EventConsumer roleEffect
identity.device.revoked.v1offline-capable clients via sync channelDelete local binding cert; prompt re-auth on return to online
identity.license.assignment.status_changed.v1offline-capable clientsInvalidate cached effective set; recompute after next sync
identity.user.suspended.v1offline-capable clientsOn next online ping, server rejects all further syncs and surfaces account-suspended screen

5. Conflict examples

ScenarioResolution
Client refreshes cached effective set while server has flipped diag.laboratory to suspendedServer wins. Client accepts new set; any queued actions against diag.laboratory created offline are marked license-revoked and require supervisor override or are discarded per tenant policy.
Client holds a binding cert revoked by adminNext online call rejects with IDENT_DEVICE_REVOKED; device must re-register (requires MFA).
Server side User.status changes to suspended while offline client has queued loginsQueued login attempts fail on sync; client clears local session tokens.

6. Cross-reference