{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/huggingbay-xyz/json-schema/huggingbay-xyz-run-card-schema.json",
  "title": "RunCard",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/huggingbay-xyz-openapi.json#/components/schemas/RunCard",
  "type": "object",
  "required": [
    "schema",
    "contractVersion",
    "id",
    "decisionId",
    "agentHandoffId",
    "signingKeyId",
    "task",
    "constraints",
    "rig",
    "representation",
    "runtime",
    "fit",
    "smoke",
    "recovery",
    "policy",
    "evidenceCutoff",
    "executableState",
    "authority",
    "authorization",
    "use",
    "runCardDigest",
    "signature"
  ],
  "properties": {
    "schema": {
      "const": "hugging-bay.run-card.v1"
    },
    "contractVersion": {
      "const": "1.1.0"
    },
    "id": {
      "type": "string",
      "pattern": "^hbrc_[a-f0-9]{32}([a-f0-9]{32})?$"
    },
    "decisionId": {
      "type": "string",
      "pattern": "^hbd_[a-f0-9]{32}([a-f0-9]{32})?$"
    },
    "agentHandoffId": {
      "type": "string",
      "pattern": "^hbah_[a-f0-9]{32}([a-f0-9]{32})?$"
    },
    "publisherReferralId": {
      "type": "string",
      "maxLength": 160
    },
    "signingKeyId": {
      "type": "string",
      "pattern": "^ed25519:[a-f0-9]{24}$"
    },
    "task": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "constraints": {
      "type": "object",
      "maxProperties": 8,
      "properties": {
        "contextTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4194304
        },
        "maxDownloadBytes": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10995116277760
        },
        "maxDiskBytes": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10995116277760
        },
        "commercialSafe": {
          "type": "boolean"
        },
        "privacy": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "bandwidthClass": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "qualityFloor": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "language": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      },
      "additionalProperties": false
    },
    "rig": {
      "type": "object",
      "required": [
        "id",
        "profileDigest"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "profileDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      },
      "additionalProperties": false
    },
    "representation": {
      "type": "object",
      "required": [
        "artifactId",
        "representationId",
        "source",
        "selectedFilesDigest",
        "representationDigest",
        "evidenceSnapshotDigest",
        "files"
      ],
      "properties": {
        "artifactId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "representationId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "source": {
          "type": "object",
          "required": [
            "provider",
            "identity",
            "revision"
          ],
          "properties": {
            "provider": {
              "type": "string",
              "minLength": 1,
              "maxLength": 40
            },
            "identity": {
              "type": "string",
              "minLength": 1,
              "maxLength": 240
            },
            "revision": {
              "type": "string",
              "pattern": "^[a-f0-9]{40}([a-f0-9]{24})?$"
            },
            "note": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object",
                  "required": [
                    "summary"
                  ],
                  "properties": {
                    "summary": {
                      "type": "string"
                    },
                    "downloadable": {
                      "type": "boolean"
                    }
                  },
                  "additionalProperties": false
                }
              ]
            },
            "noteMessage": {
              "type": "string",
              "description": "Original route note, when a public qualification occupies note."
            }
          },
          "additionalProperties": false
        },
        "selectedFilesDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "representationDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "evidenceSnapshotDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "files": {
          "type": "array",
          "minItems": 1,
          "maxItems": 256,
          "items": {
            "type": "object",
            "required": [
              "path",
              "role",
              "sizeBytes",
              "sha256"
            ],
            "properties": {
              "path": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "role": {
                "type": "string",
                "minLength": 1,
                "maxLength": 40
              },
              "sizeBytes": {
                "type": "integer",
                "minimum": 1
              },
              "sha256": {
                "type": "string",
                "pattern": "^sha256:[a-f0-9]{64}$"
              },
              "note": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "required": [
                      "summary"
                    ],
                    "properties": {
                      "summary": {
                        "type": "string"
                      },
                      "downloadable": {
                        "type": "boolean"
                      }
                    },
                    "additionalProperties": false
                  }
                ]
              },
              "noteMessage": {
                "type": "string",
                "description": "Original route note, when a public qualification occupies note."
              }
            },
            "additionalProperties": false
          }
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      },
      "additionalProperties": false
    },
    "runtime": {
      "type": "object",
      "required": [
        "adapterId",
        "engineVersion",
        "adapterVersion",
        "adapterAbiVersion",
        "executable",
        "contractDigest",
        "commandEvidenceDigest",
        "argv"
      ],
      "properties": {
        "adapterId": {
          "type": "string",
          "enum": [
            "llama.cpp",
            "sentence-transformers",
            "transformers"
          ]
        },
        "engineVersion": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "adapterVersion": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "adapterAbiVersion": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "executable": {
          "const": "hbay-runtime"
        },
        "contractDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "commandEvidenceDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "argv": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512
          }
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      },
      "additionalProperties": false
    },
    "fit": {
      "type": "object",
      "required": [
        "verdict",
        "evidenceLevel",
        "requiredBytes",
        "headroomBytes",
        "evidenceDigest"
      ],
      "additionalProperties": false,
      "properties": {
        "verdict": {
          "const": "fits"
        },
        "evidenceLevel": {
          "type": "string",
          "enum": [
            "measured",
            "conservative-estimate"
          ]
        },
        "requiredBytes": {
          "type": "integer",
          "minimum": 1
        },
        "headroomBytes": {
          "type": "integer",
          "minimum": 0
        },
        "evidenceDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      }
    },
    "smoke": {
      "type": "object",
      "required": [
        "suiteId",
        "expectedBoundary",
        "passed",
        "passedAt",
        "evidenceDigest"
      ],
      "additionalProperties": false,
      "properties": {
        "suiteId": {
          "type": "string"
        },
        "expectedBoundary": {
          "type": "string"
        },
        "passed": {
          "const": true
        },
        "passedAt": {
          "type": "string",
          "format": "date-time"
        },
        "evidenceDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      }
    },
    "recovery": {
      "type": "object",
      "required": [
        "code",
        "path"
      ],
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "path": {
          "type": "string",
          "pattern": "^/[^/].*"
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      }
    },
    "policy": {
      "type": "object",
      "required": [
        "decision",
        "policyDigest",
        "reasonCodes",
        "expiresAt"
      ],
      "additionalProperties": false,
      "properties": {
        "decision": {
          "const": "allow"
        },
        "policyDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "reasonCodes": {
          "type": "array",
          "maxItems": 64,
          "items": {
            "type": "string"
          }
        },
        "expiresAt": {
          "type": "string",
          "format": "date-time"
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      }
    },
    "evidenceCutoff": {
      "type": "string",
      "format": "date-time"
    },
    "executableState": {
      "type": "string",
      "enum": [
        "complete-runnable",
        "complete-verified"
      ]
    },
    "authority": {
      "type": "object",
      "required": [
        "automationPreflightId",
        "decisionDigest",
        "policyEvidenceId",
        "policyEvidenceDigest"
      ],
      "additionalProperties": false,
      "properties": {
        "automationPreflightId": {
          "type": "string",
          "pattern": "^hbap_[a-f0-9]{64}$"
        },
        "decisionDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "policyEvidenceId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "policyEvidenceDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      }
    },
    "authorization": {
      "type": "object",
      "required": [
        "principalId",
        "owner"
      ],
      "additionalProperties": false,
      "properties": {
        "principalId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "owner": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      }
    },
    "use": {
      "type": "object",
      "required": [
        "argv"
      ],
      "additionalProperties": false,
      "properties": {
        "argv": {
          "type": "array",
          "minItems": 3,
          "maxItems": 3,
          "prefixItems": [
            {
              "const": "hbay"
            },
            {
              "const": "use"
            },
            {
              "type": "string",
              "pattern": "^hbrc_[a-f0-9]{32}([a-f0-9]{32})?$"
            }
          ]
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      }
    },
    "runCardDigest": {
      "type": "string",
      "pattern": "^sha256:[a-f0-9]{64}$"
    },
    "signature": {
      "type": "object",
      "required": [
        "algorithm",
        "keyId",
        "canonicalDigest",
        "value"
      ],
      "additionalProperties": false,
      "properties": {
        "algorithm": {
          "const": "Ed25519"
        },
        "keyId": {
          "type": "string",
          "pattern": "^ed25519:[a-f0-9]{24}$"
        },
        "canonicalDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "value": {
          "type": "string",
          "minLength": 1
        },
        "note": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "required": [
                "summary"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "downloadable": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "noteMessage": {
          "type": "string",
          "description": "Original route note, when a public qualification occupies note."
        }
      }
    },
    "note": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "required": [
            "summary"
          ],
          "properties": {
            "summary": {
              "type": "string"
            },
            "downloadable": {
              "type": "boolean"
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "noteMessage": {
      "type": "string",
      "description": "Original route note, when a public qualification occupies note."
    }
  },
  "additionalProperties": false
}