# V1 Block 16 — Repository Adapter Checklist

Use this checklist before implementing a MongoDB runtime adapter.

## Index bootstrap

- Create every `PersistenceIndexCatalog.all` index by stable `name`.
- Treat index creation as idempotent; do not rename indexes casually.
- Enforce unique indexes before accepting writes for owner/document IDs,
  owner/project statistics, owner/notice IDs, and owner/operation IDs.
- Preserve key order exactly as declared in the catalog.
- Apply partial filter expectations where `partialFilterFields` is non-empty.

## Repository behavior

- Keep MongoDB driver types behind adapter classes; repository interfaces remain
  pure Dart.
- Scope every query by `ownerId`.
- Return deterministic ordering that matches the in-memory conformance tests.
- Implement cursor pagination without exposing raw driver cursors in public
  repository interfaces.
- Return typed `RepositoryMutationResult` failures for stale revisions,
  invalid revisions, owner mismatches, duplicate IDs, and duplicate operation
  IDs.
- Use compare-and-set writes for revisioned updates.
- Do not hard-delete authoritative task, project, locked, or settings documents
  unless a future plan explicitly adds that operation.

## Payload and retention

- Apply `PersistencePayloadLimits` before writing internal activity, operation,
  project-statistics applied IDs, and scheduling snapshot payloads.
- Retain authoritative collections indefinitely unless a later plan changes the
  product data policy.
- Apply bounded retention only to internal retained collections:
  task activities, notice acknowledgements, operation records, and scheduling
  snapshots.
- Do not denormalize hidden locked-block details into unrelated documents.

## Migration and validation

- Run V0-to-V1 migrations through `V1DocumentMigrationService` in dry-run/report
  mode before writing replacements.
- Refuse unsupported future schema versions.
- Decode all writes through V1 document codecs in tests before persisting.
- Run the repository conformance tests against the adapter before enabling it in
  application code.
