{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "const": "testing.aiwg.io/v1"
    },
    "kind": {
      "const": "TestRunReceipt"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "createdAt": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
        },
        "toolVersion": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "name",
        "createdAt",
        "toolVersion"
      ]
    },
    "spec": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "root": {
          "type": "string"
        },
        "protocolHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "snapshotHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "afterSnapshotHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "inventoryPath": {
          "type": "string"
        },
        "runId": {
          "type": "string"
        },
        "mode": {
          "enum": [
            "execution",
            "discovery"
          ]
        },
        "sourceStable": {
          "type": "boolean"
        },
        "lanes": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "runner": {
                "type": "string"
              },
              "required": {
                "type": "boolean"
              },
              "mode": {
                "enum": [
                  "execution",
                  "discovery"
                ]
              },
              "process": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "argv": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "cwd": {
                    "type": "string"
                  },
                  "environment": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "explicitKeys": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "explicitValuesHash": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      },
                      "platform": {
                        "type": "string"
                      },
                      "arch": {
                        "type": "string"
                      },
                      "node": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "explicitKeys",
                      "explicitValuesHash",
                      "platform",
                      "arch",
                      "node"
                    ]
                  },
                  "startedAt": {
                    "type": "string"
                  },
                  "endedAt": {
                    "type": "string"
                  },
                  "durationMs": {
                    "type": "number",
                    "minimum": 0
                  },
                  "exitCode": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "signal": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reason": {
                    "enum": [
                      "exit",
                      "timeout",
                      "output-limit",
                      "spawn-error"
                    ]
                  },
                  "error": {
                    "type": "string"
                  },
                  "observedOutputBytes": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "required": [
                  "argv",
                  "cwd",
                  "environment",
                  "startedAt",
                  "endedAt",
                  "durationMs",
                  "exitCode",
                  "signal",
                  "reason",
                  "observedOutputBytes"
                ]
              },
              "version": {
                "anyOf": [
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "argv": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "cwd": {
                        "type": "string"
                      },
                      "environment": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "explicitKeys": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "explicitValuesHash": {
                            "type": "string",
                            "pattern": "^[a-f0-9]{64}$"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "arch": {
                            "type": "string"
                          },
                          "node": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "explicitKeys",
                          "explicitValuesHash",
                          "platform",
                          "arch",
                          "node"
                        ]
                      },
                      "startedAt": {
                        "type": "string"
                      },
                      "endedAt": {
                        "type": "string"
                      },
                      "durationMs": {
                        "type": "number",
                        "minimum": 0
                      },
                      "exitCode": {
                        "anyOf": [
                          {
                            "type": "integer"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "signal": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "reason": {
                        "enum": [
                          "exit",
                          "timeout",
                          "output-limit",
                          "spawn-error"
                        ]
                      },
                      "error": {
                        "type": "string"
                      },
                      "observedOutputBytes": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "stdout": {
                        "type": "string"
                      },
                      "stderr": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "argv",
                      "cwd",
                      "environment",
                      "startedAt",
                      "endedAt",
                      "durationMs",
                      "exitCode",
                      "signal",
                      "reason",
                      "observedOutputBytes",
                      "stdout",
                      "stderr"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stdout": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "path": {
                    "type": "string"
                  },
                  "hash": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                },
                "required": [
                  "path",
                  "hash"
                ]
              },
              "stderr": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "path": {
                    "type": "string"
                  },
                  "hash": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                },
                "required": [
                  "path",
                  "hash"
                ]
              },
              "normalized": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "cases": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1
                        },
                        "file": {
                          "anyOf": [
                            {
                              "type": "string",
                              "minLength": 1,
                              "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*(?:^|/)\\.\\.(?:/|$))[^\\u0000]+$"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "type": "string",
                          "minLength": 1
                        },
                        "status": {
                          "enum": [
                            "passed",
                            "failed",
                            "skipped",
                            "unknown"
                          ]
                        },
                        "durationMs": {
                          "type": "number",
                          "minimum": 0
                        }
                      },
                      "required": [
                        "id",
                        "file",
                        "name",
                        "status"
                      ]
                    }
                  },
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "path": {
                          "type": "string",
                          "minLength": 1,
                          "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*(?:^|/)\\.\\.(?:/|$))[^\\u0000]+$"
                        },
                        "status": {
                          "enum": [
                            "passed",
                            "failed",
                            "skipped",
                            "unknown"
                          ]
                        }
                      },
                      "required": [
                        "path",
                        "status"
                      ]
                    }
                  },
                  "summary": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "total": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "passed": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "failed": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "skipped": {
                        "type": "integer",
                        "minimum": 0
                      }
                    },
                    "required": [
                      "total",
                      "passed",
                      "failed",
                      "skipped"
                    ]
                  },
                  "errors": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string",
                          "minLength": 1
                        },
                        "message": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "complete": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "cases",
                  "files",
                  "summary",
                  "errors",
                  "complete"
                ]
              },
              "diagnostics": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ]
                }
              },
              "report": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "path": {
                    "type": "string"
                  },
                  "hash": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  },
                  "size": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "format": {
                    "type": "string"
                  },
                  "origin": {
                    "enum": [
                      "stdout",
                      "result-file"
                    ]
                  }
                },
                "required": [
                  "path",
                  "hash",
                  "size",
                  "format",
                  "origin"
                ]
              },
              "coverage": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "report": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "path": {
                        "type": "string"
                      },
                      "hash": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      }
                    },
                    "required": [
                      "path",
                      "hash"
                    ]
                  },
                  "normalized": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "version": {
                        "type": "string"
                      },
                      "format": {
                        "enum": [
                          "canonical",
                          "istanbul"
                        ]
                      },
                      "scope": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "root": {
                            "type": "string"
                          },
                          "sourceFiles": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "missingFiles": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "extraFiles": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": [
                          "root",
                          "sourceFiles",
                          "missingFiles",
                          "extraFiles"
                        ]
                      },
                      "files": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "path": {
                              "type": "string"
                            },
                            "metrics": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "lines": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "additionalProperties": false,
                                      "properties": {
                                        "covered": {
                                          "type": "integer",
                                          "minimum": 0
                                        },
                                        "total": {
                                          "type": "integer",
                                          "minimum": 0
                                        }
                                      },
                                      "required": [
                                        "covered",
                                        "total"
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "statements": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "additionalProperties": false,
                                      "properties": {
                                        "covered": {
                                          "type": "integer",
                                          "minimum": 0
                                        },
                                        "total": {
                                          "type": "integer",
                                          "minimum": 0
                                        }
                                      },
                                      "required": [
                                        "covered",
                                        "total"
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "functions": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "additionalProperties": false,
                                      "properties": {
                                        "covered": {
                                          "type": "integer",
                                          "minimum": 0
                                        },
                                        "total": {
                                          "type": "integer",
                                          "minimum": 0
                                        }
                                      },
                                      "required": [
                                        "covered",
                                        "total"
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "branches": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "additionalProperties": false,
                                      "properties": {
                                        "covered": {
                                          "type": "integer",
                                          "minimum": 0
                                        },
                                        "total": {
                                          "type": "integer",
                                          "minimum": 0
                                        }
                                      },
                                      "required": [
                                        "covered",
                                        "total"
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "lines",
                                "statements",
                                "functions",
                                "branches"
                              ]
                            }
                          },
                          "required": [
                            "path",
                            "metrics"
                          ]
                        }
                      },
                      "totals": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "lines": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": false,
                                "properties": {
                                  "covered": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "total": {
                                    "type": "integer",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "covered",
                                  "total"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "statements": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": false,
                                "properties": {
                                  "covered": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "total": {
                                    "type": "integer",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "covered",
                                  "total"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "functions": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": false,
                                "properties": {
                                  "covered": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "total": {
                                    "type": "integer",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "covered",
                                  "total"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "branches": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": false,
                                "properties": {
                                  "covered": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "total": {
                                    "type": "integer",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "covered",
                                  "total"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "lines",
                          "statements",
                          "functions",
                          "branches"
                        ]
                      },
                      "complete": {
                        "type": "boolean"
                      },
                      "errors": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "code",
                            "message"
                          ]
                        }
                      }
                    },
                    "required": [
                      "provider",
                      "version",
                      "format",
                      "scope",
                      "files",
                      "totals",
                      "complete",
                      "errors"
                    ]
                  }
                },
                "required": [
                  "report",
                  "normalized"
                ]
              }
            },
            "required": [
              "id",
              "runner",
              "required",
              "mode",
              "normalized",
              "diagnostics"
            ]
          }
        },
        "diagnostics": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "receiptHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "adapterHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "required": [
        "root",
        "protocolHash",
        "snapshotHash",
        "afterSnapshotHash",
        "inventoryPath",
        "runId",
        "mode",
        "sourceStable",
        "lanes",
        "diagnostics",
        "receiptHash"
      ]
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://aiwg.io/schemas/testing/test-run-receipt.v1.schema.json",
  "title": "test-run-receipt v1"
}
