{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://phronesis.world/locus/lab-log.schema.json",
  "title": "locus lab log",
  "description": "Machine-readable run record for locus energy hardware prototypes P0\u2013P3. Conservation-visible: irradiance and power co-occur; status is binary.",
  "type": "object",
  "required": [
    "schema",
    "id",
    "prototype",
    "status",
    "goal",
    "samples"
  ],
  "additionalProperties": true,
  "properties": {
    "schema": {
      "const": "locus-lab-log/1"
    },
    "id": {
      "type": "string",
      "minLength": 4,
      "description": "Stable run id, e.g. YYYYMMDD-HHMM-pN-slug"
    },
    "prototype": {
      "type": "string",
      "enum": [
        "P0",
        "P1",
        "P2",
        "P3",
        "RP0"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "pass",
        "fail",
        "aborted"
      ]
    },
    "goal": {
      "type": "string",
      "minLength": 8,
      "description": "Pass line held fixed for this run \u2014 do not rewrite mid-run"
    },
    "started": {
      "type": "string",
      "format": "date-time"
    },
    "ended": {
      "type": "string",
      "format": "date-time"
    },
    "parts": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "pv",
              "mppt",
              "load",
              "fibre",
              "collector",
              "diffuser",
              "moss",
              "algae",
              "battery",
              "logger",
              "sensor",
              "other"
            ]
          },
          "model": {
            "type": "string"
          },
          "serial": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        }
      }
    },
    "organism": {
      "type": "string",
      "enum": [
        "moss",
        "algae",
        "other"
      ],
      "description": "L4 live-layer organism when present (P2+). Prefer parts[].role moss|algae for BOM detail."
    },
    "storage": {
      "type": "object",
      "description": "How this run stores energy. Electrochemical = L2 battery; algae_biomass = L4 chemical store.",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "none",
            "electrochemical",
            "algae_biomass",
            "both"
          ]
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "envelope_dry": {
      "type": "object",
      "description": "Pre-stated dry-bay bounds (required for P2+)",
      "properties": {
        "rh_max": {
          "type": "number"
        },
        "rh_min": {
          "type": "number"
        },
        "dewpoint_max_c": {
          "type": "number"
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "calibration": {
      "type": "object",
      "properties": {
        "lux_to_wm2": {
          "type": [
            "number",
            "null"
          ]
        },
        "irradiance_instrument": {
          "type": "string"
        },
        "lux_instrument": {
          "type": "string"
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "summary": {
      "type": "object",
      "properties": {
        "energy_baseline_wh": {
          "type": "number"
        },
        "energy_treatment_wh": {
          "type": "number"
        },
        "duration_s": {
          "type": "number"
        },
        "optical_delivery": {
          "type": "number",
          "description": "0\u20131 end-to-end optical if measured"
        },
        "biomass_start_g": {
          "type": "number",
          "description": "Dry biomass at run start (algae battery SoC)"
        },
        "biomass_end_g": {
          "type": "number",
          "description": "Dry biomass at run end"
        },
        "biomass_gain_g": {
          "type": "number",
          "description": "end \u2212 start; chemical store delta"
        },
        "od_start": {
          "type": "number",
          "description": "Optical density proxy at start"
        },
        "od_end": {
          "type": "number",
          "description": "Optical density proxy at end"
        },
        "notes": {
          "type": "string"
        },
        "f0_hz": {
          "type": "number"
        },
        "f_drive_hz": {
          "type": "number"
        },
        "energy_piezo_j": {
          "type": "number"
        }
      }
    },
    "samples": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "t"
        ],
        "properties": {
          "t": {
            "type": "string",
            "format": "date-time"
          },
          "G": {
            "type": "number",
            "description": "W/m\u00b2 irradiance"
          },
          "lux_proxy": {
            "type": "number"
          },
          "V_pv": {
            "type": "number"
          },
          "I_pv": {
            "type": "number"
          },
          "P_pv": {
            "type": "number"
          },
          "P_load": {
            "type": "number"
          },
          "lux_exit": {
            "type": "number"
          },
          "T_wet": {
            "type": "number"
          },
          "RH_wet": {
            "type": "number"
          },
          "T_dry": {
            "type": "number"
          },
          "RH_dry": {
            "type": "number"
          },
          "OD": {
            "type": "number",
            "description": "Algae culture optical density \u2014 biomass battery SoC proxy"
          },
          "V_batt": {
            "type": "number",
            "description": "Electrochemical battery voltage if L2 store present"
          },
          "f_drive": {
            "type": "number",
            "description": "Drive frequency Hz"
          },
          "f0": {
            "type": "number",
            "description": "Membrane natural frequency Hz"
          },
          "x_peak": {
            "type": "number",
            "description": "Peak displacement m"
          },
          "F_drive": {
            "type": "number",
            "description": "Drive force N"
          },
          "P_piezo": {
            "type": "number",
            "description": "Piezo harvest power W"
          },
          "V_harv": {
            "type": "number"
          },
          "I_harv": {
            "type": "number"
          },
          "drive_on": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      }
    },
    "photos": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Paths or URLs to setup photos"
    },
    "notes": {
      "type": "string"
    },
    "scheme": {
      "type": "string",
      "enum": [
        "grow_your_own_energy",
        "resonance_harvester",
        "hybrid"
      ],
      "description": "Which locus scheme this run belongs to"
    }
  }
}
