{
  "kind": "guardian-predeclared-repair-cases",
  "schema_version": 1,
  "source_commit": "57923ca70a2b3b2552f62d2be0a51aafacfa765e",
  "source_sha256": {
    "api/orders.py": "e10dfe95999fbb8c616611c8ce7c937fe38851979b1d35b7e78d693dbdd702d1",
    "api/product.py": "fbf62d6935909399da8609666fc3dc7c72e1dcf8393f955c20962d8547b49058",
    "api/server.py": "b6868af83ff2331f5a64d6fd5a976d831efe9862844cba76a758666abf5fa099"
  },
  "policy_sha256": "509f809232d33e294029a8ff106c522deb5aae956dcffb59356f8a40371dc496",
  "cases": [
    {
      "id": "unchanged",
      "title": "Unchanged accepted backend",
      "kind": "baseline",
      "gate_prediction": "accepted",
      "expected_duo_outcome": "no_repair_needed",
      "patches": []
    },
    {
      "id": "case_sensitive_header",
      "title": "Read the idempotency header case-sensitively",
      "kind": "unsafe",
      "gate_prediction": "rejected",
      "expected_duo_outcome": "repair",
      "patches": [
        {
          "file": "api/server.py",
          "before": "self.headers.get(\"Idempotency-Key\")",
          "after": "dict(self.headers.items()).get(\"Idempotency-Key\")"
        }
      ]
    },
    {
      "id": "global_retry_key",
      "title": "Look up retry identities across accounts",
      "kind": "unsafe",
      "gate_prediction": "rejected",
      "expected_duo_outcome": "repair",
      "patches": [
        {
          "file": "api/orders.py",
          "before": "WHERE a.account_id = ? AND a.namespace = ? AND a.client_key = ?",
          "after": "WHERE ? IS NOT NULL AND a.namespace = ? AND a.client_key = ?"
        },
        {
          "file": "api/orders.py",
          "before": "SELECT * FROM orders WHERE account_id = ? AND operation_key = ?",
          "after": "SELECT * FROM orders WHERE ? IS NOT NULL AND operation_key = ?"
        }
      ]
    },
    {
      "id": "expire_on_restart",
      "title": "Lose retry mappings at a server restart (deterministic expiry stand-in)",
      "kind": "unsafe",
      "gate_prediction": "rejected",
      "expected_duo_outcome": "repair",
      "patches": [
        {
          "file": "api/orders.py",
          "before": "            _restore_raw_operation_keys(connection)",
          "after": "            _restore_raw_operation_keys(connection)\n            connection.execute(\"DELETE FROM operation_aliases\")\n            connection.execute(\"UPDATE orders SET operation_key = 'expired:' || order_id\")"
        }
      ]
    },
    {
      "id": "payload_similarity",
      "title": "Merge identical purchases using payload similarity",
      "kind": "unsafe",
      "gate_prediction": "rejected",
      "expected_duo_outcome": "repair",
      "patches": [
        {
          "file": "api/orders.py",
          "before": "operation_key = select_operation_key(modern_key, legacy_key)",
          "after": "operation_key = \"payload:\" + str(payload.get(\"productId\")) + \":\" + str(payload.get(\"quantity\"))"
        }
      ]
    },
    {
      "id": "rollback_alias_dependency",
      "title": "Leave canonical keys unreadable by the original backend on rollback",
      "kind": "unsafe",
      "gate_prediction": "rejected",
      "expected_duo_outcome": "repair",
      "patches": [
        {
          "file": "api/orders.py",
          "before": "(order_id, account, operation_key, product_id, quantity, PRICE_CENTS * quantity, \"USD\"),",
          "after": "(order_id, account, LEGACY_CANDIDATE_PREFIX + operation_key, product_id, quantity, PRICE_CENTS * quantity, \"USD\"),"
        }
      ]
    },
    {
      "id": "new_retry_receipt",
      "title": "Return a new receipt identifier on retry",
      "kind": "unsafe",
      "gate_prediction": "rejected",
      "expected_duo_outcome": "repair",
      "patches": [
        {
          "file": "api/orders.py",
          "before": "\"orderId\": row[\"order_id\"],",
          "after": "\"orderId\": str(uuid.uuid4()) if replayed else row[\"order_id\"],"
        }
      ]
    },
    {
      "id": "missing_stable_identity",
      "title": "Keep the declared unidentified client blocked",
      "kind": "missing_identity",
      "gate_prediction": "blocked",
      "expected_duo_outcome": "refuse_without_commit",
      "patches": []
    },
    {
      "id": "benign_comment",
      "title": "Harmless backend comment",
      "kind": "benign",
      "gate_prediction": "accepted",
      "expected_duo_outcome": "no_repair_needed",
      "patches": [
        {
          "file": "api/orders.py",
          "before": "ALIAS_NAMESPACE = \"orders/v2\"",
          "after": "# A formatting-only fixture; operation identity remains explicit.\nALIAS_NAMESPACE = \"orders/v2\""
        }
      ]
    }
  ],
  "limits": [
    "Predictions precede execution and are not results.",
    "The original proposed TTL fault uses deterministic key loss at restart, not a wall-clock TTL test.",
    "Rollback case models alias-dependent keys; it does not claim a dropped-table implementation.",
    "The missing-identity row uses the existing trusted branch profile, not a new hosted branch.",
    "Any missed fault is retained; frozen clients, assertions and gate checks are not changed.",
    "Duo outcomes remain not_run until separately authorized hosted execution."
  ]
}
