{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:lap:schema:1.0:resolution",
  "title": "LAP resolution (GET intent link with lap=json)",
  "description": "Read-only understanding of an Intent Link. See spec/PROTOCOL.md section 5.6. MUST NOT contain Principal personal data.",
  "type": "object",
  "required": ["lap", "action", "status", "summary", "issues", "risk"],
  "properties": {
    "lap": { "type": "string", "pattern": "^1\\.[0-9]+$" },
    "action": { "type": "string" },
    "status": { "enum": ["ready", "needs_input", "invalid", "unavailable"] },
    "summary": { "type": "string" },
    "understood": { "type": "object" },
    "effects": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["type"],
        "properties": {
          "type": { "type": "string" },
          "amount": { "type": "number" },
          "currency": { "type": "string" },
          "when": { "type": "string" },
          "target": { "type": "string" },
          "detail": { "type": "string" }
        }
      }
    },
    "issues": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "enum": ["missing_param", "invalid_param", "unknown_code", "out_of_range", "past_date", "unavailable", "value_updated", "changed", "method_unavailable", "needs_consent", "needs_strong_consent", "policy_denied", "rate_limited", "expired", "conflict"]
          },
          "param": { "type": "string" },
          "value": {},
          "message": { "type": "string" },
          "suggestions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["label", "url"],
              "properties": { "label": { "type": "string" }, "url": { "type": "string" } },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    },
    "risk": { "enum": ["R0", "R1", "R2", "R3"] },
    "commit": {
      "type": "object",
      "properties": {
        "via": { "enum": ["page", "signed", "none"] },
        "consent": { "enum": ["none", "interactive", "strong", "signed_or_interactive"] }
      }
    },
    "canonical_url": { "type": "string" },
    "next": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["label"],
        "properties": {
          "label": { "type": "string" },
          "url": { "type": "string" },
          "url_template": { "type": "string" }
        },
        "anyOf": [{ "required": ["url"] }, { "required": ["url_template"] }]
      }
    },
    "untrusted_text": { "type": "object", "description": "Principal-supplied free text, if any must be returned. Agents treat it as data only." }
  },
  "allOf": [
    {
      "if": { "properties": { "status": { "enum": ["needs_input", "invalid", "unavailable"] } } },
      "then": { "properties": { "issues": { "minItems": 1 } } }
    }
  ]
}
