{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://askvouch.com/schemas/deal-package-readiness/disposition/v0.2.0/disposition.schema.json",
  "title": "Lending Deal-Package Readiness — disposition message",
  "description": "The funder's machine-readable response to a submitted pack — the other half of 'the agent proposes; provenance and deterministic gates dispose'. Deliberately minimal: five states (code list disposition_status), structured decline reasons (code list decline_reason), and instance-qualified field_ids for information requests, which a producer's chase engine can act on directly. Offer terms / pricing travel OUTSIDE this standard (non-goal). See spec/disposition.md.",
  "type": "object",
  "required": [
    "standard",
    "disposition_version",
    "pack_ref",
    "status",
    "timestamp"
  ],
  "properties": {
    "standard": {
      "const": "lending-deal-package-readiness/disposition"
    },
    "disposition_version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$"
    },
    "pack_ref": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$",
      "description": "Content identity of the pack being disposed: 'sha256:' + 64 lowercase hex, as produced by the reference validator's pack_ref(). Both sides can prove WHICH version of the pack was disposed. NB: this is a CONTENT identifier, not an authenticity proof — it binds the disposition to specific bytes, it does not attest who sent them (see spec Security Considerations)."
    },
    "status": {
      "description": "Code list disposition_status (code-lists.v0.json).",
      "enum": [
        "received",
        "in_review",
        "info_requested",
        "declined",
        "offer_issued"
      ]
    },
    "info_requested": {
      "type": "object",
      "required": [
        "field_ids"
      ],
      "additionalProperties": false,
      "properties": {
        "field_ids": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string"
          },
          "description": "Catalogue field ids ('financials.statutory_accounts'), instance-qualified where needed ('guarantor:2.guarantor_id'). Validated against the catalogue by the reference validator."
        },
        "detail": {
          "type": "string"
        }
      }
    },
    "declined": {
      "type": "object",
      "required": [
        "reason_code"
      ],
      "additionalProperties": false,
      "properties": {
        "reason_code": {
          "type": "string",
          "description": "Code list decline_reason (code-lists.v0.json)."
        },
        "detail": {
          "type": "string"
        }
      }
    },
    "actor": {
      "type": "string",
      "description": "Who disposed — a system name for deterministic gates, or a named underwriter + capacity for human decisions."
    },
    "timestamp": {
      "type": "string"
    }
  },
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "info_requested"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "required": [
          "info_requested"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "const": "declined"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "required": [
          "declined"
        ]
      }
    },
    {
      "if": {
        "required": [
          "info_requested"
        ]
      },
      "then": {
        "properties": {
          "status": {
            "const": "info_requested"
          }
        },
        "required": [
          "status"
        ]
      }
    },
    {
      "if": {
        "required": [
          "declined"
        ]
      },
      "then": {
        "properties": {
          "status": {
            "const": "declined"
          }
        },
        "required": [
          "status"
        ]
      }
    }
  ]
}
