{
  "schema": "vedokrok.public-item.v1",
  "release_id": "MHC-RPUB-20260920-75ad787a",
  "url": "/knowledge/stage-the-mutation-before-committing-it",
  "id": "MHC-D-RESEARCH-0343",
  "version": "0.1.0",
  "title": "Stage the mutation before committing it",
  "summary": "The safest write is often the one you can inspect before it becomes a write.",
  "kind": "protocol",
  "body": "Split the operation into two phases. First generate the proposed changes into a temporary or reviewable form. Validate counts, key fields, invariants and representative examples. Only then apply the verified mutation set. Keep the staged artifact tied to the exact source snapshot so a later apply does not silently target different input.",
  "limits": [
    "Staging does not remove concurrency, authorization or downstream-trigger risks; account for changes that can occur between preview and commit."
  ],
  "topics": [
    "union-safe-change-operations"
  ],
  "intents": [],
  "source_ids": [
    "RS-5D6BA8DCC62D671F"
  ],
  "evidence": [
    {
      "claim": "Google SRE describes two-phase mutation as storing proposed mutations temporarily, validating them, and applying them only after verification.",
      "source_id": "RS-5D6BA8DCC62D671F",
      "role": "supports",
      "note": "Two-phase mutation adds complexity and may not fit every storage system or transaction model.",
      "locator": "Idempotent and Two-Phase Mutations"
    }
  ],
  "use_when": [
    "A bulk update can be computed in advance and a wrong write would be costly to reverse."
  ],
  "avoid_when": [
    "Staging does not remove concurrency, authorization or downstream-trigger risks; account for changes that can occur between preview and commit."
  ],
  "example": "For a mass business-partner update, produce the exact keys and new values first, compare them with source data, then execute that fixed set.",
  "check": "The team can inspect exactly what will change before the authoritative state is modified.",
  "steps": [
    "Generate the candidate changes without applying them to the authoritative target.",
    "Validate the candidate set against explicit business and data invariants.",
    "Freeze or fingerprint the candidate set and its source snapshot.",
    "Apply only the reviewed candidate set, then verify the result."
  ],
  "sources": [
    {
      "id": "RS-5D6BA8DCC62D671F",
      "title": "Improve and Optimize Data Processing Pipelines",
      "url": "https://sre.google/workbook/data-processing/"
    }
  ],
  "relations": [
    {
      "from": "MHC-D-RESEARCH-0343",
      "to": "MHC-D-RESEARCH-0350",
      "type": "use_before",
      "url": "/knowledge/reconcile-what-changed-after-a-bulk-write"
    }
  ],
  "collections": [
    {
      "id": "RC-4F77BDBBF2481574",
      "title": "Change live systems without turning one mistake into a large one",
      "url": "/collections/change-live-systems-without-turning-one-mistake-into-a-large-one"
    }
  ]
}
