{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/fractionalteams-com/json-schema/fractionalteams-com-readiness-target-schema.json",
  "title": "ReadinessTarget",
  "x-generated": "2026-11-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/fractionalteams-com-api-openapi.json#/components/schemas/ReadinessTarget",
  "type": "object",
  "required": [
    "domain",
    "enabled",
    "latest"
  ],
  "properties": {
    "domain": {
      "type": "string"
    },
    "enabled": {
      "type": "boolean"
    },
    "latest": {
      "description": "The latest complete scan row with its summary, or null if never scanned",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "allOf": [
            {
              "$ref": "#/$defs/ReadinessScanRow"
            },
            {
              "type": "object",
              "properties": {
                "summary": {
                  "$ref": "#/$defs/ReadinessSummary"
                }
              }
            }
          ]
        }
      ]
    },
    "history": {
      "type": "array",
      "description": "Present when ?history was given",
      "items": {
        "$ref": "#/$defs/ReadinessScanRow"
      }
    }
  },
  "$defs": {
    "ReadinessScanRow": {
      "type": "object",
      "required": [
        "scan_id",
        "engine",
        "status",
        "started_at"
      ],
      "properties": {
        "scan_id": {
          "type": "integer"
        },
        "engine": {
          "type": "string",
          "enum": [
            "portal",
            "ora"
          ],
          "description": "portal = the Fractional Teams scan; ora = an ora.ai read stored for calibration"
        },
        "engine_version": {
          "type": [
            "string",
            "null"
          ]
        },
        "standard_version": {
          "type": [
            "string",
            "null"
          ],
          "description": "e.g. \"AgentReady 1.0\""
        },
        "status": {
          "type": "string",
          "enum": [
            "running",
            "complete",
            "partial",
            "failed",
            "blocked"
          ]
        },
        "triggered_by": {
          "type": "string",
          "description": "timer, cli, or admin:<id>"
        },
        "started_at": {
          "type": "string"
        },
        "finished_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "score": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0,
          "maximum": 100
        },
        "grade": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "A+",
            "A",
            "B",
            "C",
            "D",
            "F",
            null
          ]
        },
        "conforms": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether every applicable MUST of AgentReady v1.0 passed (null for ora rows)"
        },
        "fetch_count": {
          "type": [
            "integer",
            "null"
          ]
        },
        "error": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "ReadinessSummary": {
      "type": "object",
      "description": "The scan summary: score, grade, layers (Find / Read / Act with per-check status and points), actionable (ranked fixes with estimated gain), passing, bonusOpportunities, conformance (per AR-* requirement) and diff against the previous scan.",
      "required": [
        "engine",
        "domain",
        "scannedAt",
        "score",
        "layers"
      ],
      "properties": {
        "engine": {
          "type": "string"
        },
        "domain": {
          "type": "string"
        },
        "scannedAt": {
          "type": "string",
          "format": "date-time"
        },
        "status": {
          "type": "string"
        },
        "score": {
          "type": [
            "number",
            "null"
          ]
        },
        "grade": {
          "type": [
            "string",
            "null"
          ]
        },
        "gradeLabel": {
          "type": [
            "string",
            "null"
          ]
        },
        "developerCapability": {
          "type": "boolean"
        },
        "layers": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "actionable": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "conformance": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": true
        },
        "diff": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    }
  }
}