{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nanobaselabs-com/json-schema/nanobaselabs-com-check-result-schema.json",
  "title": "CheckResult",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nanobaselabs-com-openapi.json#/components/schemas/CheckResult",
  "type": "object",
  "required": [
    "outcome",
    "api_version"
  ],
  "properties": {
    "outcome": {
      "type": "string",
      "enum": [
        "compatible",
        "compatible_verify",
        "adjust",
        "structural_conflict",
        "needs_properties",
        "error"
      ]
    },
    "api_version": {
      "type": "string"
    },
    "ok": {
      "type": "boolean"
    },
    "verdict": {
      "type": "string",
      "description": "compatible | compatible_verify | adjust (not_processed on a structural_conflict answer)"
    },
    "categories": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Category"
      }
    },
    "remedies": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sev": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "body": {
            "type": "string"
          }
        }
      }
    },
    "maxLoads": {
      "type": "object"
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "i": {
            "type": "integer",
            "description": "0-based position after blends are expanded"
          },
          "line": {
            "type": "integer",
            "description": "1-based line sent"
          },
          "n": {
            "type": "string"
          },
          "c": {
            "type": "string"
          }
        }
      }
    },
    "incompatible_ingredients": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "line": {
            "type": "integer"
          },
          "ingredient": {
            "type": "string"
          },
          "issue": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "alternatives": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      }
    },
    "next_actions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/NextAction"
      }
    },
    "needs_properties": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "line": {
            "type": "integer"
          },
          "n": {
            "type": "string"
          }
        }
      }
    },
    "declared_by_caller": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "line": {
            "type": "integer"
          }
        }
      }
    },
    "grade_guidance": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "line": {
            "type": "integer"
          }
        }
      }
    },
    "structural_conflict": {
      "type": "boolean"
    },
    "status": {
      "type": "string"
    },
    "performance": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "build_path": {
      "type": "object",
      "description": "advisory only, on answers that return results (not needs_properties, structural_conflict or error), never part of outcome, verdict, categories or loading: step-by-step process instructions written for the formulating AI, each with its reason",
      "properties": {
        "advisory": {
          "type": "string"
        },
        "batch_basis_g": {
          "type": "number"
        },
        "note": {
          "type": "string"
        },
        "instructions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "step": {
                "type": "integer"
              },
              "instruction": {
                "type": "string"
              },
              "why": {
                "type": "string"
              },
              "optional": {
                "type": "boolean"
              }
            }
          }
        },
        "hydration_plan": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "ingredient": {
                "type": "string"
              },
              "lines": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              },
              "route": {
                "type": "string",
                "enum": [
                  "plain_architecture_premix",
                  "oil_loaded_premix",
                  "main_batch_direct",
                  "does_not_fit"
                ]
              },
              "where": {
                "type": "string"
              },
              "carrier_g": {
                "type": "number"
              },
              "add_at": {
                "type": "string"
              },
              "why": {
                "type": "string"
              },
              "alternative": {
                "type": "string"
              }
            }
          }
        },
        "portion_check": {
          "type": "object",
          "properties": {
            "architecture_g": {
              "type": "number"
            },
            "added_oil_g": {
              "type": "number"
            },
            "must_stay_in_main_at_oil_step_g": {
              "type": "number"
            },
            "max_withdraw_before_oils_g": {
              "type": "number"
            },
            "planned_plain_premixes_g": {
              "type": "number"
            },
            "ok": {
              "type": "boolean"
            },
            "why": {
              "type": "string"
            }
          }
        },
        "flags": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "severity": {
                "type": "string",
                "enum": [
                  "high",
                  "medium",
                  "low"
                ]
              },
              "line": {
                "type": "integer"
              },
              "text": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "ph_path": {
      "type": "object",
      "description": "advisory only, on answers that return results (not needs_properties, structural_conflict or error), never part of outcome, verdict, categories or loading: when the pH at addition can override the finished-pH placement",
      "properties": {
        "ph_add": {
          "type": "number"
        },
        "ph_add_source": {
          "type": "string"
        },
        "ph_final": {
          "type": "number"
        },
        "ph_final_source": {
          "type": "string"
        },
        "rule": {
          "type": "string"
        },
        "flags": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "line": {
                "type": "integer"
              },
              "ingredient": {
                "type": "string"
              },
              "step": {
                "type": "string",
                "enum": [
                  "precipitation",
                  "charge_flip",
                  "trapping",
                  "chemical"
                ]
              },
              "label": {
                "type": "string"
              },
              "severity": {
                "type": "string",
                "enum": [
                  "high",
                  "medium",
                  "low"
                ]
              },
              "why": {
                "type": "string"
              },
              "action": {
                "type": "string"
              },
              "data": {
                "type": "object"
              }
            }
          }
        },
        "finished_ph_notes": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "line": {
                "type": "integer"
              },
              "ingredient": {
                "type": "string"
              },
              "flag": {
                "type": "string"
              },
              "why": {
                "type": "string"
              },
              "action": {
                "type": "string"
              }
            }
          }
        },
        "not_on_file": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "line": {
                "type": "integer"
              },
              "ingredient": {
                "type": "string"
              },
              "missing": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "ask": {
                "type": "string"
              },
              "class_guidance": {
                "type": "string"
              }
            }
          }
        },
        "summary": {
          "type": "object"
        },
        "result": {
          "type": "string"
        },
        "reminders": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "note": {
          "type": "string"
        }
      }
    },
    "usage": {
      "$ref": "#/$defs/Usage"
    }
  },
  "$defs": {
    "Category": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "enum": [
            "oil",
            "ws",
            "anchor",
            "charged",
            "divalent",
            "poly"
          ]
        },
        "label": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "go",
            "verify",
            "warn",
            "stop"
          ]
        },
        "used": {},
        "max": {},
        "note": {
          "type": "string"
        },
        "used_value": {
          "type": [
            "number",
            "null"
          ]
        },
        "limit_value": {
          "type": [
            "number",
            "null"
          ]
        },
        "unit": {
          "type": [
            "string",
            "null"
          ],
          "description": "% w/w or % of capacity"
        },
        "used_pct_of_limit": {
          "type": [
            "number",
            "null"
          ],
          "description": "nearest 5 up to 100, coarser steps above; above 100 is over the limit"
        },
        "band": {
          "type": "string",
          "enum": [
            "none",
            "below ceiling",
            "near ceiling",
            "over ceiling"
          ],
          "description": "divalent only; none = no divalent source declared"
        }
      }
    },
    "NextAction": {
      "type": "object",
      "required": [
        "action",
        "target",
        "detail"
      ],
      "properties": {
        "action": {
          "type": "string",
          "description": "swap, remove, replace, reduce, adjust_ph, declare_ph, raise_loading, send_grade, submit_properties, fix, verify_at_bench, recheck, continue"
        },
        "target": {
          "type": "string"
        },
        "detail": {
          "type": "string"
        },
        "line": {
          "type": "integer"
        },
        "category": {
          "type": "string"
        }
      }
    },
    "Usage": {
      "type": "object",
      "properties": {
        "tier": {
          "type": "string"
        },
        "month": {
          "type": "string"
        },
        "runsUsed": {
          "type": "number"
        },
        "runsLimit": {
          "type": "number"
        },
        "runs_remaining": {
          "type": "number"
        },
        "run_window_ends_at": {
          "type": [
            "string",
            "null"
          ],
          "description": "ISO end of the open 60-minute run session; null when none is open"
        },
        "runCallsUsed": {
          "type": "number"
        },
        "runCallsLimit": {
          "type": "number"
        }
      }
    }
  }
}