miroir/crates/miroir-proxy/tests
jedarden ac1a0a8a81 P5.8 §13.8: Anti-entropy shard reconciler (OP#1 closure)
Implement the anti-entropy shard reconciler to detect and repair
replica drift using the fingerprint → diff → repair pipeline.

**Step 1 — Fingerprint**: iterate docs with filter=_miroir_shard={id}
paginated; hash(primary_key || canonical_content_hash); fold into
streaming xxh3 digest keyed by PK. All replicas produce same root.

**Step 2 — Diff on mismatch**: recompute per-bucket (pk-hash % 256)
digests, locate divergent buckets, enumerate divergent PKs.

**Step 3 — Repair**:
- For each divergent PK, read doc from each replica
- If any replica has _miroir_expires_at <= now: DELETE from all replicas
- Else: pick authoritative by highest _miroir_updated_at
- PUT to all replicas that disagree with origin=antientropy

**TTL interaction** (§13.14): AE treats any replica's expires_at <= now
as "delete from all" — the "highest updated_at wins" rule is suspended
for expired docs.

**Scaling mode** (plan §14.6): Mode A — each pod fingerprints and
repairs only its rendezvous-owned shards (shard_id % num_pods == pod_id).

**Config** (plan §4):
```yaml
anti_entropy:
  enabled: true
  schedule: "every 6h"
  shards_per_pass: 0
  max_read_concurrency: 2
  fingerprint_batch_size: 1000
  auto_repair: true
  updated_at_field: _miroir_updated_at
```

**Metrics**: miroir_antientropy_shards_scanned_total,
miroir_antientropy_mismatches_found_total,
miroir_antientropy_docs_repaired_total,
miroir_antientropy_last_scan_completed_seconds

**Acceptance**:
-  Induce divergence on 1 shard; reconciler detects and repairs
-  Expired-doc test: stale write does NOT resurrect expired doc
-  CDC subscribers do NOT see anti-entropy writes (origin tag)
-  Mode A: 3 pods, each owns ~1/3 of shards; AE runs once per shard

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 11:23:36 -04:00
..
docker_compose_integration.rs P9.2: Integration test harness with docker-compose 2026-05-23 07:33:34 -04:00
header_contract.rs P2.10: Implement custom HTTP header contract test suite 2026-05-20 07:14:53 -04:00
p2_phase2_dod.rs P10.2: nodeMasterKey zero-downtime rotation flow 2026-04-19 15:49:40 -04:00
p3_phase3_task_registry.rs P5.5.b: Fix verify phase parallel execution + test compilation 2026-05-23 07:59:14 -04:00
p5_5_two_phase_settings_broadcast.rs P5.5 §13.5 Two-phase settings broadcast + drift reconciler (OP#4) 2026-05-05 12:50:25 -04:00
p5_8_a_anti_entropy_fingerprint.rs P5.8 §13.8: Anti-entropy shard reconciler (OP#1 closure) 2026-05-23 11:23:36 -04:00
p5_8_b_anti_entropy_diff.rs P5.8 §13.8: Anti-entropy shard reconciler (OP#1 closure) 2026-05-23 11:23:36 -04:00
p5_14_ttl_automatic_expiration.rs P5.8 §13.8: Anti-entropy shard reconciler (OP#1 closure) 2026-05-23 11:23:36 -04:00
p7_1_core_metrics.rs P7.1: Core metrics families acceptance tests 2026-05-23 02:29:28 -04:00
p7_5_structured_logging.rs P3.3.d: Fix compilation - add missing local_search_ui_rate_limiter field 2026-04-26 11:18:02 -04:00
p10_5_scoped_key_rotation.rs P3: Task Registry + Persistence — 14-table SQLite schema, Redis mirror, Helm validation 2026-04-24 15:50:20 -04:00
p10_admin_session_revocation.rs P3: Task Registry + Persistence — 14-table SQLite schema, Redis mirror, Helm validation 2026-04-24 15:50:20 -04:00
p13_6_session_pinning.rs P5.6 §13.6: Add integration tests for session pinning 2026-05-23 00:57:18 -04:00
p13_7_alias_resolution.rs P5.7 §13.7: Add atomic index alias integration tests 2026-05-23 00:48:14 -04:00
p13_7_full_alias_integration.rs P5.7 §13.7: Add atomic index alias integration tests 2026-05-23 00:48:14 -04:00
p24_index_lifecycle.rs P2.4: Fix build and test for index lifecycle endpoints 2026-04-19 07:49:46 -04:00
p29_reserved_field_rejection.rs miroir-zc2.3: Validate 2× transient load caveat for online resharding (P12.OP3) 2026-05-20 07:24:22 -04:00
README_integration.md P9.2: Integration test harness with docker-compose 2026-05-23 07:33:34 -04:00