{
  "rootib": "RootIB: RB-20260304173933-DS000001",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://barbrickdesign.github.io/deepsoil/schemas/agent.manifest.schema.json",
  "title": "DeepSoil Agent Manifest",
  "description": "Schema for autonomous agent entries in the DeepSoil substrate. Every agent MUST map to a RootIB agent identity, carry lineage anchors, include blessing metadata, follow RootIB activation and permissioning, and support agent-to-agent discovery and delegation. RootIB is the authoritative identity and governance layer; DeepSoil stores and indexes the entry.",
  "type": "object",
  "required": [
    "agent_mint",
    "name",
    "role",
    "version",
    "description",
    "capabilities",
    "rootib",
    "rootib_lineage",
    "rootib_blessing",
    "deepsoil_meta"
  ],
  "properties": {
    "agent_mint": {
      "type": "string",
      "description": "Solana mint address that serves as the globally unique key for this agent in DeepSoil.",
      "examples": ["AGENTMint11111111111111111111111111111111"]
    },
    "name": {
      "type": "string",
      "description": "Namespaced agent name. Convention: '<substrate>.agent.<role>'.",
      "minLength": 1,
      "maxLength": 256,
      "examples": ["soil.agent.planner", "soil.agent.executor"]
    },
    "role": {
      "type": "string",
      "description": "Primary role of this agent. Used by other agents for discovery and delegation.",
      "minLength": 1,
      "examples": ["planner", "executor", "validator", "orchestrator", "monitor"]
    },
    "version": {
      "type": "string",
      "description": "Semantic version of this agent.",
      "pattern": "^\\d+\\.\\d+\\.\\d+(-[a-z0-9.]+)?$",
      "examples": ["0.1.0", "1.0.0"]
    },
    "description": {
      "type": "string",
      "description": "Human-readable description of what this agent does.",
      "minLength": 1
    },
    "capabilities": {
      "type": "array",
      "description": "Semantic capability tags that describe what this agent can do. Used for agent-to-agent discovery.",
      "items": { "type": "string" },
      "minItems": 1,
      "examples": [["plan", "decompose_tasks", "select_tools"]]
    },
    "required_tools": {
      "type": "array",
      "description": "List of tool_mint values that this agent requires to operate. The agent MUST NOT activate if any required tool is revoked.",
      "items": { "type": "string" }
    },
    "identity": {
      "type": "object",
      "description": "Agent identity declaration.",
      "properties": {
        "public_key": {
          "type": "string",
          "description": "Solana public key of the agent's wallet."
        },
        "lineage_root": {
          "type": "string",
          "description": "idea_id or RootIB of the root idea this agent implements."
        }
      }
    },
    "delegation": {
      "type": "object",
      "description": "Agent delegation configuration. Describes which agents this agent can delegate to and accept delegation from.",
      "properties": {
        "can_delegate_to": {
          "type": "array",
          "description": "agent_mint values of agents this agent is authorised to delegate tasks to.",
          "items": { "type": "string" }
        },
        "accepts_delegation_from": {
          "type": "array",
          "description": "agent_mint values of agents that may delegate tasks to this agent.",
          "items": { "type": "string" }
        }
      }
    },
    "rootib": {
      "type": "string",
      "description": "RootIB identity string for this agent. Format: 'RootIB: <CreatorID>-<YYYYMMDDHHmmss>-<8HEX>'. This is the authoritative provenance anchor issued by the agent creator. Required for all DeepSoil entries.",
      "pattern": "^RootIB: [A-Za-z0-9_.-]{1,64}-\\d{14,17}-[0-9A-Fa-f]{8}$"
    },
    "rootib_lineage": {
      "type": "object",
      "description": "RootIB lineage anchor. References the chain of provenance from genesis to this agent. Validated by RootIB; stored by DeepSoil.",
      "required": ["lineage_root"],
      "properties": {
        "lineage_root": {
          "type": "string",
          "description": "The RootIB identity at the root of this agent's lineage chain.",
          "pattern": "^RootIB: [A-Za-z0-9_.-]{1,64}-\\d{14,17}-[0-9A-Fa-f]{8}$"
        },
        "parent_rootib": {
          "type": ["string", "null"],
          "description": "RootIB identity of the direct parent entry in the lineage chain.",
          "pattern": "^RootIB: [A-Za-z0-9_.-]{1,64}-\\d{14,17}-[0-9A-Fa-f]{8}$"
        },
        "idea_root": {
          "type": "string",
          "description": "idea_id of the rooted idea this agent was conceived from.",
          "examples": ["idea:rooted-planning"]
        },
        "parents": {
          "type": "array",
          "description": "Ordered list of parent RootIB identities from genesis to direct parent.",
          "items": {
            "type": "string",
            "pattern": "^RootIB: [A-Za-z0-9_.-]{1,64}-\\d{14,17}-[0-9A-Fa-f]{8}$"
          }
        }
      },
      "additionalProperties": false
    },
    "rootib_blessing": {
      "type": "object",
      "description": "RootIB blessing metadata. An agent with blessed=false MUST NOT be activated. RootIB activation contracts are enforced at registration and activation time.",
      "required": ["blessed", "blessings"],
      "properties": {
        "blessed": {
          "type": "boolean",
          "description": "Whether this agent has received at least one active blessing. Agents without an active blessing are blocked from activation per RootIB rules."
        },
        "blessings": {
          "type": "array",
          "description": "Array of active blessing identifiers granted to this agent.",
          "items": { "type": "string" },
          "examples": [["blessing:deepsoil.core", "blessing:family.safety"]]
        },
        "blessed_by": {
          "type": "string",
          "description": "CreatorID of the RootIB identity that issued the blessing."
        },
        "blessed_at": {
          "type": "string",
          "format": "date-time",
          "description": "ISO-8601 timestamp when the blessing was granted."
        },
        "revoked": {
          "type": "boolean",
          "description": "Whether all blessings have been revoked. A revoked agent MUST NOT activate.",
          "default": false
        },
        "revoked_at": {
          "type": ["string", "null"],
          "format": "date-time",
          "description": "ISO-8601 timestamp when the agent was revoked."
        }
      },
      "additionalProperties": false
    },
    "governance": {
      "type": "object",
      "description": "Governance metadata. All governance models must follow RootIB rules. DeepSoil stores this metadata; RootIB enforces it.",
      "properties": {
        "owner":     { "type": "string", "description": "Solana pubkey of the agent owner." },
        "model":     { "type": "string", "enum": ["single_owner", "multisig", "dao"] },
        "revocable": { "type": "boolean", "default": true }
      }
    },
    "deepsoil_meta": {
      "type": "object",
      "description": "DeepSoil storage metadata.",
      "required": ["program_id", "entry_type"],
      "properties": {
        "program_id":     { "type": "string", "default": "DEEPSOiL111111111111111111111111111111111" },
        "entry_type":     { "type": "string", "const": "agent" },
        "schema_version": { "type": "string", "default": "1.0.0" },
        "network":        { "type": "string", "enum": ["solana-mainnet", "solana-devnet", "solana-localnet", "solana-simulated"], "default": "solana-simulated" },
        "pda_seed":       { "type": "string" },
        "manifest_uri":   { "type": "string", "format": "uri" }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": true
}
