{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:semantic-management-framework:0.1:schema:binding",
  "$comment": "SPDX-License-Identifier: Apache-2.0",
  "title": "SMF Binding",
  "type": "object",
  "properties": {
    "smf": {
      "const": "0.1"
    },
    "kind": {
      "const": "Binding"
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*(\\.[a-z0-9_]+)+$",
      "description": "Optional stable identifier, so a ClaimTrace can name this build record (execution.binding). Without one, a claim names it as '<platform>:<ref>'."
    },
    "subject": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*(\\.[a-z0-9_]+)+(@v[0-9]+)?$",
      "description": "Reference to an ID, optionally pinned to a version (id@vN)."
    },
    "implementation": {
      "type": "object",
      "properties": {
        "platform": {
          "type": "string",
          "description": "Free-form platform name. Recommended values: power_bi, tableau, dbt, metricflow, cube, looker, snowflake, databricks, sql, ossie. Use the same spelling across a repository so bindings can be grouped."
        },
        "ref": {
          "type": "string",
          "description": "Locator inside the platform (measure path, model and metric name, file path)."
        },
        "derived_from": {
          "type": "object",
          "description": "The implementation this one was generated from, for hub-and-spoke formats such as Apache Ossie. Lets Assurance tell a hand-built implementation from one produced by a converter.",
          "properties": {
            "platform": {
              "type": "string"
            },
            "ref": {
              "type": "string"
            }
          },
          "required": [
            "platform",
            "ref"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "platform",
        "ref"
      ],
      "additionalProperties": false
    },
    "expression_snapshot": {
      "type": "object",
      "description": "The executable logic as it was when conformance_status was last assessed. A tool that can read the platform recomputes the digest and reports drift when it differs.",
      "properties": {
        "text": {
          "type": "string"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "captured_on": {
          "type": "string",
          "format": "date"
        }
      },
      "required": [
        "sha256",
        "captured_on"
      ],
      "additionalProperties": false
    },
    "baseline": {
      "type": "string"
    },
    "conformance_status": {
      "enum": [
        "conformant",
        "non_conformant",
        "untested",
        "legacy"
      ]
    }
  },
  "required": [
    "smf",
    "kind",
    "subject",
    "implementation"
  ],
  "additionalProperties": false
}
