{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.dharma-ai.io/organization-policy/v1",
  "title": "Agent Fabric Organization Policy",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "organizationId",
    "revision",
    "evidence",
    "tasks",
    "skills",
    "retention",
    "budgets"
  ],
  "properties": {
    "schema": {
      "const": "dharma.organization-policy/v1"
    },
    "organizationId": {
      "type": "string",
      "minLength": 1
    },
    "revision": {
      "type": "string"
    },
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "defaultMode",
        "registeredWorkspaceOnly",
        "excludePaths",
        "maximumCapsuleBytes",
        "maximumDailyUploadBytes",
        "maximumExpansionBytes"
      ],
      "properties": {
        "defaultMode": {
          "type": "string",
          "enum": [
            "structured",
            "deep",
            "reduced_full_session",
            "incident_capture"
          ]
        },
        "registeredWorkspaceOnly": {
          "const": true
        },
        "excludePaths": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "maximumCapsuleBytes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1048576
        },
        "maximumDailyUploadBytes": {
          "type": "integer",
          "minimum": 1
        },
        "maximumExpansionBytes": {
          "type": "integer",
          "minimum": 1
        },
        "pseudonymizeIdentity": {
          "type": "boolean"
        }
      }
    },
    "tasks": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "defaultNetwork",
        "defaultGit",
        "allowedCommands",
        "writePaths",
        "requireLocalConfirmationFor"
      ],
      "properties": {
        "defaultNetwork": {
          "type": "string",
          "enum": [
            "deny",
            "package_registry_only",
            "allowlisted_domains",
            "inherit_local_provider"
          ]
        },
        "defaultGit": {
          "type": "string",
          "enum": [
            "read_only",
            "task_branch",
            "merge_allowed",
            "deploy_allowed"
          ]
        },
        "allowedCommands": {
          "type": "object"
        },
        "writePaths": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "requireLocalConfirmationFor": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "skills": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "automaticInstall",
        "automaticPromotionMaxRisk",
        "canaryPercent"
      ],
      "properties": {
        "automaticInstall": {
          "type": "boolean"
        },
        "automaticPromotionMaxRisk": {
          "type": "string",
          "enum": [
            "R0",
            "R1",
            "R2",
            "R3",
            "R4"
          ]
        },
        "canaryPercent": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        }
      }
    },
    "retention": {
      "type": "object"
    },
    "budgets": {
      "type": "object"
    }
  }
}
