{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/Sharathvc23/forgetproof/main/schemas/forget-me/v1/common.schema.json",
  "title": "ForgetMe v1: shared definitions",
  "description": "Types the other ForgetMe v1 schemas refer to. ForgetMe (namespace stellarminds.ai/forget-me, version \"1\", provisional) is a third-party extension proposal targeting Poppy 1.0; it is not approved, adopted or reviewed by anyone.",
  "$defs": {
    "namespace": {
      "const": "stellarminds.ai/forget-me"
    },
    "version": {
      "const": "1"
    },
    "reference": {
      "description": "An opaque reference the holder issued for one record when it stored it. Reveals nothing; bound to the owner; expires. Never an email address, a phone number or any other locator.",
      "type": "string",
      "pattern": "^fmr_[A-Za-z0-9_-]{16,48}$"
    },
    "operation-id": {
      "description": "An opaque, owner-bound operation id issued by the host that accepted the submit.",
      "type": "string",
      "pattern": "^fmo_[A-Za-z0-9_-]{16,48}$"
    },
    "idempotency-key": {
      "description": "Chosen by the client, kept for the life of one confirmation. 8 to 128 printable ASCII characters.",
      "type": "string",
      "pattern": "^[\\x21-\\x7e]{8,128}$"
    },
    "scope": {
      "type": "string",
      "enum": [
        "item",
        "account"
      ]
    },
    "choice": {
      "type": "string",
      "enum": [
        "keep",
        "delete"
      ]
    },
    "state": {
      "type": "string",
      "enum": [
        "accepted",
        "running",
        "done",
        "error"
      ]
    },
    "retention": {
      "type": "string",
      "enum": [
        "persistent",
        "none",
        "unknown"
      ]
    },
    "outcome": {
      "description": "Worst first. The overall outcome of an operation is the worst of its holders.",
      "type": "string",
      "enum": [
        "error",
        "bytes-still-found",
        "queued",
        "unsupported",
        "intentionally-retained",
        "inspected-and-clear"
      ]
    },
    "holder-name": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9_-]{0,63}$"
    },
    "date-time": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$"
    },
    "nullable-date-time": {
      "oneOf": [
        {
          "$ref": "#/$defs/date-time"
        },
        {
          "type": "null"
        }
      ]
    },
    "label": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "text": {
      "type": "string",
      "maxLength": 2000
    },
    "public-key": {
      "description": "Raw 32-byte Ed25519 public key, base64url without padding.",
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{43}$"
    },
    "fingerprint": {
      "description": "First 32 hex characters of SHA-256 over the raw public key bytes.",
      "type": "string",
      "pattern": "^[0-9a-f]{32}$"
    },
    "signature": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{86}$"
    },
    "exceptions-chosen": {
      "description": "Every exception the preview listed, decided. Keys are the exception ids from the preview.",
      "type": "object",
      "maxProperties": 64,
      "propertyNames": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128
      },
      "additionalProperties": {
        "$ref": "#/$defs/choice"
      }
    },
    "terms": {
      "description": "The exact terms: what the preview showed and what submit must echo.",
      "type": "object",
      "properties": {
        "reference": {
          "oneOf": [
            {
              "$ref": "#/$defs/reference"
            },
            {
              "type": "null"
            }
          ]
        },
        "scope": {
          "$ref": "#/$defs/scope"
        },
        "exceptions": {
          "$ref": "#/$defs/exceptions-chosen"
        }
      },
      "required": [
        "reference",
        "scope",
        "exceptions"
      ],
      "additionalProperties": false
    },
    "item": {
      "description": "What the operation is about. For scope account, reference is null and the text says how much.",
      "type": "object",
      "properties": {
        "reference": {
          "oneOf": [
            {
              "$ref": "#/$defs/reference"
            },
            {
              "type": "null"
            }
          ]
        },
        "label": {
          "$ref": "#/$defs/label"
        },
        "text": {
          "$ref": "#/$defs/text"
        },
        "kind": {
          "type": "string",
          "maxLength": 64
        },
        "saved_at": {
          "$ref": "#/$defs/nullable-date-time"
        }
      },
      "required": [
        "reference",
        "label"
      ]
    },
    "holder": {
      "description": "Who keeps the item and whether it keeps anything at all. `party` names the organisation when it is not the host itself (a recipient the host shared the item with).",
      "type": "object",
      "properties": {
        "holder": {
          "$ref": "#/$defs/holder-name"
        },
        "title": {
          "$ref": "#/$defs/label"
        },
        "kind": {
          "type": "string",
          "maxLength": 64
        },
        "retention": {
          "$ref": "#/$defs/retention"
        },
        "what": {
          "$ref": "#/$defs/text"
        },
        "party": {
          "$ref": "#/$defs/label"
        },
        "recipient": {
          "type": "string",
          "maxLength": 64
        }
      },
      "required": [
        "holder",
        "title",
        "retention"
      ]
    },
    "holder-row": {
      "description": "One holder's row in an outcome: the outcome word, what was done, the evidence (a receipt id, or null for an observation), what is unresolved, and when.",
      "type": "object",
      "properties": {
        "holder": {
          "$ref": "#/$defs/holder-name"
        },
        "title": {
          "$ref": "#/$defs/label"
        },
        "kind": {
          "type": "string",
          "maxLength": 64
        },
        "outcome": {
          "$ref": "#/$defs/outcome"
        },
        "detail": {
          "$ref": "#/$defs/text"
        },
        "receipt_id": {
          "type": "string",
          "maxLength": 128
        },
        "party": {
          "$ref": "#/$defs/label"
        },
        "action": {
          "$ref": "#/$defs/text"
        },
        "evidence": {
          "oneOf": [
            {
              "type": "string",
              "maxLength": 128
            },
            {
              "type": "null"
            }
          ]
        },
        "unresolved": {
          "oneOf": [
            {
              "$ref": "#/$defs/text"
            },
            {
              "type": "null"
            }
          ]
        },
        "at": {
          "$ref": "#/$defs/nullable-date-time"
        },
        "retained_until": {
          "$ref": "#/$defs/nullable-date-time"
        }
      },
      "required": [
        "holder",
        "title",
        "outcome"
      ]
    },
    "poppy-id": {
      "description": "An id in the URL-safe base64 alphabet, as Poppy 1.0 section 8.2 defines them (operation ids, revisions, approval references).",
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{1,256}$"
    },
    "poppy-operation": {
      "description": "An operation of Poppy's Operations extension, version 3, as a Company returns it in a 403 approval_required: the action it will perform once its exact terms are approved. The same shape as upstream's operation.schema.json (schemas/poppy-1.0-kit).",
      "type": "object",
      "properties": {
        "operation_id": {
          "$ref": "#/$defs/poppy-id"
        },
        "revision": {
          "$ref": "#/$defs/poppy-id"
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "terms": {
          "type": "object"
        },
        "expires_at": {
          "$ref": "#/$defs/date-time"
        }
      },
      "required": [
        "operation_id",
        "revision",
        "terms",
        "expires_at"
      ],
      "additionalProperties": true
    },
    "approval-offer": {
      "description": "The exact terms a recipient stated for its part of a withdrawal (Operations extension, version 3), carried on a preview exception so the person sees them before deciding: what confirming with that recipient chosen approves. operation_id, revision, summary, terms and expires_at are the recipient's own, unchanged; party names it; approver says who the recipient accepts approvals from (this extension's Companies: the person).",
      "type": "object",
      "properties": {
        "party": {
          "$ref": "#/$defs/label"
        },
        "protocol": {
          "const": "operations/3"
        },
        "approver": {
          "type": "string",
          "enum": [
            "user",
            "user-or-agent"
          ]
        },
        "operation_id": {
          "$ref": "#/$defs/poppy-id"
        },
        "revision": {
          "$ref": "#/$defs/poppy-id"
        },
        "summary": {
          "type": "string",
          "maxLength": 4000
        },
        "terms": {
          "type": "object"
        },
        "expires_at": {
          "$ref": "#/$defs/date-time"
        }
      },
      "required": [
        "operation_id",
        "revision",
        "terms",
        "expires_at"
      ],
      "additionalProperties": true
    },
    "approvals-given": {
      "description": "The person's approvals of recipients' exact terms, keyed by the exception id the preview used: the operation id and revision they saw (from the exception's `approval`), and how they answered (input_type: a short word such as tap or keyboard). A client sends an entry only for terms it showed; a host accepts only what it offered.",
      "type": "object",
      "maxProperties": 64,
      "propertyNames": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "operation_id": {
            "$ref": "#/$defs/poppy-id"
          },
          "revision": {
            "$ref": "#/$defs/poppy-id"
          },
          "input_type": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32
          }
        },
        "required": [
          "operation_id",
          "revision"
        ],
        "additionalProperties": false
      }
    }
  }
}
