From 0ad96cd38e2b3d479e5454fb633b99d9d9c8279a Mon Sep 17 00:00:00 2001 From: jedarden Date: Sun, 24 May 2026 17:38:23 -0400 Subject: [PATCH] feat(reshard): tag backfill writes with _miroir_origin for CDC suppression (P5.1.c, miroir-uhj.1.3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per plan §13.1 step 3, backfill writes must be tagged with _miroir_origin: reshard_backfill so that §13.13 CDC suppresses them by default. This ensures that shadow-index writes during backfill do not generate duplicate CDC events for client writes (only the live-index write emits an event). Changes: - Add _miroir_origin field to shadow documents in process_reshard_chunk - Remove unnecessary X-Miroir-Origin header (field-based tagging is canonical) - Aligns with dual-write preparation code (reshard.rs line 1779) Closes: miroir-uhj.1.3 --- crates/miroir-core/src/mode_c_worker/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/miroir-core/src/mode_c_worker/mod.rs b/crates/miroir-core/src/mode_c_worker/mod.rs index 20621d8..a7e78b1 100644 --- a/crates/miroir-core/src/mode_c_worker/mod.rs +++ b/crates/miroir-core/src/mode_c_worker/mod.rs @@ -641,6 +641,9 @@ impl ModeCWorker { // Clone document and update _miroir_shard field let mut shadow_doc = doc.clone(); shadow_doc["_miroir_shard"] = serde_json::json!(new_shard_id); + // Tag with _miroir_origin for CDC suppression (plan §13.1, §13.13) + // Backfill writes are suppressed from CDC by default + shadow_doc["_miroir_origin"] = serde_json::json!(ORIGIN_RESHARD_BACKFILL); shadow_documents.push(shadow_doc); } @@ -655,7 +658,6 @@ impl ModeCWorker { let response = client .post(&write_url) .header("Authorization", format!("Bearer {}", node_master_key)) - .header("X-Miroir-Origin", ORIGIN_RESHARD_BACKFILL) .json(&shadow_documents) .send() .await