{
  "type": "object",
  "properties": {
    "schema_version": {
      "type": "integer",
      "enum": [
        1
      ]
    },
    "observed_at": {
      "type": "string",
      "format": "date-time"
    },
    "stale_after_seconds": {
      "type": "integer",
      "minimum": 1
    },
    "run_state": {
      "type": "string"
    },
    "executor": {
      "type": "object",
      "properties": {
        "child_id": {
          "type": "string",
          "minLength": 1
        },
        "model": {
          "type": "string"
        },
        "effort": {
          "type": "string"
        },
        "host": {
          "type": "string"
        },
        "startup_confirmed": {
          "type": "boolean"
        },
        "observed_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "criteria": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/criterion"
      }
    },
    "workers": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/worker"
      }
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "owner": {
            "type": "string",
            "enum": [
              "parent",
              "child"
            ]
          },
          "state": {
            "type": "string"
          },
          "time": {
            "type": "string",
            "format": "date-time"
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "owner",
          "text"
        ],
        "additionalProperties": false
      }
    },
    "decisions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "resume_point": {
      "type": "string"
    },
    "recovery_state": {
      "type": "string"
    }
  },
  "required": [
    "schema_version"
  ],
  "additionalProperties": false,
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:missive-board-status:v1",
  "title": "Strict board snapshot or receipt",
  "$comment": "Each status.json, assignments.json, or receipts/*.json uses this shape. All PASS entries need proof refs. SENT prompt history needs content or a root-relative immutable file, SHA256, sent_at and a registered worker ID. Absent observations are UNKNOWN. Update atomically, render on status events, then publish the assembled board. Never infer live state from reload.",
  "$defs": {
    "proof": {
      "type": "object",
      "properties": {
        "ref": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "artifact",
            "screenshot",
            "provider",
            "review",
            "test"
          ]
        }
      },
      "required": [
        "ref"
      ],
      "additionalProperties": false
    },
    "prompt": {
      "type": "object",
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "PLANNED",
            "SENT"
          ]
        },
        "content": {
          "type": "string",
          "minLength": 1
        },
        "prompt_file": {
          "type": "string",
          "minLength": 1
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "sent_at": {
          "type": "string",
          "format": "date-time"
        },
        "note": {
          "type": "string"
        }
      },
      "required": [
        "state"
      ],
      "additionalProperties": false
    },
    "worker": {
      "type": "object",
      "properties": {
        "child_id": {
          "type": "string",
          "minLength": 1
        },
        "parent_id": {
          "type": "string",
          "minLength": 1
        },
        "role": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "enum": [
            "ACTIVE",
            "RUNNING",
            "WAITING",
            "QUEUED",
            "BLOCKED",
            "DONE",
            "STALLED",
            "UNKNOWN"
          ]
        },
        "observed_at": {
          "type": "string",
          "format": "date-time"
        },
        "deliverables": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "mode": {
          "type": "string",
          "enum": [
            "READ_ONLY",
            "ISOLATED_PATCH",
            "SERIAL_INTEGRATION"
          ]
        },
        "prompt_history": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/prompt"
          }
        }
      },
      "required": [
        "child_id",
        "role",
        "status",
        "deliverables"
      ],
      "additionalProperties": false
    },
    "criterion": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "PENDING",
            "REUSE_CHECK_PENDING",
            "PASS",
            "FAIL",
            "BLOCKED",
            "DEFERRED_BY_USER"
          ]
        },
        "proof": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/proof"
          }
        },
        "note": {
          "type": "string"
        }
      },
      "required": [
        "status",
        "proof"
      ],
      "additionalProperties": false
    }
  }
}
