# Edit offline and synchronize

**Flow key:** `offline-edit-and-sync`

## Outcome

A user can make permitted offline changes, understand local state, reconnect, and converge without silent loss, duplication, or cross-account leakage.

## Actors

- User
- Local client/store
- Sync service
- Other device/collaborator

## Preconditions and entry points

- A synthetic record is cached for offline use.
- Offline capability, conflict, queue, identity-change, quota, and encryption policies are known.

## Required test data

Use synthetic, isolated, resettable data. Never use real credentials, payment instruments, private customer records, or production notifications.

| Data | Canonical valid seed | Critical variations |
|---|---|---|
| Record | `CARBON-OFFLINE-001` version 1 | deleted/permission-revoked remotely, attachment, related record |
| Offline edits | change title and note `Offline :)` | many edits, emoji/RTL, create/delete, boundary size |
| Remote edits | second device changes status | same-field conflict, record deletion, ownership change |
| Network | online then airplane/offline then reconnect | flapping, slow, captive portal, partial requests |
| Identity | same signed-in user | logout/login different account, expired token, other tenant |

## Canonical steps

Treat this as the ordinary successful path inferred from common product behavior. Adapt it to observed labels, business rules, APIs, and implementation evidence; do not invent a requirement.

| Step | User or system action | Expected evidence |
|---:|---|---|
| 1 | Load the record online and enter offline mode. | Offline availability and last-synced state are explicit. |
| 2 | Edit and save locally. | One durable local version/outbox entry appears without false server success. |
| 3 | Make compatible or conflicting remote change from another device. | Server version advances independently. |
| 4 | Reconnect. | Sync authenticates current identity, sends stable operations, and handles ordering/idempotency. |
| 5 | Resolve any conflict. | The user can understand versions and preserve intended content. |
| 6 | Reload both devices and inspect history. | Final record, queue, attachments, audit, and notifications converge exactly once. |

## Alternate paths

- Offline update
- Offline create/delete
- Automatic merge
- Manual conflict resolution
- Background sync

## Failure and recovery paths

- App crashes before local commit
- Token expires
- User switches account
- Server record deleted
- Partial batch sync/retry duplicates operations

## Completion oracle

- The stated outcome is true in visible UI and authoritative persisted state.
- Exactly one intended business result and no unintended side effect occurred.
- Identity, tenant, authorization, money/data, lifecycle, notifications, integrations, analytics, and audit agree where applicable.
- Refresh, retry, back/forward, and a second authorized read do not reveal a contradictory result.
- Any partial, delayed, canceled, failed, or unknown outcome is labeled truthfully and has a safe recovery path.

## Evidence to capture

- Entry context, actor, tenant, role, feature flags, locale, time zone, and initial identifiers/state.
- Step-level screenshots or DOM state plus request/response, correlation, job, event, and stable business IDs where available.
- Before/after authoritative records, versions, totals, permissions, lifecycle states, and downstream side effects.
- Notifications, audit events, integration deliveries, retries, deduplication, latency, and recovery evidence.
- Untested branches, unsafe-to-run cases, product decisions, and evidence tier.

## Product decisions to resolve

- Exact eligibility, required data, authorization, and validation rules.
- Which steps are synchronous, asynchronous, optional, skippable, reversible, or irreversible.
- Idempotency, concurrency, timeout, retry, cancellation, and compensation semantics.
- Retention, privacy, notification, audit, performance, accessibility, and localization commitments.

## Related CARBON items

- [pwa install and offline](../../items/specialized-controls/pwa-install-and-offline.md)
- [resilience and recovery](../../items/quality/resilience-and-recovery.md)
- [concurrency and idempotency](../../items/quality/concurrency-and-idempotency.md)
- [update](../../items/actions/update.md)

[Back to Resilience and privacy flows](index.md)
