Skip to main content

Config Service — Sync Contract

Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template · 16 offline-first-and-sync


1. Offline Posture

The config-service is a server-authoritative service. No config state is written from offline clients. Clients consume resolution results (read-only) which may be cached locally with TTL.


2. Per-Aggregate Conflict Policy

AggregateConflict PolicyRationale
ConfigNodeserver_authoritativeDAG structure must be validated server-side for cycle detection; no offline mutations permitted
FeatureDefinitionserver_authoritativeAdmin-only mutation; no offline write path
RoleDefinitionserver_authoritativeAdmin-only; system roles require SUPER_ADMIN validation
RoleInheritanceserver_authoritativeBFS depth validation requires full graph; not safe to merge offline
RoleFeatureGrantserver_authoritativePermissions must be centrally authoritative
UserNodeOverrideserver_authoritativeClinical safety: ExplicitDeny must not be overridable by stale offline state
UIDefinitionserver_authoritativePlatform admin tooling only
UIVisibilityRuleserver_authoritativeAdmin-only
DesignTokenserver_authoritativeTenant branding admin only
EvaluationResult (read cache)lww (client-side TTL)Clients may cache resolved results for 60 s; stale reads are acceptable; hard-expiry on cache bust event

3. Client-Side Caching Rules

Cache itemClient TTLInvalidation
EvaluationResult (full resolution)60 sOn config.config.cache_busted.v1 received via SSE/WebSocket
UIElementConfig[]120 sOn config.ui_definition.updated.v1
DesignTokens map300 sOn config.design_token.updated.v1

Clients MUST NOT use cached results beyond their TTL without re-validation.


4. Server-Side Redis Cache Contract

Key patternTTLEviction trigger
cfg:{tenantId}:{userId}:{nodeId}:{moduleKey}:{featureKey}60 sAny config.feature., config.role., config.user_override.*
cfg:ui:{tenantId}:{userId}:{featureKey}120 sconfig.ui_definition.*
cfg:tokens:{tenantId}:{userId}:{moduleKey}:{locale}:{nodeId}300 sconfig.design_token.updated.v1
cfg:roles:{tenantId}:{roleKey}:expanded300 sconfig.role., config.role_grant.

5. Sync Not Applicable

Config mutations do not use CRDT or LWW merge. All writes go through the server and emit events. There is no sync protocol for bidirectional reconciliation. The sync framework (@ghasi/sync-protocol) is not used by this service.