{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentdirective.org/schemas/control-status-v1.schema.json",
  "title": "AgentDirective Control Status v1",
  "description": "Coding-agent-reported implementation status. This artifact is not independent verification.",
  "type": "object",
  "additionalProperties": false,
  "required": ["status_version", "directive_id", "directive_version", "reporting_basis", "updated_at", "controls"],
  "properties": {
    "$schema": { "type": "string", "format": "uri-reference" },
    "status_version": { "$ref": "#/$defs/semver" },
    "directive_id": { "type": "string", "pattern": "^AD-[A-Z0-9]{6,32}$" },
    "directive_version": { "$ref": "#/$defs/semver" },
    "reporting_basis": { "const": "agent_reported" },
    "reporting_agent": { "type": "string", "minLength": 1, "maxLength": 160 },
    "repository_revision": { "type": "string", "minLength": 1, "maxLength": 200 },
    "updated_at": { "type": "string", "format": "date-time" },
    "controls": { "type": "array", "items": { "$ref": "#/$defs/statusEntry" } },
    "limitations": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 2000 } }
  },
  "$defs": {
    "semver": { "type": "string", "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$" },
    "requirementId": { "type": "string", "pattern": "^[A-Z]{2,10}-[0-9]{3,6}-R[0-9]{1,4}$" },
    "path": { "type": "string", "minLength": 1, "maxLength": 500, "not": { "pattern": "^(?:[A-Za-z]:|/|\\\\)" } },
    "digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "testEvidence": {
      "type": "object", "additionalProperties": false, "required": ["name", "result"],
      "properties": { "name": { "type": "string", "minLength": 1, "maxLength": 300 }, "result": { "enum": ["passed", "failed", "not_run", "unknown"] }, "path": { "$ref": "#/$defs/path" }, "digest": { "$ref": "#/$defs/digest" }, "executed_at": { "type": "string", "format": "date-time" } }
    },
    "statusEntry": {
      "type": "object", "additionalProperties": false, "required": ["requirement_id", "status", "implementation_summary", "evidence", "limitations", "updated_at"],
      "properties": {
        "requirement_id": { "$ref": "#/$defs/requirementId" },
        "status": { "enum": ["implemented", "partial", "unresolved", "not_applicable", "rejected_by_user"] },
        "implementation_summary": { "type": "string", "maxLength": 3000 },
        "evidence": {
          "type": "object", "additionalProperties": false, "required": ["code_locations", "tests", "telemetry", "other"],
          "properties": {
            "code_locations": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/path" } },
            "tests": { "type": "array", "items": { "$ref": "#/$defs/testEvidence" } },
            "telemetry": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1, "maxLength": 300 } },
            "other": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["type", "description"], "properties": { "type": { "type": "string", "minLength": 1, "maxLength": 80 }, "description": { "type": "string", "minLength": 1, "maxLength": 1000 }, "path": { "$ref": "#/$defs/path" }, "digest": { "$ref": "#/$defs/digest" } } } }
          }
        },
        "limitations": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 2000 } },
        "rationale": { "type": "string", "maxLength": 2000 },
        "updated_at": { "type": "string", "format": "date-time" },
        "reported_by": { "type": "string", "maxLength": 160 }
      },
      "allOf": [
        { "if": { "properties": { "status": { "const": "partial" } }, "required": ["status"] }, "then": { "properties": { "limitations": { "minItems": 1 } } } },
        { "if": { "properties": { "status": { "enum": ["not_applicable", "rejected_by_user"] } }, "required": ["status"] }, "then": { "required": ["rationale"], "properties": { "rationale": { "minLength": 1 } } } }
      ]
    }
  }
}
