{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://jarvislandingdeploy.vercel.app/agent-skill-permission-manifest.schema.json",
  "title": "Agent Skill Permission Manifest",
  "description": "A portable permission manifest for reviewing AI-agent skills before install, sale, publication, delegation, or production use.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "skill",
    "authority",
    "inputs",
    "tools",
    "external_actions",
    "memory_policy",
    "receipt_policy",
    "exception_policy",
    "review"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "1.0.0"
    },
    "skill": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "version", "purpose", "runtime", "status"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "version": { "type": "string", "minLength": 1 },
        "maintainer": { "type": "string" },
        "purpose": { "type": "string", "minLength": 20 },
        "runtime": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string", "examples": ["OpenClaw", "Claude Code", "Hermes", "Codex", "browser-agent"] }
        },
        "status": { "enum": ["draft", "sandbox", "pilot", "production", "deprecated"] },
        "non_goals": { "type": "array", "items": { "type": "string" } }
      }
    },
    "authority": {
      "type": "object",
      "additionalProperties": false,
      "required": ["file_read", "file_write", "browser", "external_apis", "messaging", "finance_spend", "memory_read", "memory_write", "workflow_triggers"],
      "properties": {
        "file_read": { "$ref": "#/$defs/authority_area" },
        "file_write": { "$ref": "#/$defs/authority_area" },
        "browser": { "$ref": "#/$defs/authority_area" },
        "external_apis": { "$ref": "#/$defs/authority_area" },
        "messaging": { "$ref": "#/$defs/authority_area" },
        "finance_spend": { "$ref": "#/$defs/authority_area" },
        "memory_read": { "$ref": "#/$defs/authority_area" },
        "memory_write": { "$ref": "#/$defs/authority_area" },
        "workflow_triggers": { "$ref": "#/$defs/authority_area" }
      }
    },
    "inputs": {
      "type": "object",
      "additionalProperties": false,
      "required": ["allowed", "forbidden"],
      "properties": {
        "allowed": {
          "type": "array",
          "items": { "$ref": "#/$defs/input_source" }
        },
        "forbidden": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        }
      }
    },
    "tools": {
      "type": "array",
      "items": { "$ref": "#/$defs/tool_rule" }
    },
    "external_actions": {
      "type": "object",
      "additionalProperties": false,
      "required": ["default_mode", "requires_approval", "forbidden_actions"],
      "properties": {
        "default_mode": { "enum": ["forbidden", "draft", "staging", "direct"] },
        "requires_approval": { "type": "array", "items": { "type": "string" } },
        "forbidden_actions": { "type": "array", "items": { "type": "string" } },
        "pre_authorized_channels": { "type": "array", "items": { "type": "string" } },
        "receipt_required": { "type": "boolean", "const": true }
      }
    },
    "memory_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["read_scope", "write_mode", "promotion_required_fields", "expiry_rule", "secrets_policy"],
      "properties": {
        "read_scope": { "type": "string" },
        "write_mode": { "enum": ["none", "propose_only", "direct_with_receipt"] },
        "promotion_required_fields": {
          "type": "array",
          "items": { "enum": ["source", "timestamp", "owner", "scope", "confidence", "replaces", "expiry_or_review_date", "reason"] },
          "minItems": 8,
          "uniqueItems": true
        },
        "expiry_rule": { "type": "string" },
        "conflict_rule": { "type": "string" },
        "secrets_policy": { "enum": ["never_read_or_write", "redacted_only", "explicit_approval_required"] }
      }
    },
    "receipt_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["required", "fields"],
      "properties": {
        "required": { "type": "boolean", "const": true },
        "fields": {
          "type": "array",
          "items": { "enum": ["skill", "version", "task", "inputs_read", "tools_used", "external_actions_taken", "files_changed", "memory_changes_proposed", "memory_changes_written", "approvals_requested", "exceptions_queued", "rollback_available", "output_artifacts", "confidence"] },
          "minItems": 8,
          "uniqueItems": true
        },
        "storage_location": { "type": "string" },
        "retention_rule": { "type": "string" }
      }
    },
    "exception_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["stop_conditions", "packet_fields", "human_owner_required"],
      "properties": {
        "stop_conditions": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "packet_fields": { "type": "array", "minItems": 5, "items": { "type": "string" } },
        "human_owner_required": { "type": "boolean", "const": true },
        "sla": { "type": "string" }
      }
    },
    "evals": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "type", "expected_outcome"],
        "properties": {
          "name": { "type": "string" },
          "type": { "enum": ["happy_path", "edge_case", "adversarial", "rollback", "permission_boundary", "memory_poisoning"] },
          "expected_outcome": { "type": "string" },
          "fixture": { "type": "string" }
        }
      }
    },
    "review": {
      "type": "object",
      "additionalProperties": false,
      "required": ["reviewer", "review_date", "verdict"],
      "properties": {
        "reviewer": { "type": "string" },
        "review_date": { "type": "string", "format": "date" },
        "verdict": { "enum": ["safe_to_run", "sandbox_only", "install_with_limits", "ask_for_changes", "do_not_run"] },
        "notes": { "type": "string" },
        "next_review_date": { "type": "string", "format": "date" }
      }
    }
  },
  "$defs": {
    "authority_area": {
      "type": "object",
      "additionalProperties": false,
      "required": ["allowed", "mode", "approval_required"],
      "properties": {
        "allowed": { "type": "boolean" },
        "mode": { "type": "string", "examples": ["none", "scoped", "draft_only", "read_only", "approved_domains", "propose_only", "direct"] },
        "approval_required": { "type": "boolean" },
        "notes": { "type": "string" }
      }
    },
    "input_source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "source", "sensitivity", "freshness_rule", "may_store"],
      "properties": {
        "name": { "type": "string" },
        "source": { "type": "string" },
        "sensitivity": { "enum": ["low", "medium", "high", "critical"] },
        "freshness_rule": { "type": "string" },
        "may_store": { "type": "boolean" }
      }
    },
    "tool_rule": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "allowed_scope", "forbidden_actions", "receipt_required", "approval_rule"],
      "properties": {
        "name": { "type": "string" },
        "allowed_scope": { "type": "string" },
        "forbidden_actions": { "type": "array", "items": { "type": "string" } },
        "receipt_required": { "type": "boolean", "const": true },
        "approval_rule": { "type": "string" }
      }
    }
  }
}
