{
  "schema": "ai-02-contract-v1",
  "task": "Accept a payment.captured webhook once, apply a credit to an account, and return the same accepted outcome when the provider retries the event.",
  "provenance": "synthetic contract; not Brian's system or experience",
  "invariants": [
    "one event identity can apply at most one credit",
    "a receipt and its credit commit together",
    "a retryable failure leaves no receipt and no credit",
    "an exact duplicate changes no state",
    "a conflicting payload for an existing event is refused without mutation"
  ],
  "scenarios": [
    {
      "id": "first_delivery",
      "response": "accepted",
      "receipt": true,
      "credit": 1200,
      "retry_response": "duplicate",
      "retry_credit": 1200
    },
    {
      "id": "exact_duplicate",
      "response": "accepted",
      "receipt": true,
      "credit": 1200,
      "retry_response": "duplicate",
      "retry_credit": 1200
    },
    {
      "id": "transition_failure_then_retry",
      "response": "retryable",
      "receipt": false,
      "credit": 0,
      "retry_response": "accepted",
      "retry_credit": 1200
    },
    {
      "id": "receipt_failure_then_retry",
      "response": "retryable",
      "receipt": false,
      "credit": 0,
      "retry_response": "accepted",
      "retry_credit": 1200
    },
    {
      "id": "conflicting_payload",
      "response": "refused",
      "receipt": true,
      "credit": 1200,
      "retry_response": "not-applicable",
      "retry_credit": 1200
    }
  ]
}
