{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/agentstack-tech/json-schema/agentstack-tech-project-data-patch-body-schema.json",
  "title": "ProjectDataPatchBody",
  "description": "Leaf write on project.data (MCP parity: projects.patch_data).",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/agentstack-tech-openapi.json#/components/schemas/ProjectDataPatchBody",
  "properties": {
    "path": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Path",
      "description": "Dotted path into project.data (wins over patches[] when set)"
    },
    "patches": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/ProjectDataPatchLeafItem"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Patches",
      "description": "Up to 16 leaves when path is omitted (plain replace SET may be atomic)"
    },
    "value": {
      "title": "Value",
      "description": "Leaf JSON, or string editor {replacements|unified_diff}"
    },
    "write_mode": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Write Mode",
      "description": "replace | merge | delete | search_replace | fuzzy_replace | unified_diff | append | prepend"
    },
    "allow_shrink": {
      "type": "boolean",
      "title": "Allow Shrink",
      "description": "Allow deliberate shorter string (not read-window write-back)",
      "default": false
    },
    "replacements": {
      "anyOf": [
        {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Replacements",
      "description": "search_replace pairs on a string leaf (merged into value)."
    },
    "unified_diff": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Unified Diff",
      "description": "Unified diff on a string leaf (fuzzy unless strict_diff=true)."
    },
    "strict_diff": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Strict Diff",
      "description": "Strict unified_diff apply (no fuzzy fallback)."
    },
    "ops": {
      "anyOf": [
        {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ops",
      "description": "Up to 16 directed edit ops on the path leaf (merge, search_replace, insert_after, …)."
    },
    "dry_run": {
      "type": "boolean",
      "title": "Dry Run",
      "description": "Preview without writing DNA: directed ops or leaf write_mode (search_replace, merge, replace, …) returns leaf_sha256.",
      "default": false
    },
    "expected_sha256": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expected Sha256",
      "description": "Optimistic concurrency digest of the leaf before ops."
    },
    "missing": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Missing",
      "description": "When a path op misses: error | skip.",
      "default": "error"
    }
  },
  "type": "object",
  "$defs": {
    "ProjectDataPatchLeafItem": {
      "properties": {
        "path": {
          "type": "string",
          "minLength": 1,
          "title": "Path",
          "description": "Dotted path into project.data"
        },
        "value": {
          "title": "Value",
          "description": "Leaf value for this path"
        }
      },
      "type": "object",
      "required": [
        "path"
      ],
      "title": "ProjectDataPatchLeafItem",
      "description": "One leaf in a multi-path PATCH (MCP patches[] parity)."
    }
  }
}