{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.8/agentInterface/proposals.schema.json",
  "$comment": "OpenEik 0.6: folded by tools/fold-schemas-0.6.mjs from the proposal agentInterface, which 0.6 makes a rule (open questions, 146). Written by hand, not generated.",
  "title": "The proposals an agent host keeps",
  "description": "The answer of proposals (Part VII, 10.2, rule 4): a page of the proposals the host keeps, each row its id, its state, its intent, its agent, how many commands it holds and when it was made; or one proposal whole, its kept form, its state, when it was made and, once a person decided it, by whom, when, and the sequence or the version its commands made.",
  "oneOf": [
    {
      "$ref": "#/$defs/list"
    },
    {
      "$ref": "#/$defs/one"
    }
  ],
  "$defs": {
    "state": {
      "description": "open until a person decides it, then accepted or declined (Part VII, 10.2, rule 4).",
      "enum": [
        "open",
        "accepted",
        "declined"
      ]
    },
    "at": {
      "type": "string",
      "format": "date-time",
      "minLength": 1,
      "maxLength": 64
    },
    "list": {
      "type": "object",
      "properties": {
        "columns": {
          "const": [
            "id",
            "state",
            "intent",
            "agent",
            "commands",
            "made"
          ]
        },
        "rows": {
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              {
                "$ref": "#/$defs/state"
              },
              {
                "oneOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              {
                "oneOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              {
                "type": "integer",
                "minimum": 0
              },
              {
                "oneOf": [
                  {
                    "$ref": "#/$defs/at"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            ],
            "minItems": 6,
            "maxItems": 6
          }
        },
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "returned": {
          "type": "integer",
          "minimum": 0
        },
        "offset": {
          "type": "integer",
          "minimum": 0
        },
        "nextOffset": {
          "oneOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "null"
            }
          ]
        },
        "truncated": {
          "type": "boolean"
        },
        "sequence": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "columns",
        "rows",
        "total",
        "returned",
        "offset",
        "nextOffset",
        "truncated",
        "sequence"
      ]
    },
    "one": {
      "type": "object",
      "properties": {
        "proposal": {
          "$ref": "../hostKept/kept.schema.json"
        },
        "state": {
          "$ref": "#/$defs/state"
        },
        "made": {
          "description": "When the proposal was made, and the host's sequence then.",
          "type": "object",
          "properties": {
            "at": {
              "$ref": "#/$defs/at"
            },
            "sequence": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "at"
          ]
        },
        "decided": {
          "description": "Once a person decided it: by whom, when, how, and the sequence or the version its commands made where it was accepted.",
          "type": "object",
          "properties": {
            "at": {
              "$ref": "#/$defs/at"
            },
            "by": {
              "type": "string",
              "minLength": 1
            },
            "state": {
              "enum": [
                "accepted",
                "declined"
              ]
            },
            "sequence": {
              "type": "integer",
              "minimum": 0
            },
            "version": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          "required": [
            "at",
            "by",
            "state"
          ]
        },
        "refused": {
          "description": "Where a person's acceptance was refused, and the proposal stays open: by whom, when, and why.",
          "type": "object",
          "properties": {
            "at": {
              "$ref": "#/$defs/at"
            },
            "by": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "at",
            "by"
          ]
        }
      },
      "required": [
        "proposal",
        "state",
        "made"
      ],
      "if": {
        "properties": {
          "state": {
            "enum": [
              "accepted",
              "declined"
            ]
          }
        }
      },
      "then": {
        "required": [
          "decided"
        ]
      }
    }
  }
}
