avniproject / avniproject/snapshot-server

Define and apply entity exclusion list for snapshots

Open
#1 2 comments 0 reactions 1 assignee Claimed by @ombhardwajj View on GitHub
Dominant language
JavaScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### Background

Parent: avniproject/avni-client#1942. Snapshot-server runs against a read replica, so any pulled entity whose sync path issues an `UPDATE` on avni-server breaks the run. Some other entity types must be excluded for separate reasons — per-user/device identity, telemetry (upload-only), or device-local state. Today the snapshot-server omits some of these implicitly; this card makes the full list explicit in code with a single source of truth and a rationale per entry.

### Scope

Add a named constant in snapshot-server listing entity types to exclude. Apply it during snapshot generation. Document the rationale alongside the list.

### Exclusion list

```
IdentifierAssignment - read-replica blocker: pulling this triggers
PrefixedUserPoolBasedIdentifierGenerator,
which UPDATEs identifier_user_assignment to
top up the pool. On a read-only replica that
UPDATE fails and the whole sync request 500s.
Confirmed in prod-read-replica testing.
SyncTelemetry - upload-only (syncPullRequired: false)
VideoTelemetric - upload-only
RuleFailureTelemetry - upload-only
EntityApprovalStatus - syncPullRequired=true in openchs-models, so
this IS pulled by the device on incremental
sync. Safe to exclude from the snapshot
because the first incremental sync after
restore will re-pull it. Verify approval-
gated screens render correctly in that gap.
DraftSubject - device-local
DraftEncounter - device-local
DraftEnrolment - device-local
DraftProgramEncounter - device-local
EntityQueue - device-local pending-upload tracking
MediaQueue - device-local pending-upload tracking
Settings - device-local
LocaleMapping - device-local
MyGroups - per-user; already implicitly excluded
UserSubjectAssignment - per-user; already implicitly excluded
```

`News` is intentionally included. `UserInfo` is intentionally included — required for the client identity check at `BackupRestoreSqliteService.js:110-116`.

### Acceptance criteria

- [ ] Exclusion list is a named constant in snapshot-server code with a one-line rationale per entry.
- [ ] Snapshot generation skips all listed entities (no API fetches for them; no rows in output).
- [ ] Automated assertion: snapshot generated for a fixture user has zero rows for every excluded type.
- [ ] Manual verification (or automated equivalent): a device restored from a snapshot lands on approval-gated screens without errors before the first incremental sync completes; immediately after the first incremental sync, `EntityApprovalStatus` rows are present and screens behave normally.
- [ ] `UserInfo` continues to be included.
- [ ] README note: when avni-client `EntityMetaData` adds a new synced type, evaluate it against this list before next rollout wave.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.