{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/shardflux-dev/json-schema/shardflux-dev-workspace-schema.json",
  "title": "Workspace",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/shardflux-dev-openapi.json#/components/schemas/Workspace",
  "type": "object",
  "required": [
    "id",
    "organization_id",
    "project_id",
    "workspace_key",
    "labels",
    "template_version_id",
    "template",
    "desired_state",
    "observed_state",
    "cell_id",
    "cell_endpoint",
    "ownership_epoch",
    "caps",
    "memory",
    "ceilings",
    "grants",
    "active_operation",
    "pending_reason",
    "forked_from_workspace_id",
    "disk_layout",
    "lifetime",
    "purpose",
    "idle_timeout_seconds",
    "idle",
    "origin",
    "ended_reason",
    "dev_template_id",
    "startup",
    "mode",
    "tree_revision",
    "computer_use",
    "created_at",
    "updated_at",
    "deleted_at"
  ],
  "properties": {
    "secret_redaction_required": {
      "type": "boolean",
      "description": "Bound secrets require tool-call capture redaction inside the guest before storage."
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "UUIDv7, lowercase canonical form."
    },
    "organization_id": {
      "type": "string",
      "format": "uuid",
      "description": "UUIDv7, lowercase canonical form."
    },
    "project_id": {
      "type": "string",
      "format": "uuid",
      "description": "UUIDv7, lowercase canonical form."
    },
    "workspace_key": {
      "type": "string"
    },
    "labels": {
      "type": "object",
      "maxProperties": 50,
      "additionalProperties": {
        "type": "string",
        "maxLength": 256
      },
      "description": "Searchable workspace metadata; not secrets. At most 50 labels."
    },
    "retention": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "delete_after_idle_days",
            "delete_at"
          ],
          "properties": {
            "delete_after_idle_days": {
              "type": "integer"
            },
            "delete_at": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "template_version_id": {
      "type": "string",
      "format": "uuid",
      "description": "UUIDv7, lowercase canonical form."
    },
    "template": {
      "type": "object",
      "required": [
        "version_id",
        "template_id",
        "slug",
        "version",
        "immutable_version"
      ],
      "properties": {
        "version_id": {
          "type": "string",
          "format": "uuid",
          "description": "UUIDv7, lowercase canonical form."
        },
        "template_id": {
          "type": "string",
          "format": "uuid",
          "description": "UUIDv7, lowercase canonical form."
        },
        "slug": {
          "type": "string"
        },
        "version": {
          "type": "integer"
        },
        "immutable_version": {
          "anyOf": [
            {
              "type": "integer",
              "description": "Immutable paths: the template version whose read-only content the workspace has mounted at the template’s immutable paths. It follows the template’s newest published version at a cold boot or a resume. null when the workspace mounts none (its version declares no immutable paths, a draft or a test instance, or not booted yet)."
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "description": "The workspace’s current template base (changed only by an explicit upgrade), and the version its immutable paths show."
    },
    "desired_state": {
      "type": "string",
      "enum": [
        "running",
        "suspended",
        "deleted"
      ]
    },
    "observed_state": {
      "type": "string",
      "enum": [
        "creating",
        "starting",
        "running",
        "suspending",
        "suspended",
        "resuming",
        "forking",
        "stopping",
        "failed",
        "deleting",
        "deleted"
      ]
    },
    "cell_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "cell_endpoint": {
      "anyOf": [
        {
          "type": "string",
          "description": "Cell gateway base URL when placed and resolvable."
        },
        {
          "type": "null"
        }
      ]
    },
    "ownership_epoch": {
      "type": "integer"
    },
    "caps": {
      "type": "object",
      "required": [
        "cpu_millis",
        "memory_mib",
        "disk_gib",
        "allocation_mode"
      ],
      "properties": {
        "cpu_millis": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "memory_mib": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "disk_gib": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "description": "Requested disk cap (GiB), bounded by the admitted plan/template ceiling and acknowledged VM disk. Null means no user disk restriction."
            },
            {
              "type": "null"
            }
          ]
        },
        "allocation_mode": {
          "type": "string",
          "enum": [
            "fixed",
            "elastic"
          ],
          "description": "Memory allocation: elastic holds memory_mib_held while idle and grows up to memory_mib as its processes use memory. Every workspace is elastic from its next start; fixed (memory_mib held in full) remains on a VM that booted fixed until it is converted, and on a maximum below 1 GiB."
        },
        "memory_mib_held": {
          "type": "integer",
          "minimum": 512,
          "description": "Elastic only: the memory held while idle (MiB)."
        }
      },
      "additionalProperties": false,
      "description": "CPU and memory user caps (null = no user restriction), the effective disk cap, and the memory allocation mode."
    },
    "memory": {
      "type": "object",
      "required": [
        "allocation_mode",
        "promised_mib",
        "held_mib",
        "plugged_mib"
      ],
      "properties": {
        "allocation_mode": {
          "type": "string",
          "enum": [
            "fixed",
            "elastic"
          ],
          "description": "The layout of the running VM, else the one the next start uses."
        },
        "promised_mib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "The memory the workspace may use (MiB): the running allocation, else the last admitted size; null before the first start."
            },
            {
              "type": "null"
            }
          ]
        },
        "held_mib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "The memory held while idle (MiB): the elastic floor; equal to promised_mib for fixed."
            },
            {
              "type": "null"
            }
          ]
        },
        "plugged_mib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "Elastic and running: the memory currently plugged above the held floor (MiB, from the host’s latest report); null otherwise."
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "description": "Memory of the workspace."
    },
    "ceilings": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "cpu_millis",
            "memory_mib",
            "disk_gib",
            "sources",
            "resolved_at"
          ],
          "properties": {
            "cpu_millis": {
              "type": "integer"
            },
            "memory_mib": {
              "type": "integer"
            },
            "disk_gib": {
              "type": "integer"
            },
            "sources": {
              "type": "object",
              "required": [
                "cpu_millis",
                "memory_mib",
                "disk_gib"
              ],
              "properties": {
                "cpu_millis": {
                  "type": "string",
                  "enum": [
                    "template",
                    "user",
                    "plan"
                  ]
                },
                "memory_mib": {
                  "type": "string",
                  "enum": [
                    "template",
                    "user",
                    "plan"
                  ]
                },
                "disk_gib": {
                  "type": "string",
                  "enum": [
                    "template",
                    "user",
                    "plan"
                  ]
                }
              },
              "additionalProperties": false,
              "description": "Which input bounded each ceiling: min(template, user cap, plan cap)."
            },
            "resolved_at": {
              "type": "string",
              "format": "date-time",
              "description": "RFC 3339 UTC timestamp with Z."
            }
          },
          "additionalProperties": false,
          "description": "Effective per-workspace ceilings computed at the last admission (start/resume/fork)."
        },
        {
          "type": "null"
        }
      ]
    },
    "grants": {
      "anyOf": [
        {
          "type": "object",
          "properties": {},
          "additionalProperties": true,
          "description": "Actual grants reported by the cell; live memory allocation overrides the last successful start."
        },
        {
          "type": "null"
        }
      ]
    },
    "storage_recovery": {
      "type": "object",
      "required": [
        "state",
        "reason",
        "copy_id",
        "files_kept",
        "message"
      ],
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "stored"
          ]
        },
        "reason": {
          "type": "string",
          "enum": [
            "maintenance"
          ]
        },
        "copy_id": {
          "type": "string",
          "format": "uuid",
          "description": "UUIDv7, lowercase canonical form."
        },
        "files_kept": {
          "type": "boolean",
          "enum": [
            true
          ]
        },
        "message": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "description": "Files stored independently of compute. Resume restarts processes from the kept filesystem."
    },
    "disk_space": {
      "type": "object",
      "required": [
        "state",
        "available_bytes",
        "total_bytes",
        "at_maximum",
        "maximum_gib",
        "reported_at",
        "message"
      ],
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "full",
            "low"
          ],
          "description": "full: nothing can be written; low: under 1/5 of the disk (or 4 GiB) is free."
        },
        "available_bytes": {
          "type": "integer",
          "minimum": 0,
          "description": "Free space the workspace can write, rounded down to whole GiB."
        },
        "total_bytes": {
          "type": "integer",
          "minimum": 0,
          "description": "Size of the workspace filesystem, rounded down to whole GiB."
        },
        "at_maximum": {
          "type": "boolean",
          "description": "The disk is at the largest size the plan and template allow, so it does not grow further on its own."
        },
        "maximum_gib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "The largest disk the plan and template allow."
            },
            {
              "type": "null"
            }
          ]
        },
        "reported_at": {
          "type": "string",
          "format": "date-time",
          "description": "RFC 3339 UTC timestamp with Z."
        },
        "message": {
          "type": "string",
          "description": "What is happening and what to do, for the person or agent using the workspace."
        }
      },
      "additionalProperties": false,
      "description": "Present while a running workspace’s disk is full, or nearly full at its maximum size. Below the maximum the disk grows on its own as it fills. The workspace keeps running, suspending, resuming, moving and forking while it is full, and this clears on its own once space is free."
    },
    "active_operation": {
      "anyOf": [
        {
          "$ref": "#/$defs/Operation"
        },
        {
          "type": "null"
        }
      ]
    },
    "pending_reason": {
      "anyOf": [
        {
          "type": "string",
          "description": "Why the workspace waits: the capacity_pending reason of its active operation, else null. Background work of the platform (moving the workspace to another host while it keeps its state) never sets it; that operation is still the active_operation, with its own state."
        },
        {
          "type": "null"
        }
      ]
    },
    "failure": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "operation_id",
            "kind",
            "code",
            "failed_at"
          ],
          "properties": {
            "operation_id": {
              "type": "string",
              "format": "uuid",
              "description": "UUIDv7, lowercase canonical form."
            },
            "kind": {
              "type": "string",
              "enum": [
                "open",
                "suspend",
                "resume",
                "fork",
                "snapshot",
                "restore",
                "delete",
                "move",
                "resize",
                "upgrade",
                "volume_create",
                "volume_attach",
                "volume_detach",
                "volume_delete",
                "reset",
                "layer_snapshot"
              ]
            },
            "code": {
              "type": "string",
              "description": "The operation error code, e.g. vm_start_failed or template_unavailable."
            },
            "message": {
              "type": "string",
              "description": "A human readable description."
            },
            "retryable": {
              "type": "boolean",
              "description": "Whether the same request may succeed later."
            },
            "details": {
              "type": "object",
              "properties": {},
              "additionalProperties": true,
              "description": "Code-specific details, e.g. host_reason or reason."
            },
            "failed_at": {
              "type": "string",
              "format": "date-time",
              "description": "RFC 3339 UTC timestamp with Z."
            }
          },
          "additionalProperties": false,
          "description": "observed_state failed: why. The error of the operation that left the workspace failed. Opening the key again (or resume) starts it again; until a start succeeds this stays set. null otherwise."
        },
        {
          "type": "null"
        }
      ]
    },
    "forked_from_workspace_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid",
          "description": "UUIDv7, lowercase canonical form."
        },
        {
          "type": "null"
        }
      ]
    },
    "disk_layout": {
      "$ref": "#/$defs/DiskLayout"
    },
    "lifetime": {
      "$ref": "#/$defs/WorkspaceLifetime"
    },
    "purpose": {
      "$ref": "#/$defs/WorkspacePurpose"
    },
    "idle_timeout_seconds": {
      "anyOf": [
        {
          "type": "integer",
          "description": "Sessions only: the session ends after this long without activity (template default, else 600). Null for persistent workspaces."
        },
        {
          "type": "null"
        }
      ]
    },
    "idle": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "policy",
            "source",
            "mode",
            "timeout_seconds",
            "basis",
            "next_eligible_at",
            "suspend_request"
          ],
          "properties": {
            "policy": {
              "type": "string",
              "description": "The effective policy: adaptive, never or fixed:<seconds>."
            },
            "source": {
              "type": "string",
              "enum": [
                "workspace",
                "template",
                "default"
              ],
              "description": "Where the policy comes from."
            },
            "mode": {
              "type": "string",
              "enum": [
                "adaptive",
                "fixed",
                "never"
              ]
            },
            "timeout_seconds": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The timeout applied to the current idle period while the workspace runs (as of the idle loop’s last decision), else null."
            },
            "basis": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "What the timeout comes from, e.g. \"learned from 37 idle periods (active-hours)\", \"template prior\", \"default\"."
            },
            "next_eligible_at": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "When the workspace becomes eligible for automatic suspend if nothing happens before (work signals always win)."
            },
            "suspend_request": {
              "anyOf": [
                {
                  "$ref": "#/$defs/SuspendRequest"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The pending suspend-when-idle request (POST …/suspend-when-idle) while the workspace runs and no tool call or resume has happened since the request, else null. It applies under every idle policy, never included."
            }
          },
          "additionalProperties": false,
          "description": "Automatic suspend of a persistent workspace. Null for session workspaces."
        },
        {
          "type": "null"
        }
      ]
    },
    "origin": {
      "anyOf": [
        {
          "$ref": "#/$defs/WorkspaceOrigin"
        },
        {
          "type": "null"
        }
      ]
    },
    "ended_reason": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "closed",
            "idle_timeout",
            "draft_discarded"
          ],
          "description": "How a session ended (closed, idle_timeout, draft_discarded); null otherwise."
        },
        {
          "type": "null"
        }
      ]
    },
    "dev_template_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid",
          "description": "UUIDv7, lowercase canonical form."
        },
        {
          "type": "null"
        }
      ]
    },
    "startup": {
      "anyOf": [
        {
          "$ref": "#/$defs/WorkspaceStartup"
        },
        {
          "type": "null"
        }
      ]
    },
    "mode": {
      "$ref": "#/$defs/WorkspaceMode"
    },
    "tree_revision": {
      "type": "integer",
      "minimum": 0,
      "description": "file_first: the latest revision of the file tree (0 = the empty tree the workspace starts with; each mutating file call or execution publishes the next one; cell file responses carry it as X-Tree-Revision). Always 0 for processful workspaces."
    },
    "upgrade_available": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "memory_layout",
            "guest_revision",
            "template_version"
          ],
          "properties": {
            "memory_layout": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "guest_revision": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "template_version": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": false,
          "description": "Supported target dimensions of an opt-in upgrade; null dimension stays unchanged."
        },
        {
          "type": "null"
        }
      ]
    },
    "upgrade_pending": {
      "anyOf": [
        {
          "type": "object",
          "properties": {},
          "additionalProperties": true,
          "description": "The pinned upgrade target awaiting its cold start."
        },
        {
          "type": "null"
        }
      ]
    },
    "computer_use": {
      "$ref": "#/$defs/ComputerUse"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "RFC 3339 UTC timestamp with Z."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "RFC 3339 UTC timestamp with Z."
    },
    "deleted_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time",
          "description": "RFC 3339 UTC timestamp with Z."
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "additionalProperties": false,
  "$defs": {
    "ComputerUse": {
      "type": "object",
      "required": [
        "enabled",
        "workspace",
        "template",
        "available"
      ],
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Effective: tool tokens carry the computer tool (the workspace’s value, else the template’s, and the version runs a desktop)."
        },
        "workspace": {
          "anyOf": [
            {
              "type": "boolean",
              "description": "The workspace’s own value; null follows the template."
            },
            {
              "type": "null"
            }
          ]
        },
        "template": {
          "type": "boolean",
          "description": "The template’s switch for its workspaces."
        },
        "available": {
          "type": "boolean",
          "description": "The workspace’s template version can run a desktop (its guest agent has desktop.v1)."
        }
      },
      "additionalProperties": false
    },
    "DiskLayout": {
      "type": "string",
      "enum": [
        "legacy",
        "layered"
      ],
      "description": "legacy: one disk (template copy + changes). layered: the template chain read-only plus a workspace layer holding only the changes. Immutable."
    },
    "Operation": {
      "type": "object",
      "required": [
        "id",
        "kind",
        "state",
        "workspace_id",
        "created_at",
        "updated_at"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "UUIDv7, lowercase canonical form."
        },
        "kind": {
          "type": "string",
          "enum": [
            "open",
            "suspend",
            "resume",
            "fork",
            "snapshot",
            "restore",
            "delete",
            "move",
            "resize",
            "upgrade",
            "volume_create",
            "volume_attach",
            "volume_detach",
            "volume_delete",
            "reset",
            "layer_snapshot"
          ]
        },
        "state": {
          "type": "string",
          "enum": [
            "queued",
            "capacity_pending",
            "running",
            "succeeded",
            "failed",
            "canceled"
          ]
        },
        "workspace_id": {
          "anyOf": [
            {
              "type": "string",
              "format": "uuid",
              "description": "UUIDv7, lowercase canonical form."
            },
            {
              "type": "null"
            }
          ]
        },
        "volume_id": {
          "anyOf": [
            {
              "type": "string",
              "format": "uuid",
              "description": "UUIDv7, lowercase canonical form."
            },
            {
              "type": "null"
            }
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "RFC 3339 UTC timestamp with Z."
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "description": "RFC 3339 UTC timestamp with Z."
        },
        "started_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "description": "RFC 3339 UTC timestamp with Z."
            },
            {
              "type": "null"
            }
          ],
          "description": "When the cell started executing the operation: set once, in the transaction that first moves it to `running`, and never changed afterwards (it stays set if the operation later returns to `capacity_pending`, e.g. when a host rejects the start). null while the operation is `queued`, or `capacity_pending` before it ever ran, and on an operation canceled before it started. An operation the cell finishes without running it (e.g. `dependency_failed`) gets started_at = completed_at. created_at to started_at is the time queued; started_at to completed_at the time running."
        },
        "completed_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "description": "RFC 3339 UTC timestamp with Z."
            },
            {
              "type": "null"
            }
          ]
        },
        "state_reason": {
          "anyOf": [
            {
              "type": "string",
              "description": "Closed reason code while waiting (e.g. capacity_pending: no_ready_host)."
            },
            {
              "type": "null"
            }
          ]
        },
        "input": {
          "type": "object",
          "properties": {},
          "additionalProperties": true
        },
        "error": {
          "type": "object",
          "properties": {},
          "additionalProperties": true
        },
        "result": {
          "type": "object",
          "properties": {
            "durable": {
              "type": "boolean",
              "description": "suspend and fork: whether the capture is in durable storage. false while `durability.state` is pending (the suspend completed on its host) or lost; true once it committed. Absent on other kinds."
            },
            "suspend_path": {
              "type": "string",
              "description": "suspend: `local_commit` when the suspend completed on its host and the durable copy followed in the background."
            },
            "durability": {
              "type": "object",
              "required": [
                "state"
              ],
              "properties": {
                "state": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "durable",
                    "lost"
                  ],
                  "description": "pending: sealed on its host, the durable copy is being written; durable: the copy committed; lost: the copy could not be made and the previous recovery point stays current."
                },
                "checkpoint_id": {
                  "type": "string",
                  "description": "The checkpoint being made durable."
                },
                "generation_id": {
                  "type": "string",
                  "description": "Its generation on the host."
                },
                "local_commit_at": {
                  "type": "string",
                  "description": "RFC 3339: when the suspend (or fork) completed on its host."
                },
                "durable_by": {
                  "type": "string",
                  "description": "RFC 3339: when the durable copy is expected to have committed (local_commit_at + the deadline)."
                },
                "durable_at": {
                  "type": "string",
                  "description": "RFC 3339 (state durable): when the durable copy committed."
                },
                "local_commit_to_durable_ms": {
                  "type": "number",
                  "description": "State durable: local_commit_at to durable_at, in milliseconds."
                },
                "overdue_at": {
                  "type": "string",
                  "description": "RFC 3339: set once durable_by passed while the copy was still pending; it keeps retrying."
                },
                "reason": {
                  "type": "string",
                  "description": "State lost: why, e.g. host_lost."
                },
                "code": {
                  "type": "string",
                  "description": "State lost: the error code of the failed copy."
                },
                "recovery_point_checkpoint_id": {
                  "anyOf": [
                    {
                      "type": "string",
                      "description": "State lost: the durable checkpoint that stays the recovery point (null when there is none)."
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "additionalProperties": true
            },
            "lost_suspend": {
              "type": "object",
              "required": [
                "checkpoint_id"
              ],
              "properties": {
                "checkpoint_id": {
                  "type": "string",
                  "description": "The suspend checkpoint whose durable copy was lost."
                },
                "generation_id": {
                  "type": "string",
                  "description": "Its generation on the host."
                },
                "reason": {
                  "type": "string",
                  "description": "Why it was lost, e.g. host_lost."
                },
                "suspended_at": {
                  "type": "string",
                  "description": "RFC 3339: when that suspend captured the workspace."
                },
                "restored_checkpoint_id": {
                  "type": "string",
                  "description": "The earlier durable checkpoint this resume restored."
                },
                "state_as_of": {
                  "type": "string",
                  "description": "RFC 3339: when the restored checkpoint committed; the workspace state is as of then."
                }
              },
              "additionalProperties": true
            },
            "host_lost": {
              "type": "object",
              "required": [
                "detected_at"
              ],
              "properties": {
                "detected_at": {
                  "type": "string",
                  "description": "RFC 3339: when the host failure was detected; the workspace was suspended then."
                },
                "restored_from": {
                  "type": "string",
                  "enum": [
                    "disk",
                    "checkpoint"
                  ],
                  "description": "resume and open: disk when the workspace booted from its disk (files kept, processes and memory not); checkpoint when it was restored from its newest checkpoint (see state_as_of). Absent on a suspend."
                },
                "restored_checkpoint_id": {
                  "type": "string",
                  "description": "restored_from checkpoint: the checkpoint this resume restored."
                },
                "state_as_of": {
                  "type": "string",
                  "description": "restored_from checkpoint, RFC 3339: when that checkpoint committed; the workspace state is as of then."
                }
              },
              "additionalProperties": true
            }
          },
          "additionalProperties": true
        },
        "progress": {
          "$ref": "#/$defs/SuspendProgress"
        }
      },
      "additionalProperties": false
    },
    "SuspendProgress": {
      "type": "object",
      "required": [
        "operation_id",
        "state",
        "workspace_state",
        "phase",
        "cancelable",
        "supported",
        "safe_action"
      ],
      "properties": {
        "operation_id": {
          "type": "string",
          "format": "uuid",
          "description": "UUIDv7, lowercase canonical form."
        },
        "state": {
          "type": "string",
          "enum": [
            "queued",
            "capacity_pending",
            "running",
            "succeeded",
            "failed",
            "canceled"
          ]
        },
        "workspace_state": {
          "type": "string",
          "enum": [
            "creating",
            "starting",
            "running",
            "suspending",
            "suspended",
            "resuming",
            "forking",
            "stopping",
            "failed",
            "deleting",
            "deleted"
          ]
        },
        "phase": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[a-z][a-z0-9_]*$",
          "description": "Actual snapshot preparation/capture phase, or an explicitly unavailable control status."
        },
        "cancelable": {
          "type": "boolean",
          "description": "True only while the host can acknowledge cancellation before its capture cut."
        },
        "supported": {
          "type": "boolean"
        },
        "safe_action": {
          "type": "string",
          "enum": [
            "wait_for_terminal",
            "resume",
            "retry_tools",
            "inspect_failure"
          ]
        },
        "phase_started_at": {
          "type": "string",
          "format": "date-time",
          "description": "RFC 3339 UTC timestamp with Z."
        },
        "deadline_at": {
          "type": "string",
          "format": "date-time",
          "description": "RFC 3339 UTC timestamp with Z."
        },
        "accepted": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "SuspendRequest": {
      "type": "object",
      "required": [
        "requested_at",
        "after_seconds",
        "not_before"
      ],
      "properties": {
        "requested_at": {
          "type": "string",
          "format": "date-time",
          "description": "When the request was made; a newer request replaces it."
        },
        "after_seconds": {
          "type": "integer",
          "minimum": 0,
          "maximum": 3600
        },
        "not_before": {
          "type": "string",
          "format": "date-time",
          "description": "requested_at + after_seconds: the earliest suspend (within a few seconds of activity flush grace after it). A running command, an attached stream or a keepalive still active then defers the suspend until after_seconds after it ends."
        }
      },
      "additionalProperties": false,
      "description": "A pending suspend-when-idle request: once the workspace has been idle for after_seconds, it is suspended. A tool call after requested_at (the next turn) or a resume cancels it; other work only defers it."
    },
    "WorkspaceLifetime": {
      "type": "string",
      "enum": [
        "persistent",
        "session"
      ],
      "description": "persistent: kept until deleted (default). session: discarded when the session ends (close(), idle timeout or draft discard;)."
    },
    "WorkspaceMode": {
      "type": "string",
      "enum": [
        "processful",
        "file_first"
      ],
      "description": "processful (default): one VM keeps processes, memory and files between calls; it can be suspended, resumed and forked. file_first: the state is a versioned file tree (tree_revision); there is no VM between executions, each exec runs in a fresh VM and publishes the changed files as the next revision, nothing but files survives an execution. A file-first workspace is ready (running) from creation and is never suspended; suspend, resume, snapshot, fork, reset, save-as-template, volumes and idle policies are 409 not_supported_for_mode. Immutable."
    },
    "WorkspaceOrigin": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "kind",
            "workspace_id"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "fork"
              ]
            },
            "workspace_id": {
              "type": "string",
              "format": "uuid",
              "description": "UUIDv7, lowercase canonical form."
            }
          },
          "additionalProperties": false,
          "description": "Forked from workspace_id."
        },
        {
          "type": "object",
          "required": [
            "kind",
            "template_id",
            "draft_workspace_id",
            "checkpoint_id",
            "captured_at"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "draft_state"
              ]
            },
            "template_id": {
              "type": "string",
              "format": "uuid",
              "description": "UUIDv7, lowercase canonical form."
            },
            "draft_workspace_id": {
              "type": "string",
              "format": "uuid",
              "description": "UUIDv7, lowercase canonical form."
            },
            "checkpoint_id": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid",
                  "description": "UUIDv7, lowercase canonical form."
                },
                {
                  "type": "null"
                }
              ]
            },
            "captured_at": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "description": "RFC 3339 UTC timestamp with Z."
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": false,
          "description": "A test instance of a draft state: the draft and the captured state (checkpoint_id is null until the cell placed an instance whose state is being captured)."
        },
        {
          "type": "object",
          "required": [
            "kind",
            "template_id",
            "version"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "template_version"
              ]
            },
            "template_id": {
              "type": "string",
              "format": "uuid",
              "description": "UUIDv7, lowercase canonical form."
            },
            "version": {
              "type": "integer",
              "minimum": 1
            }
          },
          "additionalProperties": false,
          "description": "A test instance of a template version, published or not: a fresh workspace on that version."
        }
      ],
      "description": "Where the workspace’s disk came from; null for a workspace opened from its template."
    },
    "WorkspacePurpose": {
      "type": "string",
      "enum": [
        "standard",
        "template_draft",
        "template_test"
      ],
      "description": "standard, template_draft (a template’s dev-mode draft) or template_test (a test instance of a draft state;)."
    },
    "WorkspaceStartup": {
      "type": "object",
      "required": [
        "state",
        "trigger",
        "step",
        "service",
        "exit_code",
        "output_tail",
        "reason",
        "operation_id",
        "at"
      ],
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "pending",
            "running",
            "ready",
            "failed"
          ],
          "description": "pending: a start is in progress and its startup has not begun (or never ran); running: start commands, services or readiness waits are running; ready: every step succeeded; failed: a step failed (the workspace still runs so it can be inspected; the next open runs the failed step again)."
        },
        "trigger": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "create",
                "boot",
                "resume"
              ],
              "description": "create: a new workspace layer; boot: a cold boot; resume: a memory restore. null while pending."
            },
            {
              "type": "null"
            }
          ]
        },
        "step": {
          "anyOf": [
            {
              "type": "string",
              "description": "The start command (or `services`, `ready:<service>`) running or failed."
            },
            {
              "type": "null"
            }
          ]
        },
        "service": {
          "anyOf": [
            {
              "type": "string",
              "description": "The service that failed or is awaited."
            },
            {
              "type": "null"
            }
          ]
        },
        "exit_code": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        },
        "output_tail": {
          "anyOf": [
            {
              "type": "string",
              "description": "Up to the last 4096 bytes of the failed step’s output (stdout and stderr interleaved)."
            },
            {
              "type": "null"
            }
          ]
        },
        "reason": {
          "anyOf": [
            {
              "type": "string",
              "description": "Failure reason: startup_failed, service_not_ready, secrets_unavailable, secret_not_available or guest_feature_unavailable."
            },
            {
              "type": "null"
            }
          ]
        },
        "operation_id": {
          "anyOf": [
            {
              "type": "string",
              "format": "uuid",
              "description": "UUIDv7, lowercase canonical form."
            },
            {
              "type": "null"
            }
          ]
        },
        "at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "description": "RFC 3339 UTC timestamp with Z."
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "description": "Start commands and services of the workspace’s template version; null when the version has none."
    }
  }
}