{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://veydrin.codeberg.page/protocols/omds/omds-v1.0.schema.json",
  "title": "OMDS v1.0 schema",
  "description": "Open Mycology Data Standard, a VODS domain specialization for mushroom and fungal cultivation. Every OMDS document is also a valid VODS document.",
  "allOf": [
    {
      "$ref": "https://veydrin.codeberg.page/protocols/vods/vods-v1.0.schema.json"
    },
    {
      "type": "object",
      "required": [
        "omds_version"
      ],
      "anyOf": [
        {
          "required": [
            "cultures"
          ]
        },
        {
          "required": [
            "environment_logs"
          ]
        },
        {
          "required": [
            "flushes"
          ]
        },
        {
          "required": [
            "contamination"
          ]
        }
      ],
      "properties": {
        "omds_version": {
          "type": "string",
          "pattern": "^1\\.[0-9]+$"
        },
        "extensions": {
          "type": "object"
        },
        "cultures": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "inoculation_date",
              "species"
            ],
            "properties": {
              "culture_ref": {
                "type": "string",
                "description": "Pseudonymous identifier for this grow run, referenced by other records."
              },
              "site_ref": {
                "type": "string",
                "description": "Pseudonymous identifier grouping runs by physical site."
              },
              "specimen_ref": {
                "type": "string",
                "pattern": "^wemush:[A-Za-z0-9]+$",
                "description": "Optional link to a WOLS (WeMush Open Labeling Standard) specimen passport, shape wemush:<id>. Identity and lineage live in WOLS; OMDS carries the grow log."
              },
              "inoculation_date": {
                "type": "string",
                "format": "date"
              },
              "species": {
                "type": "string",
                "description": "Scientific name (Darwin Core scientificName). Free text."
              },
              "species_id": {
                "type": "string",
                "pattern": "^[a-z]+:[A-Za-z0-9._-]+$",
                "description": "Optional resolvable taxon reference (Darwin Core scientificNameID), prefix:id. Recommend a fungal nomenclatural authority: mycobank:<n> or indexfungorum:<n>. gbif:<key> and ncbi:<taxid> permitted as matching keys."
              },
              "common_name": {
                "type": "string"
              },
              "strain": {
                "type": "string",
                "description": "Free-text strain label only. Lineage and generation are modelled by WOLS, not OMDS."
              },
              "substrate": {
                "type": "string",
                "enum": [
                  "straw",
                  "sawdust",
                  "supplemented_sawdust",
                  "hardwood_log",
                  "masters_mix",
                  "coffee_grounds",
                  "grain",
                  "cardboard",
                  "manure",
                  "coco_coir",
                  "cvg",
                  "soy_hull",
                  "other"
                ]
              },
              "spawn_type": {
                "type": "string",
                "enum": [
                  "grain",
                  "sawdust",
                  "plug",
                  "liquid_culture",
                  "agar",
                  "other"
                ]
              },
              "method": {
                "type": "string",
                "enum": [
                  "monotub",
                  "bag",
                  "bottle",
                  "jar",
                  "log",
                  "outdoor_bed",
                  "bucket",
                  "tray",
                  "other"
                ]
              },
              "treatment": {
                "type": "string",
                "enum": [
                  "sterilized",
                  "steam_pasteurized",
                  "lime_pasteurized",
                  "cold_pasteurized",
                  "fermented",
                  "none"
                ],
                "description": "The processing outcome applied to the substrate."
              },
              "sterilization_method": {
                "type": "string",
                "enum": [
                  "autoclave",
                  "steam",
                  "atmospheric_steam",
                  "hot_water_bath",
                  "chemical",
                  "none"
                ],
                "description": "The apparatus or process, distinct from the treatment outcome."
              },
              "sterilization_temp_c": {
                "type": "number",
                "description": "Degrees Celsius (UCUM Cel)."
              },
              "sterilization_duration_min": {
                "type": "number",
                "minimum": 0,
                "description": "Minutes held at temperature (UCUM min)."
              },
              "substrate_wet_weight_kg": {
                "type": "number",
                "minimum": 0,
                "description": "Hydrated substrate mass, kilograms (UCUM kg)."
              },
              "substrate_dry_weight_kg": {
                "type": "number",
                "minimum": 0,
                "description": "Dry substrate mass, kilograms (UCUM kg). Denominator of biological efficiency."
              },
              "moisture_content_pct": {
                "type": "number",
                "minimum": 0,
                "maximum": 100,
                "description": "Substrate moisture by weight (UCUM %). Field capacity target 60-65%."
              },
              "spawn_ratio_pct": {
                "type": "number",
                "minimum": 0,
                "maximum": 100,
                "description": "Spawn as percent of total volume (UCUM %). Growers speak in ratios (1:2 = 33%); store the single number."
              },
              "container_count": {
                "type": "integer",
                "minimum": 0
              },
              "substrate_cn_ratio": {
                "type": "number",
                "minimum": 0,
                "description": "Carbon-to-nitrogen ratio as a single number (30 means 30:1)."
              },
              "initial_ph": {
                "type": "number",
                "minimum": 0,
                "maximum": 14
              },
              "supplement_type": {
                "type": "string",
                "enum": [
                  "wheat_bran",
                  "oat_bran",
                  "soy_hull",
                  "gypsum",
                  "none",
                  "other"
                ]
              },
              "supplement_pct": {
                "type": "number",
                "minimum": 0,
                "maximum": 100,
                "description": "Supplement as percent of dry substrate weight (UCUM %)."
              },
              "spent_substrate": {
                "type": "object",
                "description": "End-of-run disposition of spent mushroom substrate (SMS).",
                "properties": {
                  "fate": {
                    "type": "string",
                    "enum": [
                      "composted",
                      "secondary_cultivation",
                      "animal_feed",
                      "soil_amendment",
                      "biofuel",
                      "landfill",
                      "other"
                    ]
                  },
                  "mass_kg": {
                    "type": "number",
                    "minimum": 0
                  },
                  "reuse_ref": {
                    "type": "string",
                    "description": "culture_ref of a downstream run when SMS becomes a new substrate."
                  }
                }
              },
              "inputs": {
                "type": "object",
                "description": "Optional per-run resource inputs for sustainability accounting.",
                "properties": {
                  "energy_kwh": {
                    "type": "number",
                    "minimum": 0
                  },
                  "water_liters": {
                    "type": "number",
                    "minimum": 0
                  },
                  "carbon_kg_co2e": {
                    "type": "number",
                    "minimum": 0
                  }
                }
              },
              "coordinates": {
                "type": "object",
                "properties": {
                  "lat": {
                    "type": "number",
                    "minimum": -90,
                    "maximum": 90
                  },
                  "lon": {
                    "type": "number",
                    "minimum": -180,
                    "maximum": 180
                  }
                }
              },
              "coordinate_uncertainty_m": {
                "type": "number",
                "minimum": 0,
                "description": "Horizontal radius of uncertainty in metres (Darwin Core coordinateUncertaintyInMeters)."
              },
              "region": {
                "type": "string"
              },
              "notes": {
                "type": "string"
              }
            }
          }
        },
        "environment_logs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "logged_at"
            ],
            "properties": {
              "culture_ref": {
                "type": "string"
              },
              "logged_at": {
                "type": "string",
                "format": "date-time"
              },
              "phase": {
                "type": "string",
                "enum": [
                  "inoculation",
                  "spawn_run",
                  "consolidation",
                  "primordia",
                  "fruiting",
                  "harvest",
                  "rest"
                ]
              },
              "source": {
                "type": "string",
                "enum": [
                  "manual",
                  "sensor"
                ],
                "description": "Provenance of the reading. Lets consumers separate hand readings from automated streams."
              },
              "device_id": {
                "type": "string",
                "description": "Sensor identity for multi-device or automated grows."
              },
              "temperature_c": {
                "type": "number",
                "description": "Air temperature, degrees Celsius (UCUM Cel)."
              },
              "substrate_temp_c": {
                "type": "number",
                "description": "Substrate or surface temperature, degrees Celsius (UCUM Cel). Colonization is exothermic."
              },
              "humidity_pct": {
                "type": "number",
                "minimum": 0,
                "maximum": 100,
                "description": "Relative humidity (UCUM %)."
              },
              "co2_ppm": {
                "type": "number",
                "minimum": 0,
                "description": "Carbon dioxide (UCUM [ppm])."
              },
              "fae_per_day": {
                "type": "number",
                "minimum": 0,
                "description": "Fresh air exchanges per day."
              },
              "light_hours": {
                "type": "number",
                "minimum": 0,
                "maximum": 24,
                "description": "Hours of light per day (UCUM h)."
              },
              "light_lux": {
                "type": "number",
                "minimum": 0,
                "description": "Illuminance (UCUM lx). Light is a fruiting trigger, not an energy input."
              },
              "colonization_pct": {
                "type": "number",
                "minimum": 0,
                "maximum": 100,
                "description": "Percent of substrate colonized (UCUM %)."
              },
              "misting_events": {
                "type": "integer",
                "minimum": 0,
                "description": "Manual watering events since the previous log."
              },
              "vpd_kpa": {
                "type": "number",
                "minimum": 0,
                "description": "Vapour pressure deficit (UCUM kPa). Derivable from temperature and humidity."
              },
              "notes": {
                "type": "string"
              }
            }
          }
        },
        "flushes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "harvest_date",
              "fresh_weight",
              "unit"
            ],
            "properties": {
              "culture_ref": {
                "type": "string"
              },
              "harvest_date": {
                "type": "string",
                "format": "date"
              },
              "flush_number": {
                "type": "integer",
                "minimum": 1
              },
              "fresh_weight": {
                "type": "number",
                "minimum": 0,
                "description": "Fresh mushroom mass at picking, in the unit given by unit. Numerator of biological efficiency."
              },
              "unit": {
                "type": "string",
                "enum": [
                  "g",
                  "kg",
                  "oz",
                  "lb"
                ]
              },
              "dry_weight": {
                "type": "number",
                "minimum": 0,
                "description": "Dried fruit-body mass, same unit as fresh_weight. Enables true dry-matter yield."
              },
              "fruitbody_moisture_pct": {
                "type": "number",
                "minimum": 0,
                "maximum": 100,
                "description": "Fruit-body moisture by weight (UCUM %). Basis for medicinal-assay normalization."
              },
              "biological_efficiency_pct": {
                "type": "number",
                "minimum": 0,
                "description": "DERIVED. fresh_weight / substrate_dry_weight x 100 (UCUM %). Values over 100 are normal."
              },
              "fruitbody_count": {
                "type": "integer",
                "minimum": 0,
                "description": "Number of fruiting bodies in the flush."
              },
              "assays": {
                "type": "array",
                "description": "Optional functional or medicinal compound assays for this flush.",
                "items": {
                  "type": "object",
                  "required": [
                    "analyte",
                    "value"
                  ],
                  "properties": {
                    "analyte": {
                      "type": "string",
                      "enum": [
                        "beta_glucan",
                        "alpha_glucan",
                        "total_glucan",
                        "triterpenes",
                        "ergothioneine",
                        "hericenones",
                        "erinacines",
                        "cordycepin",
                        "other"
                      ]
                    },
                    "value": {
                      "type": "number",
                      "minimum": 0
                    },
                    "unit": {
                      "type": "string",
                      "description": "UCUM unit, e.g. % for glucans and triterpenes, mg/g for ergothioneine."
                    },
                    "basis": {
                      "type": "string",
                      "enum": [
                        "dry_weight",
                        "fresh_weight",
                        "extract"
                      ],
                      "description": "Reporting basis. Results are meaningless without it."
                    },
                    "method": {
                      "type": "string",
                      "description": "Assay method, e.g. Megazyme_K-BGLU or HPLC."
                    },
                    "lab_ref": {
                      "type": "string",
                      "description": "Batch or report reference for traceability."
                    }
                  }
                }
              },
              "notes": {
                "type": "string"
              }
            }
          }
        },
        "contamination": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "detected_date",
              "type"
            ],
            "properties": {
              "culture_ref": {
                "type": "string"
              },
              "detected_date": {
                "type": "string",
                "format": "date"
              },
              "category": {
                "type": "string",
                "enum": [
                  "mold",
                  "bacterial",
                  "pest",
                  "viral",
                  "abiotic",
                  "unknown"
                ]
              },
              "type": {
                "type": "string",
                "description": "Specific contaminant. Open string; use the suggested vocabulary where known, else a plain description or 'unknown'. See spec section 7."
              },
              "phase": {
                "type": "string",
                "enum": [
                  "inoculation",
                  "spawn_run",
                  "consolidation",
                  "primordia",
                  "fruiting",
                  "harvest",
                  "rest"
                ]
              },
              "severity": {
                "type": "string",
                "enum": [
                  "trace",
                  "localized",
                  "widespread",
                  "total_loss"
                ]
              },
              "identification_method": {
                "type": "string",
                "enum": [
                  "visual",
                  "smell",
                  "microscopy",
                  "culture",
                  "lab_assay"
                ],
                "description": "How the contaminant was identified. Lets consumers weight confidence."
              },
              "action": {
                "type": "string",
                "enum": [
                  "isolate",
                  "discard",
                  "cutout",
                  "surface_treat",
                  "resterilize",
                  "increase_fae",
                  "lower_humidity",
                  "lower_temp",
                  "exclusion",
                  "biocontrol",
                  "sticky_trap",
                  "monitor",
                  "none"
                ]
              },
              "outcome": {
                "type": "string",
                "enum": [
                  "recovered",
                  "contained",
                  "lost"
                ]
              },
              "notes": {
                "type": "string"
              }
            }
          }
        }
      },
      "additionalProperties": true
    }
  ]
}
