Skip to documentation
Design system / Sources & standards
Current repository source
ADR-0113-atomic-theme-setting-audit-evidence.md
docs/decisions/ADR-0113-atomic-theme-setting-audit-evidence.md
This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.
# ADR-0113: Atomic theme-setting audit evidence ## Status accepted ## Date 2026-10-29 ## Context Theme settings live in DynamoDB rather than Aurora. Writing a setting before its required masquerade completion audit can leave a changed setting after HTTP 503. Early authorization and validation exits can also omit required denial evidence. The user approved correcting both findings in PR #233. ## Options considered 1. Write an external completion event before persistence. Rejected: it can claim a change that never commits. 2. Revert the setting after audit failure. Rejected: a failed or concurrent rollback can lose either a setting or its evidence. 3. Commit completion evidence inside the setting's existing DynamoDB item. Accepted. ## Decision - Every selection/custom-palette save atomically writes its setting and one pending completion event in one conditional PutItem. A revision guards both saves and delivery acknowledgements. Legacy items without a revision remain readable and migrate on their next save. Light/dark keys and three-color contracts remain unchanged. - Evidence contains a stable event ID, action time, trusted actor, before/after settings, appearance and any masquerade dual identity. Missing trusted identity or a failed conditional write prevents the setting change. Mutation reads fail closed rather than substituting presentation defaults for unavailable before-images. - After commit, attempt direct primary audit delivery with the existing idempotent audit facade. Remove pending evidence only after a matching primary acknowledgement. Delivery failure leaves the committed save successful and evidence available for retry. - Keep at most one pending event per setting item. Before replacing a setting, deliver its previous event; an unavailable audit store blocks that subsequent save without changing either the setting or its evidence. Other setting keys remain independent. - Retry through the next save or the explicit tenant-scoped `audit:drain-theme-outbox` command. Read only the four fixed tenant keys; no scan, index, worker, new AWS resource, IAM change or relational migration is required. - During masquerade, authorization and validation rejections record action-specific, privacy-safe denial evidence through the strict console facade. Include no arbitrary submitted payloads. Denial-audit failure returns 503 without a setting mutation; ordinary denials retain their existing 400/non-enumerating 404 behavior. ## Relationship to accepted decisions Extends ADR-0036/0037/0112's theme persistence and ADR-0028's facade boundary. Refines completion delivery for theme events only: durable evidence commits with the setting before external delivery. It does not supersede ADR-0042/0061's fail-closed dual-identity audit requirement or ADR-0073's invitation-specific primary-acknowledgement protocol. Other domains, authorization, browser mode and presentation remain unchanged. ## Consequences Tests must inspect retained state/evidence under failed writes, primary outages, acknowledgement failure, concurrent saves, retries and denial-audit failures. Operators can recover at most four pending events per tenant and then verify its primary audit chain. Pending evidence is mutable to privileged configuration-table operators until delivered; no hosted deployment or operator recovery is performed here.All sources and standards