{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/kitepon/Lattice/blob/main/docs/schemas/lattice.todo_structure_binding.v1.schema.json",
  "title": "lattice.todo_structure_binding.v1",
  "description": "Immutable activation binding emitted by a successful authoritative planned compile.",
  "$comment": "Runtime validation additionally enforces exact keys, strict timestamps, actor identity, and the canonical self-digest.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema", "project_id", "plan_key", "plan_version", "topology_digest", "profile",
    "baseline_sha", "structure_set_digest", "compiled_head_sha", "compile_artifact_digest",
    "activated_at", "actor", "binding_digest"
  ],
  "properties": {
    "schema": { "const": "lattice.todo_structure_binding.v1" },
    "project_id": { "$ref": "#/$defs/identifier" },
    "plan_key": { "$ref": "#/$defs/identifier" },
    "plan_version": { "$ref": "#/$defs/identifier" },
    "topology_digest": { "$ref": "#/$defs/digest" },
    "profile": { "const": "code-dataflow" },
    "baseline_sha": { "$ref": "#/$defs/gitSha" },
    "structure_set_digest": { "$ref": "#/$defs/digest" },
    "compiled_head_sha": { "$ref": "#/$defs/gitSha" },
    "compile_artifact_digest": { "$ref": "#/$defs/digest" },
    "activated_at": { "$ref": "#/$defs/strictTimestamp" },
    "actor": { "$ref": "#/$defs/actor" },
    "binding_digest": { "$ref": "#/$defs/digest" }
  },
  "$defs": {
    "identifier": { "type": "string", "pattern": "^[0-9A-Za-z](?:[0-9A-Za-z._-]{0,127})$" },
    "digest": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "gitSha": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
    "strictTimestamp": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"
    },
    "actor": {
      "type": "object", "additionalProperties": false,
      "required": ["host", "session", "agent"],
      "properties": {
        "host": { "$ref": "#/$defs/identifier" },
        "session": { "$ref": "#/$defs/identifier" },
        "agent": { "$ref": "#/$defs/identifier" }
      }
    }
  }
}
