{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/shardflux-dev/json-schema/shardflux-dev-resize-result-schema.json",
  "title": "ResizeResult",
  "description": "Per resource the request named (allocation_mode and memory_mib_held report under memory): what applied now and what applies later. caps: the workspace caps every later start uses.",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/shardflux-dev-openapi.json#/components/schemas/ResizeResult",
  "type": "object",
  "required": [
    "workspace_id",
    "operation_id",
    "state",
    "caps"
  ],
  "properties": {
    "workspace_id": {
      "type": "string",
      "format": "uuid",
      "description": "UUIDv7, lowercase canonical form."
    },
    "operation_id": {
      "type": "string",
      "format": "uuid",
      "description": "UUIDv7, lowercase canonical form."
    },
    "state": {
      "type": "string",
      "description": "The workspace state the resize found (running, suspended, ...)."
    },
    "memory": {
      "type": "object",
      "required": [
        "applies_at",
        "allocation_mode",
        "requested_mib",
        "target_mib",
        "previous_mib",
        "applied_mib",
        "held_mib",
        "converged",
        "at_maximum",
        "limit_reason",
        "reason"
      ],
      "properties": {
        "applies_at": {
          "type": "string",
          "enum": [
            "now",
            "resume",
            "next_start"
          ],
          "description": "now: live; resume: right after the next resume, before its first call; next_start: at the next start that boots the workspace."
        },
        "allocation_mode": {
          "type": "string",
          "enum": [
            "fixed",
            "elastic"
          ],
          "description": "The memory layout after the resize."
        },
        "requested_mib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "memory_mib as sent (null when only the mode or the held floor was sent)."
            },
            {
              "type": "null"
            }
          ]
        },
        "target_mib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "The maximum the workspace gets."
            },
            {
              "type": "null"
            }
          ]
        },
        "previous_mib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "The size or maximum before the resize."
            },
            {
              "type": "null"
            }
          ]
        },
        "applied_mib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "What is live after the call (null when no VM runs)."
            },
            {
              "type": "null"
            }
          ]
        },
        "held_mib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "Elastic: the held floor; null for fixed."
            },
            {
              "type": "null"
            }
          ]
        },
        "converged": {
          "anyOf": [
            {
              "type": "boolean",
              "description": "A live change reached the guest (null when nothing ran)."
            },
            {
              "type": "null"
            }
          ]
        },
        "at_maximum": {
          "type": "boolean",
          "description": "The target is the most this workspace can have (the smaller of the plan and template maximums): a larger request cannot add more. With target equal to previous, the resize changed nothing."
        },
        "limit_reason": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "plan",
                "template",
                "host_capacity",
                "shrink_stalled"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Why the target or the applied value is below what was requested: plan or template (bounded like caps at open), host_capacity (the rest did not fit on the host at once), shrink_stalled (the guest kept the memory its processes use)."
        },
        "reason": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "region",
                "below_base",
                "legacy_layout",
                "boot_vcpus",
                "suspended",
                "stopped"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Why it does not apply now (null when it does)."
        }
      },
      "additionalProperties": false
    },
    "cpu": {
      "type": "object",
      "required": [
        "applies_at",
        "requested_millis",
        "target_millis",
        "previous_millis",
        "applied_millis",
        "at_maximum",
        "limit_reason",
        "reason"
      ],
      "properties": {
        "applies_at": {
          "type": "string",
          "enum": [
            "now",
            "resume",
            "next_start"
          ],
          "description": "now: live; resume: right after the next resume, before its first call; next_start: at the next start that boots the workspace."
        },
        "requested_millis": {
          "anyOf": [
            {
              "type": "integer",
              "description": "cpu_millis as sent."
            },
            {
              "type": "null"
            }
          ]
        },
        "target_millis": {
          "anyOf": [
            {
              "type": "integer",
              "description": "The CPU the workspace gets."
            },
            {
              "type": "null"
            }
          ]
        },
        "previous_millis": {
          "anyOf": [
            {
              "type": "integer",
              "description": "The CPU before the resize."
            },
            {
              "type": "null"
            }
          ]
        },
        "applied_millis": {
          "anyOf": [
            {
              "type": "integer",
              "description": "What is live after the call (null when no VM runs)."
            },
            {
              "type": "null"
            }
          ]
        },
        "at_maximum": {
          "type": "boolean",
          "description": "The target is the most this workspace can have (the smaller of the plan and template maximums): a larger request cannot add more. With target equal to previous, the resize changed nothing."
        },
        "limit_reason": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "plan",
                "template",
                "host_capacity",
                "shrink_stalled"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Why the target or the applied value is below what was requested: plan or template (bounded like caps at open), host_capacity (the rest did not fit on the host at once), shrink_stalled (the guest kept the memory its processes use)."
        },
        "reason": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "region",
                "below_base",
                "legacy_layout",
                "boot_vcpus",
                "suspended",
                "stopped"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Why it does not apply now (null when it does)."
        }
      },
      "additionalProperties": false
    },
    "disk": {
      "type": "object",
      "required": [
        "applies_at",
        "requested_gib",
        "target_gib",
        "previous_gib",
        "applied_gib",
        "at_maximum",
        "limit_reason",
        "reason"
      ],
      "properties": {
        "applies_at": {
          "type": "string",
          "enum": [
            "now",
            "resume",
            "next_start"
          ],
          "description": "now: live; resume: right after the next resume, before its first call; next_start: at the next start that boots the workspace."
        },
        "requested_gib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "disk_gib as sent."
            },
            {
              "type": "null"
            }
          ]
        },
        "target_gib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "The disk size the workspace gets."
            },
            {
              "type": "null"
            }
          ]
        },
        "previous_gib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "The disk size before the resize."
            },
            {
              "type": "null"
            }
          ]
        },
        "applied_gib": {
          "anyOf": [
            {
              "type": "integer",
              "description": "What is live after the call (null when no VM runs)."
            },
            {
              "type": "null"
            }
          ]
        },
        "at_maximum": {
          "type": "boolean",
          "description": "The target is the most this workspace can have (the smaller of the plan and template maximums): a larger request cannot add more. With target equal to previous, the resize changed nothing."
        },
        "limit_reason": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "plan",
                "template",
                "host_capacity",
                "shrink_stalled"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Why the target or the applied value is below what was requested: plan or template (bounded like caps at open), host_capacity (the rest did not fit on the host at once), shrink_stalled (the guest kept the memory its processes use)."
        },
        "reason": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "region",
                "below_base",
                "legacy_layout",
                "boot_vcpus",
                "suspended",
                "stopped"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Why it does not apply now (null when it does)."
        }
      },
      "additionalProperties": false
    },
    "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."
    }
  },
  "additionalProperties": false
}