{
  "$defs": {
    "AppProjectDefinitionSpec": {
      "additionalProperties": false,
      "properties": {
        "management": {
          "$ref": "#/$defs/AppProjectManagement",
          "description": "Whether Nyl emits the AppProject or validates against an externally managed project contract."
        },
        "manifest": {
          "description": "Argo CD `argoproj.io/v1alpha1` AppProject manifest. Its metadata name supplies the Argo CD project identity."
        },
        "sourceRepositoryRefs": {
          "description": "GitRepository names admitted as source repositories. Valid only for a Rendered project; duplicate names are rejected.",
          "items": {
            "$ref": "#/$defs/LocalReference"
          },
          "type": "array"
        }
      },
      "required": [
        "management",
        "manifest"
      ],
      "type": "object"
    },
    "AppProjectManagement": {
      "oneOf": [
        {
          "const": "Rendered",
          "description": "Emit this AppProject into the target catalog.",
          "type": "string"
        },
        {
          "const": "External",
          "description": "Use the project contract for validation without emitting or owning the AppProject.",
          "type": "string"
        }
      ]
    },
    "GitOpsResourceMetadata": {
      "additionalProperties": false,
      "description": "Metadata shared by local GitOps compiler resources.",
      "properties": {
        "labels": {
          "additionalProperties": {
            "type": "string"
          },
          "description": "Literal labels used for organization and target selection.",
          "type": "object"
        },
        "name": {
          "description": "Project-local identity, validated by the resource kind; remains static during discovery.",
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "LocalReference": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "description": "Project-local name of the referenced resource; its kind and API group are determined by the containing field.",
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Defines an Argo CD AppProject manifest or an externally managed project contract.\n\nRendered projects are emitted into the catalog. External projects supply an admission contract without transferring ownership to Nyl.\n\n## When needed\n\nRequired when one project is shared by several ApplicationGroups, when the Argo CD AppProject is externally managed, or when the project needs AppProject fields beyond `spec.projectTemplate`.\n\n## If omitted\n\nAn ApplicationGroup generates its own AppProject, admitting only what the group's Applications deploy unless `spec.projectTemplate` declares otherwise. Nyl does not assume an existing Argo CD project supplies the required policy contract.",
  "examples": [
    {
      "apiVersion": "k8s.gitops.nyl/v1",
      "kind": "AppProjectDefinition",
      "metadata": {
        "name": "workloads"
      },
      "spec": {
        "management": "External",
        "manifest": {
          "apiVersion": "argoproj.io/v1alpha1",
          "kind": "AppProject",
          "metadata": {
            "name": "workloads",
            "namespace": "argocd"
          },
          "spec": {}
        }
      }
    }
  ],
  "properties": {
    "apiVersion": {
      "const": "k8s.gitops.nyl/v1",
      "description": "API group and version defining this resource.",
      "type": "string"
    },
    "kind": {
      "const": "AppProjectDefinition",
      "description": "Resource kind within the API group.",
      "type": "string"
    },
    "metadata": {
      "$ref": "#/$defs/GitOpsResourceMetadata",
      "description": "Resource identity and metadata."
    },
    "spec": {
      "$ref": "#/$defs/AppProjectDefinitionSpec",
      "description": "Configuration for this resource."
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ],
  "title": "AppProjectDefinition",
  "type": "object"
}
