{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/arcnm-io/json-schema/arcnm-io-nest-run-summary-schema.json",
  "title": "NestRunSummary",
  "description": "A job nest: what it was asked to nest, how far it has got and, once\nit ends, how many sheets it cuts.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/arcnm-io-nesting-api-openapi.yml#/components/schemas/NestRunSummary",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
    },
    "env_id": {
      "type": "string",
      "format": "uuid",
      "title": "Env Id",
      "description": "The costing environment it nests in."
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "queued",
        "running",
        "solved",
        "failed",
        "cancelled"
      ],
      "title": "Status",
      "description": "`draft`: kept, not queued — it was started while the month's runs were used, so it spends no run until `POST /nest-runs/{run_id}/start` starts it. `queued`: waiting to start. `running`: nesting, several materials and thicknesses at a time. `solved`: every material and thickness is nested. `failed`: it stopped, `error` says why; what it nested before stands. `cancelled`: stopped on request; what it nested before stands."
    },
    "allocation_rule": {
      "type": "string",
      "enum": [
        "area_proportional",
        "equal_per_sheet"
      ],
      "title": "Allocation Rule",
      "description": "How each sheet's cost is shared by the parts on it."
    },
    "group_budget_s": {
      "type": "number",
      "title": "Group Budget S",
      "description": "The longest each material and thickness may be nested for, in seconds of computing time."
    },
    "as_of": {
      "type": "string",
      "format": "date",
      "title": "As Of",
      "description": "The day its stock and prices are read at."
    },
    "created_by_user_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Created By User Id"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At"
    },
    "started_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Started At"
    },
    "finished_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Finished At"
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error",
      "description": "Why it stopped, when it did not finish."
    },
    "groups_total": {
      "type": "integer",
      "title": "Groups Total",
      "description": "Materials and thicknesses it nests — each is nested on its own."
    },
    "groups_done": {
      "type": "integer",
      "title": "Groups Done",
      "description": "Of those, the ones finished so far: nested, or not nestable."
    },
    "lines": {
      "type": "integer",
      "title": "Lines",
      "description": "Lines it nests."
    },
    "copies": {
      "type": "integer",
      "title": "Copies",
      "description": "Copies it nests, over all its lines."
    },
    "sheets": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Sheets",
      "description": "Sheets and remnants the nested materials and thicknesses are cut from; set once the job nest ends."
    },
    "counts_toward_savings": {
      "type": "boolean",
      "title": "Counts Toward Savings",
      "description": "True once the job nest was released: its stock is booked and what it saves adds to the total saved by nesting. False: a simulation, whose saving is potential only.",
      "default": false
    },
    "counted_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Counted At",
      "description": "When it was released; null while a simulation."
    },
    "savings": {
      "anyOf": [
        {
          "$ref": "#/$defs/NestRunSavings"
        },
        {
          "type": "null"
        }
      ],
      "description": "What it saves, once it ends; null before, or where no line compares."
    }
  },
  "type": "object",
  "required": [
    "id",
    "env_id",
    "status",
    "allocation_rule",
    "group_budget_s",
    "as_of",
    "created_by_user_id",
    "created_at",
    "started_at",
    "finished_at",
    "error",
    "groups_total",
    "groups_done",
    "lines",
    "copies"
  ],
  "$defs": {
    "NestOrderSaving": {
      "properties": {
        "currency": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Currency",
          "description": "The currency of the amounts; null where the compared lines were priced in more than one, and then the amounts are null too."
        },
        "lines": {
          "type": "integer",
          "title": "Lines",
          "description": "Lines with pieces on the sheets."
        },
        "lines_compared": {
          "type": "integer",
          "title": "Lines Compared",
          "description": "Of those, the lines whose rectangular blanks and nested figures are known in one currency: what `saved` covers."
        },
        "split_lines": {
          "type": "integer",
          "title": "Split Lines",
          "description": "Of the compared lines, those whose figure nested alone is known too: what `alone`, `saved_true_shape` and `saved_combining` cover. Where it equals `lines_compared`, `saved` is `saved_true_shape` plus `saved_combining`."
        },
        "copies": {
          "type": "integer",
          "title": "Copies",
          "description": "Pieces the compared lines have on the sheets."
        },
        "rectangular": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Rectangular",
          "description": "Rectangular blanks: the whole sheets the pieces take cut part by part as rectangles, without nesting, at the job nest's price of new sheet."
        },
        "alone": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Alone",
          "description": "Each part nested alone: the whole sheets its own true-shape layout takes for its pieces, on the sheet formats the job nest can buy, at the job nest's price of new sheet."
        },
        "nested": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Nested",
          "description": "Nested together: the lines' share of the sheets and remnants cut."
        },
        "saved": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Saved",
          "description": "`rectangular` less `nested`: what nesting saved against cutting each part from rectangular blanks; may be negative for one line or order — its share of shared sheets, stated as it is — or for a layout edited to cut more sheet."
        },
        "saved_true_shape": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Saved True Shape",
          "description": "`rectangular` less `alone`, over the lines in `split_lines`: what nesting each part to its true shape saved on its own."
        },
        "saved_combining": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Saved Combining",
          "description": "`alone` less `nested`, over the lines in `split_lines`: what nesting the orders' parts together saved on top."
        },
        "rectangular_kg": {
          "type": "number",
          "title": "Rectangular Kg"
        },
        "alone_kg": {
          "type": "number",
          "title": "Alone Kg"
        },
        "nested_kg": {
          "type": "number",
          "title": "Nested Kg"
        },
        "saved_kg": {
          "type": "number",
          "title": "Saved Kg",
          "description": "`rectangular_kg` less `nested_kg`."
        },
        "saved_true_shape_kg": {
          "type": "number",
          "title": "Saved True Shape Kg",
          "description": "`rectangular_kg` less `alone_kg`, over the lines in `split_lines`."
        },
        "saved_combining_kg": {
          "type": "number",
          "title": "Saved Combining Kg",
          "description": "`alone_kg` less `nested_kg`, over the lines in `split_lines`."
        },
        "rectangular_sheets": {
          "type": "integer",
          "title": "Rectangular Sheets",
          "description": "Sheets the lines take as rectangular blanks."
        },
        "alone_sheets": {
          "type": "integer",
          "title": "Alone Sheets",
          "description": "Sheets the lines in `split_lines` take nested alone."
        },
        "nested_sheets": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Nested Sheets",
          "description": "Sheets and remnants cut nested together; null where not every placed line compared."
        },
        "order_ref": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Order Ref",
          "description": "The order; null for the lines that name none."
        }
      },
      "type": "object",
      "required": [
        "currency",
        "lines",
        "lines_compared",
        "split_lines",
        "copies",
        "rectangular",
        "alone",
        "nested",
        "saved",
        "saved_true_shape",
        "saved_combining",
        "rectangular_kg",
        "alone_kg",
        "nested_kg",
        "saved_kg",
        "saved_true_shape_kg",
        "saved_combining_kg",
        "rectangular_sheets",
        "alone_sheets",
        "nested_sheets",
        "order_ref"
      ],
      "title": "NestOrderSaving",
      "description": "One order's lines, the same figures."
    },
    "NestRunSavings": {
      "properties": {
        "currency": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Currency",
          "description": "The currency of the amounts; null where the compared lines were priced in more than one, and then the amounts are null too."
        },
        "lines": {
          "type": "integer",
          "title": "Lines",
          "description": "Lines with pieces on the sheets."
        },
        "lines_compared": {
          "type": "integer",
          "title": "Lines Compared",
          "description": "Of those, the lines whose rectangular blanks and nested figures are known in one currency: what `saved` covers."
        },
        "split_lines": {
          "type": "integer",
          "title": "Split Lines",
          "description": "Of the compared lines, those whose figure nested alone is known too: what `alone`, `saved_true_shape` and `saved_combining` cover. Where it equals `lines_compared`, `saved` is `saved_true_shape` plus `saved_combining`."
        },
        "copies": {
          "type": "integer",
          "title": "Copies",
          "description": "Pieces the compared lines have on the sheets."
        },
        "rectangular": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Rectangular",
          "description": "Rectangular blanks: the whole sheets the pieces take cut part by part as rectangles, without nesting, at the job nest's price of new sheet."
        },
        "alone": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Alone",
          "description": "Each part nested alone: the whole sheets its own true-shape layout takes for its pieces, on the sheet formats the job nest can buy, at the job nest's price of new sheet."
        },
        "nested": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Nested",
          "description": "Nested together: the lines' share of the sheets and remnants cut."
        },
        "saved": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Saved",
          "description": "`rectangular` less `nested`: what nesting saved against cutting each part from rectangular blanks; may be negative for one line or order — its share of shared sheets, stated as it is — or for a layout edited to cut more sheet."
        },
        "saved_true_shape": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Saved True Shape",
          "description": "`rectangular` less `alone`, over the lines in `split_lines`: what nesting each part to its true shape saved on its own."
        },
        "saved_combining": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Saved Combining",
          "description": "`alone` less `nested`, over the lines in `split_lines`: what nesting the orders' parts together saved on top."
        },
        "rectangular_kg": {
          "type": "number",
          "title": "Rectangular Kg"
        },
        "alone_kg": {
          "type": "number",
          "title": "Alone Kg"
        },
        "nested_kg": {
          "type": "number",
          "title": "Nested Kg"
        },
        "saved_kg": {
          "type": "number",
          "title": "Saved Kg",
          "description": "`rectangular_kg` less `nested_kg`."
        },
        "saved_true_shape_kg": {
          "type": "number",
          "title": "Saved True Shape Kg",
          "description": "`rectangular_kg` less `alone_kg`, over the lines in `split_lines`."
        },
        "saved_combining_kg": {
          "type": "number",
          "title": "Saved Combining Kg",
          "description": "`alone_kg` less `nested_kg`, over the lines in `split_lines`."
        },
        "rectangular_sheets": {
          "type": "integer",
          "title": "Rectangular Sheets",
          "description": "Sheets the lines take as rectangular blanks."
        },
        "alone_sheets": {
          "type": "integer",
          "title": "Alone Sheets",
          "description": "Sheets the lines in `split_lines` take nested alone."
        },
        "nested_sheets": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Nested Sheets",
          "description": "Sheets and remnants cut nested together; null where not every placed line compared."
        },
        "by_order": {
          "items": {
            "$ref": "#/$defs/NestOrderSaving"
          },
          "type": "array",
          "title": "By Order",
          "description": "The same per order."
        }
      },
      "type": "object",
      "required": [
        "currency",
        "lines",
        "lines_compared",
        "split_lines",
        "copies",
        "rectangular",
        "alone",
        "nested",
        "saved",
        "saved_true_shape",
        "saved_combining",
        "rectangular_kg",
        "alone_kg",
        "nested_kg",
        "saved_kg",
        "saved_true_shape_kg",
        "saved_combining_kg",
        "rectangular_sheets",
        "alone_sheets",
        "nested_sheets"
      ],
      "title": "NestRunSavings",
      "description": "What a job nest saves on the sheet it cuts into, stated once it ends.\nBoth are the material bought, before the scrap and remnant credits\neither would earn."
    }
  }
}