{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://asi-custom-pipe.tom-pentax.chatgpt.site/agent-v2/data/pipe-specification.schema.json",
  "title": "Pipe2Size research specification",
  "description": "Validates the structure of a recorded request only. Passing does not establish dimensional consistency, compatibility, threadability, completeness, pressure rating or manufacturability. Preserve contradictory requests and clarify them, never silently correct them. Null means not supplied.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "material",
    "nominal_size",
    "sizing_system",
    "actual_od_requirement",
    "schedule",
    "finished_length",
    "required_tolerance",
    "end_a",
    "end_b",
    "quantity",
    "in_research_scope",
    "clarifications",
    "source_refs"
  ],
  "properties": {
    "material": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "PVC",
        "CPVC",
        null
      ]
    },
    "nominal_size": {
      "type": [
        "string",
        "null"
      ],
      "description": "Confirmed nominal designation with units, such as 1/2 in. If wording such as “half-inch” could mean a nominal size or an actual dimension, preserve it in original_request and use null until clarified. Preserve other requested sizes without implying availability."
    },
    "actual_od_requirement": {
      "$ref": "#/$defs/measurementOrNull",
      "description": "A separately requested measured OD, never silently substituted for nominal size."
    },
    "schedule": {
      "type": [
        "string",
        "null"
      ],
      "description": "Record the IPS Schedule actually requested. If a visitor says CTS plus Schedule 80, preserve both values and flag the contradiction; do not silently null or change either."
    },
    "finished_length": {
      "$ref": "#/$defs/measurementOrNull",
      "description": "Overall finished end-to-end length after both end treatments."
    },
    "required_tolerance": {
      "$ref": "#/$defs/toleranceOrNull",
      "description": "Requester-specified finished-length tolerance. The guide's proposed ±1/32 in illustration is not automatically assigned."
    },
    "end_a": {
      "$ref": "#/$defs/endOrNull",
      "description": "End A: left in a side view. Specify independently; null means unknown. Record exact thread or chamfer requirements in clarifications until supplied."
    },
    "end_b": {
      "$ref": "#/$defs/endOrNull",
      "description": "End B: right in a side view. Specify independently; do not copy end A by default."
    },
    "quantity": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1
    },
    "in_research_scope": {
      "type": "boolean",
      "description": "Research topic only: PVC/CPVC with half-inch or three-quarter-inch examples. This field does not confirm nominal-size interpretation, sizing system, suitability, selected-product availability or manufacturing process capability."
    },
    "clarifications": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "uniqueItems": true
    },
    "source_refs": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uri"
      }
    },
    "sizing_system": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "IPS",
        "CTS",
        null
      ],
      "description": "State IPS or CTS explicitly; half-inch CPVC is ambiguous. Reference IPS half-inch OD is 0.840 in; CTS half-inch OD is 0.625 in. Do not cut NPT threads on CTS."
    },
    "sdr": {
      "type": [
        "number",
        "null"
      ],
      "exclusiveMinimum": 0,
      "description": "Requested standard dimension ratio, e.g. CTS SDR 11. Unknown is null; do not infer a ratio from nominal size."
    },
    "original_request": {
      "type": [
        "string",
        "null"
      ],
      "description": "Preserve the requester’s nonconfidential original wording, including contradictions."
    },
    "application": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "conveyed_substance",
            "concentration",
            "temperature",
            "pressure"
          ],
          "properties": {
            "conveyed_substance": {
              "type": [
                "string",
                "null"
              ],
              "description": "Record requested value and units/conditions. Null means unknown."
            },
            "concentration": {
              "type": [
                "string",
                "null"
              ],
              "description": "Record requested value and units/conditions. Null means unknown."
            },
            "temperature": {
              "type": [
                "string",
                "null"
              ],
              "description": "Record requested value and units/conditions. Null means unknown."
            },
            "pressure": {
              "type": [
                "string",
                "null"
              ],
              "description": "Record requested value and units/conditions. Null means unknown."
            }
          }
        }
      ],
      "description": "Application and operating conditions supplied by the requester; does not select or approve a material."
    }
  },
  "$defs": {
    "measurementOrNull": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "unit"
          ],
          "properties": {
            "value": {
              "type": "number",
              "exclusiveMinimum": 0
            },
            "unit": {
              "type": "string",
              "enum": [
                "in",
                "mm"
              ]
            }
          }
        }
      ]
    },
    "toleranceOrNull": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "plus_minus",
            "unit"
          ],
          "properties": {
            "plus_minus": {
              "type": "number",
              "exclusiveMinimum": 0
            },
            "unit": {
              "type": "string",
              "enum": [
                "in",
                "mm"
              ]
            }
          }
        }
      ]
    },
    "endOrNull": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "square_cut",
        "chamfer",
        "male_npt",
        null
      ],
      "description": "Use null until the requester states the treatment. Thread and chamfer details may still need clarification."
    }
  }
}
