{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://docs.getcanyon.ai/contracts/schema/release.schema.json",
  "title": "Canyon hand-off: the release webhook, the report, the access pull",
  "description": "A release is one instruction to the org's platform — run this image here, or remove what runs here — sent as a signed webhook; the org reports back, and an environment is live only when the reported digest is the release's. Canyon's HTTP routes for the platform webhook, the hand-off and the preferences are canonical. Its example is one release told end to end: the webhook saved, a deploy delivered, its reports, a remove, the sidecar's access pull and the environment while it waits; then the delete-remove a project delete sends. Under hand-off the org's platform provisions every resource the release names and Canyon creates none: the platform builds each variable a resource gives from its own secret store, and reports back only where each one is, never a secret.",
  "type": "object",
  "additionalProperties": false,
  "required": ["repo_put", "repo_saved", "repo_get", "repo_check", "fetch_token", "repo_host_token", "canyon_json", "env_pending_repo", "webhook_put", "webhook_saved", "webhook_get", "headers", "deploy", "redelivery", "remove", "delete_remove", "report_deployed", "report_failed", "report_removed", "report_refusal", "report_resources_missing", "access", "access_deny_all", "access_token", "env_pending", "webhook_secret", "ping", "webhook_ping"],
  "properties": {
    "repo_put": {
      "description": "PUT /api/v1/platform-repo (delivery: repo): the deploy repo Canyon commits each release to. `token` is required on the first save and kept when absent; it is sealed and never answered. With api none, production is push; with api gitlab, a merge request read as a pull request, its api_url on the repo's host.",
      "type": "object", "additionalProperties": false, "required": ["url", "preview", "prod"],
      "if": { "properties": { "api": { "const": "none" } }, "required": ["api"] }, "then": { "properties": { "prod": { "properties": { "mode": { "const": "push" } }, "required": ["mode"] } } },
      "properties": {
        "url": { "$ref": "#/definitions/repoURL" }, "username": { "$ref": "#/definitions/repoUser" }, "token": { "$ref": "#/definitions/token" },
        "preview": { "$ref": "#/definitions/previewBranch" }, "prod": { "$ref": "#/definitions/prodBranch" },
        "root": { "$ref": "#/definitions/repoRoot" }, "api": { "enum": ["github", "gitlab", "none"] }, "api_url": { "$ref": "#/definitions/https_url" },
        "store": { "$ref": "#/definitions/dnsLabel" }, "ca": { "oneOf": [{ "type": "null" }, { "$ref": "#/definitions/pem" }] }
      }
    },
    "repo_get": {
      "description": "GET /api/v1/platform-repo, to any member: the repo as saved, never the token; before one is saved, the answer is 200 null. `checked_at` is the last passing check since the last save; `last_commit` the newest repo release, `problem` the code its last attempt ended on.",
      "type": "object", "additionalProperties": false,
      "required": ["url", "username", "preview", "prod", "root", "api", "api_url", "store", "ca", "set_by", "set_at", "checked_at", "last_commit"],
      "properties": {
        "url": { "$ref": "#/definitions/repoURL" }, "username": { "$ref": "#/definitions/repoUser" },
        "preview": { "$ref": "#/definitions/previewBranch" }, "prod": { "allOf": [{ "$ref": "#/definitions/prodBranch" }, { "required": ["branch", "mode"] }] },
        "root": { "$ref": "#/definitions/repoRoot" }, "api": { "enum": ["github", "gitlab", "none"] }, "api_url": { "$ref": "#/definitions/https_url" },
        "store": { "$ref": "#/definitions/dnsLabel" }, "ca": { "oneOf": [{ "type": "null" }, { "$ref": "#/definitions/pem" }] },
        "set_by": { "$ref": "#/definitions/actor" }, "set_at": { "$ref": "#/definitions/ts" },
        "checked_at": { "oneOf": [{ "type": "null" }, { "$ref": "#/definitions/ts" }] },
        "last_commit": { "oneOf": [{ "type": "null" }, {
          "type": "object", "additionalProperties": false, "required": ["release", "env", "state", "at"],
          "properties": {
            "release": { "$ref": "#/definitions/releaseId" }, "env": { "$ref": "#/definitions/environment" }, "at": { "$ref": "#/definitions/ts" },
            "state": { "enum": ["sent", "accepted", "deployed", "failed", "removed", "undelivered", "refused"] },
            "commit": { "$ref": "#/definitions/sha" }, "pull_request": { "$ref": "#/definitions/pullRequest" }, "problem": { "$ref": "#/definitions/repoProblem" }
          }
        }] }
      }
    },
    "repo_saved": {
      "description": "The PUT's answer: the read's shape, plus, once, on the first save, `fetch_token` and `token`, the host token, both kept on the platform-repo row, never a platform-webhook row. Every answer is Cache-Control: no-store.",
      "type": "object", "additionalProperties": false, "required": ["url", "username", "preview", "prod", "root", "api", "api_url", "store", "ca", "set_by", "set_at", "checked_at", "last_commit"],
      "properties": { "url": { "$ref": "#/properties/repo_get/properties/url" }, "username": { "$ref": "#/properties/repo_get/properties/username" }, "preview": { "$ref": "#/properties/repo_get/properties/preview" }, "prod": { "$ref": "#/properties/repo_get/properties/prod" }, "root": { "$ref": "#/properties/repo_get/properties/root" }, "api": { "$ref": "#/properties/repo_get/properties/api" }, "api_url": { "$ref": "#/properties/repo_get/properties/api_url" }, "store": { "$ref": "#/properties/repo_get/properties/store" }, "ca": { "$ref": "#/properties/repo_get/properties/ca" }, "set_by": { "$ref": "#/properties/repo_get/properties/set_by" }, "set_at": { "$ref": "#/properties/repo_get/properties/set_at" }, "checked_at": { "$ref": "#/properties/repo_get/properties/checked_at" }, "last_commit": { "$ref": "#/properties/repo_get/properties/last_commit" }, "fetch_token": { "$ref": "#/definitions/token" }, "token": { "$ref": "#/definitions/token" } }
    },
    "repo_check": {
      "description": "POST /api/v1/platform-repo/check's answer: each problem once, by code, with its D5 sentence and never the remote's words; the templates found under <root>/.canyon, sorted. passed exactly when problems is empty.",
      "type": "object", "additionalProperties": false, "required": ["passed", "problems", "templates"],
      "if": { "properties": { "passed": { "const": true } } }, "then": { "properties": { "problems": { "maxItems": 0 } } }, "else": { "properties": { "problems": { "minItems": 1 } } },
      "properties": {
        "passed": { "type": "boolean" },
        "problems": { "type": "array", "uniqueItems": true, "items": { "type": "object", "additionalProperties": false, "required": ["code", "message"], "properties": { "code": { "$ref": "#/definitions/repoProblem" }, "message": { "type": "string", "minLength": 1, "maxLength": 1024 } } } },
        "templates": { "type": "array", "uniqueItems": true, "items": { "type": "string", "pattern": "^\\.canyon/(route|externalsecret|resources/[a-z][a-z0-9-]*)\\.yaml$" } }
      }
    },
    "fetch_token": {
      "description": "POST /api/v1/platform-repo/fetch-token's answer: a new fetch-only token, answered once, the old one dead at that instant. It opens GET /releases/:id/access-token and nothing else.",
      "type": "object", "additionalProperties": false, "required": ["fetch_token"], "properties": { "fetch_token": { "$ref": "#/definitions/token" } }
    },
    "repo_host_token": {
      "description": "POST /api/v1/platform-repo/host-token's answer: a new host token for the platform-repo row, answered once, its old one dead at that instant. Reports and the access-token fetch take it.",
      "type": "object", "additionalProperties": false, "required": ["token"], "properties": { "token": { "$ref": "#/definitions/token" } }
    },
    "canyon_json": {
      "description": "<root>/<app>/<env>/canyon.json, the file a repo release commits beside its objects: which Canyon wrote the directory and what release it is. It binds nothing: the ApplicationSet takes the project and the namespace from the path.",
      "type": "object", "additionalProperties": false, "required": ["canyon", "app", "env", "release", "gate_run", "package", "version"],
      "properties": {
        "canyon": { "$ref": "#/definitions/https_url" }, "app": { "$ref": "#/definitions/app" }, "env": { "$ref": "#/definitions/environment" },
        "release": { "$ref": "#/definitions/releaseId" }, "gate_run": { "$ref": "#/definitions/runId" },
        "package": { "type": "string", "pattern": "^pkg_[a-z0-9]{4,}$" }, "version": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$" }
      }
    },
    "webhook_put": {
      "description": "PUT /api/v1/platform-webhook: the url, and the secret when the admin sets one; absent, Canyon makes one.",
      "type": "object", "additionalProperties": false, "required": ["url"],
      "properties": { "url": { "$ref": "#/definitions/https_url" }, "secret": { "$ref": "#/definitions/token" } }
    },
    "webhook_saved": {
      "description": "The PUT's answer. `secret`, what Canyon signs with, is present only when Canyon minted one — the first save with none in the body; `token`, the host token the org reports with, only on the first save. A PUT that keeps the stored secret answers neither. Neither is ever answered again.",
      "type": "object", "additionalProperties": false, "required": ["url", "set_by", "set_at"],
      "properties": { "url": { "$ref": "#/definitions/https_url" }, "secret": { "$ref": "#/definitions/token" }, "token": { "$ref": "#/definitions/token" }, "set_by": { "$ref": "#/definitions/actor" }, "set_at": { "$ref": "#/definitions/ts" } }
    },
    "webhook_get": {
      "description": "GET /api/v1/platform-webhook, once one is saved; before, the answer is 200 null. `last_delivery` is the newest attempt to deliver a release since the webhook was last saved (`set_at`): `sent_at` that attempt's, `status` the HTTP status it got, 0 for no connection or no answer in 10 seconds; null before any. A test delivery is never one.",
      "type": "object", "additionalProperties": false, "required": ["url", "set_by", "set_at", "last_delivery"],
      "properties": {
        "url": { "$ref": "#/definitions/https_url" }, "set_by": { "$ref": "#/definitions/actor" }, "set_at": { "$ref": "#/definitions/ts" },
        "last_delivery": { "oneOf": [{ "type": "null" }, { "type": "object", "additionalProperties": false, "required": ["delivery", "release", "sent_at", "status"], "properties": { "delivery": { "$ref": "#/definitions/uuid" }, "release": { "$ref": "#/definitions/releaseId" }, "sent_at": { "$ref": "#/definitions/ts" }, "status": { "type": "integer", "minimum": 0, "maximum": 599 } } }] }
      }
    },
    "headers": {
      "description": "The delivery's headers: the event, the delivery id (inside the signed body too) and GitHub's signature scheme, HMAC-SHA256 of the raw body under the secret. Every retry is the same delivery re-stamped and re-signed: `delivery` stays, `sent_at` is the attempt's. A receiver must refuse a delivery whose sent_at is more than 30 minutes old, and must treat a delivery it has seen in the last 30 minutes as done: freshness bounds the dedupe state it keeps.",
      "type": "object", "additionalProperties": false, "required": ["Canyon-Event", "Canyon-Delivery", "Canyon-Signature-256"],
      "properties": { "Canyon-Event": { "description": "Not signed: a receiver dispatches on the signed body's event, never on this header.", "enum": ["deploy", "remove", "ping"] }, "Canyon-Delivery": { "$ref": "#/definitions/uuid" }, "Canyon-Signature-256": { "type": "string", "pattern": "^sha256=[0-9a-f]{64}$" } }
    },
    "webhook_secret": {
      "description": "POST /api/v1/platform-webhook/secret's answer: a new webhook secret Canyon made, answered once and sealed in place of the stored one; every delivery after it is signed with it.",
      "type": "object", "additionalProperties": false, "required": ["secret"],
      "properties": { "secret": { "$ref": "#/definitions/token" } }
    },
    "ping": {
      "description": "A test delivery (POST /api/v1/platform-webhook/ping): signed and sent as a release is, with Canyon-Event: ping, to the saved url alone. It names no release, no app and no report address, so a receiver has nothing to act on: it verifies the signature (401 when it fails), checks sent_at as for any delivery, and answers 2xx.",
      "type": "object", "additionalProperties": false, "required": ["event", "delivery", "sent_at"],
      "properties": { "event": { "const": "ping" }, "delivery": { "$ref": "#/definitions/uuid" }, "sent_at": { "$ref": "#/definitions/sentAt" } }
    },
    "webhook_ping": {
      "description": "POST /api/v1/platform-webhook/ping's answer: the ping's delivery and sent_at, and the HTTP status the url answered, 0 for no connection or no answer in 10 seconds. Never why: a dial or certificate error names the network behind the url.",
      "type": "object", "additionalProperties": false, "required": ["delivery", "sent_at", "status"],
      "properties": { "delivery": { "$ref": "#/definitions/uuid" }, "sent_at": { "$ref": "#/definitions/ts" }, "status": { "type": "integer", "minimum": 0, "maximum": 599 } }
    },
    "deploy": {
      "type": "object", "additionalProperties": false,
      "required": ["event", "delivery", "release", "app", "environment", "package", "gate_run", "gate_url", "image", "platform", "port", "variables", "resources", "app_env", "sidecar", "report_url", "sent_at"],
      "properties": {
        "event": { "const": "deploy" }, "delivery": { "$ref": "#/definitions/uuid" }, "release": { "$ref": "#/definitions/releaseId" },
        "app": { "$ref": "#/definitions/app" }, "environment": { "$ref": "#/definitions/environment" },
        "package": { "type": "object", "additionalProperties": false, "required": ["id"], "properties": { "id": { "type": "string", "pattern": "^pkg_[a-z0-9]{4,}$" }, "label": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$" } } },
        "gate_run": { "$ref": "#/definitions/runId" }, "gate_url": { "$ref": "#/definitions/https_url" },
        "image": { "$ref": "#/definitions/image" }, "platform": { "$ref": "#/definitions/platform" }, "port": { "const": 3000 },
        "variables": { "description": "The names of this environment's runtime secrets rows, less every name any resource gives: the platform provides those with the resource. Values are the org's.", "type": "array", "uniqueItems": true, "items": { "$ref": "#/definitions/envName" } },
        "resources": { "description": "canyon.toml [resources]: what the app needs, each a Score resource type of the menu (GET /api/v1/component-types) and the variables the app reads from it. The platform provisions each, keyed by app, environment and name, and puts each variable in the app's environment; their formats are the docs' (build/databases.md), never sent. No class: every menu type is Score's default.", "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["name", "type", "gives"], "properties": { "name": { "$ref": "#/definitions/resourceName" }, "type": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" }, "gives": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/envName" } } } } },
        "app_env": {
          "description": "The app container's environment, exactly as the executor sets it on Kubernetes: PORT and the three CANYON_IDENTITY_* — one producer for both modes.",
          "type": "object", "additionalProperties": false, "required": ["PORT", "CANYON_IDENTITY_ISSUER", "CANYON_IDENTITY_AUDIENCE", "CANYON_IDENTITY_JWKS_URL"],
          "properties": { "PORT": { "const": "3000" }, "CANYON_IDENTITY_ISSUER": { "$ref": "#/definitions/https_url" }, "CANYON_IDENTITY_AUDIENCE": { "$ref": "#/definitions/app" }, "CANYON_IDENTITY_JWKS_URL": { "const": "http://127.0.0.1:4182/.well-known/jwks.json" } }
        },
        "sidecar": {
          "type": "object", "additionalProperties": false, "required": ["image", "port", "env", "secret"],
          "properties": {
            "image": { "type": "string", "pattern": "^[a-z0-9.:-]+(/[a-z0-9._-]+)+@sha256:[0-9a-f]{64}$" }, "port": { "const": 4180 },
            "env": {
              "description": "canyon-identity's environment: the four the executor sets when it runs an app, plus where to pull the access file from and how long to keep the last one when Canyon is unreachable. The token is named by `secret`, fetched by the org (GET /releases/:id/access-token) and never in this body.",
              "type": "object", "additionalProperties": false,
              "required": ["CANYON_FRONT_DOOR", "CANYON_IDENTITY_ISSUER", "CANYON_IDENTITY_AUDIENCE", "CANYON_TARGET", "CANYON_ACCESS_URL", "CANYON_ACCESS_GRACE"],
              "properties": { "CANYON_FRONT_DOOR": { "type": "string", "minLength": 2 }, "CANYON_IDENTITY_ISSUER": { "$ref": "#/definitions/https_url" }, "CANYON_IDENTITY_AUDIENCE": { "$ref": "#/definitions/app" }, "CANYON_TARGET": { "$ref": "#/definitions/environment" }, "CANYON_ACCESS_URL": { "$ref": "#/definitions/https_url" }, "CANYON_ACCESS_GRACE": { "$ref": "#/definitions/duration" } }
            },
            "secret": { "const": "CANYON_ACCESS_TOKEN" }
          }
        },
        "report_url": { "$ref": "#/definitions/https_url" }, "sent_at": { "$ref": "#/definitions/sentAt" }
      }
    },
    "redelivery": { "description": "The same delivery, tried again: everything the deploy is but its sent_at, the attempt's.", "$ref": "#/properties/deploy" },
    "remove": {
      "type": "object", "additionalProperties": false, "required": ["event", "delivery", "release", "app", "environment", "report_url", "sent_at"],
      "properties": { "delete": { "description": "Present, and true, on the removes a project delete sends alone: the platform also deletes what it provisioned for this app and environment — only that, keyed by app, environment and resource name, and idempotently. An undeploy's, a hold's and the brake's never carry it: they keep the data.", "const": true }, "event": { "const": "remove" }, "delivery": { "$ref": "#/definitions/uuid" }, "release": { "$ref": "#/definitions/releaseId" }, "app": { "$ref": "#/definitions/app" }, "environment": { "$ref": "#/definitions/environment" }, "report_url": { "$ref": "#/definitions/https_url" }, "sent_at": { "$ref": "#/definitions/sentAt" } }
    },
    "delete_remove": { "description": "The remove a project delete sends for each environment with any release of the org's: delete true.", "allOf": [{ "$ref": "#/properties/remove" }, { "required": ["delete"] }] },
    "report_deployed": {
      "description": "`resources` is where each resource the platform provisioned is, by the release's resource name: one entry for each resource the release lists (deploy.resources), and only the release's own, so the key is absent, or [], only on a release that lists none. Whether every one is there depends on the release, which this document cannot see: the server checks it and answers report_resources_missing. Endpoints name a place, never a credential: Canyon keeps them, replaced by the next release's deployed report, and shows them to the app's team.",
      "type": "object", "additionalProperties": false, "required": ["status", "address", "digest"],
      "properties": {
        "status": { "const": "deployed" }, "address": { "$ref": "#/definitions/address" }, "digest": { "$ref": "#/definitions/digest" },
        "resources": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["name", "endpoint"], "properties": { "name": { "$ref": "#/definitions/resourceName" }, "endpoint": { "$ref": "#/definitions/endpoint" } } } }
      }
    },
    "report_failed": { "type": "object", "additionalProperties": false, "required": ["status", "reason"], "properties": { "status": { "const": "failed" }, "reason": { "type": "string", "minLength": 1, "maxLength": 1024, "pattern": "^[^\\x00-\\x1F\\x7F]+$" } } },
    "report_removed": { "type": "object", "additionalProperties": false, "required": ["status"], "properties": { "status": { "const": "removed" } } },
    "report_refusal": {
      "description": "POST /releases/:id/report refuses a `deployed` whose digest is not the release's: nothing goes live.",
      "type": "object", "additionalProperties": false, "required": ["error", "expected"], "properties": { "error": { "const": "digest_mismatch" }, "expected": { "$ref": "#/definitions/digest" } }
    },
    "report_resources_missing": {
      "description": "POST /releases/:id/report refuses a `deployed` whose resources leave out a resource the release lists: nothing goes live. `missing` is the names left out, sorted; the message names them, joined with \", \".",
      "type": "object", "additionalProperties": false, "required": ["error", "missing", "message"],
      "properties": {
        "error": { "const": "resources_missing" },
        "missing": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "#/definitions/resourceName" } },
        "message": { "type": "string", "pattern": "^the report has no endpoint for [a-z][a-z0-9-]*(, [a-z][a-z0-9-]*)*: send one for every resource the release lists$" }
      }
    },
    "access": { "description": "GET /access/:app/:env answers the app's access file — the same object the executor writes for the app on Kubernetes.", "type": "object" },
    "access_deny_all": {
      "description": "GET /access/:app/:env's answer to a token of a release Canyon stopped under hand-off — production held, the project deleting or deleted, or the token's own release a remove, followed by a remove, or followed by a deploy Canyon ran: the access file's shape naming nobody, so the sidecar admits no one at its next pull. updated_at is when it was answered.",
      "type": "object", "additionalProperties": false, "required": ["updated_at", "groups_claim", "subject_issuer", "members", "admins", "roles", "entries"],
      "properties": {
        "updated_at": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
        "groups_claim": { "const": "" }, "subject_issuer": { "const": "" },
        "members": { "const": { "domains": [], "emails": [] } },
        "admins": { "const": { "emails": [], "claim": "", "value": "" } },
        "roles": { "const": {} }, "entries": { "const": [] }
      }
    },
    "access_token": { "type": "object", "additionalProperties": false, "required": ["name", "value"], "properties": { "name": { "const": "CANYON_ACCESS_TOKEN" }, "value": { "$ref": "#/definitions/token" } } },
    "env_pending_repo": { "description": "envs.<env> while a delivery: repo release waits on its pull request: the pending release names it, to contributors and above.", "allOf": [{ "$ref": "#/properties/env_pending" }, { "properties": { "pending": { "required": ["pull_request"], "properties": { "via": { "const": "repo" } } } } }] },
    "env_pending": {
      "description": "The project read's envs.<env> while a release is open: what runs (or nothing yet), who runs it, and the release the environment waits on.",
      "type": "object", "additionalProperties": false, "required": ["run_by", "pending"],
      "properties": {
        "run_by": { "const": "org" },
        "pending": {
          "type": "object", "additionalProperties": false, "required": ["release", "event", "sent_at", "state", "via"],
          "allOf": [
            { "if": { "required": ["missing"] }, "then": { "properties": { "event": { "const": "deploy" }, "state": { "enum": ["sent", "accepted"] } } } },
            { "if": { "required": ["pull_request"] }, "then": { "properties": { "via": { "const": "repo" } } } }
          ],
          "properties": {
            "release": { "$ref": "#/definitions/releaseId" }, "event": { "$ref": "#/definitions/event" }, "sent_at": { "$ref": "#/definitions/ts" }, "state": { "enum": ["sent", "accepted", "undelivered", "refused"] },
            "via": { "description": "How the release reaches the platform, the release's own: webhook, or a commit to the deploy repo.", "enum": ["webhook", "repo"] },
            "pull_request": { "description": "The pull request a delivery: repo release opened in the deploy repo while it waits on it; at contributor and above, as pending is.", "$ref": "#/definitions/pullRequest" },
            "missing": { "description": "The resources the platform's last deployed report on this release left out (report_resources_missing), sorted: on a deploy still sent or accepted.", "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "#/definitions/resourceName" } }
          }
        }
      }
    }
  },
  "definitions": {
    "https_url": { "type": "string", "maxLength": 2048, "pattern": "^https://[^@/?#\\s]+(/[^\\s]*)?$" },
    "address": { "description": "The app's address as the platform reports it: https, a lower-case host (a domain of one label or more, or an IP address) and an optional port, then a path of any segments of unreserved characters, with or without a trailing slash; no userinfo, query or fragment, no percent-escape or backslash. The server parses it with net/url and refuses one that does not print back as sent.", "type": "string", "maxLength": 2048, "pattern": "^https://(\\[[0-9a-f:.]+\\]|(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-z0-9]([a-z0-9-]*[a-z0-9])?\\.)*([a-z0-9]*[a-z][a-z0-9]*|[a-z0-9][a-z0-9-]*-[a-z0-9-]*[a-z0-9]))(:([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?(/[A-Za-z0-9._~-]*[A-Za-z0-9_~-][A-Za-z0-9._~-]*)*/?$", "allOf": [{ "description": "each host label at most 63 characters, as the server parses it", "pattern": "^https://(\\[[0-9a-f:.]+\\]|([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)(:|/|$)" }] },
    "endpoint": { "description": "Where a resource is, never how to sign in to it: postgres or postgresql for postgres, s3 or https for s3 (the server checks the scheme against the resource's type); a lower-case host — a domain of one label or more (a cluster's service name, a bucket), or an IP address — and an optional port; then nothing or one path segment, the database or the bucket. No userinfo, query, fragment or percent-escape; printable ASCII, at most 255 bytes.", "type": "string", "maxLength": 255, "pattern": "^(postgres|postgresql|s3|https)://(\\[[0-9a-f:.]+\\]|(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-z0-9]([a-z0-9-]*[a-z0-9])?\\.)*([a-z0-9]*[a-z][a-z0-9]*|[a-z0-9][a-z0-9-]*-[a-z0-9-]*[a-z0-9]))(:([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?(/[a-z0-9_-][a-z0-9._-]{0,62})?$", "allOf": [{ "description": "each host label at most 63 characters, as the server parses it", "pattern": "^(postgres|postgresql|s3|https)://(\\[[0-9a-f:.]+\\]|([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)(:|/|$)" }] },
    "resourceName": { "type": "string", "pattern": "^[a-z][a-z0-9-]{0,39}$" },
    "token": { "type": "string", "minLength": 1, "maxLength": 1024, "pattern": "^[\\x21-\\x7e]+$" },
    "ts": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
    "sentAt": { "description": "The time of this attempt, re-stamped on every retry; a receiver refuses one more than 30 minutes old (the headers, above).", "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
    "uuid": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
    "releaseId": { "type": "string", "pattern": "^rel_[a-z0-9]{4,}$" },
    "repoURL": { "description": "The deploy repo over https: a lower-case host, a path of one or more segments, no userinfo, query, fragment or percent-escape; with api github exactly /<owner>/<repo>, with api gitlab two segments or more, .git or not (the server checks that).", "type": "string", "maxLength": 2048, "pattern": "^https://[a-z0-9.-]+(:[0-9]{1,5})?(/[A-Za-z0-9._~-]+)+$" },
    "repoUser": { "type": "string", "pattern": "^[A-Za-z0-9._@+-]{1,128}$" },
    "branch": { "description": "A branch name: the server also refuses .., //, @{, a trailing / or .lock, and any branch under canyon/, which are Canyon's own.", "type": "string", "minLength": 1, "maxLength": 200, "pattern": "^[A-Za-z0-9._][A-Za-z0-9._/-]*$" },
    "previewBranch": { "type": "object", "additionalProperties": false, "required": ["branch"], "properties": { "branch": { "$ref": "#/definitions/branch" } } },
    "prodBranch": { "type": "object", "additionalProperties": false, "required": ["branch"], "properties": { "branch": { "$ref": "#/definitions/branch" }, "mode": { "enum": ["pull_request", "push"] } } },
    "repoRoot": { "type": "string", "maxLength": 200, "pattern": "^[a-z0-9][a-z0-9._-]*(/[a-z0-9][a-z0-9._-]*)*$" },
    "dnsLabel": { "type": "string", "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$" },
    "pem": { "type": "string", "minLength": 1, "maxLength": 65536, "pattern": "^-----BEGIN CERTIFICATE-----" },
    "sha": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
    "pullRequest": { "type": "object", "additionalProperties": false, "required": ["url", "number"], "properties": { "url": { "$ref": "#/definitions/https_url" }, "number": { "type": "integer", "minimum": 1 } } },
    "repoProblem": { "enum": ["unreachable", "tls_untrusted", "auth_refused", "branch_missing", "no_write", "protected_branch", "pulls_api_unavailable", "template_missing", "template_invalid", "directory_taken", "name_too_long"] },
    "runId": { "type": "string", "pattern": "^gr_[a-z0-9]{4,}$" },
    "app": { "type": "string", "pattern": "^[a-z]([a-z0-9-]*[a-z0-9])?$", "maxLength": 55 },
    "environment": { "enum": ["preview", "prod"] },
    "event": { "enum": ["deploy", "remove"] },
    "envName": { "type": "string", "maxLength": 128, "pattern": "^[A-Za-z_][A-Za-z0-9_]*$", "not": { "anyOf": [{ "const": "PORT" }, { "pattern": "^CANYON_IDENTITY_" }] } },
    "image": { "description": "<registry>/canyon/<app>@sha256:<digest>, the registry's manifest digest, never a tag.", "type": "string", "pattern": "^[a-z0-9.:-]+/canyon/[a-z]([a-z0-9-]*[a-z0-9])?@sha256:[0-9a-f]{64}$" },
    "platform": {
      "description": "The platform the image runs on, read from its config by digest as Canyon reads it to run an app: os and architecture, never the variant. The org's platform schedules the app's pods on nodes of that architecture (kubernetes.io/arch), as Canyon pins its own; the deploy repo's Deployment carries that nodeSelector. Every deploy body Canyon builds names it, but one: a body an earlier Canyon release built, before releases named a platform, and sent after an upgrade it was in flight across, names none, and its deploy repo Deployment pins nothing.",
      "type": "object", "additionalProperties": false, "required": ["os", "architecture"],
      "properties": { "os": { "const": "linux" }, "architecture": { "type": "string", "pattern": "^[a-z0-9]{1,16}$" } }
    },
    "digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
    "duration": { "description": "access_grace as Go spells a duration, 0 to 24h; the range is the server's to refuse.", "type": "string", "pattern": "^(0|([0-9]+h)?([0-9]+m)?([0-9]+s)?)$", "minLength": 1 },
    "actor": { "type": "object", "additionalProperties": false, "required": ["kind", "subject", "display"], "properties": { "kind": { "enum": ["person", "agent", "canyon"] }, "subject": { "type": "string", "minLength": 1 }, "display": { "type": "string" } } }
  }
}
