{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "ace://schemas/workspace-session-registry/1.0.0",
  "title": "ACE Workspace Session Registry",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "version",
    "updated_at",
    "sessions"
  ],
  "properties": {
    "version": {
      "type": "integer",
      "const": 1
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "sessions": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "session_id",
          "workspace_path",
          "root_path",
          "status",
          "source",
          "created_at",
          "updated_at",
          "hooks"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "minLength": 1
          },
          "workspace_path": {
            "type": "string",
            "minLength": 1
          },
          "root_path": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived",
              "removed",
              "failed"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "manual",
              "executor",
              "test"
            ]
          },
          "objective_id": {
            "type": "string"
          },
          "tracker_item_id": {
            "type": "string"
          },
          "last_error": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "hooks": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "after_create",
              "before_run",
              "after_run",
              "before_remove"
            ],
            "properties": {
              "after_create": {
                "$ref": "#/$defs/hook_state"
              },
              "before_run": {
                "$ref": "#/$defs/hook_state"
              },
              "after_run": {
                "$ref": "#/$defs/hook_state"
              },
              "before_remove": {
                "$ref": "#/$defs/hook_state"
              }
            }
          }
        }
      }
    }
  },
  "$defs": {
    "hook_state": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "not_run",
            "ok",
            "failed"
          ]
        },
        "detail": {
          "type": "string"
        }
      }
    }
  }
}
