{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "ace://schemas/runtime-profile/1.0.0",
  "title": "ACE Runtime Profile",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "ace_runtime_version",
    "runtime",
    "workspace",
    "executor",
    "tracker",
    "observability"
  ],
  "properties": {
    "ace_runtime_version": {
      "type": "string",
      "const": "1.0.0"
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode",
        "profile_name"
      ],
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "interactive",
            "unattended"
          ]
        },
        "profile_name": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "workspace": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "root",
        "retention",
        "hooks"
      ],
      "properties": {
        "root": {
          "type": "string",
          "minLength": 1
        },
        "retention": {
          "type": "string",
          "enum": [
            "delete",
            "archive"
          ]
        },
        "hooks": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "after_create",
            "before_run",
            "after_run",
            "before_remove"
          ],
          "properties": {
            "after_create": {
              "type": [
                "string",
                "null"
              ]
            },
            "before_run": {
              "type": [
                "string",
                "null"
              ]
            },
            "after_run": {
              "type": [
                "string",
                "null"
              ]
            },
            "before_remove": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      }
    },
    "executor": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "approval_policy",
        "thread_sandbox",
        "turn_sandbox_policy"
      ],
      "properties": {
        "command": {
          "type": [
            "string",
            "null"
          ]
        },
        "approval_policy": {
          "type": [
            "string",
            "object"
          ]
        },
        "thread_sandbox": {
          "type": "string",
          "minLength": 1
        },
        "turn_sandbox_policy": {
          "type": [
            "object",
            "null"
          ]
        },
        "max_turns": {
          "type": "integer",
          "minimum": 1
        },
        "turn_timeout_ms": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "tools": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "registry_path": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "autonomy": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "orchestrator_preflight": {
          "type": "boolean"
        },
        "recall_context": {
          "type": "boolean"
        },
        "state_sources": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "before_run_checks": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "stop_checks": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "review_mode": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1
        }
      }
    },
    "continuity": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "source_paths": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "max_sources": {
          "type": "integer",
          "minimum": 1
        },
        "max_excerpt_chars": {
          "type": "integer",
          "minimum": 1
        },
        "max_total_chars": {
          "type": "integer",
          "minimum": 1
        },
        "max_status_events": {
          "type": "integer",
          "minimum": 1
        },
        "max_run_ledger_entries": {
          "type": "integer",
          "minimum": 1
        },
        "include_snapshot": {
          "type": "boolean"
        }
      }
    },
    "tracker": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "config"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "none",
            "memory",
            "external"
          ]
        },
        "config": {
          "type": "object"
        }
      }
    },
    "observability": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "http_enabled",
        "http_port"
      ],
      "properties": {
        "http_enabled": {
          "type": "boolean"
        },
        "http_port": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "vericify_bridge": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "bridge_path": {
              "type": "string",
              "minLength": 1
            },
            "process_post_path": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    }
  }
}
