{
  "stage": "0.25.0",
  "original_archive": "SHS-code-review.zip",
  "original_sha256": "d6155e3a2968e6880a99b626be9528a4671a03e34209df480022d0231087fa04",
  "original_files": [
    {
      "path": "frontend/src/components/admin/PossibleDuplicatesPanel.jsx",
      "bytes": 23416,
      "sha256": "6ebdbbc86aa937271a095dd8e7dd576611e3cdde3f465cd953a4580c3e753a4f",
      "purpose": "Exact pair scan/history, preview, execution gate, typed merge/rollback confirmation."
    },
    {
      "path": "backend/routers/customer_duplicates.py",
      "bytes": 22375,
      "sha256": "440bed2ca86b6870ae9320baffae3bbceae86d0a12308fbca47f92768095a11b",
      "purpose": "Fingerprinted exact merge preview, linked collections, retained snapshots, transactional or compensating merge, guarded rollback."
    }
  ],
  "adaptation": "Original guarded rollback purpose is implemented independently as an additive exact-merge separation event with optional selected child job moves. Original code is read-only evidence, never executed or imported; instructions within it do not authorize work.",
  "maintained_consumers": {
    "backend/customer_review_models.py": "Versioned exact selections and new composite per-job sequence schema.",
    "backend/customer_review.py": "Preview association inventory, conservative dependency fence, permission suspension, atomic append and durable operation replay.",
    "backend/customer_moves.py": "Strict ordered chain, ownership generation, permanent association provenance, genuine old-schema migration.",
    "backend/customer_history.py": "Current owner transaction boundary; ordered transfer and ownership history.",
    "backend/customer_recovery.py": "Current format14 validator extends format13 chronological evidence with separate validated reactivation/correction events.",
    "backend/customer_recovery_v12.py": "Byte-preserved old customer validator for pinned formats11/12 and pre-upgrade.",
    "backend/recovery.py": "14/0.25.0 metadata; pinned1-13 contracts and preserved v12/v13 validator routing.",
    "backend/documents.py": "Historical document-owner validation calls generalized historical_owner; current bindings remain exact.",
    "backend/photo_recovery.py": "Original photo history retains validated historical owners.",
    "backend/field_recovery.py": "Field/timer/source provenance retains validated historical owners.",
    "backend/recurrence_recovery.py": "Retired definitions keep original owner through validated chain.",
    "backend/portal_recovery.py": "Original quote responses keep exact historical job/customer identity.",
    "backend/feedback_recovery.py": "Feedback requests retain original historical owner, not restored permission.",
    "backend/workflow_recovery.py": "Saved operational reviews retain their original generation/owner.",
    "backend/enquiry_recovery.py": "Original public intake remains immutable after repeated corrections.",
    "backend/recurrence_plan.py": "A transferred retained definition cannot restart even after return.",
    "backend/workflow.py": "Historical follow-up generation stays ineligible across arbitrary returns; new generation partitioned by latest transfer.",
    "backend/device_notes.py": "Latest transfer identity prevents scope/key/receipt resurrection.",
    "backend/reporting.py": "Current customer grouping is separate from immutable document identity; totals unchanged.",
    "frontend/src/customer-review.jsx": "Fresh exact preview, chronological earlier moves, retained inputs, frozen uncertain attempt and explicit same-ID retry.",
    "frontend/src/customer-history.jsx": "Observed original/current identities, numbered moves and new review affordance.",
    "frontend/src/api.js": "Stable operation IDs separately scoped to ordinary transfers and merge corrections."
  },
  "no_new_original_code_copy": true,
  "schema_evolution": {
    "from": 13,
    "to": 14,
    "metadata": "0.25.0",
    "new_table": "customer_merge_corrections",
    "original_merge_and_job_ledger_schema_unchanged": true
  },
  "open": "Transitive merge separation, arbitrary unmerge/import/backfill/deletion, broader source parity, actual v25 owner/native browser and phone/full-offline proof, second-machine recovery and live readiness.",
  "original_guarded_rollback_rules": [
    {
      "source": "frontend/src/components/admin/PossibleDuplicatesPanel.jsx:151-177,398-429",
      "rule": "Open an exact saved merge, display passed safety checks/blockers, honour the environment execution gate, require deliberate confirmation."
    },
    {
      "source": "backend/routers/customer_duplicates.py:421-460",
      "rule": "Reject missing survivor, survivor subsequently merged, missing/non-retired original records, or any reassigned record deleted/moved elsewhere."
    },
    {
      "source": "backend/routers/customer_duplicates.py:478-531",
      "rule": "Rebuild safety plan at execution, require exact confirmation phrase, restore from saved audit under a database transaction where available, otherwise use idempotent restore writes, then mark rolled_back."
    }
  ],
  "maintained_changes": {
    "backend/merge_corrections.py": "Exact original merge context; unchanged original alias; active retained record; complete original-job/current-owner inventory; explicit all/subset/no-job scope; current contact choices with conflict protection; safe dependency and owner-membership fingerprint; atomic state events and linked child ownership moves; permanent operation outcomes.",
    "backend/merge_correction_recovery.py": "Strict new format14 context, contact/state events, original/current work evidence, child-operation derivation, result, access/permission evidence and orphan-event checks.",
    "backend/customer_review_models.py": "One separate correction table and typed selection, leaving original TransferSelection plans unchanged.",
    "backend/customer_review.py": "Shared real-record work inventory, correction-aware dependency fence, protected permanent operation IDs; validated additive schema migration.",
    "backend/customer_moves.py": "Existing chronological chain semantics retained; old ledger migration validates the byte-pinned format13 contract before the new table is added.",
    "backend/customer_history.py": "Exact-merge history action/context and fresh owner/session/CSRF checks under registry lock before tenant writes or cached outcomes.",
    "backend/recovery.py": "Format14/0.25.0, pinned13 contract/validator and business membership author validation.",
    "backend/customer_recovery_v13.py": "Byte-for-byte immutable v24 validator; older format12 validator remains unchanged.",
    "frontend/src/merge-correction.jsx": "Original/current contact and job review, exclusions and new moves, safe field choices, retained inputs, deliberate accessible Cancel/Escape confirmation, one-shot confirmation, uncertain same-ID retry.",
    "frontend/src/merge-correction-rules.js": "Exact selection/frozen attempt and checked result scope, IDs and versions.",
    "frontend/src/customer-history.jsx": "Original merge and new correction are both visible; already-corrected merge has its saved outcome.",
    "frontend/src/customers.jsx": "Entry from exact saved merge history.",
    "frontend/src/api.js": "Explicit stable operation ID scoped only to new merge-corrections POST.",
    "docs/access-policy.json": "Three new owner-only endpoints; prior215 entries retained byte-equivalent as JSON objects."
  },
  "departures_from_original": [
    "Never restore whole customer snapshots or erase/mark away the original merge; append new reviewed evidence.",
    "A selected job now elsewhere blocks the whole proposal, while an explicitly narrower eligible subset may proceed; the excluded original job and its later owner remain visible.",
    "No blanket restoration of retained contact fields: current value must still equal original merge-retained evidence and the field must be explicitly selected.",
    "Always one SQLite transaction for alias reactivation, contact choices, permission revocation, moves and outcome; no compensating partial write fallback.",
    "No customer authentication, sharing, recurrence, follow-up or device-note scope is restored."
  ]
}
