# MAAM v0.1 JSON Schema (YAML format)
# Minimal Agent Accountability Manifest
# Canonical URL: https://agentprotocols.org/maam/v0.1/schema.yaml

$schema: "https://json-schema.org/draft/2020-12/schema"
$id: "https://agentprotocols.org/schemas/maam/v0.1"
title: "Minimal Agent Accountability Manifest"
description: "A lightweight declaration that makes agent action legible and accountable"
type: object

required:
  - manifest_version
  - manifest_id
  - timestamp
  - initiator
  - intent
  - executor
  - justification
  - reflection

properties:
  manifest_version:
    type: string
    const: "0.1"
    description: "Schema version"

  manifest_id:
    type: string
    description: "Unique identifier (UUID or hash)"

  timestamp:
    type: string
    format: date-time
    description: "ISO-8601 timestamp of manifest creation"

  initiator:
    type: object
    required:
      - identity
      - role
      - context
    properties:
      identity:
        type: string
        description: "Who or what initiated the action"
      role:
        type: string
        enum: ["owner", "operator", "requester"]
        description: "Capacity of the initiator"
      context:
        type: string
        description: "Session, environment, or deployment context"

  intent:
    type: object
    required:
      - declared
      - constraints
      - risk_envelope
    properties:
      declared:
        type: string
        description: "Plain-language description of requested outcome"
      constraints:
        type: array
        items:
          type: string
        description: "Explicitly forbidden actions or limits"
      risk_envelope:
        type: object
        properties:
          acceptable:
            type: array
            items:
              type: string
            description: "Known failure modes that are allowed"
          unacceptable:
            type: array
            items:
              type: string
            description: "Hard-stop outcomes that must not occur"

  executor:
    type: object
    required:
      - type
      - name
      - version
      - permissions
    properties:
      type:
        type: string
        enum: ["browser-agent", "api-agent", "tool", "workflow"]
        description: "Category of executor"
      name:
        type: string
        description: "Executor name or identifier"
      version:
        type: string
        description: "Version number or commit hash"
      permissions:
        type: array
        items:
          type: string
        description: "Granted capabilities"

  justification:
    type: object
    required:
      - pre_action
      - tension_addressed
    properties:
      pre_action:
        type: object
        properties:
          rationale:
            type: string
            description: "Why this action is appropriate now"
          alternatives_considered:
            type: array
            items:
              type: string
            description: "Options rejected and reasons"
      tension_addressed:
        type: object
        properties:
          description:
            type: string
            description: "What problem or conflict this resolves"
          urgency:
            type: string
            enum: ["low", "medium", "high"]
            description: "Priority level"

  reflection:
    type: object
    required:
      - post_action_hook
      - attribution
    properties:
      post_action_hook:
        type: string
        description: "How outcome will be evaluated"
      attribution:
        type: object
        required:
          - accountable_party
          - escalation_path
        properties:
          accountable_party:
            type: string
            description: "Who owns consequences"
          escalation_path:
            type: string
            description: "If harm occurs, who is notified"

  integrity:
    type: object
    properties:
      signature:
        type: ["string", "null"]
        description: "Optional cryptographic signature"
      checksum:
        type: ["string", "null"]
        description: "Optional content hash"
