{
  "id": "starter-data-service-cleanup",
  "name": "Clean up the disposable Starter Data App",
  "risk": "mutating",
  "completionMutation": {
    "guardId": "starter-data-app-cleanup",
    "recoveryPath": "/project/data-service?orgId={{starterOrgId}}&projectId={{starterProjectId}}"
  },
  "start": { "path": "/project/data-service?orgId={{starterOrgId}}&projectId={{starterProjectId}}" },
  "goal": [
    "If {{dataAppName}} exists, open its Settings and permanently delete only that Data App using the exact confirmation text shown by the dialog.",
    "If it is already absent, do nothing and finish."
  ],
  "success": {
    "evidence": [
      { "kind": "url", "matches": "/project/data-service(?:[/?]|$)" },
      {
        "kind": "responseArrayAbsent",
        "pathMatches": "^/api/v1/dataservices/central/orgs/{{starterOrgId}}/projects/{{starterProjectId}}/apps$",
        "arrayPath": "data",
        "where": { "id": "{{starterDataAppId}}" }
      },
      { "kind": "absentText", "matches": "^{{dataAppName}}$" }
    ]
  },
  "recovery": [
    "This is the cleanup barrier before Networking and cluster deletion; never create a Data App or endpoint here."
  ],
  "limits": { "maxDurationMs": 180000, "maxActions": 16 },
  "safety": {
    "requiredResourceIdentityVariable": "starterDataAppId",
    "deny": ["Do not modify or delete any other Data App or endpoint."],
    "networkGuards": [
      {
        "id": "starter-data-app-cleanup",
        "method": "DELETE",
        "pathMatches": "^/api/v1/dataservices/central/orgs/[^/]+/projects/[^/]+/apps/([^/]+)$",
        "pageMustContain": ["{{dataAppName}}"],
        "maxRequests": 1,
        "resourceIdentity": {
          "requestPathMatches": "^/api/v1/dataservices/central/orgs/[^/]+/projects/[^/]+/apps/([^/]+)$",
          "capturedVariable": "starterDataAppId"
        }
      }
    ]
  }
}
