{
  "type": "object",
  "properties": {
    "profile": {
      "const": "agent_runtime_contracts_v1"
    },
    "version": {
      "const": "1.0.0"
    },
    "package_id": {
      "type": "string",
      "minLength": 1
    },
    "contexts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "plane": {
            "enum": [
              "build",
              "product_runtime"
            ]
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "source_kind": {
            "enum": [
              "package",
              "repository",
              "runtime",
              "approved_knowledge",
              "memory"
            ]
          },
          "locator": {
            "type": "string",
            "minLength": 1
          },
          "scope": {
            "type": "string",
            "minLength": 1
          },
          "trust_class": {
            "enum": [
              "normative",
              "verified_state",
              "untrusted_evidence",
              "derived_memory"
            ]
          },
          "may_grant_authority": {
            "const": false
          },
          "required_fields": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "freshness_seconds": {
            "type": "integer",
            "minimum": 1
          },
          "loading": {
            "const": "on_demand"
          },
          "secret_policy": {
            "type": "string",
            "minLength": 1
          },
          "memory_admission": {
            "enum": [
              "never_authority",
              "verified_only"
            ]
          }
        },
        "required": [
          "id",
          "plane",
          "name",
          "source_kind",
          "locator",
          "scope",
          "trust_class",
          "may_grant_authority",
          "required_fields",
          "freshness_seconds",
          "loading",
          "secret_policy",
          "memory_admission"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "skills": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "plane": {
            "enum": [
              "build",
              "product_runtime"
            ]
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "version": {
            "type": "string",
            "minLength": 1
          },
          "format": {
            "const": "openagentworks_procedure"
          },
          "activation": {
            "type": "string",
            "minLength": 1
          },
          "instructions": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "minItems": 3
          },
          "context_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "tool_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "requirement_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "grants_permissions": {
            "const": false
          },
          "output_schema": {
            "type": "object"
          }
        },
        "required": [
          "id",
          "plane",
          "name",
          "version",
          "format",
          "activation",
          "instructions",
          "context_ids",
          "tool_ids",
          "requirement_ids",
          "grants_permissions",
          "output_schema"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "tools": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "plane": {
            "enum": [
              "build",
              "product_runtime"
            ]
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "transport": {
            "enum": [
              "function",
              "http",
              "mcp",
              "repository_adapter",
              "test_adapter"
            ]
          },
          "effect": {
            "enum": [
              "read",
              "propose",
              "internal_write",
              "external_write",
              "repository_write",
              "test_execution"
            ]
          },
          "input_schema": {
            "type": "object"
          },
          "output_schema": {
            "type": "object"
          },
          "policy_gate": {
            "type": "string",
            "minLength": 1
          },
          "idempotency": {
            "type": "string",
            "minLength": 1
          },
          "unknown_outcome": {
            "type": "string",
            "minLength": 1
          },
          "source_catalog_id": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "plane",
          "name",
          "transport",
          "effect",
          "input_schema",
          "output_schema",
          "policy_gate",
          "idempotency",
          "unknown_outcome",
          "source_catalog_id"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "brains": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "plane": {
            "enum": [
              "build",
              "product_runtime"
            ]
          },
          "kind": {
            "const": "model_plus_orchestrator"
          },
          "model_binding": {
            "type": "string",
            "minLength": 1
          },
          "planner": {
            "type": "string",
            "minLength": 1
          },
          "memory_scope": {
            "type": "string",
            "minLength": 1
          },
          "max_tool_calls_per_run": {
            "type": "integer",
            "minimum": 1
          },
          "foreground_deadline_seconds": {
            "type": "integer",
            "minimum": 1
          },
          "policy_enforcement": {
            "const": "outside_model"
          },
          "may_override_contract": {
            "const": false
          },
          "decision_record_fields": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "failure_mode": {
            "type": "string",
            "minLength": 1
          },
          "guardrails": {
            "type": "object",
            "properties": {
              "model_may_authorise_money": {
                "const": false
              },
              "model_may_attest_physical_facts": {
                "const": false
              },
              "memory_may_override_current_policy": {
                "const": false
              }
            },
            "required": [
              "model_may_authorise_money",
              "model_may_attest_physical_facts",
              "memory_may_override_current_policy"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "plane",
          "kind",
          "model_binding",
          "planner",
          "memory_scope",
          "max_tool_calls_per_run",
          "foreground_deadline_seconds",
          "policy_enforcement",
          "may_override_contract",
          "decision_record_fields",
          "failure_mode",
          "guardrails"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "agents": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "plane": {
            "enum": [
              "build",
              "product_runtime"
            ]
          },
          "role": {
            "type": "string",
            "minLength": 1
          },
          "brain_id": {
            "type": "string",
            "minLength": 1
          },
          "skill_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "context_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "tool_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "requirement_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "verification": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "plane",
          "role",
          "brain_id",
          "skill_ids",
          "context_ids",
          "tool_ids",
          "requirement_ids",
          "verification"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "authority_order": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "separation": {
      "type": "object",
      "properties": {
        "skill_is_permission": {
          "const": false
        },
        "model_is_policy_engine": {
          "const": false
        },
        "context_is_automatically_trusted": {
          "const": false
        },
        "private_chain_of_thought_required": {
          "const": false
        }
      },
      "required": [
        "skill_is_permission",
        "model_is_policy_engine",
        "context_is_automatically_trusted",
        "private_chain_of_thought_required"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "profile",
    "version",
    "package_id",
    "contexts",
    "skills",
    "tools",
    "brains",
    "agents",
    "authority_order",
    "separation"
  ],
  "additionalProperties": false,
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
