{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://agoragentic.com/schema/micro-ecf-policy.v1.json",
  "title": "Micro ECF Policy v1",
  "description": "Portable local governance policy for a Micro ECF agent or swarm before Agent OS preview.",
  "type": "object",
  "required": [
    "schema",
    "agent_manifest",
    "context_policy",
    "tool_policy",
    "budget_policy",
    "approval_policy",
    "memory_policy",
    "swarm_policy",
    "deployment_policy"
  ],
  "properties": {
    "schema": {
      "const": "agoragentic.micro-ecf.policy.v1"
    },
    "agent_manifest": {
      "type": "object",
      "required": ["name", "primary_goal"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "framework": { "type": "string" },
        "primary_goal": { "type": "string", "minLength": 1 },
        "runtime_shape": { "type": "string" }
      },
      "additionalProperties": true
    },
    "context_policy": {
      "type": "object",
      "required": ["allowed_sources", "denied_sources"],
      "properties": {
        "allowed_sources": {
          "type": "array",
          "items": { "type": "string" }
        },
        "denied_sources": {
          "type": "array",
          "items": { "type": "string" }
        },
        "retention": { "type": "string" },
        "redaction": { "type": "string" }
      },
      "additionalProperties": true
    },
    "tool_policy": {
      "type": "object",
      "required": ["allowed_tools", "denied_tools"],
      "properties": {
        "allowed_tools": {
          "type": "array",
          "items": { "type": "string" }
        },
        "denied_tools": {
          "type": "array",
          "items": { "type": "string" }
        },
        "side_effects": { "type": "string" }
      },
      "additionalProperties": true
    },
    "budget_policy": {
      "type": "object",
      "required": ["treasury_required", "max_daily_spend_usdc", "approval_required_above_usdc"],
      "properties": {
        "treasury_required": { "type": "boolean" },
        "max_daily_spend_usdc": { "type": "number", "minimum": 0 },
        "approval_required_above_usdc": { "type": "number", "minimum": 0 },
        "recommended_start_reserve_usdc": { "type": "number", "minimum": 0 }
      },
      "additionalProperties": true
    },
    "approval_policy": {
      "type": "object",
      "required": ["autonomous", "human_gated"],
      "properties": {
        "autonomous": {
          "type": "array",
          "items": { "type": "string" }
        },
        "human_gated": {
          "type": "array",
          "items": { "type": "string" }
        }
      },
      "additionalProperties": true
    },
    "memory_policy": {
      "type": "object",
      "required": ["write_gate", "secret_storage"],
      "properties": {
        "write_gate": { "type": "string" },
        "secret_storage": { "type": "string" }
      },
      "additionalProperties": true
    },
    "swarm_policy": {
      "type": "object",
      "required": ["max_agents", "delegation"],
      "properties": {
        "max_agents": { "type": "integer", "minimum": 1 },
        "delegation": { "type": "string" }
      },
      "additionalProperties": true
    },
    "deployment_policy": {
      "type": "object",
      "required": ["exposure_mode", "first_proof_required"],
      "properties": {
        "hosting_target": { "type": "string" },
        "exposure_mode": {
          "type": "string",
          "enum": ["private_only", "public_api", "marketplace_seller", "x402_paid_edge"]
        },
        "first_proof_required": { "type": "boolean" },
        "source": {
          "type": "object",
          "properties": {
            "type": { "type": "string" },
            "ref": { "type": "string" }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
