{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/unattended-policy.schema.json",
  "title": "Unattended guard policy",
  "description": "The data unattended_policy.py and agent-guard.py judge an unattended command against: the network allowlist, the protected repo and home paths, the manifests a run may not edit, and the publisher scripts it may not call.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "network",
    "protectedRepoPaths",
    "protectedHostRoots",
    "protectedHostEntries",
    "protectedHomeFiles",
    "protectedHomeDirs",
    "manifests",
    "publisherScripts"
  ],
  "$defs": {
    "names": { "type": "array", "items": { "type": "string", "minLength": 1 }, "uniqueItems": true }
  },
  "properties": {
    "$comment": { "type": "string" },
    "$commentHomeDirs": { "type": "string" },
    "network": {
      "type": "object",
      "additionalProperties": false,
      "required": ["staticHosts", "prefsHostKeys"],
      "properties": {
        "$comment": { "type": "string" },
        "staticHosts": {
          "$ref": "#/$defs/names",
          "description": "Hosts a fetch may always reach."
        },
        "prefsHostKeys": {
          "$ref": "#/$defs/names",
          "description": "prefs.global.hosts keys whose configured host joins the allowlist."
        }
      }
    },
    "protectedRepoPaths": {
      "type": "object",
      "additionalProperties": false,
      "required": ["dirs", "files"],
      "properties": {
        "$comment": { "type": "string" },
        "dirs": { "$ref": "#/$defs/names" },
        "files": { "$ref": "#/$defs/names" }
      }
    },
    "protectedHostRoots": { "$ref": "#/$defs/names" },
    "protectedHostEntries": { "$ref": "#/$defs/names" },
    "protectedHomeFiles": { "$ref": "#/$defs/names" },
    "protectedHomeDirs": { "$ref": "#/$defs/names" },
    "protectedAncestorsOf": {
      "$ref": "#/$defs/names",
      "description": "Directories under $HOME a run may not move, remove or replace by acting on a directory above them."
    },
    "manifests": {
      "type": "object",
      "additionalProperties": false,
      "required": ["files", "patterns"],
      "properties": {
        "$comment": { "type": "string" },
        "files": { "$ref": "#/$defs/names" },
        "patterns": { "$ref": "#/$defs/names" }
      }
    },
    "publisherScripts": {
      "type": "object",
      "description": "Script name to the subcommands a run may not call; null blocks every invocation.",
      "properties": { "$comment": { "type": "string" } },
      "additionalProperties": {
        "anyOf": [{ "type": "null" }, { "$ref": "#/$defs/names", "minItems": 1 }]
      }
    }
  }
}
