{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agenticstiger.github.io/flux/schema/flux-manifest-0.5.0.json",
  "title": "FLUX Bundle Manifest",
  "description": "RFC-09: the self-describing manifest inside a FLUX evidence bundle. The archive is deterministic (sorted entries, zeroed timestamps), so identical bundle directories produce byte-identical archives. Signing is a detached signature over the manifest file bytes (flux-manifest.json), transport-agnostic: ssh-keygen -Y, cosign, or openssl all work. A verifier recomputes every file digest and the Merkle root offline, then replays the reference validator.",
  "type": "object",
  "required": [
    "manifestVersion",
    "schemaId",
    "fluxVersions",
    "files",
    "merkleRoot",
    "attestation"
  ],
  "additionalProperties": false,
  "properties": {
    "manifestVersion": {
      "const": 1
    },
    "generator": {
      "type": "string"
    },
    "schemaId": {
      "type": "string",
      "pattern": "^https://",
      "description": "The $id of the FLUX schema the bundle was validated against."
    },
    "fluxVersions": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^\\d+\\.\\d+\\.\\d+$"
      },
      "description": "Every fluxVersion pinned by documents in the bundle."
    },
    "files": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "string",
        "pattern": "^sha256:[a-f0-9]{64}$"
      },
      "description": "Relative path -> sha256 of every file in the bundle (the manifest itself excluded)."
    },
    "merkleRoot": {
      "type": "string",
      "pattern": "^sha256:[a-f0-9]{64}$",
      "description": "Root over the sorted file entries. Leaves are sha256('leaf:' + path + ':' + fileDigestHex) in path order; parents are sha256('node:' + leftHex + rightHex); an odd node is promoted unchanged."
    },
    "attestation": {
      "type": "object",
      "required": [
        "profile",
        "validator"
      ],
      "additionalProperties": false,
      "properties": {
        "profile": {
          "type": "string",
          "enum": [
            "core",
            "enterprise"
          ],
          "description": "Highest conformance profile the offline toolchain can attest. 'enterprise' requires a green validator plus a Playback scorecard in the bundle; 'runtime' (Level 3) requires a live engine and is never claimable by an offline bundler."
        },
        "validator": {
          "type": "object",
          "required": [
            "status"
          ],
          "additionalProperties": false,
          "properties": {
            "status": {
              "const": "green"
            },
            "documents": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "scorecards": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "playbackId",
              "grade",
              "credibility"
            ],
            "additionalProperties": false,
            "properties": {
              "playbackId": {
                "type": "string"
              },
              "grade": {
                "type": "string",
                "enum": [
                  "A",
                  "B",
                  "C",
                  "D",
                  "E",
                  "F"
                ]
              },
              "credibility": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              }
            }
          }
        },
        "seam": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "simulationId",
              "productRef",
              "exposeId",
              "fluidVersion"
            ],
            "additionalProperties": false,
            "properties": {
              "simulationId": {
                "type": "string"
              },
              "productRef": {
                "type": "string"
              },
              "exposeId": {
                "type": "string"
              },
              "fluidVersion": {
                "type": "string"
              },
              "contractDigest": {
                "type": "string",
                "pattern": "^sha256:[a-f0-9]{64}$"
              }
            }
          }
        }
      }
    }
  }
}
