{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "v": {
      "type": "number",
      "const": 1,
      "description": "Protocol major version."
    },
    "type": {
      "type": "string",
      "const": "feedback"
    },
    "id": {
      "type": "string",
      "pattern": "^evt_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "description": "The event's own id. Stable across a retry of the same event."
    },
    "ts": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
      "description": "When it happened, by Chips' clock. Stamped on the way in; a value the sender writes is replaced."
    },
    "workspace_id": {
      "type": "string",
      "pattern": "^ws_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "description": "A workspace identifier: `ws_` followed by a ULID."
    },
    "space_id": {
      "description": "The space, when the event belongs to one.",
      "type": "string",
      "pattern": "^spc_[0-7][0-9A-HJKMNP-TV-Z]{25}$"
    },
    "run_id": {
      "description": "The run, when the event belongs to one.",
      "type": "string",
      "pattern": "^run_[0-7][0-9A-HJKMNP-TV-Z]{25}$"
    },
    "seq": {
      "description": "Assigned by the server on append, monotonic per workspace. Absent on the way in.",
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "idempotency_key": {
      "description": "Required on every client-originated write. Sending the same key twice is a no-op.",
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "actor": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "person",
            "harness",
            "agent",
            "system"
          ],
          "description": "Whether a person, a harness, one of a harness's agents or Chips itself acted."
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "The participant id, or `system` for Chips."
        },
        "harness_id": {
          "description": "For an agent: the harness it speaks through, whose budget and runs are the agent's (ADR 0087). Filled in by Chips.",
          "type": "string",
          "pattern": "^hrn_[0-7][0-9A-HJKMNP-TV-Z]{25}$"
        }
      },
      "required": [
        "kind",
        "id"
      ],
      "description": "The participant an event is attributed to."
    },
    "message_id": {
      "type": "string",
      "pattern": "^msg_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "description": "The message it is about: one a harness said, in the space the event names."
    },
    "kind": {
      "type": "string",
      "enum": [
        "reaction",
        "correction"
      ],
      "description": "A light signal, or a written note."
    },
    "reaction": {
      "description": "The emoji, when the kind is `reaction`. Required then.",
      "type": "string",
      "minLength": 1,
      "maxLength": 16
    },
    "text": {
      "description": "What went wrong, when the kind is `correction`. Required then.",
      "type": "string",
      "minLength": 1,
      "maxLength": 4000
    },
    "from": {
      "type": "object",
      "properties": {
        "participant_id": {
          "type": "string",
          "minLength": 1,
          "description": "The stable id of the sender."
        },
        "kind": {
          "type": "string",
          "enum": [
            "person",
            "harness",
            "agent"
          ],
          "description": "Whether the sender is a person or an agent (ADR 0087); `harness` for a harness written before agents, and for any agent as a harness that has not declared `agents` is told it."
        },
        "display_name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120,
          "description": "The name to show."
        },
        "role": {
          "type": "string",
          "enum": [
            "owner",
            "member",
            "guest"
          ],
          "description": "The sender's standing in this space. Multi-user is Chips' job, not the harness's."
        },
        "workspace_role": {
          "description": "A person's standing in the workspace (SEC-15): what a model should weigh the words by, since a guest's read as the owner's otherwise. `promptFor` says it after the name. Absent for an agent or a harness, and from a Chips before it said.",
          "type": "string",
          "enum": [
            "owner",
            "admin",
            "member",
            "guest"
          ]
        }
      },
      "required": [
        "participant_id",
        "kind",
        "display_name",
        "role"
      ],
      "description": "Who gave it. Filled in by Chips from the credential and the membership; a value the sender writes is replaced."
    }
  },
  "required": [
    "v",
    "type",
    "id",
    "ts",
    "workspace_id",
    "actor",
    "message_id",
    "kind",
    "from"
  ],
  "description": "A reaction, or a note about what went wrong, on one of the harness's messages.",
  "$id": "https://chipschat.ai/schema/v1/feedback.json",
  "title": "Feedback"
}
