{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.driftframe.org/site-reading-governance/v2.0/machine-node.schema.json",
  "title": "Machine Node Orientation",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "machine_node_id",
    "canonical_identity",
    "title",
    "purpose",
    "control_plane_profile",
    "schema_release",
    "repository_role",
    "authority",
    "lifecycle_state",
    "coordination_horizon_id",
    "contracts",
    "campaigns",
    "current_provenance",
    "first_receipt_contract_id",
    "open_receipts",
    "invalidation_conditions",
    "downstream_consumers",
    "source_boundaries",
    "metadata"
  ],
  "properties": {
    "machine_node_id": {
      "$ref": "common.schema.json#/$defs/identifier"
    },
    "canonical_identity": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:[./-][a-z0-9]+)*$",
      "minLength": 5,
      "maxLength": 240
    },
    "title": {
      "type": "string",
      "minLength": 5,
      "maxLength": 180
    },
    "purpose": {
      "type": "string",
      "minLength": 20,
      "maxLength": 1000
    },
    "control_plane_profile": {
      "type": "string",
      "const": "0.3.0"
    },
    "schema_release": {
      "type": "string",
      "const": "2.1.0"
    },
    "repository_role": {
      "type": "string",
      "enum": [
        "program_specification",
        "enterprise_implementation",
        "simulated_final_state",
        "comparative_evidence",
        "site_reading_governance"
      ]
    },
    "authority": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode",
        "statement",
        "authorization_sources"
      ],
      "properties": {
        "mode": {
          "type": "string",
          "const": "orientation_only"
        },
        "statement": {
          "type": "string",
          "minLength": 20,
          "maxLength": 700
        },
        "authorization_sources": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 5,
            "maxLength": 240
          }
        }
      }
    },
    "lifecycle_state": {
      "type": "string",
      "enum": [
        "proposed",
        "reference_ready",
        "active",
        "settling",
        "superseded"
      ]
    },
    "coordination_horizon_id": {
      "$ref": "common.schema.json#/$defs/identifier"
    },
    "contracts": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "common.schema.json#/$defs/contractReference"
      }
    },
    "campaigns": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "campaign_id",
          "marking_schema_version",
          "status"
        ],
        "properties": {
          "campaign_id": {
            "$ref": "common.schema.json#/$defs/identifier"
          },
          "marking_schema_version": {
            "$ref": "common.schema.json#/$defs/semver"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "resting",
              "settling",
              "complete"
            ]
          }
        }
      }
    },
    "seed_lineage": {
      "$ref": "common.schema.json#/$defs/versionedCoordinate"
    },
    "current_provenance": {
      "$ref": "common.schema.json#/$defs/versionedCoordinate"
    },
    "first_receipt_contract_id": {
      "$ref": "common.schema.json#/$defs/identifier"
    },
    "open_receipts": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "common.schema.json#/$defs/identifier"
      }
    },
    "invalidation_conditions": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 10,
        "maxLength": 700
      }
    },
    "downstream_consumers": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 3,
        "maxLength": 240
      }
    },
    "source_boundaries": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source_class",
          "instruction_authority",
          "handling"
        ],
        "properties": {
          "source_class": {
            "type": "string",
            "enum": [
              "released_contract",
              "repository_content",
              "retrieved_content",
              "tool_output",
              "human_direction"
            ]
          },
          "instruction_authority": {
            "type": "string",
            "enum": [
              "governing",
              "advisory",
              "data_only"
            ]
          },
          "handling": {
            "type": "string",
            "minLength": 10,
            "maxLength": 700
          }
        }
      }
    },
    "metadata": {
      "$ref": "common.schema.json#/$defs/recordMetadata"
    }
  }
}
