{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://bot0.ai/schemas/poa/1.2/grant.schema.json",
  "title": "Agentic Power of Action — Grant document (poa_version 1.2)",
  "description": "The canonical, carrier-neutral record of the authority a principal delegated to an agent for specified work. Two levels: a grant envelope (who, for what, until when, ceilings, delegation, revocation) and one authority per act. A Grant does not authorize an agent; it authorizes an agent to perform specified work. Sealed for integrity (sha-256 over the RFC 8785 canonical form); signed for authenticity as a JWS carrier (RFC 7519 claims, RFC 8693 act, RFC 9396 authorization_details).",
  "type": "object",
  "additionalProperties": false,
  "required": ["poa_version", "grant_id", "iss", "principal", "delegate", "purpose", "work_scope", "note", "defaults",
               "authorities", "denied", "ceilings", "discovery", "work_system", "delegation", "validity", "revocation",
               "confirmation", "audit", "record"],
  "properties": {
    "poa_version": { "const": "1.2" },
    "grant_id": { "type": "string", "pattern": "^poa_[0-9a-f]{4,}$", "description": "RFC 7519 jti when carried." },
    "iss": { "type": "string", "format": "uri", "description": "RFC 7519 iss — a URL." },
    "principal": {
      "type": "object", "additionalProperties": false,
      "required": ["sub", "name", "on_behalf_of", "household_names"],
      "properties": {
        "sub": { "type": "string", "description": "Opaque stable subject (JWT sub). Never a display name." },
        "name": { "type": "string", "maxLength": 160 },
        "on_behalf_of": { "enum": ["me", "household", "business"] },
        "household_names": { "type": "array", "items": { "type": "string" } }
      }
    },
    "delegate": {
      "type": "object", "additionalProperties": false,
      "required": ["sub", "name", "role", "platform", "instance"],
      "properties": {
        "sub": { "type": "string", "description": "The acting agent's stable identifier (RFC 8693 act.sub)." },
        "name": { "type": "string", "maxLength": 160, "description": "Identity as the person knows it (Jeeves), or the team's name." },
        "role": { "type": ["string", "null"], "maxLength": 160, "description": "Durable job (household assistant) — not this grant's purpose." },
        "platform": { "enum": ["grok_bot", "openai", "claude", "custom", "other", null], "description": "The orchestrator or runtime the grant is handed to." },
        "instance": { "type": ["string", "null"], "maxLength": 160 }
      }
    },
    "purpose": { "type": "string", "maxLength": 600, "description": "What THIS grant is for. A later grant to the same agent never inherits this one." },
    "work_scope": { "enum": ["this_job", "recurring_work", "everything"], "description": "Not OAuth scope." },
    "note": { "type": ["string", "null"], "maxLength": 600, "description": "Carried for the reader; never widens the grant." },
    "defaults": {
      "type": "object", "additionalProperties": false,
      "required": ["autonomy", "pace", "max_binding_per_day", "hours", "pause_on_surprise", "targets", "grounding", "limits"],
      "properties": {
        "autonomy": { "enum": ["draft_only", "routine_then_ask", "within_limits"] },
        "pace": { "enum": ["act_then_tell", "tell_then_act", "batch_daily"] },
        "max_binding_per_day": { "type": ["integer", "null"], "minimum": 0 },
        "hours": { "oneOf": [ { "type": "null" }, { "type": "object", "additionalProperties": false, "required": ["from", "until"], "properties": { "from": { "$ref": "#/$defs/hhmm" }, "until": { "$ref": "#/$defs/hhmm" } } } ] },
        "pause_on_surprise": { "type": "boolean" },
        "triggers": { "type": "array", "uniqueItems": true, "items": { "enum": ["asked", "routine", "message", "notification", "app_event", "agent_handoff", "autonomous"] }, "description": "What may start the agent on its own. Absent = anything (grants issued before the rule)." },
        "self_changes": { "type": "object", "additionalProperties": false, "required": ["memory", "schedules", "settings"],
          "properties": { "memory": { "$ref": "#/$defs/self_rule" }, "schedules": { "$ref": "#/$defs/self_rule" }, "settings": { "$ref": "#/$defs/self_rule" } },
          "description": "Changes the agent makes to itself — its memory, its own schedules, the person's account settings. Absent = not judged (grants issued before the rule)." },
        "new_connectors": { "enum": ["not_covered", "read_only"], "description": "Apps or tools that appear after the grant: not covered, or readable with nothing official. Absent = not judged." },
        "data_movement": { "enum": ["never", "ask", "listed_apps"], "description": "Optional (10-01): moving information between apps — copy, paste, upload, export, sync, forward. Absent = not judged." },
        "max_recipients": { "type": ["integer", "null"], "minimum": 1, "description": "Optional (10-01): the most people one message may go to. Null = no cap." },
        "targets": { "type": "array", "items": { "$ref": "authority.schema.json#/$defs/target" }, "minItems": 2, "maxItems": 2 },
        "grounding": {
          "type": "object", "additionalProperties": false,
          "required": ["allowed_sources", "freshness", "on_conflict"],
          "properties": {
            "allowed_sources": { "type": "array", "items": { "type": "string" } },
            "freshness": { "type": "string" },
            "on_conflict": { "enum": ["ask", "prefer_live", "stop"] }
          }
        },
        "limits": {
          "type": "object", "additionalProperties": false,
          "required": ["per_act_usd", "per_month_usd"],
          "properties": { "per_act_usd": { "type": ["number", "null"], "minimum": 0 }, "per_month_usd": { "type": ["number", "null"], "minimum": 0 } }
        }
      }
    },
    "authorities": { "type": "array", "items": { "$ref": "authority.schema.json" } },
    "denied": {
      "type": "array",
      "items": {
        "type": "object", "additionalProperties": false,
        "required": ["act_id", "effect", "kind", "label", "reason"],
        "properties": {
          "act_id": { "type": "string" },
          "effect": { "$ref": "authority.schema.json#/$defs/effect" },
          "kind": { "$ref": "authority.schema.json#/$defs/kind" },
          "label": { "type": "string" },
          "reason": { "const": "forbidden" }
        }
      }
    },
    "ceilings": {
      "type": "object", "additionalProperties": false,
      "required": ["sent", "purchased", "transferred", "submitted", "deleted", "shared"],
      "properties": {
        "sent": { "$ref": "#/$defs/official" }, "purchased": { "$ref": "#/$defs/official" }, "transferred": { "$ref": "#/$defs/official" },
        "submitted": { "$ref": "#/$defs/official" }, "changed": { "$ref": "#/$defs/official" }, "deleted": { "$ref": "#/$defs/official" }, "shared": { "$ref": "#/$defs/official" }
      },
      "description": "Result-kind ceilings: an authority may be stricter, never looser."
    },
    "discovery": {
      "type": "object", "additionalProperties": false,
      "required": ["connected", "agent_name", "scopes"],
      "properties": {
        "connected": { "type": "boolean" },
        "agent_name": { "type": ["string", "null"] },
        "scopes": { "type": "array", "items": { "$ref": "authority.schema.json#/$defs/resource_scope" } },
        "inventories": {
          "type": "array",
          "description": "1.2 (G15): the SHA-256 of every inventory text the person reviewed, one per agent. A capability outside what was reviewed can be told apart.",
          "items": { "type": "object", "additionalProperties": false, "required": ["agent", "sha256"],
                     "properties": { "agent": { "type": "string" }, "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" } } }
        }
      },
      "description": "What the agent said it can use and the person ticked. Never authority on its own."
    },
    "work_system": {
      "type": "object", "additionalProperties": false,
      "required": ["type", "team_name", "lead", "members", "sharing", "answer_mode"],
      "properties": {
        "type": { "enum": ["one_agent", "lead_with_specialists", "named_team", "external_system"] },
        "unnamed_agents": { "enum": ["read_draft", "nothing", "same_as_team"], "description": "What an acting agent the grant does not name may do. Absent = same_as_team (grants issued before the rule)." },
        "team_name": { "type": ["string", "null"], "maxLength": 80 },
        "lead": { "oneOf": [ { "type": "null" }, { "type": "object", "additionalProperties": false, "required": ["sub", "name"], "properties": { "sub": { "type": "string" }, "name": { "type": "string" }, "role": { "type": "string" }, "platform": { "type": "string", "description": "Optional (10-06): where this agent lives when the team spans AI systems." } } } ] },
        "members": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["sub", "name", "role"], "properties": { "sub": { "type": "string" }, "name": { "type": "string" }, "role": { "type": "string" }, "platform": { "type": "string", "description": "Optional (10-06): where this agent lives when the team spans AI systems. Absent = the delegate's platform." } } } },
        "sharing": { "enum": ["lead_only", "each_own", "all_authorized"] },
        "answer_mode": { "enum": ["collective", "per_agent"], "description": "Whether the six questions were answered once for the team or per agent." }
      },
      "description": "The authority-bearing structure of the work system, not its execution graph."
    },
    "delegation": {
      "type": "object", "additionalProperties": false,
      "required": ["allowed", "max_depth", "attenuation_required", "named_agents"],
      "properties": {
        "allowed": { "type": "boolean" },
        "max_depth": { "type": "integer", "minimum": 0 },
        "attenuation_required": { "const": true },
        "named_agents": { "type": "array", "items": { "type": "string" } },
        "chain": {
          "type": "array",
          "description": "The grants this one was attenuated from, root first; empty for a grant the principal issued directly. A child MUST be within its parent (G9) and is verified beside it. RFC 8693 nests act from it.",
          "items": {
            "type": "object", "additionalProperties": false,
            "required": ["grant_id", "delegate_sub"],
            "properties": {
              "grant_id": { "type": "string", "pattern": "^poa_[0-9a-f]{4,}$" },
              "delegate_sub": { "type": "string" }
            }
          }
        }
      }
    },
    "validity": {
      "type": "object", "additionalProperties": false,
      "required": ["not_before", "expires"],
      "properties": { "not_before": { "type": "string" }, "expires": { "type": "string" } }
    },
    "revocation": {
      "type": "object", "additionalProperties": false,
      "required": ["revocable", "phrase"],
      "properties": { "revocable": { "const": true }, "phrase": { "type": "string", "description": "The human command. The machine fact is the jti's status at the issuer." } }
    },
    "confirmation": {
      "type": "object", "additionalProperties": false,
      "required": ["channel", "phrase"],
      "properties": {
        "channel": { "enum": ["app", "text", "email", "call"] },
        "phrase": { "type": "string" },
        "reach_me": { "type": "array", "items": { "enum": ["app", "text", "email", "call"] }, "uniqueItems": true, "description": "Optional (10-01): every way the agent may reach the principal when it pauses; channel is the first." }
      }
    },
    "audit": {
      "type": "object", "additionalProperties": false,
      "required": ["record_actions", "record_commits", "record_grounding"],
      "properties": { "record_actions": { "const": true }, "record_commits": { "const": true }, "record_grounding": { "const": true } }
    },
    "record": {
      "type": "object", "additionalProperties": false,
      "required": ["receipt_for_every_official_act", "report_within_minutes"],
      "properties": { "receipt_for_every_official_act": { "type": "boolean" }, "report_within_minutes": { "type": ["integer", "null"], "minimum": 0 } }
    },
    "conflicts": {
      "type": "array",
      "description": "Optional (10-01): disagreements the person left in the grant. The stricter rule already applies; this records what was chosen, what applies, and why.",
      "items": {
        "type": "object", "additionalProperties": false,
        "required": ["act_id", "label", "chose", "applies", "why"],
        "properties": {
          "act_id": { "type": "string" },
          "label": { "type": "string" },
          "chose": { "enum": ["do", "ask"] },
          "applies": { "enum": ["asks_first", "prepared_only", "cannot_happen"] },
          "why": { "type": "string" }
        }
      }
    },
    "formations": {
      "type": "array",
      "description": "Optional (1.2): how the agents act together — one entry per arrangement, side by side (spec §4b). Absent: no formation.",
      "items": {
        "$ref": "#/$defs/formation"
      }
    },
    "seal": {
      "oneOf": [
        { "type": "null" },
        { "type": "object", "additionalProperties": false, "required": ["algorithm", "canonicalization", "value"],
          "properties": { "algorithm": { "const": "sha-256" }, "canonicalization": { "const": "RFC8785" }, "value": { "type": "string", "pattern": "^[0-9a-f]{64}$" } } }
      ],
      "description": "Human-visible fingerprint over the canonical Grant without this member. Integrity, not a signature."
    }
  },
  "$defs": {
    "self_rule": { "enum": ["never", "ask", "allowed"] },
    "official": { "enum": ["proposal", "on_confirm", "self_within_limits"] },
    "hhmm": { "type": "string", "pattern": "^[0-2][0-9]:[0-5][0-9]$" },
    "formation": {
      "type": "object",
      "additionalProperties": false,
      "description": "How the agents act together in one arrangement (spec §4b). The vocabulary is Bot0's arrangement registry; ten arrangements, closed. Set by the person; unset fields take least-privilege defaults, and no default widens the Grant.",
      "required": [
        "arrangement",
        "routing_authority",
        "participants",
        "settlement"
      ],
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 80
        },
        "arrangement": {
          "enum": [
            "path.sequential",
            "path.choice",
            "path.fanout_fanin",
            "path.bounded_loop",
            "hub.manager_worker",
            "habitat.handoff",
            "habitat.committee",
            "habitat.market",
            "habitat.blackboard",
            "habitat.mesh"
          ]
        },
        "routing_authority": {
          "enum": [
            "code",
            "one_model",
            "any_peer",
            "none",
            "protocol",
            "environment"
          ]
        },
        "participants": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "actor",
              "membership"
            ],
            "properties": {
              "actor": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "membership": {
                "enum": [
                  "member",
                  "adjacent"
                ]
              },
              "interaction": {
                "enum": [
                  "none",
                  "consulted",
                  "notified"
                ]
              },
              "authority": {
                "enum": [
                  "none",
                  "delegates",
                  "delegated"
                ]
              },
              "commit": {
                "enum": [
                  "none",
                  "ratifies"
                ]
              }
            }
          }
        },
        "settlement": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "evidence"
          ],
          "properties": {
            "kind": {
              "enum": [
                "authored_completion",
                "rule_fires",
                "owner_acceptance",
                "ownership_transfer",
                "aggregated_judgment",
                "allocation_award",
                "committed_state_transition",
                "protocol_convergence"
              ]
            },
            "rule": {
              "type": "string",
              "maxLength": 500
            },
            "threshold": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "approvals"
              ],
              "properties": {
                "approvals": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "evaluator": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "reversibility": {
              "enum": [
                "reversible",
                "costly",
                "irreversible"
              ]
            },
            "evidence": {
              "type": "array",
              "items": {
                "enum": [
                  "accept",
                  "votes",
                  "transfer",
                  "award",
                  "commit"
                ]
              },
              "uniqueItems": true
            }
          }
        },
        "join": {
          "enum": [
            "all",
            "any",
            "first_completed",
            "decision",
            "wait_for_activated_arms"
          ]
        },
        "termination": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind"
          ],
          "properties": {
            "kind": {
              "enum": [
                "construction",
                "declared_bound",
                "model_signal",
                "unbounded"
              ]
            },
            "max_rounds": {
              "type": "integer",
              "minimum": 1
            },
            "stop_rule": {
              "type": "string",
              "maxLength": 500
            },
            "on_limit": {
              "enum": [
                "ask",
                "stop"
              ]
            }
          }
        },
        "handoffs": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "from",
              "to",
              "seam",
              "ownership"
            ],
            "properties": {
              "from": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "to": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "seam": {
                "enum": [
                  "coordination",
                  "specialisation",
                  "segregation_of_duties",
                  "accountability",
                  "external_sla"
                ]
              },
              "ownership": {
                "enum": [
                  "moves",
                  "stays"
                ]
              },
              "acceptance": {
                "type": "string",
                "maxLength": 500
              }
            }
          }
        },
        "transitions": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "from",
              "to",
              "authority",
              "acts"
            ],
            "properties": {
              "from": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "to": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "authority": {
                "enum": [
                  "human_gate",
                  "agent_delegates"
                ]
              },
              "acts": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "configuration": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "plan_provenance": {
              "enum": [
                "authored",
                "runtime",
                "hybrid"
              ]
            },
            "performer_composition": {
              "type": "string",
              "maxLength": 80
            }
          }
        },
        "protocol": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "who_may_act": {
              "type": "string",
              "maxLength": 500
            },
            "artifact": {
              "type": "string",
              "maxLength": 500
            },
            "interactions": {
              "type": "string",
              "maxLength": 500
            },
            "conflict": {
              "type": "string",
              "maxLength": 500
            },
            "settlement": {
              "type": "string",
              "maxLength": 500
            },
            "eligibility": {
              "type": "string",
              "maxLength": 500
            },
            "envelope": {
              "type": "string",
              "maxLength": 500
            },
            "acceptance": {
              "type": "string",
              "maxLength": 500
            }
          }
        },
        "acts": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "unresolved": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "path.sequential"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "authored_completion"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "path.choice"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "authored_completion"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "path.fanout_fanin"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "authored_completion"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "path.bounded_loop"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "rule_fires"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "hub.manager_worker"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "owner_acceptance"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "habitat.handoff"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "ownership_transfer"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "habitat.committee"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "aggregated_judgment"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "habitat.market"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "allocation_award"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "habitat.blackboard"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "committed_state_transition"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "habitat.mesh"
              }
            }
          },
          "then": {
            "properties": {
              "settlement": {
                "properties": {
                  "kind": {
                    "const": "protocol_convergence"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "arrangement": {
                "const": "habitat.mesh"
              }
            }
          },
          "then": {
            "required": [
              "protocol"
            ],
            "properties": {
              "protocol": {
                "required": [
                  "who_may_act",
                  "artifact",
                  "interactions",
                  "conflict",
                  "settlement"
                ]
              }
            }
          }
        }
      ]
    }
  }
}
