From a8d5e737f60b34ad3d152d44a95a25221f031ebe Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Sun, 6 Dec 2026 08:09:14 -0500 Subject: [PATCH 1/7] feat(delivery): estate vocabulary for locations, environments, deployments and provisions The delivery pack registers the words that say where systems and apps run (ADR-0070, calls 3 to 6): location.jurisdiction (@countries) holding location.region and location.zone, flat; environment.stage (@owner, @purpose, @lifespan); deployment.system and deployment.app (@locations, @mode); provision.resource (@locations, @replication, @consistency). References use the reference facet and raise ERR_DELIVERY_UNRESOLVED_REF. Retires environment.standing/.ephemeral/.local and deployment.base's platform attributes and value children; the railway and cloudflare packs declare those on their own deployment subtypes until they move. Builds and runtime.process stay; value.* stays only under platform deployments. New fixtures: delivery-estate-quillhaven and five error cases. --- changelog.d/delivery-estate-vocabulary.md | 10 + packs/README.md | 2 +- packs/cloudflare/CHANGELOG.md | 5 + packs/cloudflare/README.md | 4 +- .../cloudflare-pages-secrets/expected.json | 22 +- .../input/meta.help.json | 7 +- .../cloudflare-pages-site/expected.json | 22 +- .../input/meta.docs.json | 7 +- .../expected.json | 13 +- .../input/meta.trips.json | 5 +- .../expected.json | 21 +- .../input/meta.quiz.json | 7 +- .../input/meta.shop.json | 5 +- .../input/meta.shop.json | 5 +- .../input/meta.shop.json | 5 +- .../input/meta.shop.json | 5 +- .../input/meta.shop.json | 5 +- .../fixtures/expected-vocabulary.json | 20 +- packs/cloudflare/metamodel/cloudflare.json | 18 +- packs/cloudflare/typescript/src/constants.ts | 10 + packs/cloudflare/typescript/src/model.ts | 10 +- .../cloudflare/typescript/test/model.test.ts | 8 +- packs/delivery/CHANGELOG.md | 34 ++ packs/delivery/README.md | 102 ++++-- .../fixtures/conformance/ERROR-CODES.json | 4 +- .../expected.json | 30 +- .../input/meta.shop.json | 30 +- .../delivery-estate-quillhaven/expected.json | 271 ++++++++++++++++ .../input/meta.deployments.json | 15 + .../input/meta.environments.json | 11 + .../input/meta.locations.json | 25 ++ .../input/meta.org.json | 11 + .../input/meta.parcels.json | 13 + .../delivery-estate-quillhaven/providers.json | 1 + .../input/meta.shop.json | 11 +- .../expected-errors.json | 75 +++++ .../input/meta.estate.json | 15 + .../error-estate-closed-values/providers.json | 1 + .../expected-errors.json | 75 +++++ .../input/meta.estate.json | 15 + .../providers.json | 1 + .../error-estate-refs/expected-errors.json | 75 +++++ .../error-estate-refs/input/meta.estate.json | 15 + .../error-estate-refs/providers.json | 1 + .../expected-errors.json | 25 ++ .../input/meta.estate.json | 11 + .../error-jurisdiction-nested/providers.json | 1 + .../expected-errors.json | 65 ++++ .../input/meta.estate.json | 13 + .../error-retired-estate-words/providers.json | 1 + .../fixtures/expected-vocabulary.json | 305 +++++++++++++++--- packs/delivery/metamodel/delivery.json | 295 ++++++++++++++--- packs/delivery/typescript/src/constants.ts | 53 ++- packs/delivery/typescript/src/index.ts | 57 +++- packs/railway/CHANGELOG.md | 5 + packs/railway/README.md | 7 +- .../expected.json | 13 +- .../input/meta.shop.json | 5 +- .../input/meta.shop.json | 11 +- .../input/meta.shop.json | 11 +- .../input/meta.shop.json | 11 +- .../input/meta.shop.json | 11 +- .../input/meta.shop.json | 11 +- .../input/meta.shop.json | 11 +- .../input/meta.shop.json | 5 +- .../railway-emit-environments/expected.json | 21 +- .../input/meta.shop.json | 7 +- .../railway-emit-one-service/expected.json | 13 +- .../input/meta.game.json | 5 +- .../railway-emit-two-services/expected.json | 15 +- .../input/meta.tables.json | 5 +- .../railway-worked-example/expected.json | 28 +- .../input/meta.app-system.json | 5 +- .../input/meta.estate.json | 5 +- .../railway/fixtures/expected-vocabulary.json | 10 +- packs/railway/metamodel/railway.json | 9 +- packs/railway/typescript/src/constants.ts | 10 + packs/railway/typescript/src/model.ts | 10 +- packs/railway/typescript/test/model.test.ts | 4 +- 79 files changed, 1820 insertions(+), 301 deletions(-) create mode 100644 changelog.d/delivery-estate-vocabulary.md create mode 100644 packs/delivery/fixtures/conformance/delivery-estate-quillhaven/expected.json create mode 100644 packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.deployments.json create mode 100644 packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.environments.json create mode 100644 packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.locations.json create mode 100644 packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.org.json create mode 100644 packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.parcels.json create mode 100644 packs/delivery/fixtures/conformance/delivery-estate-quillhaven/providers.json create mode 100644 packs/delivery/fixtures/conformance/error-estate-closed-values/expected-errors.json create mode 100644 packs/delivery/fixtures/conformance/error-estate-closed-values/input/meta.estate.json create mode 100644 packs/delivery/fixtures/conformance/error-estate-closed-values/providers.json create mode 100644 packs/delivery/fixtures/conformance/error-estate-missing-required/expected-errors.json create mode 100644 packs/delivery/fixtures/conformance/error-estate-missing-required/input/meta.estate.json create mode 100644 packs/delivery/fixtures/conformance/error-estate-missing-required/providers.json create mode 100644 packs/delivery/fixtures/conformance/error-estate-refs/expected-errors.json create mode 100644 packs/delivery/fixtures/conformance/error-estate-refs/input/meta.estate.json create mode 100644 packs/delivery/fixtures/conformance/error-estate-refs/providers.json create mode 100644 packs/delivery/fixtures/conformance/error-jurisdiction-nested/expected-errors.json create mode 100644 packs/delivery/fixtures/conformance/error-jurisdiction-nested/input/meta.estate.json create mode 100644 packs/delivery/fixtures/conformance/error-jurisdiction-nested/providers.json create mode 100644 packs/delivery/fixtures/conformance/error-retired-estate-words/expected-errors.json create mode 100644 packs/delivery/fixtures/conformance/error-retired-estate-words/input/meta.estate.json create mode 100644 packs/delivery/fixtures/conformance/error-retired-estate-words/providers.json diff --git a/changelog.d/delivery-estate-vocabulary.md b/changelog.d/delivery-estate-vocabulary.md new file mode 100644 index 000000000..321e48ed4 --- /dev/null +++ b/changelog.d/delivery-estate-vocabulary.md @@ -0,0 +1,10 @@ +- **Delivery pack: the estate vocabulary (ADR-0070, calls 3 to 6).** The independent `delivery` + pack registers `location.jurisdiction` (`@countries`) with `location.region` and + `location.zone` under it, `environment.stage` (`@owner`, `@purpose`, `@lifespan`), + `deployment.system` and `deployment.app` (`@locations`, `@mode`) and `provision.resource` + (`@locations`, `@replication`, `@consistency`): where systems and apps run, in the company's + own words, with no platform, product or size. It retires `environment.standing`, `.ephemeral` + and `.local` and the platform attributes of `deployment.base`, which the `railway` and + `cloudflare` packs now declare on their own deployment subtypes. Packs are TypeScript only and + unpublished (ADR-0069); core's vocabulary and `metamodelVersion` are unchanged. See + `packs/delivery/CHANGELOG.md`. diff --git a/packs/README.md b/packs/README.md index 4cb553ec7..b8378f87c 100644 --- a/packs/README.md +++ b/packs/README.md @@ -8,7 +8,7 @@ that is not part of core, built and versioned as if it were its own repository |---|---|---|---| | [`config`](config/README.md) | settings groups, `@secret` / `@envName` / `@phase`, vaults (Infisical) and their scopes; `.env.example`, key manifest and `.keys-axi.toml` generators | core | TypeScript | | [`systems`](systems/README.md) | systems, apps (service, client, job), resources | core | TypeScript | -| [`delivery`](delivery/README.md) | environments, builds, runtime processes, deployments, value bindings | `systems` | TypeScript | +| [`delivery`](delivery/README.md) | locations (jurisdiction, region, zone), `environment.stage`, `deployment.system` and `.app`, `provision.resource`, builds, runtime processes, value bindings for platform deployments | `systems` | TypeScript | | [`railway`](railway/README.md) | `deployment.railway`; `.railway/railway.ts` (Railway Infrastructure as Code), unexpressed-facts list, secret sync, deploy and doctor scripts and a deploy skill | `delivery`, `config` | TypeScript | | [`cloudflare`](cloudflare/README.md) | `deployment.worker`, `deployment.pages` and a Worker's D1, KV, R2, queue and rate limiting bindings; `wrangler.jsonc`, token-scoped deploy, secret sync and doctor script generators | `delivery`, `config` | TypeScript | diff --git a/packs/cloudflare/CHANGELOG.md b/packs/cloudflare/CHANGELOG.md index 28d4f04d9..4cb1914a9 100644 --- a/packs/cloudflare/CHANGELOG.md +++ b/packs/cloudflare/CHANGELOG.md @@ -4,6 +4,11 @@ This pack's own changelog (ADR-0069). The root `CHANGELOG.md` records core only. ## [0.1.0] - unreleased +- `deployment.worker` and `deployment.pages` declare `@app`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets` and + their `value.*` children themselves: the delivery pack's `deployment.base` now holds only + `@environment`, which the loader resolves through the reference facet. Environments are the + delivery pack's `environment.stage` (`@owner`, `@purpose`, `@lifespan`); the fixtures and + tests declare an `organization.company` to own them. No generated file changes. - **First version.** `deployment.worker` (a Worker, with or without static assets) and `deployment.pages` (a Pages site) on the delivery pack's `deployment.base`, held to its references, and the Worker's bindings `cloudflare.d1`, `.kv`, `.r2`, `.queue` and diff --git a/packs/cloudflare/README.md b/packs/cloudflare/README.md index dce8be66e..abf69db49 100644 --- a/packs/cloudflare/README.md +++ b/packs/cloudflare/README.md @@ -16,8 +16,8 @@ The scripts do, with `wrangler` and `keys-axi`, when someone runs them. | Node | Attributes | |---|---| -| `deployment.worker` | every `deployment.base` attribute (`@app`, `@environment`, `@domains`, `@branch`, `@secrets`, and `value.*` children), plus `@compatibilityDate` (required), `@tokenSecret` (required), `@script` (the Worker's name; absent: the app's), `@main`, `@compatibilityFlags`, `@workersDev`, `@assetsBinding`, `@notFound`, `@workerFirst` or `@workerFirstPaths`, `@jobs`, `@tokenVault`, `@extra` | -| `deployment.pages` | every `deployment.base` attribute, plus `@project` (required), `@tokenSecret` (required), `@tokenVault` | +| `deployment.worker` | `@environment` (from `deployment.base`), its own `@app`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets` and `value.*` children, plus `@compatibilityDate` (required), `@tokenSecret` (required), `@script` (the Worker's name; absent: the app's), `@main`, `@compatibilityFlags`, `@workersDev`, `@assetsBinding`, `@notFound`, `@workerFirst` or `@workerFirstPaths`, `@jobs`, `@tokenVault`, `@extra` | +| `deployment.pages` | the same deployment attributes as `deployment.worker` (`@environment` through the `value.*` children), plus `@project` (required), `@tokenSecret` (required), `@tokenVault` | | `cloudflare.d1` | `@databaseName` (required), `@databaseId`, `@migrationsDir` | | `cloudflare.kv` | `@namespaceId` (required) | | `cloudflare.r2` | `@bucketName` (required) | diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/expected.json b/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/expected.json index 8cc1cd5c4..8ee27fbe0 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/expected.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/expected.json @@ -78,13 +78,18 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "acme::help::Acme", + "@purpose": "production" } }, { - "environment.ephemeral": { - "name": "preview" + "environment.stage": { + "name": "preview", + "@lifespan": "ephemeral", + "@owner": "acme::help::Acme", + "@purpose": "test" } }, { @@ -106,7 +111,7 @@ "@domains": [ "help.example.com" ], - "@environment": "production" + "@environment": "acme::help::production" } }, { @@ -114,7 +119,12 @@ "name": "sitePreview", "extends": "acme::help::siteBase", "@branch": "preview", - "@environment": "preview" + "@environment": "acme::help::preview" + } + }, + { + "organization.company": { + "name": "Acme" } } ] diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/input/meta.help.json b/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/input/meta.help.json index 6ea94ce91..7d99cbf32 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/input/meta.help.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/input/meta.help.json @@ -35,8 +35,8 @@ { "scope.env": { "name": "dev", "@project": "acme-deploy" } } ] } }, - { "environment.standing": { "name": "production" } }, - { "environment.ephemeral": { "name": "preview" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, + { "environment.stage": { "name": "preview", "@owner": "Acme", "@purpose": "test", "@lifespan": "ephemeral" } }, { "deployment.pages": { "name": "siteBase", "abstract": true, @@ -47,7 +47,8 @@ "@tokenSecret": "ACME_PAGES_TOKEN" } }, { "deployment.pages": { "name": "siteProduction", "extends": "siteBase", "@environment": "production", "@branch": "main", "@domains": ["help.example.com"] } }, - { "deployment.pages": { "name": "sitePreview", "extends": "siteBase", "@environment": "preview", "@branch": "preview" } } + { "deployment.pages": { "name": "sitePreview", "extends": "siteBase", "@environment": "preview", "@branch": "preview" } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/expected.json b/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/expected.json index fc13636fb..0df77cd83 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/expected.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/expected.json @@ -57,13 +57,18 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "acme::docs::Acme", + "@purpose": "production" } }, { - "environment.ephemeral": { - "name": "preview" + "environment.stage": { + "name": "preview", + "@lifespan": "ephemeral", + "@owner": "acme::docs::Acme", + "@purpose": "test" } }, { @@ -84,7 +89,7 @@ "@domains": [ "docs.example.com" ], - "@environment": "production" + "@environment": "acme::docs::production" } }, { @@ -92,7 +97,12 @@ "name": "sitePreview", "extends": "acme::docs::siteBase", "@branch": "preview", - "@environment": "preview" + "@environment": "acme::docs::preview" + } + }, + { + "organization.company": { + "name": "Acme" } } ] diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/input/meta.docs.json b/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/input/meta.docs.json index 736150c4f..1b4284cd7 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/input/meta.docs.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/input/meta.docs.json @@ -28,8 +28,8 @@ { "scope.env": { "name": "dev", "@project": "acme-deploy" } } ] } }, - { "environment.standing": { "name": "production" } }, - { "environment.ephemeral": { "name": "preview" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, + { "environment.stage": { "name": "preview", "@owner": "Acme", "@purpose": "test", "@lifespan": "ephemeral" } }, { "deployment.pages": { "name": "siteBase", "abstract": true, @@ -39,7 +39,8 @@ "@tokenSecret": "ACME_PAGES_TOKEN" } }, { "deployment.pages": { "name": "siteProduction", "extends": "siteBase", "@environment": "production", "@branch": "main", "@domains": ["docs.example.com"] } }, - { "deployment.pages": { "name": "sitePreview", "extends": "siteBase", "@environment": "preview", "@branch": "preview" } } + { "deployment.pages": { "name": "sitePreview", "extends": "siteBase", "@environment": "preview", "@branch": "preview" } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/expected.json b/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/expected.json index 3dceaef12..8c98a0335 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/expected.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/expected.json @@ -161,8 +161,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "acme::trips::Acme", + "@purpose": "production" } }, { @@ -178,7 +180,7 @@ "trips.example.com", "www.trips.example.com" ], - "@environment": "production", + "@environment": "acme::trips::production", "@jobs": [ "Trips.coverCleanup" ], @@ -268,6 +270,11 @@ } ] } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/input/meta.trips.json b/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/input/meta.trips.json index c21a35cb1..bebdd8690 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/input/meta.trips.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/input/meta.trips.json @@ -55,7 +55,7 @@ { "scope.env": { "name": "dev", "@project": "acme-deploy" } } ] } }, - { "environment.standing": { "name": "production" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, { "deployment.worker": { "name": "webProduction", "@app": "Trips.web", @@ -85,7 +85,8 @@ { "value.literal": { "name": "aud", "@setting": "Access.aud", "@literal": "0000000000000000000000000000000000000000000000000000000000000000" } }, { "value.literal": { "name": "notifyEmail", "@setting": "Notify.email", "@literal": "host@example.com" } } ] - } } + } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/expected.json b/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/expected.json index 197475d2b..7b88df4e5 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/expected.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/expected.json @@ -141,13 +141,17 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "acme::quiz::Acme", + "@purpose": "production" } }, { - "environment.standing": { - "name": "staging" + "environment.stage": { + "name": "staging", + "@owner": "acme::quiz::Acme", + "@purpose": "staging" } }, { @@ -205,7 +209,7 @@ "quiz.example.com", "www.quiz.example.com" ], - "@environment": "production" + "@environment": "acme::quiz::production" } }, { @@ -217,7 +221,7 @@ "@domains": [ "staging.quiz.example.com" ], - "@environment": "staging", + "@environment": "acme::quiz::staging", "children": [ { "cloudflare.d1": { @@ -242,6 +246,11 @@ } ] } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/input/meta.quiz.json b/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/input/meta.quiz.json index 2203d52b3..be7f69d5c 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/input/meta.quiz.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/input/meta.quiz.json @@ -53,8 +53,8 @@ { "scope.env": { "name": "dev", "@project": "acme-deploy" } } ] } }, - { "environment.standing": { "name": "production" } }, - { "environment.standing": { "name": "staging" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, + { "environment.stage": { "name": "staging", "@owner": "Acme", "@purpose": "staging" } }, { "deployment.worker": { "name": "siteBase", "abstract": true, @@ -95,7 +95,8 @@ { "cloudflare.kv": { "name": "rateLimit", "@namespaceId": "00000000000000000000000000000002" } }, { "value.literal": { "name": "killSwitch", "@setting": "Limits.killSwitch", "@literal": "on" } } ] - } } + } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/cloudflare/fixtures/conformance/error-binding-base-authored/input/meta.shop.json b/packs/cloudflare/fixtures/conformance/error-binding-base-authored/input/meta.shop.json index e7dc55010..0b064aa04 100644 --- a/packs/cloudflare/fixtures/conformance/error-binding-base-authored/input/meta.shop.json +++ b/packs/cloudflare/fixtures/conformance/error-binding-base-authored/input/meta.shop.json @@ -2,7 +2,8 @@ { "system.internal": { "name": "Shop", "children": [ { "app.service": { "name": "site", "@needs": ["db"], "children": [ { "build.static": { "name": "assets", "@directory": "public" } } ] } }, { "resource.database": { "name": "db" } } ] } }, - { "environment.standing": { "name": "production" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, { "deployment.worker": { "name": "siteProduction", "@app": "Shop.site", "@environment": "production", "@compatibilityDate": "2026-07-01", "@tokenSecret": "ACME_WORKERS_TOKEN", "children": [ - { "cloudflare.base": { "name": "db" } } ] } } + { "cloudflare.base": { "name": "db" } } ] } }, + { "organization.company": { "name": "Acme" } } ]}} diff --git a/packs/cloudflare/fixtures/conformance/error-binding-on-pages/input/meta.shop.json b/packs/cloudflare/fixtures/conformance/error-binding-on-pages/input/meta.shop.json index 0f5f0bb87..15dec5a90 100644 --- a/packs/cloudflare/fixtures/conformance/error-binding-on-pages/input/meta.shop.json +++ b/packs/cloudflare/fixtures/conformance/error-binding-on-pages/input/meta.shop.json @@ -2,7 +2,8 @@ { "system.internal": { "name": "Shop", "children": [ { "app.service": { "name": "site", "@needs": ["db"], "children": [ { "build.static": { "name": "assets", "@directory": "public" } } ] } }, { "resource.database": { "name": "db" } } ] } }, - { "environment.standing": { "name": "production" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, { "deployment.pages": { "name": "siteProduction", "@app": "Shop.site", "@environment": "production", "@project": "shop", "@tokenSecret": "ACME_PAGES_TOKEN", "children": [ - { "cloudflare.d1": { "name": "db", "@databaseName": "shop" } } ] } } + { "cloudflare.d1": { "name": "db", "@databaseName": "shop" } } ] } }, + { "organization.company": { "name": "Acme" } } ]}} diff --git a/packs/cloudflare/fixtures/conformance/error-not-found-not-allowed/input/meta.shop.json b/packs/cloudflare/fixtures/conformance/error-not-found-not-allowed/input/meta.shop.json index 4bf88f127..030184bb5 100644 --- a/packs/cloudflare/fixtures/conformance/error-not-found-not-allowed/input/meta.shop.json +++ b/packs/cloudflare/fixtures/conformance/error-not-found-not-allowed/input/meta.shop.json @@ -2,6 +2,7 @@ { "system.internal": { "name": "Shop", "children": [ { "app.service": { "name": "site", "@needs": ["db"], "children": [ { "build.static": { "name": "assets", "@directory": "public" } } ] } }, { "resource.database": { "name": "db" } } ] } }, - { "environment.standing": { "name": "production" } }, - { "deployment.worker": { "name": "siteProduction", "@app": "Shop.site", "@environment": "production", "@compatibilityDate": "2026-07-01", "@tokenSecret": "ACME_WORKERS_TOKEN", "@notFound": "index" } } + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, + { "deployment.worker": { "name": "siteProduction", "@app": "Shop.site", "@environment": "production", "@compatibilityDate": "2026-07-01", "@tokenSecret": "ACME_WORKERS_TOKEN", "@notFound": "index" } }, + { "organization.company": { "name": "Acme" } } ]}} diff --git a/packs/cloudflare/fixtures/conformance/error-worker-app-unresolved/input/meta.shop.json b/packs/cloudflare/fixtures/conformance/error-worker-app-unresolved/input/meta.shop.json index 0ae8b6d27..1e5c0e352 100644 --- a/packs/cloudflare/fixtures/conformance/error-worker-app-unresolved/input/meta.shop.json +++ b/packs/cloudflare/fixtures/conformance/error-worker-app-unresolved/input/meta.shop.json @@ -2,6 +2,7 @@ { "system.internal": { "name": "Shop", "children": [ { "app.service": { "name": "site", "@needs": ["db"], "children": [ { "build.static": { "name": "assets", "@directory": "public" } } ] } }, { "resource.database": { "name": "db" } } ] } }, - { "environment.standing": { "name": "production" } }, - { "deployment.worker": { "name": "siteProduction", "@app": "Shop.web", "@environment": "production", "@compatibilityDate": "2026-07-01", "@tokenSecret": "ACME_WORKERS_TOKEN" } } + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, + { "deployment.worker": { "name": "siteProduction", "@app": "Shop.web", "@environment": "production", "@compatibilityDate": "2026-07-01", "@tokenSecret": "ACME_WORKERS_TOKEN" } }, + { "organization.company": { "name": "Acme" } } ]}} diff --git a/packs/cloudflare/fixtures/conformance/error-worker-missing-compatibility-date/input/meta.shop.json b/packs/cloudflare/fixtures/conformance/error-worker-missing-compatibility-date/input/meta.shop.json index 0f166b1d2..cc8176ebd 100644 --- a/packs/cloudflare/fixtures/conformance/error-worker-missing-compatibility-date/input/meta.shop.json +++ b/packs/cloudflare/fixtures/conformance/error-worker-missing-compatibility-date/input/meta.shop.json @@ -2,7 +2,8 @@ { "system.internal": { "name": "Shop", "children": [ { "app.service": { "name": "site", "@needs": ["db"], "children": [ { "build.static": { "name": "assets", "@directory": "public" } } ] } }, { "resource.database": { "name": "db" } } ] } }, - { "environment.standing": { "name": "production" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, { "deployment.worker": { "name": "siteBase", "abstract": true, "@app": "Shop.site", "@tokenSecret": "ACME_WORKERS_TOKEN" } }, - { "deployment.worker": { "name": "siteProduction", "extends": "siteBase", "@environment": "production" } } + { "deployment.worker": { "name": "siteProduction", "extends": "siteBase", "@environment": "production" } }, + { "organization.company": { "name": "Acme" } } ]}} diff --git a/packs/cloudflare/fixtures/expected-vocabulary.json b/packs/cloudflare/fixtures/expected-vocabulary.json index c3a7059d2..f03a42462 100644 --- a/packs/cloudflare/fixtures/expected-vocabulary.json +++ b/packs/cloudflare/fixtures/expected-vocabulary.json @@ -119,7 +119,7 @@ { "type": "deployment", "subType": "pages", - "description": "An app deployed as a Cloudflare Pages site in one environment: the directory of its build.static, uploaded by `wrangler pages deploy`. Takes every deployment.base attribute; @branch is the branch the upload is recorded on (the project's production branch, or a preview branch). A Pages project has two environments, production and preview, each with its own variables: the upload of the production branch serves production and every other upload serves preview, and the secret sync writes to the environment the @branch serves. The model states the production branch with the @branch of the deployment.pages in the environment named `production`; when it states none, a deployment that reads a secret is refused.", + "description": "An app deployed as a Cloudflare Pages site in one environment: the directory of its build.static, uploaded by `wrangler pages deploy`. Takes deployment.base's @environment and declares the same platform attributes as deployment.worker; @branch is the branch the upload is recorded on (the project's production branch, or a preview branch). A Pages project has two environments, production and preview, each with its own variables: the upload of the production branch serves production and every other upload serves preview, and the secret sync writes to the environment the @branch serves. The model states the production branch with the @branch of the deployment.pages in the environment named `production`; when it states none, a deployment that reads a secret is refused.", "whenToUse": "Each (app, environment) pair that ships as a Cloudflare Pages site.", "attrs": [ { @@ -148,7 +148,11 @@ "valueType": "string", "isArray": false, "required": true, - "description": "The environment.* node it deploys to, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." + "ref": { + "targetType": "environment", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The environment it is placed in: an environment.* node, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." }, { "name": "project", @@ -176,7 +180,7 @@ "valueType": "string", "isArray": false, "required": false, - "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack). Recorded by name only: this pack does not require the config pack." + "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack)." }, { "name": "tokenSecret", @@ -209,7 +213,7 @@ { "type": "deployment", "subType": "worker", - "description": "An app deployed as one Cloudflare Worker, with or without static assets, in one environment. Takes every deployment.base attribute (@app, @environment, @domains, @branch, @secrets, and value.* children) and adds the Worker's own. The facts every environment shares belong on an abstract deployment.worker that each environment's deployment extends; the environment's deployment then holds only what differs there. The wrangler.jsonc generator writes the top-level environment and one complete env block per other environment.", + "description": "An app deployed as one Cloudflare Worker, with or without static assets, in one environment. Takes deployment.base's @environment and declares the rest itself: @app, @domains, @replicas, @region, @branch, @secrets, value.* children, and the Worker's own. A platform-named subtype, kept until this pack moves onto deployment.system and deployment.app (ADR-0070). The facts every environment shares belong on an abstract deployment.worker that each environment's deployment extends; the environment's deployment then holds only what differs there. The wrangler.jsonc generator writes the top-level environment and one complete env block per other environment.", "whenToUse": "Each (app, environment) pair that runs as a Cloudflare Worker.", "attrs": [ { @@ -259,7 +263,11 @@ "valueType": "string", "isArray": false, "required": true, - "description": "The environment.* node it deploys to, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." + "ref": { + "targetType": "environment", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The environment it is placed in: an environment.* node, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." }, { "name": "extra", @@ -320,7 +328,7 @@ "valueType": "string", "isArray": false, "required": false, - "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack). Recorded by name only: this pack does not require the config pack." + "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack)." }, { "name": "tokenSecret", diff --git a/packs/cloudflare/metamodel/cloudflare.json b/packs/cloudflare/metamodel/cloudflare.json index 5ce5ebb9c..01fcc2879 100644 --- a/packs/cloudflare/metamodel/cloudflare.json +++ b/packs/cloudflare/metamodel/cloudflare.json @@ -5,9 +5,16 @@ "type": "deployment", "subType": "worker", "extendsBase": true, - "description": "An app deployed as one Cloudflare Worker, with or without static assets, in one environment. Takes every deployment.base attribute (@app, @environment, @domains, @branch, @secrets, and value.* children) and adds the Worker's own. The facts every environment shares belong on an abstract deployment.worker that each environment's deployment extends; the environment's deployment then holds only what differs there. The wrangler.jsonc generator writes the top-level environment and one complete env block per other environment.", + "description": "An app deployed as one Cloudflare Worker, with or without static assets, in one environment. Takes deployment.base's @environment and declares the rest itself: @app, @domains, @replicas, @region, @branch, @secrets, value.* children, and the Worker's own. A platform-named subtype, kept until this pack moves onto deployment.system and deployment.app (ADR-0070). The facts every environment shares belong on an abstract deployment.worker that each environment's deployment extends; the environment's deployment then holds only what differs there. The wrangler.jsonc generator writes the top-level environment and one complete env block per other environment.", "whenToUse": "Each (app, environment) pair that runs as a Cloudflare Worker.", "children": [ + { "type": "attr", "subType": "string", "name": "app", "min": 1, "max": 1, "description": "The app deployed: `System.app` (`Shop.web`), or `pkg::System.app` from another package. It must resolve to an app.* node (ERR_DELIVERY_UNRESOLVED_REF)." }, + { "type": "attr", "subType": "string", "name": "domains", "isArray": true, "min": 0, "max": 1, "description": "The public host names that route to the app here." }, + { "type": "attr", "subType": "int", "name": "replicas", "min": 0, "max": 1, "description": "How many copies run. Absent means the platform's default." }, + { "type": "attr", "subType": "string", "name": "region", "min": 0, "max": 1, "description": "The platform's region name." }, + { "type": "attr", "subType": "string", "name": "branch", "min": 0, "max": 1, "description": "The repository branch whose pushes deploy here." }, + { "type": "attr", "subType": "string", "name": "secrets", "min": 0, "max": 1, "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack)." }, + { "type": "value", "subType": ["literal", "ref"], "name": "*", "min": 0, "max": null }, { "type": "attr", "subType": "string", "name": "script", "min": 0, "max": 1, "description": "The Worker's name on Cloudflare. Absent means the app's name. In an env block the name is `-` (Wrangler's own default) unless this deployment's @script differs from the top level's: two environments never deploy over one Worker." }, { "type": "attr", "subType": "string", "name": "main", "min": 0, "max": 1, "description": "The Worker's entry module from the repository root (`src/index.ts`). Absent for a Worker that only serves assets." }, { "type": "attr", "subType": "string", "name": "compatibilityDate", "min": 1, "max": 1, "description": "The Workers runtime compatibility date (`2026-07-01`)." }, @@ -28,9 +35,16 @@ "type": "deployment", "subType": "pages", "extendsBase": true, - "description": "An app deployed as a Cloudflare Pages site in one environment: the directory of its build.static, uploaded by `wrangler pages deploy`. Takes every deployment.base attribute; @branch is the branch the upload is recorded on (the project's production branch, or a preview branch). A Pages project has two environments, production and preview, each with its own variables: the upload of the production branch serves production and every other upload serves preview, and the secret sync writes to the environment the @branch serves. The model states the production branch with the @branch of the deployment.pages in the environment named `production`; when it states none, a deployment that reads a secret is refused.", + "description": "An app deployed as a Cloudflare Pages site in one environment: the directory of its build.static, uploaded by `wrangler pages deploy`. Takes deployment.base's @environment and declares the same platform attributes as deployment.worker; @branch is the branch the upload is recorded on (the project's production branch, or a preview branch). A Pages project has two environments, production and preview, each with its own variables: the upload of the production branch serves production and every other upload serves preview, and the secret sync writes to the environment the @branch serves. The model states the production branch with the @branch of the deployment.pages in the environment named `production`; when it states none, a deployment that reads a secret is refused.", "whenToUse": "Each (app, environment) pair that ships as a Cloudflare Pages site.", "children": [ + { "type": "attr", "subType": "string", "name": "app", "min": 1, "max": 1, "description": "The app deployed: `System.app` (`Shop.web`), or `pkg::System.app` from another package. It must resolve to an app.* node (ERR_DELIVERY_UNRESOLVED_REF)." }, + { "type": "attr", "subType": "string", "name": "domains", "isArray": true, "min": 0, "max": 1, "description": "The public host names that route to the app here." }, + { "type": "attr", "subType": "int", "name": "replicas", "min": 0, "max": 1, "description": "How many copies run. Absent means the platform's default." }, + { "type": "attr", "subType": "string", "name": "region", "min": 0, "max": 1, "description": "The platform's region name." }, + { "type": "attr", "subType": "string", "name": "branch", "min": 0, "max": 1, "description": "The repository branch whose pushes deploy here." }, + { "type": "attr", "subType": "string", "name": "secrets", "min": 0, "max": 1, "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack)." }, + { "type": "value", "subType": ["literal", "ref"], "name": "*", "min": 0, "max": null }, { "type": "attr", "subType": "string", "name": "project", "min": 1, "max": 1, "description": "The Pages project's name." }, { "type": "attr", "subType": "string", "name": "tokenSecret", "min": 1, "max": 1, "description": "The name, in the vault, of the narrow Cloudflare API token the deploy scripts use for this site (Pages Write). The scripts map it to CLOUDFLARE_API_TOKEN and unset the global-key variables. The vault entry CLOUDFLARE_ACCOUNT_ID sits beside it." }, { "type": "attr", "subType": "string", "name": "tokenVault", "min": 0, "max": 1, "description": "The vault (a vault.* of the config pack, by name) whose scope for this environment holds @tokenSecret and CLOUDFLARE_ACCOUNT_ID. Absent means the @secrets vault." } diff --git a/packs/cloudflare/typescript/src/constants.ts b/packs/cloudflare/typescript/src/constants.ts index d9638e301..57c4be270 100644 --- a/packs/cloudflare/typescript/src/constants.ts +++ b/packs/cloudflare/typescript/src/constants.ts @@ -6,6 +6,16 @@ export const CLOUDFLARE_PROVIDER_ID = "metaobjects-cloudflare"; export const DEPLOYMENT_SUBTYPE_WORKER = "worker"; export const DEPLOYMENT_SUBTYPE_PAGES = "pages"; +// The platform attributes of this pack's deployment subtypes. The delivery pack registered +// them on deployment.base until its estate vocabulary (deployment.system, deployment.app) +// replaced them; a platform-named deployment declares them itself until this pack moves +// onto that vocabulary (ADR-0070). +export const DEPLOYMENT_ATTR_DOMAINS = "domains"; +export const DEPLOYMENT_ATTR_REPLICAS = "replicas"; +export const DEPLOYMENT_ATTR_REGION = "region"; +export const DEPLOYMENT_ATTR_BRANCH = "branch"; +export const DEPLOYMENT_ATTR_SECRETS = "secrets"; + /** The two environments a Pages project has, each with its own variables: what `pages secret put|list --env` takes. */ export const PAGES_ENV_PRODUCTION = "production"; export const PAGES_ENV_PREVIEW = "preview"; diff --git a/packs/cloudflare/typescript/src/model.ts b/packs/cloudflare/typescript/src/model.ts index dc4bae45f..1bf3e5ee8 100644 --- a/packs/cloudflare/typescript/src/model.ts +++ b/packs/cloudflare/typescript/src/model.ts @@ -27,12 +27,7 @@ import { import { BUILD_SUBTYPE_STATIC, DEPLOYMENT_ATTR_APP, - DEPLOYMENT_ATTR_BRANCH, - DEPLOYMENT_ATTR_DOMAINS, DEPLOYMENT_ATTR_ENVIRONMENT, - DEPLOYMENT_ATTR_REGION, - DEPLOYMENT_ATTR_REPLICAS, - DEPLOYMENT_ATTR_SECRETS, TYPE_BUILD, TYPE_DEPLOYMENT, TYPE_ENVIRONMENT, @@ -59,6 +54,11 @@ import { resolveSystemRef, } from "@metaobjectsdev/pack-systems"; import { + DEPLOYMENT_ATTR_BRANCH, + DEPLOYMENT_ATTR_DOMAINS, + DEPLOYMENT_ATTR_REGION, + DEPLOYMENT_ATTR_REPLICAS, + DEPLOYMENT_ATTR_SECRETS, ATTR_TOKEN_SECRET, ATTR_TOKEN_VAULT, BINDING_D1, diff --git a/packs/cloudflare/typescript/test/model.test.ts b/packs/cloudflare/typescript/test/model.test.ts index 72ccbc7b2..3308b26b5 100644 --- a/packs/cloudflare/typescript/test/model.test.ts +++ b/packs/cloudflare/typescript/test/model.test.ts @@ -248,7 +248,7 @@ describe("refusals", () => { test("no top-level environment: several environments, none named production", async () => { const sources = editFixture(ENVS, (r) => { - child(r, "environment.standing", "production")["name"] = "live"; + child(r, "environment.stage", "production")["name"] = "live"; child(r, "deployment.worker", "siteProduction")["@environment"] = "live"; for (const c of children(child(r, "vault.infisical", "keys"))) if (c["scope.env"]?.["name"] === "production") c["scope.env"]["name"] = "live"; }); @@ -262,7 +262,7 @@ describe("refusals", () => { test("two environments that would deploy over one Worker", async () => { const sources = editFixture(ENVS, (r) => { r["metadata.root"].children.push( - { "environment.standing": { name: "qa" } }, + { "environment.stage": { name: "qa", "@owner": "Acme", "@purpose": "staging" } }, { "deployment.worker": { name: "siteQa", extends: "siteBase", "@environment": "qa", "@script": "quiz-staging" } }, ); children(child(r, "vault.infisical", "keys")).push({ "scope.env": { name: "qa", "@project": "quiz" } }); @@ -303,7 +303,7 @@ describe("refusals", () => { test("one app deployed both as a Worker and as a Pages site", async () => { const sources = editFixture(ENVS, (r) => { r["metadata.root"].children.push( - { "environment.standing": { name: "docs" } }, + { "environment.stage": { name: "docs", "@owner": "Acme", "@purpose": "production" } }, { "deployment.pages": { name: "sitePages", "@app": "Quiz.site", "@environment": "docs", "@project": "quiz", "@tokenVault": "deployKeys", "@tokenSecret": "T" } }, ); }); @@ -367,7 +367,7 @@ describe("a Pages site's environments", () => { const keys = child(r, "vault.infisical", "keys"); vault(keys, children(keys)); r["metadata.root"].children.push( - { "environment.standing": { "name": "staging" } }, + { "environment.stage": { "name": "staging", "@owner": "Acme", "@purpose": "staging" } }, { "deployment.pages": { name: "siteStaging", extends: "siteBase", "@environment": "staging", "@branch": "staging", ...staging } }, ); }); diff --git a/packs/delivery/CHANGELOG.md b/packs/delivery/CHANGELOG.md index eb9ef8898..99af0b54e 100644 --- a/packs/delivery/CHANGELOG.md +++ b/packs/delivery/CHANGELOG.md @@ -4,6 +4,40 @@ This pack's own changelog (ADR-0069). The root `CHANGELOG.md` records core only. ## [0.1.0] - unreleased +- **The estate vocabulary (ADR-0070, calls 3 to 6): where systems and apps run.** + `location.jurisdiction` (`@countries`, ISO 3166-1 alpha-2, required) holds `location.region`, + which holds `location.zone`; jurisdictions do not nest, so a region belongs to exactly one. + `environment.stage` is the one kind of environment, with `@owner` (an organization, required), + `@purpose` (`production`, `staging`, `test` or `development`, required) and `@lifespan` + (`standing`, the default, or `ephemeral`). `deployment.system` (`@system`) and + `deployment.app` (`@app`) place a system or one app in an environment at `@locations` + (regions or zones, required) with an optional `@mode` (`activeActive`, `activePassive`). + `provision.resource` (`@resource`, `@environment`, `@locations`) says how a resource's copies + in more than one region relate: `@replication` (`none`, `standby`, `multiWriter`) and + `@consistency` (`strong`, `eventual`). None of `@mode`, `@replication` or `@consistency` + defaults. Every reference is declared with the reference facet, so the loader resolves it and + raises `ERR_DELIVERY_UNRESOLVED_REF`; a misspelt country is `ERR_BAD_ATTR_VALUE`. Fixtures + `delivery-estate-quillhaven` (a cut of the Quillhaven estate: two jurisdictions, four + environments, system, app and provision nodes) and five error cases. The placement and + residency rules over these words are `meta verify` rules and come later. + + Retired: `environment.standing`, `.ephemeral` and `.local` (an environment is + `environment.stage`; "local" is where an environment is placed, which is a setting), and + `deployment.base`'s `@app`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets` and its + `value.*` children. `deployment.base` keeps only `@environment`. A platform, product, size, + count, host name or identifier is a setting keyed by the node's name, not an attribute. The + `railway` and `cloudflare` packs declare those attributes and `value.*` children on their own + `deployment.` subtypes until they move onto `deployment.system` and + `deployment.app`. The `DEPLOYMENT_ATTR_DOMAINS`, `_REPLICAS`, `_REGION`, `_BRANCH` and + `_SECRETS` and `ENVIRONMENT_SUBTYPE_STANDING`, `_EPHEMERAL` and `_LOCAL` exports are gone. + + How the pack's other kinds stand under ADR-0070's test: `build.dockerfile`, `.command` and + `.static` stay here, extending core's `build.base`; `runtime.process` stays, since how a + process starts and is checked is the same in every environment and names no platform; + `value.literal` and `value.ref` stay only as children of the platform deployments, and go + with them: on the new deployments a value that differs per environment is a setting and an + address is derived. + - **`build.base` is core's from metamodel 1.4.** Core registers `build.base` and `build.image` and lets an app hold one build (ADR-0070), so this pack's `build.dockerfile`, `.command` and `.static` extend core's base and the pack requires metamodel 1.4. Each still declares diff --git a/packs/delivery/README.md b/packs/delivery/README.md index 884012a0d..813da4380 100644 --- a/packs/delivery/README.md +++ b/packs/delivery/README.md @@ -4,65 +4,105 @@ ([ADR-0069](../../spec/decisions/ADR-0069-independent-packs.md)). Requires [`systems`](../systems/README.md). -It answers: **what runs where, and what differs per environment?** Facts true in every -environment sit under the app (how it is built, how its process runs). A deployment places one app -in one environment on one platform, and holds only what differs there. +It answers: **where do systems and apps run, and how are their copies arranged?** Facts true in +every environment sit under the app (how it is built, how its process runs). The estate words +(ADR-0070, calls 3 to 6) say where each system or app runs and how a resource's copies relate, +in the company's own words. They name no platform, product, size, count, host name or +identifier: those are settings ([docs/features/settings.md](../../docs/features/settings.md)), +keyed by the node's name. ## Vocabulary | Node | Where | What it is | Attributes | |---|---|---|---| -| `environment.standing`, `.ephemeral`, `.local` | document root | A named environment: production, a pull-request preview, a workstation | (documentation only) | +| `location.jurisdiction` | document root | A legal boundary data may be confined to (`EU`) | `@countries` (ISO 3166-1 alpha-2, required) | +| `location.region` | under a jurisdiction | An area one disaster does not take two of (`EU.EuWest`) | none | +| `location.zone` | under a region | One failure domain: a building, a power feed (`EU.EuWest.a`) | none | +| `environment.stage` | document root | A named environment: Production, Staging, a pull-request preview, a developer's copy | `@owner` (an organization, required), `@purpose` (`production`, `staging`, `test`, `development`, required), `@lifespan` (`standing`, the default, or `ephemeral`) | +| `deployment.system` | document root | Every app of a system runs in an environment at these locations | `@system`, `@environment`, `@locations` (required), `@mode` | +| `deployment.app` | document root | One app runs apart from its system's deployment | `@app`, `@environment`, `@locations` (required), `@mode` | +| `provision.resource` | document root | A resource kept in more than one region, and how its copies relate | `@resource`, `@environment`, `@locations` (required), `@replication`, `@consistency` | | `build.dockerfile` | under an `app.*`, at most one build | Built as an image from a Dockerfile | `@path`, `@context`, `@watchInclude`, `@watchExclude` | | `build.command` | under an `app.*` | Built by a command the platform's builder runs | `@command`, `@watchInclude`, `@watchExclude` | | `build.static` | under an `app.*` | A directory of files served as they are | `@directory`, `@command`, `@watchInclude`, `@watchExclude` | | `runtime.process` | under an `app.*` | How one of its processes runs | `@command`, `@port`, `@healthPath`, `@healthTimeoutSeconds`, `@drainSeconds`, `@restart` (`always`, `onFailure`, `never`) | -| `deployment.` | document root | An app in an environment on a platform. A **platform pack** registers the subtype (the [`railway`](../railway/README.md) pack registers `deployment.railway`) | `@app`, `@environment`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets`, plus the platform's own | -| `value.literal` | under a deployment | A setting's fixed value there | `@setting`, `@literal` | -| `value.ref` | under a deployment | A setting's value produced by another node at deploy time | `@setting`, `@producedBy`, `@output`, `@path` | +| `value.literal` | under a platform deployment | A setting's fixed value there | `@setting`, `@literal` | +| `value.ref` | under a platform deployment | A setting's value produced by another node at deploy time | `@setting`, `@producedBy`, `@output`, `@path` | + +- **Jurisdictions do not nest.** A region belongs to exactly one jurisdiction, and a + jurisdiction holds only regions (`ERR_CHILD_NOT_ALLOWED` otherwise): `residency: confined` + says "one jurisdiction" and not which level. +- **`@locations`** names regions or zones. A region means all of its zones. The order matters + when one site leads: under `activePassive` the first serves, under `standby` the first accepts + writes. +- **`@mode`** is `activeActive` (every site serves) or `activePassive` (the first serves, the rest + take over). **`@replication`** is `none`, `standby` or `multiWriter`; **`@consistency`** + (`strong` or `eventual`) goes with `multiWriter`. None of them defaults: a deployment or + resource in more than one region states them. The rules that require them, and the rest of + placement, are `meta verify` rules over the estate, not load errors. +- **A provision node is written only for more than one region.** A resource used from one region + is provisioned there with no node. +- **Environments.** "Local" is gone: a developer's laptop is a target the `development` + environment is placed on by a setting. The `build.*` subtypes extend core's `build.base` (metamodel 1.4); core also registers -`build.image`, an image built elsewhere. `deployment.base` is the abstract anchor platform packs specialise (`extendsBase: true`); this pack -registers no concrete deployment, and an authored `deployment.base` fails to load -(`ERR_ABSTRACT_SUBTYPE_AUTHORED`). A secret needs no value node: the setting is marked secret in -the config pack and the deployment names its vault in `@secrets`. The full definition is +`build.image`, an image built elsewhere. A build and a runtime process are the same in every +environment and name no platform, so they stay with the app. `deployment.base` is abstract: an +authored `deployment.base` fails to load (`ERR_ABSTRACT_SUBTYPE_AUTHORED`). It holds +`@environment`, which every deployment kind shares. + +**Platform deployments, until they move.** The [`railway`](../railway/README.md) and +[`cloudflare`](../cloudflare/README.md) packs still register `deployment.railway`, +`deployment.worker` and `deployment.pages` on `deployment.base`. Each declares its own `@app`, +`@domains`, `@replicas`, `@region`, `@branch`, `@secrets` and `value.*` children; this pack no +longer registers them on `deployment.base`. ADR-0070 retires those subtypes in favour of +`deployment.system` and `deployment.app` with the platform as a setting, and the `value.*` kinds +go with them: a value that differs per environment is a setting, and an address is derived. A +`deployment.system` or `deployment.app` holds no `value.*`. The full definition is [`metamodel/delivery.json`](metamodel/delivery.json). ## References -- `@app` names an app as `System.app`, or `pkg::System.app` from another package. -- `@environment` names an `environment.*` node. -- `value.ref`'s `@producedBy` names a `resource.*` or `app.*` the same way. A deployment sits at the - document root, in no system, so these are always written `System.child`: a bare name finds - only a top-level node. `@output` says which of its - values (`url`, `host`, `port`, `user`, `password`, `privateUrl`, `publicUrl`), for a platform - generator to map. This is how an address - stays out of a repository: it is named, never written. +Every reference is declared with the reference facet +([spec/metamodel-definitions.md](../../spec/metamodel-definitions.md)) and resolved by the +loader, and raises `ERR_DELIVERY_UNRESOLVED_REF` when it names nothing or the wrong kind of node: + +- `@system` names a `system.*`, and `@app` an `app.*` as `System.app` (`pkg::System.app` from + another package). A deployment sits at the document root, in no system, so an app or resource + is always written `System.child`. +- `@resource` names a `resource.*` as `System.resource`. +- `@environment` names an `environment.*`; `@owner` an `organization.*` (a unit as + `Company.Unit`). +- `@locations` names a `location.region` or `location.zone` (`EU.EuWest`, `EU.EuWest.a`); a + jurisdiction is refused. +- `value.ref`'s `@producedBy` names a `resource.*` or `app.*` the same way, and `@output` says which + of its values (`url`, `host`, `port`, `user`, `password`, `privateUrl`, `publicUrl`), for a + platform generator to map. + +A jurisdiction's `@countries` are two upper-case letters each (`ERR_BAD_ATTR_VALUE`). A platform +pack holds its deployments' `@app` to the same rule by passing `validateDeployment` as its +subtype's validator. `@setting` (`Group.field` of an `object.settings`) is a name only: this pack +does not require the config pack. ## Uniqueness -- A deployment holds at most one `value.*` per `@setting` (`ERR_DELIVERY_DUPLICATE_SETTING`). An estate +- A platform deployment holds at most one `value.*` per `@setting` (`ERR_DELIVERY_DUPLICATE_SETTING`). An estate overlay that overrides a value has to reuse the value node's name so the overlay merges it; a second, differently named value for the same setting is an error. -- A model holds at most one deployment per (`@app`, `@environment`), compared as resolved nodes, so - `Game.server` and `acme::game::Game.server` collide (`ERR_DELIVERY_DUPLICATE_DEPLOYMENT`). +- A model holds at most one platform deployment per (`@app`, `@environment`), compared as resolved + nodes, so `Game.server` and `acme::game::Game.server` collide (`ERR_DELIVERY_DUPLICATE_DEPLOYMENT`). + Where a `deployment.app` overlaps a `deployment.system` is a placement rule, not a load error. A `value.ref` asks only for an output its producer has (`ERR_DELIVERY_UNSUPPORTED_OUTPUT`): `@path` extends a URL output only (`url`, `privateUrl`, `publicUrl`); an app produces `host`, `port`, `privateUrl` and `publicUrl`, and `port` and `privateUrl` need a process that declares `@port`. A resource's outputs depend on its engine and are left to the platform pack. -A reference fails the load with `ERR_DELIVERY_UNRESOLVED_REF` when it resolves to nothing or to the wrong -kind of node. A platform pack holds its deployments to the same rule by passing -`validateDeployment` as its subtype's validator. `@secrets` (a config pack `vault.*`) and -`@setting` (`Group.field` of an `object.settings`) are names only: this pack does not require the -config pack. - ## The estate pattern -The app's repository declares its own deployments. A separate estate repository loads that model, -adds deployments the app never declared (a staging environment), and overrides the ones it did by -overlay, using the loader's existing merge: +Shown here with a platform deployment. The app's repository declares its own deployments. A +separate estate repository loads that model, adds deployments the app never declared (a staging +environment), and overrides the ones it did by overlay, using the loader's existing merge: ```json { "metadata.root": { "package": "acme::game", "children": [ diff --git a/packs/delivery/fixtures/conformance/ERROR-CODES.json b/packs/delivery/fixtures/conformance/ERROR-CODES.json index e24dd1a9b..58104238c 100644 --- a/packs/delivery/fixtures/conformance/ERROR-CODES.json +++ b/packs/delivery/fixtures/conformance/ERROR-CODES.json @@ -1,9 +1,9 @@ { "version": 1, "codes": { - "ERR_DELIVERY_UNRESOLVED_REF": "A deployment's @app or @environment, or a value.ref's @producedBy, names no node, or names a node of the wrong kind (@app takes an app.*, @environment an environment.*, @producedBy a resource.* or an app.*).", + "ERR_DELIVERY_UNRESOLVED_REF": "A reference of the delivery pack names no node, or names a node of the wrong kind: a deployment's @system (a system.*), @app (an app.*), @environment (an environment.*) or @locations (a location.region or location.zone), a provision's @resource (a resource.*), @environment or @locations, an environment's @owner (an organization.*), or a value.ref's @producedBy (a resource.* or an app.*).", "ERR_DELIVERY_DUPLICATE_SETTING": "A deployment holds two value.* nodes for one @setting. An estate overlay that overrides a value must reuse the value node's name so it merges.", - "ERR_DELIVERY_DUPLICATE_DEPLOYMENT": "Two deployments target the same (@app, @environment), compared as resolved nodes.", + "ERR_DELIVERY_DUPLICATE_DEPLOYMENT": "Two platform deployments (deployment.) target the same (@app, @environment), compared as resolved nodes.", "ERR_DELIVERY_UNSUPPORTED_OUTPUT": "A value.ref asks its producer for an output it does not have: @path on an output that is not a URL (url, privateUrl, publicUrl), an app asked for anything but host, port, privateUrl or publicUrl, or an app with no runtime.process @port asked for its port or privateUrl." } } diff --git a/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/expected.json b/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/expected.json index eac0375b0..8c1f6d719 100644 --- a/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/expected.json +++ b/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/expected.json @@ -79,23 +79,37 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "acme::shop::Acme", + "@purpose": "production" } }, { - "environment.standing": { - "name": "staging" + "environment.stage": { + "name": "staging", + "@owner": "acme::shop::Acme", + "@purpose": "staging" } }, { - "environment.ephemeral": { - "name": "preview" + "environment.stage": { + "name": "preview", + "@lifespan": "ephemeral", + "@owner": "acme::shop::Acme", + "@purpose": "test" } }, { - "environment.local": { - "name": "workstation" + "environment.stage": { + "name": "workstation", + "@owner": "acme::shop::Acme", + "@purpose": "development" + } + }, + { + "organization.company": { + "name": "Acme" } } ] diff --git a/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/input/meta.shop.json b/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/input/meta.shop.json index d13717b2a..26b5903a9 100644 --- a/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/input/meta.shop.json +++ b/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/input/meta.shop.json @@ -79,23 +79,37 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "Acme", + "@purpose": "production" } }, { - "environment.standing": { - "name": "staging" + "environment.stage": { + "name": "staging", + "@owner": "Acme", + "@purpose": "staging" } }, { - "environment.ephemeral": { - "name": "preview" + "environment.stage": { + "name": "preview", + "@owner": "Acme", + "@purpose": "test", + "@lifespan": "ephemeral" } }, { - "environment.local": { - "name": "workstation" + "environment.stage": { + "name": "workstation", + "@owner": "Acme", + "@purpose": "development" + } + }, + { + "organization.company": { + "name": "Acme" } } ] diff --git a/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/expected.json b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/expected.json new file mode 100644 index 000000000..0b244a538 --- /dev/null +++ b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/expected.json @@ -0,0 +1,271 @@ +{ + "metadata.root": { + "children": [ + { + "deployment.system": { + "name": "parcels-production-eu", + "package": "quillhaven::estate", + "@environment": "quillhaven::estate::Production", + "@locations": [ + "quillhaven::estate::EU.EuWest" + ], + "@system": "quillhaven::parcels::Parcels" + } + }, + { + "deployment.system": { + "name": "parcels-production-us", + "package": "quillhaven::estate", + "@environment": "quillhaven::estate::Production", + "@locations": [ + "quillhaven::estate::US.UsEast", + "quillhaven::estate::US.UsWest" + ], + "@mode": "activeActive", + "@system": "quillhaven::parcels::Parcels" + } + }, + { + "deployment.app": { + "name": "parcels-export-us", + "package": "quillhaven::estate", + "@app": "quillhaven::parcels::Parcels.manifestExport", + "@environment": "quillhaven::estate::Production", + "@locations": [ + "quillhaven::estate::US.UsEast.a" + ] + } + }, + { + "provision.resource": { + "name": "parcels-db-eu", + "package": "quillhaven::estate", + "@environment": "quillhaven::estate::Production", + "@locations": [ + "quillhaven::estate::EU.EuWest", + "quillhaven::estate::EU.EuCentral" + ], + "@replication": "standby", + "@resource": "quillhaven::parcels::Parcels.db" + } + }, + { + "provision.resource": { + "name": "parcels-events-us", + "package": "quillhaven::estate", + "@consistency": "eventual", + "@environment": "quillhaven::estate::Production", + "@locations": [ + "quillhaven::estate::US.UsEast", + "quillhaven::estate::US.UsWest" + ], + "@replication": "multiWriter", + "@resource": "quillhaven::parcels::Parcels.events" + } + }, + { + "deployment.system": { + "name": "parcels-staging-eu", + "package": "quillhaven::estate", + "@environment": "quillhaven::estate::Staging", + "@locations": [ + "quillhaven::estate::EU.EuWest" + ], + "@system": "quillhaven::parcels::Parcels" + } + }, + { + "deployment.system": { + "name": "parcels-preview", + "package": "quillhaven::estate", + "@environment": "quillhaven::estate::Preview", + "@locations": [ + "quillhaven::estate::EU.EuWest" + ], + "@system": "quillhaven::parcels::Parcels" + } + }, + { + "deployment.system": { + "name": "parcels-development", + "package": "quillhaven::estate", + "@environment": "quillhaven::estate::Development", + "@locations": [ + "quillhaven::estate::EU.EuWest" + ], + "@system": "quillhaven::parcels::Parcels" + } + }, + { + "environment.stage": { + "name": "Production", + "package": "quillhaven::estate", + "@owner": "quillhaven::Quillhaven", + "@purpose": "production" + } + }, + { + "environment.stage": { + "name": "Staging", + "package": "quillhaven::estate", + "@lifespan": "standing", + "@owner": "quillhaven::Quillhaven", + "@purpose": "staging" + } + }, + { + "environment.stage": { + "name": "Preview", + "package": "quillhaven::estate", + "@lifespan": "ephemeral", + "@owner": "quillhaven::Quillhaven.Platform", + "@purpose": "test" + } + }, + { + "environment.stage": { + "name": "Development", + "package": "quillhaven::estate", + "@owner": "quillhaven::Quillhaven", + "@purpose": "development" + } + }, + { + "location.jurisdiction": { + "name": "EU", + "package": "quillhaven::estate", + "@countries": [ + "DE", + "FR", + "IE", + "NL" + ], + "children": [ + { + "location.region": { + "name": "EuWest", + "children": [ + { + "location.zone": { + "name": "a" + } + }, + { + "location.zone": { + "name": "b" + } + }, + { + "location.zone": { + "name": "c" + } + } + ] + } + }, + { + "location.region": { + "name": "EuCentral", + "children": [ + { + "location.zone": { + "name": "a" + } + }, + { + "location.zone": { + "name": "b" + } + } + ] + } + } + ] + } + }, + { + "location.jurisdiction": { + "name": "US", + "package": "quillhaven::estate", + "@countries": [ + "US" + ], + "children": [ + { + "location.region": { + "name": "UsEast", + "children": [ + { + "location.zone": { + "name": "a" + } + }, + { + "location.zone": { + "name": "b" + } + } + ] + } + }, + { + "location.region": { + "name": "UsWest" + } + } + ] + } + }, + { + "organization.company": { + "name": "Quillhaven", + "package": "quillhaven", + "children": [ + { + "organization.unit": { + "name": "ParcelOps" + } + }, + { + "organization.unit": { + "name": "Platform" + } + } + ] + } + }, + { + "system.software": { + "name": "Parcels", + "package": "quillhaven::parcels", + "@owner": "quillhaven::Quillhaven.ParcelOps", + "children": [ + { + "resource.rdb": { + "name": "db", + "@residency": "confined" + } + }, + { + "resource.stream": { + "name": "events" + } + }, + { + "app.service": { + "name": "api", + "@public": true + } + }, + { + "app.job": { + "name": "manifestExport", + "@schedule": "0 2 * * *" + } + } + ] + } + } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.deployments.json b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.deployments.json new file mode 100644 index 000000000..f303234a5 --- /dev/null +++ b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.deployments.json @@ -0,0 +1,15 @@ +{ + "metadata.root": { + "package": "quillhaven::estate", + "children": [ + { "deployment.system": { "name": "parcels-production-eu", "@system": "quillhaven::parcels::Parcels", "@environment": "Production", "@locations": ["EU.EuWest"] } }, + { "deployment.system": { "name": "parcels-production-us", "@system": "quillhaven::parcels::Parcels", "@environment": "Production", "@mode": "activeActive", "@locations": ["US.UsEast", "US.UsWest"] } }, + { "deployment.app": { "name": "parcels-export-us", "@app": "quillhaven::parcels::Parcels.manifestExport", "@environment": "Production", "@locations": ["US.UsEast.a"] } }, + { "provision.resource": { "name": "parcels-db-eu", "@resource": "quillhaven::parcels::Parcels.db", "@environment": "Production", "@replication": "standby", "@locations": ["EU.EuWest", "EU.EuCentral"] } }, + { "provision.resource": { "name": "parcels-events-us", "@resource": "quillhaven::parcels::Parcels.events", "@environment": "Production", "@replication": "multiWriter", "@consistency": "eventual", "@locations": ["US.UsEast", "US.UsWest"] } }, + { "deployment.system": { "name": "parcels-staging-eu", "@system": "quillhaven::parcels::Parcels", "@environment": "Staging", "@locations": ["EU.EuWest"] } }, + { "deployment.system": { "name": "parcels-preview", "@system": "quillhaven::parcels::Parcels", "@environment": "Preview", "@locations": ["EU.EuWest"] } }, + { "deployment.system": { "name": "parcels-development", "@system": "quillhaven::parcels::Parcels", "@environment": "Development", "@locations": ["EU.EuWest"] } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.environments.json b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.environments.json new file mode 100644 index 000000000..b41afc565 --- /dev/null +++ b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.environments.json @@ -0,0 +1,11 @@ +{ + "metadata.root": { + "package": "quillhaven::estate", + "children": [ + { "environment.stage": { "name": "Production", "@owner": "quillhaven::Quillhaven", "@purpose": "production" } }, + { "environment.stage": { "name": "Staging", "@owner": "quillhaven::Quillhaven", "@purpose": "staging", "@lifespan": "standing" } }, + { "environment.stage": { "name": "Preview", "@owner": "quillhaven::Quillhaven.Platform", "@purpose": "test", "@lifespan": "ephemeral" } }, + { "environment.stage": { "name": "Development", "@owner": "quillhaven::Quillhaven", "@purpose": "development" } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.locations.json b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.locations.json new file mode 100644 index 000000000..b0d925088 --- /dev/null +++ b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.locations.json @@ -0,0 +1,25 @@ +{ + "metadata.root": { + "package": "quillhaven::estate", + "children": [ + { "location.jurisdiction": { "name": "EU", "@countries": ["DE", "FR", "IE", "NL"], "children": [ + { "location.region": { "name": "EuWest", "children": [ + { "location.zone": { "name": "a" } }, + { "location.zone": { "name": "b" } }, + { "location.zone": { "name": "c" } } + ] } }, + { "location.region": { "name": "EuCentral", "children": [ + { "location.zone": { "name": "a" } }, + { "location.zone": { "name": "b" } } + ] } } + ] } }, + { "location.jurisdiction": { "name": "US", "@countries": ["US"], "children": [ + { "location.region": { "name": "UsEast", "children": [ + { "location.zone": { "name": "a" } }, + { "location.zone": { "name": "b" } } + ] } }, + { "location.region": { "name": "UsWest" } } + ] } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.org.json b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.org.json new file mode 100644 index 000000000..cdbad2c11 --- /dev/null +++ b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.org.json @@ -0,0 +1,11 @@ +{ + "metadata.root": { + "package": "quillhaven", + "children": [ + { "organization.company": { "name": "Quillhaven", "children": [ + { "organization.unit": { "name": "ParcelOps" } }, + { "organization.unit": { "name": "Platform" } } + ] } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.parcels.json b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.parcels.json new file mode 100644 index 000000000..a873ac24e --- /dev/null +++ b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/input/meta.parcels.json @@ -0,0 +1,13 @@ +{ + "metadata.root": { + "package": "quillhaven::parcels", + "children": [ + { "system.software": { "name": "Parcels", "@owner": "quillhaven::Quillhaven.ParcelOps", "children": [ + { "resource.rdb": { "name": "db", "@residency": "confined" } }, + { "resource.stream": { "name": "events" } }, + { "app.service": { "name": "api", "@public": true } }, + { "app.job": { "name": "manifestExport", "@schedule": "0 2 * * *" } } + ] } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/providers.json b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/providers.json new file mode 100644 index 000000000..a956b47c3 --- /dev/null +++ b/packs/delivery/fixtures/conformance/delivery-estate-quillhaven/providers.json @@ -0,0 +1 @@ +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/conformance/error-deployment-base-authored/input/meta.shop.json b/packs/delivery/fixtures/conformance/error-deployment-base-authored/input/meta.shop.json index 7eb8e84a4..23512767c 100644 --- a/packs/delivery/fixtures/conformance/error-deployment-base-authored/input/meta.shop.json +++ b/packs/delivery/fixtures/conformance/error-deployment-base-authored/input/meta.shop.json @@ -32,8 +32,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "Acme", + "@purpose": "production" } }, { @@ -42,6 +44,11 @@ "@app": "Shop.api", "@environment": "production" } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/delivery/fixtures/conformance/error-estate-closed-values/expected-errors.json b/packs/delivery/fixtures/conformance/error-estate-closed-values/expected-errors.json new file mode 100644 index 000000000..7b369a32b --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-estate-closed-values/expected-errors.json @@ -0,0 +1,75 @@ +{ + "errors": [ + { + "code": "ERR_BAD_ATTR_VALUE", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[4]['location.jurisdiction']" + } + }, + { + "code": "ERR_BAD_ATTR_VALUE", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[4]['location.jurisdiction']" + } + }, + { + "code": "ERR_BAD_ATTR_VALUE", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['environment.stage']" + } + }, + { + "code": "ERR_BAD_ATTR_VALUE", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['environment.stage']" + } + }, + { + "code": "ERR_BAD_ATTR_VALUE", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[6]['deployment.system']" + } + }, + { + "code": "ERR_BAD_ATTR_VALUE", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[7]['provision.resource']" + } + }, + { + "code": "ERR_BAD_ATTR_VALUE", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[7]['provision.resource']" + } + } + ], + "warnings": [] +} diff --git a/packs/delivery/fixtures/conformance/error-estate-closed-values/input/meta.estate.json b/packs/delivery/fixtures/conformance/error-estate-closed-values/input/meta.estate.json new file mode 100644 index 000000000..7bef215ca --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-estate-closed-values/input/meta.estate.json @@ -0,0 +1,15 @@ +{ + "metadata.root": { + "package": "acme::estate", + "children": [ + { "organization.company": { "name": "Acme" } }, + { "system.software": { "name": "Shop", "children": [ { "resource.rdb": { "name": "db" } }, { "app.service": { "name": "api" } } ] } }, + { "location.jurisdiction": { "name": "EU", "@countries": ["DE"], "children": [ { "location.region": { "name": "EuWest", "children": [ { "location.zone": { "name": "a" } } ] } } ] } }, + { "environment.stage": { "name": "Production", "@owner": "Acme", "@purpose": "production" } }, + { "location.jurisdiction": { "name": "UK", "@countries": ["uk", "GBR"] } }, + { "environment.stage": { "name": "Preview", "@owner": "Acme", "@purpose": "preview", "@lifespan": "temporary" } }, + { "deployment.system": { "name": "shop-production", "@system": "Shop", "@environment": "Production", "@mode": "hotStandby", "@locations": ["EU.EuWest"] } }, + { "provision.resource": { "name": "db-production", "@resource": "Shop.db", "@environment": "Production", "@replication": "async", "@consistency": "causal", "@locations": ["EU.EuWest"] } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/error-estate-closed-values/providers.json b/packs/delivery/fixtures/conformance/error-estate-closed-values/providers.json new file mode 100644 index 000000000..a956b47c3 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-estate-closed-values/providers.json @@ -0,0 +1 @@ +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/conformance/error-estate-missing-required/expected-errors.json b/packs/delivery/fixtures/conformance/error-estate-missing-required/expected-errors.json new file mode 100644 index 000000000..0381ca3ef --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-estate-missing-required/expected-errors.json @@ -0,0 +1,75 @@ +{ + "errors": [ + { + "code": "ERR_MISSING_REQUIRED_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[4]['location.jurisdiction']" + } + }, + { + "code": "ERR_MISSING_REQUIRED_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['environment.stage']" + } + }, + { + "code": "ERR_MISSING_REQUIRED_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['environment.stage']" + } + }, + { + "code": "ERR_MISSING_REQUIRED_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[6]['deployment.system']" + } + }, + { + "code": "ERR_MISSING_REQUIRED_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[6]['deployment.system']" + } + }, + { + "code": "ERR_MISSING_REQUIRED_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[7]['provision.resource']" + } + }, + { + "code": "ERR_MISSING_REQUIRED_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[7]['provision.resource']" + } + } + ], + "warnings": [] +} diff --git a/packs/delivery/fixtures/conformance/error-estate-missing-required/input/meta.estate.json b/packs/delivery/fixtures/conformance/error-estate-missing-required/input/meta.estate.json new file mode 100644 index 000000000..c784c3218 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-estate-missing-required/input/meta.estate.json @@ -0,0 +1,15 @@ +{ + "metadata.root": { + "package": "acme::estate", + "children": [ + { "organization.company": { "name": "Acme" } }, + { "system.software": { "name": "Shop", "children": [ { "resource.rdb": { "name": "db" } }, { "app.service": { "name": "api" } } ] } }, + { "location.jurisdiction": { "name": "EU", "@countries": ["DE"], "children": [ { "location.region": { "name": "EuWest", "children": [ { "location.zone": { "name": "a" } } ] } } ] } }, + { "environment.stage": { "name": "Production", "@owner": "Acme", "@purpose": "production" } }, + { "location.jurisdiction": { "name": "US" } }, + { "environment.stage": { "name": "Staging" } }, + { "deployment.system": { "name": "shop-production", "@environment": "Production" } }, + { "provision.resource": { "name": "db-production", "@resource": "Shop.db" } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/error-estate-missing-required/providers.json b/packs/delivery/fixtures/conformance/error-estate-missing-required/providers.json new file mode 100644 index 000000000..a956b47c3 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-estate-missing-required/providers.json @@ -0,0 +1 @@ +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/conformance/error-estate-refs/expected-errors.json b/packs/delivery/fixtures/conformance/error-estate-refs/expected-errors.json new file mode 100644 index 000000000..921b90614 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-estate-refs/expected-errors.json @@ -0,0 +1,75 @@ +{ + "errors": [ + { + "code": "ERR_DELIVERY_UNRESOLVED_REF", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[4]['environment.stage']" + } + }, + { + "code": "ERR_DELIVERY_UNRESOLVED_REF", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['deployment.system']" + } + }, + { + "code": "ERR_DELIVERY_UNRESOLVED_REF", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['deployment.system']" + } + }, + { + "code": "ERR_DELIVERY_UNRESOLVED_REF", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[6]['deployment.app']" + } + }, + { + "code": "ERR_DELIVERY_UNRESOLVED_REF", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[6]['deployment.app']" + } + }, + { + "code": "ERR_DELIVERY_UNRESOLVED_REF", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[7]['provision.resource']" + } + }, + { + "code": "ERR_DELIVERY_UNRESOLVED_REF", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[7]['provision.resource']" + } + } + ], + "warnings": [] +} diff --git a/packs/delivery/fixtures/conformance/error-estate-refs/input/meta.estate.json b/packs/delivery/fixtures/conformance/error-estate-refs/input/meta.estate.json new file mode 100644 index 000000000..b1ed54b11 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-estate-refs/input/meta.estate.json @@ -0,0 +1,15 @@ +{ + "metadata.root": { + "package": "acme::estate", + "children": [ + { "organization.company": { "name": "Acme" } }, + { "system.software": { "name": "Shop", "children": [ { "resource.rdb": { "name": "db" } }, { "app.service": { "name": "api" } } ] } }, + { "location.jurisdiction": { "name": "EU", "@countries": ["DE"], "children": [ { "location.region": { "name": "EuWest", "children": [ { "location.zone": { "name": "a" } } ] } } ] } }, + { "environment.stage": { "name": "Production", "@owner": "Acme", "@purpose": "production" } }, + { "environment.stage": { "name": "Staging", "@owner": "Shop", "@purpose": "staging" } }, + { "deployment.system": { "name": "shop-production", "@system": "Shop.api", "@environment": "Production", "@locations": ["EU"] } }, + { "deployment.app": { "name": "api-production", "@app": "Shop.db", "@environment": "Prod", "@locations": ["EU.EuWest"] } }, + { "provision.resource": { "name": "db-production", "@resource": "Shop.cache", "@environment": "Production", "@replication": "none", "@locations": ["EU.EuWest.a", "EU.EuNorth"] } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/error-estate-refs/providers.json b/packs/delivery/fixtures/conformance/error-estate-refs/providers.json new file mode 100644 index 000000000..a956b47c3 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-estate-refs/providers.json @@ -0,0 +1 @@ +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/conformance/error-jurisdiction-nested/expected-errors.json b/packs/delivery/fixtures/conformance/error-jurisdiction-nested/expected-errors.json new file mode 100644 index 000000000..9beea02cb --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-jurisdiction-nested/expected-errors.json @@ -0,0 +1,25 @@ +{ + "errors": [ + { + "code": "ERR_CHILD_NOT_ALLOWED", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root']" + } + }, + { + "code": "ERR_CHILD_NOT_ALLOWED", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[0]['location.jurisdiction']" + } + } + ], + "warnings": [] +} diff --git a/packs/delivery/fixtures/conformance/error-jurisdiction-nested/input/meta.estate.json b/packs/delivery/fixtures/conformance/error-jurisdiction-nested/input/meta.estate.json new file mode 100644 index 000000000..60592d272 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-jurisdiction-nested/input/meta.estate.json @@ -0,0 +1,11 @@ +{ + "metadata.root": { + "package": "acme::estate", + "children": [ + { "location.jurisdiction": { "name": "EU", "@countries": ["DE", "FR"], "children": [ + { "location.jurisdiction": { "name": "DE", "@countries": ["DE"] } } + ] } }, + { "location.region": { "name": "Floating" } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/error-jurisdiction-nested/providers.json b/packs/delivery/fixtures/conformance/error-jurisdiction-nested/providers.json new file mode 100644 index 000000000..a956b47c3 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-jurisdiction-nested/providers.json @@ -0,0 +1 @@ +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/conformance/error-retired-estate-words/expected-errors.json b/packs/delivery/fixtures/conformance/error-retired-estate-words/expected-errors.json new file mode 100644 index 000000000..608ff8315 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-retired-estate-words/expected-errors.json @@ -0,0 +1,65 @@ +{ + "errors": [ + { + "code": "ERR_UNKNOWN_SUBTYPE", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[4]['environment.standing']" + } + }, + { + "code": "ERR_UNKNOWN_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['deployment.system']" + } + }, + { + "code": "ERR_UNKNOWN_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['deployment.system']" + } + }, + { + "code": "ERR_UNKNOWN_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['deployment.system']" + } + }, + { + "code": "ERR_UNKNOWN_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['deployment.system']" + } + }, + { + "code": "ERR_UNKNOWN_ATTR", + "source": { + "format": "json", + "files": [ + "meta.estate.json" + ], + "jsonPath": "$['metadata.root'].children[5]['deployment.system']" + } + } + ], + "warnings": [] +} diff --git a/packs/delivery/fixtures/conformance/error-retired-estate-words/input/meta.estate.json b/packs/delivery/fixtures/conformance/error-retired-estate-words/input/meta.estate.json new file mode 100644 index 000000000..65ecda5fc --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-retired-estate-words/input/meta.estate.json @@ -0,0 +1,13 @@ +{ + "metadata.root": { + "package": "acme::estate", + "children": [ + { "organization.company": { "name": "Acme" } }, + { "system.software": { "name": "Shop", "children": [ { "resource.rdb": { "name": "db" } }, { "app.service": { "name": "api" } } ] } }, + { "location.jurisdiction": { "name": "EU", "@countries": ["DE"], "children": [ { "location.region": { "name": "EuWest", "children": [ { "location.zone": { "name": "a" } } ] } } ] } }, + { "environment.stage": { "name": "Production", "@owner": "Acme", "@purpose": "production" } }, + { "environment.standing": { "name": "Staging" } }, + { "deployment.system": { "name": "shop-production", "@system": "Shop", "@environment": "Production", "@locations": ["EU.EuWest"], "@replicas": 2, "@region": "eu-west-1", "@domains": ["shop.example.com"], "@branch": "main", "@secrets": "keys" } } + ] + } +} diff --git a/packs/delivery/fixtures/conformance/error-retired-estate-words/providers.json b/packs/delivery/fixtures/conformance/error-retired-estate-words/providers.json new file mode 100644 index 000000000..a956b47c3 --- /dev/null +++ b/packs/delivery/fixtures/conformance/error-retired-estate-words/providers.json @@ -0,0 +1 @@ +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/expected-vocabulary.json b/packs/delivery/fixtures/expected-vocabulary.json index 7f929a57d..b3a07cc0c 100644 --- a/packs/delivery/fixtures/expected-vocabulary.json +++ b/packs/delivery/fixtures/expected-vocabulary.json @@ -107,66 +107,199 @@ }, { "type": "deployment", - "subType": "base", - "description": "Abstract deployment base: an app placed in an environment on a platform. A platform pack registers the concrete subtype (`deployment.`), which takes these attributes and adds the platform's own. A deployment holds only what differs per environment; what is true everywhere sits under the app. An estate repository adds deployments the app never declared and overrides the ones it did by overlay. Not authored directly: a `deployment.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "subType": "app", + "description": "One app runs in this environment at these locations, where it differs from its system's deployment. In the regions they share, it replaces the system-level deployment for that app.", + "whenToUse": "An app placed apart from the rest of its system: in fewer regions, or in another mode.", "attrs": [ { "name": "app", "valueType": "string", "isArray": false, "required": true, - "description": "The app deployed: `System.app` (`Shop.web`), or `pkg::System.app` from another package. It must resolve to an app.* node (ERR_DELIVERY_UNRESOLVED_REF)." + "ref": { + "targetType": "app", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The app deployed: `System.app` (`Parcels.api`), or `pkg::System.app` from another package. It must resolve to an app.* node (ERR_DELIVERY_UNRESOLVED_REF)." }, { - "name": "branch", + "name": "environment", "valueType": "string", "isArray": false, - "required": false, - "description": "The repository branch whose pushes deploy here." + "required": true, + "ref": { + "targetType": "environment", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The environment it is placed in: an environment.* node, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." }, { - "name": "domains", + "name": "locations", "valueType": "string", "isArray": true, - "required": false, - "description": "The public host names that route to the app here." + "required": true, + "ref": { + "targetType": "location", + "targetSubTypes": [ + "region", + "zone" + ], + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "Where it runs: regions or zones, as `Jurisdiction.Region` or `Jurisdiction.Region.zone` (`EU.EuWest`). A region means all of its zones. The order matters when one site leads: under activePassive the first serves. Each must resolve to a location.region or location.zone (ERR_DELIVERY_UNRESOLVED_REF)." }, + { + "name": "mode", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "activeActive", + "activePassive" + ], + "description": "How the sites relate when it spans more than one region: activeActive (every site serves) or activePassive (the first serves, the rest take over). Declared, never guessed: nothing defaults it." + } + ], + "children": [] + }, + { + "type": "deployment", + "subType": "base", + "description": "Abstract deployment base: something placed in an environment. `deployment.system` and `deployment.app` are its kinds; a platform pack may still register a `deployment.` subtype (`extendsBase: true`) until it moves onto them. A deployment names no platform, product, size, count, host name or identifier: those are settings, keyed by the deployment's name. Not authored directly: a `deployment.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "attrs": [ { "name": "environment", "valueType": "string", "isArray": false, "required": true, - "description": "The environment.* node it deploys to, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." + "ref": { + "targetType": "environment", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The environment it is placed in: an environment.* node, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." + } + ], + "children": [] + }, + { + "type": "deployment", + "subType": "system", + "description": "Every app of a system runs in this environment at these locations. The common case: one node per system per environment and site, rather than one per app. The system may be in any package, an imported one included.", + "whenToUse": "Placing a whole system. Write a deployment.app only where one app differs from its system.", + "attrs": [ + { + "name": "environment", + "valueType": "string", + "isArray": false, + "required": true, + "ref": { + "targetType": "environment", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The environment it is placed in: an environment.* node, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." }, { - "name": "region", + "name": "locations", + "valueType": "string", + "isArray": true, + "required": true, + "ref": { + "targetType": "location", + "targetSubTypes": [ + "region", + "zone" + ], + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "Where it runs: regions or zones, as `Jurisdiction.Region` or `Jurisdiction.Region.zone` (`EU.EuWest`). A region means all of its zones. The order matters when one site leads: under activePassive the first serves. Each must resolve to a location.region or location.zone (ERR_DELIVERY_UNRESOLVED_REF)." + }, + { + "name": "mode", "valueType": "string", "isArray": false, "required": false, - "description": "The platform's region name." + "allowedValues": [ + "activeActive", + "activePassive" + ], + "description": "How the sites relate when it spans more than one region: activeActive (every site serves) or activePassive (the first serves, the rest take over). Declared, never guessed: nothing defaults it." }, { - "name": "replicas", - "valueType": "int", + "name": "system", + "valueType": "string", + "isArray": false, + "required": true, + "ref": { + "targetType": "system", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The system deployed: a system.* node, by name (`Parcels`, `quillhaven::parcels::Parcels`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." + } + ], + "children": [] + }, + { + "type": "environment", + "subType": "stage", + "description": "A named environment: Production, Staging, a pull-request preview, a developer's own copy. The one kind of environment. Where it runs, a laptop included, is a setting, never the model.", + "whenToUse": "Every environment a deployment or provision names with @environment.", + "attrs": [ + { + "name": "lifespan", + "valueType": "string", "isArray": false, "required": false, - "description": "How many copies run. Absent means the platform's default." + "allowedValues": [ + "standing", + "ephemeral" + ], + "description": "standing (the default): one long-lived copy. ephemeral: a copy made and thrown away, one per branch or pull request." }, { - "name": "secrets", + "name": "owner", "valueType": "string", "isArray": false, - "required": false, - "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack). Recorded by name only: this pack does not require the config pack." + "required": true, + "ref": { + "targetType": "organization", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "Who operates the environment: an organization node, or a unit of one, by name (`quillhaven::Quillhaven`). It must resolve to an organization (ERR_DELIVERY_UNRESOLVED_REF)." + }, + { + "name": "purpose", + "valueType": "string", + "isArray": false, + "required": true, + "allowedValues": [ + "production", + "staging", + "test", + "development" + ], + "description": "What the environment is for: production, staging, test or development. Settings take defaults by purpose rather than by name, and a rule can say \"never in production\" without comparing names." + } + ], + "children": [] + }, + { + "type": "location", + "subType": "jurisdiction", + "description": "A legal boundary data may be confined to, in the company's own words (`EU`, `US`). Its regions are its children, so a region belongs to exactly one jurisdiction: jurisdictions do not nest (a jurisdiction holds no jurisdiction). Which platform region or building a region is mapped to is a setting, never a node.", + "whenToUse": "Each body of law the estate's data may be confined to. A resource with `@residency: confined` keeps every copy of one provision inside one jurisdiction.", + "attrs": [ + { + "name": "countries", + "valueType": "string", + "isArray": true, + "required": true, + "description": "The countries the jurisdiction covers, as ISO 3166-1 alpha-2 codes (`DE`, `US`): two upper-case letters each (ERR_BAD_ATTR_VALUE otherwise). A settings target mapped to a region of this jurisdiction must lie in one of them." } ], "children": [ { - "childType": "value", - "childSubType": [ - "literal", - "ref" - ], + "childType": "location", + "childSubType": "region", "childName": "*", "min": 0, "max": null @@ -174,34 +307,96 @@ ] }, { - "type": "environment", - "subType": "base", - "description": "Abstract environment base. Not authored directly: an `environment.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "type": "location", + "subType": "region", + "description": "An area far enough from the others that one disaster does not take two, named in the company's own words (`EuWest`). A child of one jurisdiction, addressed `Jurisdiction.Region` (`EU.EuWest`). Naming a region in `@locations` means every zone in it.", + "whenToUse": "Each area the business needs to run in or survive the loss of.", "attrs": [], - "children": [] - }, - { - "type": "environment", - "subType": "ephemeral", - "description": "An environment created for one change and removed after it: a pull-request preview.", - "whenToUse": "Per-branch or per-pull-request previews.", - "attrs": [], - "children": [] + "children": [ + { + "childType": "location", + "childSubType": "zone", + "childName": "*", + "min": 0, + "max": null + } + ] }, { - "type": "environment", - "subType": "local", - "description": "A developer's own machine.", - "whenToUse": "The settings and resources a project needs to run on a workstation.", + "type": "location", + "subType": "zone", + "description": "One failure domain inside a region: a building, a power feed. A child of a region, addressed `Jurisdiction.Region.zone` (`EU.EuWest.a`).", + "whenToUse": "When a deployment or provision must survive the loss of one building, and so names zones rather than a whole region.", "attrs": [], "children": [] }, { - "type": "environment", - "subType": "standing", - "description": "A named environment that stays up: production, staging. Deployments name it with @environment; a settings vault maps its secrets to it by the same name.", - "whenToUse": "Every environment that exists whether or not anyone is working on it.", - "attrs": [], + "type": "provision", + "subType": "resource", + "description": "A resource has copies at these locations in this environment, related this way. Written only for a resource used from more than one region: one used from one region is provisioned there with no node. Names no product, size or replica count: those are settings, keyed by the provision's name.", + "whenToUse": "A resource kept in more than one region, to say how its copies relate.", + "attrs": [ + { + "name": "consistency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "strong", + "eventual" + ], + "description": "With multiWriter: strong (a write is visible everywhere before it is acknowledged) or eventual (the sites converge afterwards)." + }, + { + "name": "environment", + "valueType": "string", + "isArray": false, + "required": true, + "ref": { + "targetType": "environment", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The environment the copies are kept in: an environment.* node, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." + }, + { + "name": "locations", + "valueType": "string", + "isArray": true, + "required": true, + "ref": { + "targetType": "location", + "targetSubTypes": [ + "region", + "zone" + ], + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "Where the copies are kept: regions or zones, as `Jurisdiction.Region` or `Jurisdiction.Region.zone`. The order matters: under standby the first site accepts writes. Each must resolve to a location.region or location.zone (ERR_DELIVERY_UNRESOLVED_REF)." + }, + { + "name": "replication", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "none", + "standby", + "multiWriter" + ], + "description": "How the copies relate: none (each site has its own, nothing moves between them), standby (the first site accepts writes, the others hold a copy and can be promoted) or multiWriter (every site accepts writes). Declared, never guessed: nothing defaults it." + }, + { + "name": "resource", + "valueType": "string", + "isArray": false, + "required": true, + "ref": { + "targetType": "resource", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The resource provisioned: `System.resource` (`Parcels.db`), or `pkg::System.resource` from another package. It must resolve to a resource.* node (ERR_DELIVERY_UNRESOLVED_REF)." + } + ], "children": [] }, { @@ -263,7 +458,7 @@ { "type": "value", "subType": "base", - "description": "Abstract value base: how one setting gets its value in one deployment. A child of a deployment. A secret needs no value node: the setting is marked secret and the deployment names its vault. Not authored directly: a `value.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "description": "Abstract value base: how one setting gets its value in one platform deployment (`deployment.`, which declares value.* children). A `deployment.system` or `deployment.app` holds none: a value that differs per environment is a setting. Kept for the platform packs until they move onto deployment.system and deployment.app. A secret needs no value node: the setting is marked secret. Not authored directly: a `value.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", "attrs": [ { "name": "setting", @@ -402,11 +597,21 @@ }, { "childType": "environment", - "childSubType": [ - "standing", - "ephemeral", - "local" - ], + "childSubType": "stage", + "childName": "*", + "min": 0, + "max": null + }, + { + "childType": "location", + "childSubType": "jurisdiction", + "childName": "*", + "min": 0, + "max": null + }, + { + "childType": "provision", + "childSubType": "resource", "childName": "*", "min": 0, "max": null diff --git a/packs/delivery/metamodel/delivery.json b/packs/delivery/metamodel/delivery.json index ecb29c935..c677e6701 100644 --- a/packs/delivery/metamodel/delivery.json +++ b/packs/delivery/metamodel/delivery.json @@ -2,30 +2,98 @@ "provider": "metaobjects-delivery", "types": [ { - "type": "environment", - "subType": "base", - "description": "Abstract environment base. Not authored directly: an `environment.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + "type": "location", + "subType": "jurisdiction", + "description": "A legal boundary data may be confined to, in the company's own words (`EU`, `US`). Its regions are its children, so a region belongs to exactly one jurisdiction: jurisdictions do not nest (a jurisdiction holds no jurisdiction). Which platform region or building a region is mapped to is a setting, never a node.", + "whenToUse": "Each body of law the estate's data may be confined to. A resource with `@residency: confined` keeps every copy of one provision inside one jurisdiction.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "countries", + "isArray": true, + "min": 1, + "max": 1, + "description": "The countries the jurisdiction covers, as ISO 3166-1 alpha-2 codes (`DE`, `US`): two upper-case letters each (ERR_BAD_ATTR_VALUE otherwise). A settings target mapped to a region of this jurisdiction must lie in one of them." + }, + { + "type": "location", + "subType": "region", + "name": "*", + "min": 0, + "max": null, + "description": "The jurisdiction's regions." + } + ] }, { - "type": "environment", - "subType": "standing", - "extendsBase": true, - "description": "A named environment that stays up: production, staging. Deployments name it with @environment; a settings vault maps its secrets to it by the same name.", - "whenToUse": "Every environment that exists whether or not anyone is working on it." + "type": "location", + "subType": "region", + "description": "An area far enough from the others that one disaster does not take two, named in the company's own words (`EuWest`). A child of one jurisdiction, addressed `Jurisdiction.Region` (`EU.EuWest`). Naming a region in `@locations` means every zone in it.", + "whenToUse": "Each area the business needs to run in or survive the loss of.", + "children": [ + { + "type": "location", + "subType": "zone", + "name": "*", + "min": 0, + "max": null, + "description": "The region's zones." + } + ] }, { - "type": "environment", - "subType": "ephemeral", - "extendsBase": true, - "description": "An environment created for one change and removed after it: a pull-request preview.", - "whenToUse": "Per-branch or per-pull-request previews." + "type": "location", + "subType": "zone", + "description": "One failure domain inside a region: a building, a power feed. A child of a region, addressed `Jurisdiction.Region.zone` (`EU.EuWest.a`).", + "whenToUse": "When a deployment or provision must survive the loss of one building, and so names zones rather than a whole region." }, { "type": "environment", - "subType": "local", - "extendsBase": true, - "description": "A developer's own machine.", - "whenToUse": "The settings and resources a project needs to run on a workstation." + "subType": "stage", + "description": "A named environment: Production, Staging, a pull-request preview, a developer's own copy. The one kind of environment. Where it runs, a laptop included, is a setting, never the model.", + "whenToUse": "Every environment a deployment or provision names with @environment.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "owner", + "min": 1, + "max": 1, + "description": "Who operates the environment: an organization node, or a unit of one, by name (`quillhaven::Quillhaven`). It must resolve to an organization (ERR_DELIVERY_UNRESOLVED_REF).", + "ref": { + "targetType": "organization", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + } + }, + { + "type": "attr", + "subType": "string", + "name": "purpose", + "min": 1, + "max": 1, + "allowedValues": [ + "production", + "staging", + "test", + "development" + ], + "description": "What the environment is for: production, staging, test or development. Settings take defaults by purpose rather than by name, and a rule can say \"never in production\" without comparing names." + }, + { + "type": "attr", + "subType": "string", + "name": "lifespan", + "min": 0, + "max": 1, + "allowedValues": [ + "standing", + "ephemeral" + ], + "default": "standing", + "description": "standing (the default): one long-lived copy. ephemeral: a copy made and thrown away, one per branch or pull request." + } + ] }, { "type": "build", @@ -212,81 +280,200 @@ { "type": "deployment", "subType": "base", - "description": "Abstract deployment base: an app placed in an environment on a platform. A platform pack registers the concrete subtype (`deployment.`), which takes these attributes and adds the platform's own. A deployment holds only what differs per environment; what is true everywhere sits under the app. An estate repository adds deployments the app never declared and overrides the ones it did by overlay. Not authored directly: a `deployment.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "description": "Abstract deployment base: something placed in an environment. `deployment.system` and `deployment.app` are its kinds; a platform pack may still register a `deployment.` subtype (`extendsBase: true`) until it moves onto them. A deployment names no platform, product, size, count, host name or identifier: those are settings, keyed by the deployment's name. Not authored directly: a `deployment.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", "children": [ { "type": "attr", "subType": "string", - "name": "app", + "name": "environment", "min": 1, "max": 1, - "description": "The app deployed: `System.app` (`Shop.web`), or `pkg::System.app` from another package. It must resolve to an app.* node (ERR_DELIVERY_UNRESOLVED_REF)." - }, + "description": "The environment it is placed in: an environment.* node, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF).", + "ref": { + "targetType": "environment", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + } + } + ] + }, + { + "type": "deployment", + "subType": "system", + "extendsBase": true, + "description": "Every app of a system runs in this environment at these locations. The common case: one node per system per environment and site, rather than one per app. The system may be in any package, an imported one included.", + "whenToUse": "Placing a whole system. Write a deployment.app only where one app differs from its system.", + "children": [ { "type": "attr", "subType": "string", - "name": "environment", + "name": "system", "min": 1, "max": 1, - "description": "The environment.* node it deploys to, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." + "description": "The system deployed: a system.* node, by name (`Parcels`, `quillhaven::parcels::Parcels`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF).", + "ref": { + "targetType": "system", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + } }, { "type": "attr", "subType": "string", - "name": "domains", + "name": "locations", "isArray": true, - "min": 0, + "min": 1, "max": 1, - "description": "The public host names that route to the app here." + "description": "Where it runs: regions or zones, as `Jurisdiction.Region` or `Jurisdiction.Region.zone` (`EU.EuWest`). A region means all of its zones. The order matters when one site leads: under activePassive the first serves. Each must resolve to a location.region or location.zone (ERR_DELIVERY_UNRESOLVED_REF).", + "ref": { + "targetType": "location", + "targetSubTypes": [ + "region", + "zone" + ], + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + } }, { "type": "attr", - "subType": "int", - "name": "replicas", + "subType": "string", + "name": "mode", "min": 0, "max": 1, - "description": "How many copies run. Absent means the platform's default." + "allowedValues": [ + "activeActive", + "activePassive" + ], + "description": "How the sites relate when it spans more than one region: activeActive (every site serves) or activePassive (the first serves, the rest take over). Declared, never guessed: nothing defaults it." + } + ] + }, + { + "type": "deployment", + "subType": "app", + "extendsBase": true, + "description": "One app runs in this environment at these locations, where it differs from its system's deployment. In the regions they share, it replaces the system-level deployment for that app.", + "whenToUse": "An app placed apart from the rest of its system: in fewer regions, or in another mode.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "app", + "min": 1, + "max": 1, + "description": "The app deployed: `System.app` (`Parcels.api`), or `pkg::System.app` from another package. It must resolve to an app.* node (ERR_DELIVERY_UNRESOLVED_REF).", + "ref": { + "targetType": "app", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + } }, { "type": "attr", "subType": "string", - "name": "region", - "min": 0, + "name": "locations", + "isArray": true, + "min": 1, "max": 1, - "description": "The platform's region name." + "description": "Where it runs: regions or zones, as `Jurisdiction.Region` or `Jurisdiction.Region.zone` (`EU.EuWest`). A region means all of its zones. The order matters when one site leads: under activePassive the first serves. Each must resolve to a location.region or location.zone (ERR_DELIVERY_UNRESOLVED_REF).", + "ref": { + "targetType": "location", + "targetSubTypes": [ + "region", + "zone" + ], + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + } }, { "type": "attr", "subType": "string", - "name": "branch", + "name": "mode", "min": 0, "max": 1, - "description": "The repository branch whose pushes deploy here." + "allowedValues": [ + "activeActive", + "activePassive" + ], + "description": "How the sites relate when it spans more than one region: activeActive (every site serves) or activePassive (the first serves, the rest take over). Declared, never guessed: nothing defaults it." + } + ] + }, + { + "type": "provision", + "subType": "resource", + "description": "A resource has copies at these locations in this environment, related this way. Written only for a resource used from more than one region: one used from one region is provisioned there with no node. Names no product, size or replica count: those are settings, keyed by the provision's name.", + "whenToUse": "A resource kept in more than one region, to say how its copies relate.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "resource", + "min": 1, + "max": 1, + "description": "The resource provisioned: `System.resource` (`Parcels.db`), or `pkg::System.resource` from another package. It must resolve to a resource.* node (ERR_DELIVERY_UNRESOLVED_REF).", + "ref": { + "targetType": "resource", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + } }, { "type": "attr", "subType": "string", - "name": "secrets", - "min": 0, + "name": "environment", + "min": 1, "max": 1, - "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack). Recorded by name only: this pack does not require the config pack." + "description": "The environment the copies are kept in: an environment.* node, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF).", + "ref": { + "targetType": "environment", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + } }, { - "type": "value", - "subType": [ - "literal", - "ref" + "type": "attr", + "subType": "string", + "name": "locations", + "isArray": true, + "min": 1, + "max": 1, + "description": "Where the copies are kept: regions or zones, as `Jurisdiction.Region` or `Jurisdiction.Region.zone`. The order matters: under standby the first site accepts writes. Each must resolve to a location.region or location.zone (ERR_DELIVERY_UNRESOLVED_REF).", + "ref": { + "targetType": "location", + "targetSubTypes": [ + "region", + "zone" + ], + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + } + }, + { + "type": "attr", + "subType": "string", + "name": "replication", + "min": 0, + "max": 1, + "allowedValues": [ + "none", + "standby", + "multiWriter" ], - "name": "*", + "description": "How the copies relate: none (each site has its own, nothing moves between them), standby (the first site accepts writes, the others hold a copy and can be promoted) or multiWriter (every site accepts writes). Declared, never guessed: nothing defaults it." + }, + { + "type": "attr", + "subType": "string", + "name": "consistency", "min": 0, - "max": null + "max": 1, + "allowedValues": [ + "strong", + "eventual" + ], + "description": "With multiWriter: strong (a write is visible everywhere before it is acknowledged) or eventual (the sites converge afterwards)." } ] }, { "type": "value", "subType": "base", - "description": "Abstract value base: how one setting gets its value in one deployment. A child of a deployment. A secret needs no value node: the setting is marked secret and the deployment names its vault. Not authored directly: a `value.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "description": "Abstract value base: how one setting gets its value in one platform deployment (`deployment.`, which declares value.* children). A `deployment.system` or `deployment.app` holds none: a value that differs per environment is a setting. Kept for the platform packs until they move onto deployment.system and deployment.app. A secret needs no value node: the setting is marked secret. Not authored directly: a `value.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", "children": [ { "type": "attr", @@ -363,13 +550,16 @@ "type": "metadata", "subType": "root", "children": [ + { + "type": "location", + "subType": "jurisdiction", + "name": "*", + "min": 0, + "max": null + }, { "type": "environment", - "subType": [ - "standing", - "ephemeral", - "local" - ], + "subType": "stage", "name": "*", "min": 0, "max": null @@ -380,6 +570,13 @@ "name": "*", "min": 0, "max": null + }, + { + "type": "provision", + "subType": "resource", + "name": "*", + "min": 0, + "max": null } ] }, diff --git a/packs/delivery/typescript/src/constants.ts b/packs/delivery/typescript/src/constants.ts index 20da13be7..6355d7aa2 100644 --- a/packs/delivery/typescript/src/constants.ts +++ b/packs/delivery/typescript/src/constants.ts @@ -3,10 +3,25 @@ export const DELIVERY_PROVIDER_ID = "metaobjects-delivery"; +/** Where things may run, in the company's own words: a jurisdiction holds regions, a region zones. */ +export const TYPE_LOCATION = "location"; +export const LOCATION_SUBTYPE_JURISDICTION = "jurisdiction"; +export const LOCATION_SUBTYPE_REGION = "region"; +export const LOCATION_SUBTYPE_ZONE = "zone"; +export const LOCATION_ATTR_COUNTRIES = "countries"; +/** An ISO 3166-1 alpha-2 country code: two upper-case letters. */ +export const COUNTRY_CODE_PATTERN = /^[A-Z]{2}$/; + +/** The one kind of environment. */ export const TYPE_ENVIRONMENT = "environment"; -export const ENVIRONMENT_SUBTYPE_STANDING = "standing"; -export const ENVIRONMENT_SUBTYPE_EPHEMERAL = "ephemeral"; -export const ENVIRONMENT_SUBTYPE_LOCAL = "local"; +export const ENVIRONMENT_SUBTYPE_STAGE = "stage"; +export const ENVIRONMENT_ATTR_OWNER = "owner"; +export const ENVIRONMENT_ATTR_PURPOSE = "purpose"; +export const ENVIRONMENT_ATTR_LIFESPAN = "lifespan"; +export const PURPOSES = ["production", "staging", "test", "development"] as const; +export type Purpose = (typeof PURPOSES)[number]; +export const LIFESPANS = ["standing", "ephemeral"] as const; +export type Lifespan = (typeof LIFESPANS)[number]; export const TYPE_BUILD = "build"; export const BUILD_SUBTYPE_DOCKERFILE = "dockerfile"; @@ -31,15 +46,31 @@ export const RESTART_ALWAYS = "always"; export const RESTART_ON_FAILURE = "onFailure"; export const RESTART_NEVER = "never"; -/** A platform pack registers the concrete `deployment.` subtype. */ +/** deployment.system and deployment.app; a platform pack may still register `deployment.`. */ export const TYPE_DEPLOYMENT = "deployment"; +export const DEPLOYMENT_SUBTYPE_BASE = "base"; +export const DEPLOYMENT_SUBTYPE_SYSTEM = "system"; +export const DEPLOYMENT_SUBTYPE_APP = "app"; +export const DEPLOYMENT_ATTR_SYSTEM = "system"; export const DEPLOYMENT_ATTR_APP = "app"; export const DEPLOYMENT_ATTR_ENVIRONMENT = "environment"; -export const DEPLOYMENT_ATTR_DOMAINS = "domains"; -export const DEPLOYMENT_ATTR_REPLICAS = "replicas"; -export const DEPLOYMENT_ATTR_REGION = "region"; -export const DEPLOYMENT_ATTR_BRANCH = "branch"; -export const DEPLOYMENT_ATTR_SECRETS = "secrets"; +export const DEPLOYMENT_ATTR_LOCATIONS = "locations"; +export const DEPLOYMENT_ATTR_MODE = "mode"; +export const MODES = ["activeActive", "activePassive"] as const; +export type Mode = (typeof MODES)[number]; + +/** How a resource's copies in more than one region relate. */ +export const TYPE_PROVISION = "provision"; +export const PROVISION_SUBTYPE_RESOURCE = "resource"; +export const PROVISION_ATTR_RESOURCE = "resource"; +export const PROVISION_ATTR_ENVIRONMENT = "environment"; +export const PROVISION_ATTR_LOCATIONS = "locations"; +export const PROVISION_ATTR_REPLICATION = "replication"; +export const PROVISION_ATTR_CONSISTENCY = "consistency"; +export const REPLICATIONS = ["none", "standby", "multiWriter"] as const; +export type Replication = (typeof REPLICATIONS)[number]; +export const CONSISTENCIES = ["strong", "eventual"] as const; +export type Consistency = (typeof CONSISTENCIES)[number]; export const TYPE_VALUE = "value"; export const VALUE_SUBTYPE_LITERAL = "literal"; @@ -57,13 +88,13 @@ export const OUTPUT_PORT = "port"; export const OUTPUT_PRIVATE_URL = "privateUrl"; export const OUTPUT_PUBLIC_URL = "publicUrl"; -/** Raised when a deployment's @app / @environment or a value.ref's @producedBy names nothing, or the wrong kind of node. */ +/** Raised when a reference of this pack names nothing, or the wrong kind of node: a deployment's @system, @app, @environment or @locations, a provision's @resource, @environment or @locations, an environment's @owner, or a value.ref's @producedBy. */ export const ERR_DELIVERY_UNRESOLVED_REF = "ERR_DELIVERY_UNRESOLVED_REF"; /** Raised when a deployment holds two values for one @setting. */ export const ERR_DELIVERY_DUPLICATE_SETTING = "ERR_DELIVERY_DUPLICATE_SETTING"; -/** Raised when two deployments target the same (@app, @environment). */ +/** Raised when two platform deployments (`deployment.`) target the same (@app, @environment). */ export const ERR_DELIVERY_DUPLICATE_DEPLOYMENT = "ERR_DELIVERY_DUPLICATE_DEPLOYMENT"; /** Raised when a value.ref asks its producer for an output it does not have: `@path` on an output that is not a URL, or an app asked for its url, user or password, or for its port with none declared. */ diff --git a/packs/delivery/typescript/src/index.ts b/packs/delivery/typescript/src/index.ts index bbb8ef810..a6933d11b 100644 --- a/packs/delivery/typescript/src/index.ts +++ b/packs/delivery/typescript/src/index.ts @@ -1,12 +1,15 @@ -// @metaobjectsdev/pack-delivery: what runs where, and what differs per environment -// (ADR-0069 independent pack). The vocabulary is metamodel/delivery.json; this module -// registers it and checks the references the data cannot: a deployment's @app and -// @environment, and a value.ref's @producedBy. +// @metaobjectsdev/pack-delivery: where systems and apps run (ADR-0069 independent pack, +// ADR-0070 estate vocabulary). The vocabulary is metamodel/delivery.json: locations +// (jurisdiction, region, zone), environment.stage, deployment.system and deployment.app, +// provision.resource, and the per-app build.* and runtime.process. Its references to +// organizations, systems, apps, resources, environments and locations are declared with +// the reference facet, so the loader resolves them; this module checks what the data +// cannot say: country codes, and a platform deployment's @app and uniqueness. // -// The pack registers `deployment.base` and no concrete deployment: the platform is the -// subtype, and a platform pack registers it (`deployment.`, `extendsBase: true`). -// Such a pack passes `validateDeployment` as that subtype's validator, so its -// deployments are held to the same references. +// A platform pack may still register a `deployment.` subtype (`extendsBase: +// true`) that declares its own platform attributes, and passes `validateDeployment` as +// its validator; ADR-0070 retires those subtypes in favour of deployment.system and +// deployment.app with the platform as a setting. import { applyProviderDefinition, @@ -30,9 +33,14 @@ import { ERR_DELIVERY_DUPLICATE_SETTING, ERR_DELIVERY_UNRESOLVED_REF, ERR_DELIVERY_UNSUPPORTED_OUTPUT, + COUNTRY_CODE_PATTERN, + DEPLOYMENT_SUBTYPE_BASE, + LOCATION_ATTR_COUNTRIES, + LOCATION_SUBTYPE_JURISDICTION, PORT_OUTPUTS, TYPE_DEPLOYMENT, TYPE_ENVIRONMENT, + TYPE_LOCATION, TYPE_VALUE, URL_OUTPUTS, VALUE_ATTR_OUTPUT, @@ -82,21 +90,37 @@ function checkDeploymentUnique(node: MetaData, ctx: ValidationContext): void { } } -/** The validator a platform pack attaches to its `deployment.` subtype. */ +/** + * The validator a platform pack attaches to its `deployment.` subtype: the @app it + * declares itself, and one deployment per (@app, @environment). @environment is + * deployment.base's, and the loader resolves it through the reference facet. + */ export const validateDeployment: NodeValidator = (node, ctx) => { checkRefs(node, DEPLOYMENT_ATTR_APP, [TYPE_APP], ERR_DELIVERY_UNRESOLVED_REF, ctx); - checkRefs(node, DEPLOYMENT_ATTR_ENVIRONMENT, [TYPE_ENVIRONMENT], ERR_DELIVERY_UNRESOLVED_REF, ctx); checkDeploymentUnique(node, ctx); }; -// `deployment.base` is abstract, but the parser treats a `.base` as abstract only -// once a concrete sibling is registered, and none is until a platform pack is composed. -// Refuse it here too, with the parser's code, so it never loads either way. +// A jurisdiction's countries are ISO 3166-1 alpha-2 codes, which a settings target's country +// is compared against; a misspelt one would match nothing. +const validateJurisdiction: NodeValidator = (node, ctx) => { + for (const c of refList(node, LOCATION_ATTR_COUNTRIES)) { + if (!COUNTRY_CODE_PATTERN.test(c)) { + ctx.error( + "ERR_BAD_ATTR_VALUE", + node, + `location.jurisdiction "${node.name}" @${LOCATION_ATTR_COUNTRIES} "${c}" is not an ISO 3166-1 alpha-2 code (two upper-case letters, such as DE or US).`, + ); + } + } +}; + +// `deployment.base` is abstract. Refuse it here too, with the parser's code, so it never +// loads whichever concrete siblings are registered. const refuseAbstractDeployment: NodeValidator = (node, ctx) => { ctx.error( "ERR_ABSTRACT_SUBTYPE_AUTHORED", node, - `deployment.base "${node.name}" is abstract: declare the platform's own subtype (deployment.), which a platform pack registers.`, + `deployment.base "${node.name}" is abstract: declare a deployment.system or a deployment.app.`, ); }; @@ -145,11 +169,12 @@ export const provider: MetaDataTypeProvider = { id: DELIVERY_PROVIDER_ID, dependencies: ["metaobjects-core-types", SYSTEMS_PROVIDER_ID], description: - "Delivery: environment.*, build.*, runtime.process, deployment.base (a platform pack adds the concrete subtype) and value.literal / value.ref.", + "Delivery: location.jurisdiction / .region / .zone, environment.stage, deployment.system / .app, provision.resource, build.*, runtime.process, and value.literal / value.ref for the platform deployments.", registerTypes(registry: TypeRegistry): void { const { factories, validators } = packTypeMaps(DELIVERY_DEFINITION, { [TYPE_VALUE]: validateValue, - [TYPE_DEPLOYMENT]: refuseAbstractDeployment, + [`${TYPE_DEPLOYMENT}.${DEPLOYMENT_SUBTYPE_BASE}`]: refuseAbstractDeployment, + [`${TYPE_LOCATION}.${LOCATION_SUBTYPE_JURISDICTION}`]: validateJurisdiction, }); applyProviderDefinition(registry, DELIVERY_DEFINITION, factories, validators); }, diff --git a/packs/railway/CHANGELOG.md b/packs/railway/CHANGELOG.md index 6ba125f43..c62c8533f 100644 --- a/packs/railway/CHANGELOG.md +++ b/packs/railway/CHANGELOG.md @@ -4,6 +4,11 @@ This pack's own changelog (ADR-0069). The root `CHANGELOG.md` records core only. ## [0.1.0] - unreleased +- `deployment.railway` declare `@app`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets` and + their `value.*` children themselves: the delivery pack's `deployment.base` now holds only + `@environment`, which the loader resolves through the reference facet. Environments are the + delivery pack's `environment.stage` (`@owner`, `@purpose`, `@lifespan`); the fixtures and + tests declare an `organization.company` to own them. No generated file changes. - **First version.** `deployment.railway` (`@project`, `@service`) on the delivery pack's `deployment.base`, held to its references. The worked example (an app's model plus an estate repository's additions and overlay) is the `railway-worked-example` fixture. TypeScript port. diff --git a/packs/railway/README.md b/packs/railway/README.md index f721eda74..b5d929582 100644 --- a/packs/railway/README.md +++ b/packs/railway/README.md @@ -15,10 +15,13 @@ them. | Node | Attributes | |---|---| -| `deployment.railway` | every `deployment.base` attribute (`@app`, `@environment`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets`, and `value.*` children), plus `@project` (required), `@service` (absent: the app's name), `@repo` (GitHub `owner/name`) or `@image` (a container image), and `@checkSuites` (whether a deploy waits for GitHub check suites; absent leaves Railway's setting alone) | +| `deployment.railway` | `@environment` (from `deployment.base`), its own `@app`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets` and `value.*` children, plus `@project` (required), `@service` (absent: the app's name), `@repo` (GitHub `owner/name`) or `@image` (a container image), and `@checkSuites` (whether a deploy waits for GitHub check suites; absent leaves Railway's setting alone) | A `deployment.railway` is held to the delivery pack's references: `@app` must name an `app.*`, -`@environment` an `environment.*` (`ERR_DELIVERY_UNRESOLVED_REF`). +`@environment` an `environment.stage` (`ERR_DELIVERY_UNRESOLVED_REF`). It is a platform-named +subtype carrying platform facts, which ADR-0070 retires in favour of the delivery pack's +`deployment.system` and `deployment.app` with the platform as a setting; until this pack moves +onto them it declares those attributes itself. ## Generators diff --git a/packs/railway/fixtures/conformance/abstract-deployment-with-environment/expected.json b/packs/railway/fixtures/conformance/abstract-deployment-with-environment/expected.json index 645961a0b..2285ee1ec 100644 --- a/packs/railway/fixtures/conformance/abstract-deployment-with-environment/expected.json +++ b/packs/railway/fixtures/conformance/abstract-deployment-with-environment/expected.json @@ -22,8 +22,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "acme::shop::Acme", + "@purpose": "production" } }, { @@ -31,7 +33,7 @@ "name": "server-base", "abstract": true, "@app": "Shop.server", - "@environment": "production", + "@environment": "acme::shop::production", "@project": "acme-shop", "@repo": "acme/shop" } @@ -42,6 +44,11 @@ "extends": "acme::shop::server-base", "@branch": "main" } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/abstract-deployment-with-environment/input/meta.shop.json b/packs/railway/fixtures/conformance/abstract-deployment-with-environment/input/meta.shop.json index a200df983..53068edd2 100644 --- a/packs/railway/fixtures/conformance/abstract-deployment-with-environment/input/meta.shop.json +++ b/packs/railway/fixtures/conformance/abstract-deployment-with-environment/input/meta.shop.json @@ -8,7 +8,7 @@ { "app.service": { "name": "server", "children": [ { "runtime.process": { "name": "web" } } ] } } ] } }, - { "environment.standing": { "name": "production" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, { "deployment.railway": { "name": "server-base", "abstract": true, @@ -21,7 +21,8 @@ "name": "server-production", "extends": "server-base", "@branch": "main" - } } + } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/railway/fixtures/conformance/error-deployment-missing-app/input/meta.shop.json b/packs/railway/fixtures/conformance/error-deployment-missing-app/input/meta.shop.json index a3f246b3e..b7e8c8bcb 100644 --- a/packs/railway/fixtures/conformance/error-deployment-missing-app/input/meta.shop.json +++ b/packs/railway/fixtures/conformance/error-deployment-missing-app/input/meta.shop.json @@ -32,8 +32,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "Acme", + "@purpose": "production" } }, { @@ -42,6 +44,11 @@ "@environment": "production", "@project": "shop" } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/error-deployment-refs/input/meta.shop.json b/packs/railway/fixtures/conformance/error-deployment-refs/input/meta.shop.json index 9a3292e5b..c51cfec2e 100644 --- a/packs/railway/fixtures/conformance/error-deployment-refs/input/meta.shop.json +++ b/packs/railway/fixtures/conformance/error-deployment-refs/input/meta.shop.json @@ -32,8 +32,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "Acme", + "@purpose": "production" } }, { @@ -43,6 +45,11 @@ "@environment": "prod", "@project": "shop" } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/error-duplicate-deployment/input/meta.shop.json b/packs/railway/fixtures/conformance/error-duplicate-deployment/input/meta.shop.json index c55ef8a9a..31ce9a44f 100644 --- a/packs/railway/fixtures/conformance/error-duplicate-deployment/input/meta.shop.json +++ b/packs/railway/fixtures/conformance/error-duplicate-deployment/input/meta.shop.json @@ -21,8 +21,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "Acme", + "@purpose": "production" } }, { @@ -40,6 +42,11 @@ "@environment": "production", "@project": "shop" } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/error-duplicate-setting/input/meta.shop.json b/packs/railway/fixtures/conformance/error-duplicate-setting/input/meta.shop.json index 75bdf93a4..554fb976a 100644 --- a/packs/railway/fixtures/conformance/error-duplicate-setting/input/meta.shop.json +++ b/packs/railway/fixtures/conformance/error-duplicate-setting/input/meta.shop.json @@ -21,8 +21,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "Acme", + "@purpose": "production" } }, { @@ -48,6 +50,11 @@ } ] } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/error-value-ref-bare-producedby-and-bad-output/input/meta.shop.json b/packs/railway/fixtures/conformance/error-value-ref-bare-producedby-and-bad-output/input/meta.shop.json index a6d7a2036..2f52f182c 100644 --- a/packs/railway/fixtures/conformance/error-value-ref-bare-producedby-and-bad-output/input/meta.shop.json +++ b/packs/railway/fixtures/conformance/error-value-ref-bare-producedby-and-bad-output/input/meta.shop.json @@ -20,8 +20,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "Acme", + "@purpose": "production" } }, { @@ -41,6 +43,11 @@ } ] } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/error-value-ref-unresolved/input/meta.shop.json b/packs/railway/fixtures/conformance/error-value-ref-unresolved/input/meta.shop.json index b3c365411..c36415e72 100644 --- a/packs/railway/fixtures/conformance/error-value-ref-unresolved/input/meta.shop.json +++ b/packs/railway/fixtures/conformance/error-value-ref-unresolved/input/meta.shop.json @@ -32,8 +32,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "Acme", + "@purpose": "production" } }, { @@ -61,6 +63,11 @@ } ] } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/error-value-ref-unsupported-output/input/meta.shop.json b/packs/railway/fixtures/conformance/error-value-ref-unsupported-output/input/meta.shop.json index 92ebb9555..a9dff6ec4 100644 --- a/packs/railway/fixtures/conformance/error-value-ref-unsupported-output/input/meta.shop.json +++ b/packs/railway/fixtures/conformance/error-value-ref-unsupported-output/input/meta.shop.json @@ -7,7 +7,7 @@ { "app.service": { "name": "api", "children": [ { "runtime.process": { "name": "main" } } ] } }, { "resource.database": { "name": "db", "@engine": "postgres" } } ] } }, - { "environment.standing": { "name": "production" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, { "deployment.railway": { "name": "web-production", "@app": "Shop.web", @@ -19,7 +19,8 @@ { "value.ref": { "name": "apiPrivate", "@setting": "Api.privateUrl", "@producedBy": "Shop.api", "@output": "privateUrl" } }, { "value.ref": { "name": "apiHost", "@setting": "Api.host", "@producedBy": "Shop.api", "@output": "host" } } ] - } } + } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/railway/fixtures/conformance/railway-emit-environments/expected.json b/packs/railway/fixtures/conformance/railway-emit-environments/expected.json index 9dda602ad..a0df2be91 100644 --- a/packs/railway/fixtures/conformance/railway-emit-environments/expected.json +++ b/packs/railway/fixtures/conformance/railway-emit-environments/expected.json @@ -56,13 +56,17 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "acme::shop::Acme", + "@purpose": "production" } }, { - "environment.standing": { - "name": "staging" + "environment.stage": { + "name": "staging", + "@owner": "acme::shop::Acme", + "@purpose": "staging" } }, { @@ -92,7 +96,7 @@ "@domains": [ "shop.example.com" ], - "@environment": "production", + "@environment": "acme::shop::production", "@replicas": 2, "children": [ { @@ -113,7 +117,7 @@ "@domains": [ "staging.shop.example.com" ], - "@environment": "staging", + "@environment": "acme::shop::staging", "children": [ { "value.literal": { @@ -131,6 +135,11 @@ } ] } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/railway-emit-environments/input/meta.shop.json b/packs/railway/fixtures/conformance/railway-emit-environments/input/meta.shop.json index fad50b454..2fb426fb4 100644 --- a/packs/railway/fixtures/conformance/railway-emit-environments/input/meta.shop.json +++ b/packs/railway/fixtures/conformance/railway-emit-environments/input/meta.shop.json @@ -28,8 +28,8 @@ { "field.string": { "name": "logLevel", "@envName": "LOG_LEVEL" } }, { "field.string": { "name": "banner", "@envName": "BANNER" } } ]}}, - { "environment.standing": { "name": "production" } }, - { "environment.standing": { "name": "staging" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, + { "environment.stage": { "name": "staging", "@owner": "Acme", "@purpose": "staging" } }, { "deployment.railway": { "name": "server-base", "abstract": true, @@ -62,7 +62,8 @@ { "value.literal": { "name": "log", "@setting": "Runtime.logLevel", "@literal": "debug" } }, { "value.literal": { "name": "banner", "@setting": "Runtime.banner", "@literal": "staging" } } ] - } } + } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/railway/fixtures/conformance/railway-emit-one-service/expected.json b/packs/railway/fixtures/conformance/railway-emit-one-service/expected.json index bc6b07f5d..9f192bf47 100644 --- a/packs/railway/fixtures/conformance/railway-emit-one-service/expected.json +++ b/packs/railway/fixtures/conformance/railway-emit-one-service/expected.json @@ -133,8 +133,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "acme::game::Acme", + "@purpose": "production" } }, { @@ -143,12 +145,17 @@ "@app": "Game.server", "@branch": "main", "@checkSuites": false, - "@environment": "production", + "@environment": "acme::game::production", "@project": "game", "@repo": "acme/game", "@secrets": "keys", "@service": "game" } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/railway-emit-one-service/input/meta.game.json b/packs/railway/fixtures/conformance/railway-emit-one-service/input/meta.game.json index 0cbba2d17..ec9b4722e 100644 --- a/packs/railway/fixtures/conformance/railway-emit-one-service/input/meta.game.json +++ b/packs/railway/fixtures/conformance/railway-emit-one-service/input/meta.game.json @@ -42,7 +42,7 @@ { "vault.infisical": { "name": "keys", "children": [ { "scope.env": { "name": "production", "@project": "acme-game", "@env": "prod" } } ]}}, - { "environment.standing": { "name": "production" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, { "deployment.railway": { "name": "server-production", "@app": "Game.server", @@ -53,7 +53,8 @@ "@branch": "main", "@checkSuites": false, "@secrets": "keys" - } } + } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/railway/fixtures/conformance/railway-emit-two-services/expected.json b/packs/railway/fixtures/conformance/railway-emit-two-services/expected.json index 21191a3f1..8ee9f2f21 100644 --- a/packs/railway/fixtures/conformance/railway-emit-two-services/expected.json +++ b/packs/railway/fixtures/conformance/railway-emit-two-services/expected.json @@ -224,8 +224,10 @@ } }, { - "environment.standing": { - "name": "production" + "environment.stage": { + "name": "production", + "@owner": "acme::tables::Acme", + "@purpose": "production" } }, { @@ -236,7 +238,7 @@ "@domains": [ "example.com" ], - "@environment": "production", + "@environment": "acme::tables::production", "@project": "acme-prod", "@repo": "acme/tables", "@secrets": "keys", @@ -292,7 +294,7 @@ "@domains": [ "admin.example.com" ], - "@environment": "production", + "@environment": "acme::tables::production", "@project": "acme-prod", "@repo": "acme/tables", "children": [ @@ -306,6 +308,11 @@ } ] } + }, + { + "organization.company": { + "name": "Acme" + } } ] } diff --git a/packs/railway/fixtures/conformance/railway-emit-two-services/input/meta.tables.json b/packs/railway/fixtures/conformance/railway-emit-two-services/input/meta.tables.json index 2326e4503..7f8988065 100644 --- a/packs/railway/fixtures/conformance/railway-emit-two-services/input/meta.tables.json +++ b/packs/railway/fixtures/conformance/railway-emit-two-services/input/meta.tables.json @@ -65,7 +65,7 @@ { "vault.infisical": { "name": "keys", "children": [ { "scope.env": { "name": "production", "@project": "acme-tables", "@env": "prod" } } ]}}, - { "environment.standing": { "name": "production" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, { "deployment.railway": { "name": "arena-production", "@app": "Tables.arena", @@ -94,7 +94,8 @@ "children": [ { "value.ref": { "name": "db", "@setting": "Database.url", "@producedBy": "Tables.Postgres", "@output": "url" } } ] - } } + } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/railway/fixtures/conformance/railway-worked-example/expected.json b/packs/railway/fixtures/conformance/railway-worked-example/expected.json index b71900103..4e2beeb6a 100644 --- a/packs/railway/fixtures/conformance/railway-worked-example/expected.json +++ b/packs/railway/fixtures/conformance/railway-worked-example/expected.json @@ -87,9 +87,11 @@ } }, { - "environment.standing": { + "environment.stage": { "name": "production", - "package": "acme::game" + "package": "acme::game", + "@owner": "acme::game::Acme", + "@purpose": "production" } }, { @@ -102,7 +104,7 @@ "app.example.com", "play.example.com" ], - "@environment": "production", + "@environment": "acme::game::production", "@notes": "The estate overrides what differs: two replicas in production.", "@project": "game", "@replicas": 2, @@ -128,9 +130,17 @@ } }, { - "environment.standing": { + "organization.company": { + "name": "Acme", + "package": "acme::game" + } + }, + { + "environment.stage": { "name": "staging", - "package": "acme::estate" + "package": "acme::estate", + "@owner": "acme::estate::Acme", + "@purpose": "staging" } }, { @@ -142,10 +152,16 @@ "@domains": [ "staging.example.com" ], - "@environment": "staging", + "@environment": "acme::estate::staging", "@project": "game", "@service": "game" } + }, + { + "organization.company": { + "name": "Acme", + "package": "acme::estate" + } } ] } diff --git a/packs/railway/fixtures/conformance/railway-worked-example/input/meta.app-system.json b/packs/railway/fixtures/conformance/railway-worked-example/input/meta.app-system.json index eb202b433..98851257e 100644 --- a/packs/railway/fixtures/conformance/railway-worked-example/input/meta.app-system.json +++ b/packs/railway/fixtures/conformance/railway-worked-example/input/meta.app-system.json @@ -34,7 +34,7 @@ { "system.external": { "name": "Payments" } } ] } }, - { "environment.standing": { "name": "production" } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, { "deployment.railway": { "name": "server-production", "@app": "Game.server", @@ -48,7 +48,8 @@ { "value.ref": { "name": "dbUrl", "@setting": "Database.url", "@producedBy": "Game.db", "@output": "url" } }, { "value.literal": { "name": "profile", "@setting": "Spring.profile", "@literal": "prod" } } ] - } } + } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/railway/fixtures/conformance/railway-worked-example/input/meta.estate.json b/packs/railway/fixtures/conformance/railway-worked-example/input/meta.estate.json index fe1635d38..22db2ad28 100644 --- a/packs/railway/fixtures/conformance/railway-worked-example/input/meta.estate.json +++ b/packs/railway/fixtures/conformance/railway-worked-example/input/meta.estate.json @@ -2,7 +2,7 @@ "metadata.root": { "package": "acme::estate", "children": [ - { "environment.standing": { "name": "staging" } }, + { "environment.stage": { "name": "staging", "@owner": "Acme", "@purpose": "staging" } }, { "deployment.railway": { "name": "server-staging", "@description": "A deployment the app's own model never declared.", @@ -11,7 +11,8 @@ "@project": "game", "@service": "game", "@domains": ["staging.example.com"] - } } + } }, + { "organization.company": { "name": "Acme" } } ] } } diff --git a/packs/railway/fixtures/expected-vocabulary.json b/packs/railway/fixtures/expected-vocabulary.json index 8ec472323..d4507891a 100644 --- a/packs/railway/fixtures/expected-vocabulary.json +++ b/packs/railway/fixtures/expected-vocabulary.json @@ -4,7 +4,7 @@ { "type": "deployment", "subType": "railway", - "description": "An app deployed as one Railway service in one Railway environment. Takes every deployment.base attribute (@app, @environment, @domains, @replicas, @region, @branch, @secrets, and value.* children) and adds where it lives on Railway.", + "description": "An app deployed as one Railway service in one Railway environment. Takes deployment.base's @environment and declares the rest itself: @app, @domains, @replicas, @region, @branch, @secrets, value.* children, and where it lives on Railway. A platform-named subtype carrying platform facts, kept until this pack moves onto deployment.system and deployment.app (ADR-0070).", "whenToUse": "Each (app, environment) pair that runs on Railway.", "attrs": [ { @@ -40,7 +40,11 @@ "valueType": "string", "isArray": false, "required": true, - "description": "The environment.* node it deploys to, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." + "ref": { + "targetType": "environment", + "errorCode": "ERR_DELIVERY_UNRESOLVED_REF" + }, + "description": "The environment it is placed in: an environment.* node, by name (or `pkg::name`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." }, { "name": "image", @@ -82,7 +86,7 @@ "valueType": "string", "isArray": false, "required": false, - "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack). Recorded by name only: this pack does not require the config pack." + "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack)." }, { "name": "service", diff --git a/packs/railway/metamodel/railway.json b/packs/railway/metamodel/railway.json index a7e871cac..a376ad650 100644 --- a/packs/railway/metamodel/railway.json +++ b/packs/railway/metamodel/railway.json @@ -5,9 +5,16 @@ "type": "deployment", "subType": "railway", "extendsBase": true, - "description": "An app deployed as one Railway service in one Railway environment. Takes every deployment.base attribute (@app, @environment, @domains, @replicas, @region, @branch, @secrets, and value.* children) and adds where it lives on Railway.", + "description": "An app deployed as one Railway service in one Railway environment. Takes deployment.base's @environment and declares the rest itself: @app, @domains, @replicas, @region, @branch, @secrets, value.* children, and where it lives on Railway. A platform-named subtype carrying platform facts, kept until this pack moves onto deployment.system and deployment.app (ADR-0070).", "whenToUse": "Each (app, environment) pair that runs on Railway.", "children": [ + { "type": "attr", "subType": "string", "name": "app", "min": 1, "max": 1, "description": "The app deployed: `System.app` (`Shop.web`), or `pkg::System.app` from another package. It must resolve to an app.* node (ERR_DELIVERY_UNRESOLVED_REF)." }, + { "type": "attr", "subType": "string", "name": "domains", "isArray": true, "min": 0, "max": 1, "description": "The public host names that route to the app here." }, + { "type": "attr", "subType": "int", "name": "replicas", "min": 0, "max": 1, "description": "How many copies run. Absent means the platform's default." }, + { "type": "attr", "subType": "string", "name": "region", "min": 0, "max": 1, "description": "The platform's region name." }, + { "type": "attr", "subType": "string", "name": "branch", "min": 0, "max": 1, "description": "The repository branch whose pushes deploy here." }, + { "type": "attr", "subType": "string", "name": "secrets", "min": 0, "max": 1, "description": "The vault the deployment's secret settings come from, by name (a vault.* of the config pack)." }, + { "type": "value", "subType": ["literal", "ref"], "name": "*", "min": 0, "max": null }, { "type": "attr", "subType": "string", "name": "project", "min": 1, "max": 1, "description": "The Railway project's name." }, { "type": "attr", "subType": "string", "name": "service", "min": 0, "max": 1, "description": "The Railway service's name. Absent means the app's name." }, { "type": "attr", "subType": "string", "name": "repo", "min": 0, "max": 1, "description": "The GitHub repository Railway builds the service from, as `owner/name`. A deployment names a @repo or an @image: the generated file must declare the source, because a plan of a service with none disconnects it." }, diff --git a/packs/railway/typescript/src/constants.ts b/packs/railway/typescript/src/constants.ts index 02b3ab971..abcba9413 100644 --- a/packs/railway/typescript/src/constants.ts +++ b/packs/railway/typescript/src/constants.ts @@ -11,6 +11,16 @@ export const RAILWAY_ATTR_REPO = "repo"; export const RAILWAY_ATTR_IMAGE = "image"; export const RAILWAY_ATTR_CHECK_SUITES = "checkSuites"; +// The platform attributes of this pack's deployment subtypes. The delivery pack registered +// them on deployment.base until its estate vocabulary (deployment.system, deployment.app) +// replaced them; a platform-named deployment declares them itself until this pack moves +// onto that vocabulary (ADR-0070). +export const DEPLOYMENT_ATTR_DOMAINS = "domains"; +export const DEPLOYMENT_ATTR_REPLICAS = "replicas"; +export const DEPLOYMENT_ATTR_REGION = "region"; +export const DEPLOYMENT_ATTR_BRANCH = "branch"; +export const DEPLOYMENT_ATTR_SECRETS = "secrets"; + /** The `railway` npm package version the generated file and scripts were written against. */ export const RAILWAY_SDK_VERSION = "3.17.0"; diff --git a/packs/railway/typescript/src/model.ts b/packs/railway/typescript/src/model.ts index 3e4cf88fc..1cd59b147 100644 --- a/packs/railway/typescript/src/model.ts +++ b/packs/railway/typescript/src/model.ts @@ -24,12 +24,7 @@ import { } from "@metaobjectsdev/pack-config"; import { DEPLOYMENT_ATTR_APP, - DEPLOYMENT_ATTR_BRANCH, - DEPLOYMENT_ATTR_DOMAINS, DEPLOYMENT_ATTR_ENVIRONMENT, - DEPLOYMENT_ATTR_REGION, - DEPLOYMENT_ATTR_REPLICAS, - DEPLOYMENT_ATTR_SECRETS, OUTPUT_HOST, OUTPUT_PORT, OUTPUT_PUBLIC_URL, @@ -61,6 +56,11 @@ import { resolveSystemRef, } from "@metaobjectsdev/pack-systems"; import { + DEPLOYMENT_ATTR_BRANCH, + DEPLOYMENT_ATTR_DOMAINS, + DEPLOYMENT_ATTR_REGION, + DEPLOYMENT_ATTR_REPLICAS, + DEPLOYMENT_ATTR_SECRETS, DATABASE_OUTPUTS, DEPLOYMENT_SUBTYPE_RAILWAY, PARTIAL_PATTERN, diff --git a/packs/railway/typescript/test/model.test.ts b/packs/railway/typescript/test/model.test.ts index efe4f342e..c2312c11e 100644 --- a/packs/railway/typescript/test/model.test.ts +++ b/packs/railway/typescript/test/model.test.ts @@ -50,7 +50,7 @@ describe("readRailway refuses what Railway cannot do", () => { }); test("a vault with no scope for the environment", async () => { - const p = await problems(oneService((c) => (deployment(c)["@environment"] = "staging", c.push({ "environment.standing": { name: "staging" } })))); + const p = await problems(oneService((c) => (deployment(c)["@environment"] = "staging", c.push({ "environment.stage": { name: "staging", "@owner": "Acme", "@purpose": "staging" } })))); expect(p.join("\n")).toContain('no scope.env named "staging"'); }); @@ -106,7 +106,7 @@ describe("readRailway refuses what Railway cannot do", () => { test("two Railway projects need { project }", async () => { const json = oneService((c) => { - c.push({ "environment.standing": { name: "staging" } }); + c.push({ "environment.stage": { name: "staging", "@owner": "Acme", "@purpose": "staging" } }); c.push({ "vault.infisical": { name: "keys2", children: [{ "scope.env": { name: "staging", "@project": "acme-game" } }] } }); c.push({ "deployment.railway": { ...deployment(c), name: "server-staging", "@environment": "staging", "@project": "other", "@secrets": "keys2" } }); }); From 2ac9c44dff8884f2d457422d833559fca9091409 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Sun, 6 Dec 2026 08:13:13 -0500 Subject: [PATCH 2/7] no-mistakes(review): apply reviewer inline fixes --- packs/railway/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packs/railway/CHANGELOG.md b/packs/railway/CHANGELOG.md index c62c8533f..a82149912 100644 --- a/packs/railway/CHANGELOG.md +++ b/packs/railway/CHANGELOG.md @@ -4,8 +4,8 @@ This pack's own changelog (ADR-0069). The root `CHANGELOG.md` records core only. ## [0.1.0] - unreleased -- `deployment.railway` declare `@app`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets` and - their `value.*` children themselves: the delivery pack's `deployment.base` now holds only +- `deployment.railway` declares `@app`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets` and + its `value.*` children itself: the delivery pack's `deployment.base` now holds only `@environment`, which the loader resolves through the reference facet. Environments are the delivery pack's `environment.stage` (`@owner`, `@purpose`, `@lifespan`); the fixtures and tests declare an `organization.company` to own them. No generated file changes. From 6ccd97909a42072667d9d24e794913f96ad2d884 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Sun, 6 Dec 2026 08:13:56 -0500 Subject: [PATCH 3/7] no-mistakes(review): Exclude app and system from duplicate check --- packs/delivery/typescript/src/index.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packs/delivery/typescript/src/index.ts b/packs/delivery/typescript/src/index.ts index a6933d11b..3509c6b4a 100644 --- a/packs/delivery/typescript/src/index.ts +++ b/packs/delivery/typescript/src/index.ts @@ -34,7 +34,9 @@ import { ERR_DELIVERY_UNRESOLVED_REF, ERR_DELIVERY_UNSUPPORTED_OUTPUT, COUNTRY_CODE_PATTERN, + DEPLOYMENT_SUBTYPE_APP, DEPLOYMENT_SUBTYPE_BASE, + DEPLOYMENT_SUBTYPE_SYSTEM, LOCATION_ATTR_COUNTRIES, LOCATION_SUBTYPE_JURISDICTION, PORT_OUTPUTS, @@ -76,7 +78,15 @@ function checkDeploymentUnique(node: MetaData, ctx: ValidationContext): void { const root = topLevelNodeOf(node).parent; if (mine === undefined || root === undefined) return; // ADR-0039: resolving, the deployments the model effectively holds. - const deployments = root.children().filter((c) => c.type === TYPE_DEPLOYMENT && !c.isAbstract); + const deployments = root + .children() + .filter( + (c) => + c.type === TYPE_DEPLOYMENT && + !c.isAbstract && + c.subType !== DEPLOYMENT_SUBTYPE_SYSTEM && + c.subType !== DEPLOYMENT_SUBTYPE_APP, + ); const first = deployments.find((d) => { const t = deploymentTarget(d); return t !== undefined && t[0] === mine[0] && t[1] === mine[1]; From a0738627425ab306f34d527ebc15397e74c90a9a Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Sun, 6 Dec 2026 08:18:05 -0500 Subject: [PATCH 4/7] no-mistakes(document): Reorder 1.4.0 plan: deploys and APIs first --- spec/roadmap.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/roadmap.md b/spec/roadmap.md index 3f7ced50f..9e889dba6 100644 --- a/spec/roadmap.md +++ b/spec/roadmap.md @@ -689,9 +689,13 @@ the breaking half at `1.1`. - **FR-022 — protobuf emitter** — overlaps the protobuf serializer (shared `wireId`/type mapping); do together. -#### 1.4 — Metadata API + runtime-driven UI +#### 1.4 — Deploys and APIs first, then the metadata API + runtime-driven UI -- **FR-029** — metadata API endpoint (all backends) → browser runtime metadata loader → +The 1.4.0 work runs in this order: the deploy packs (the estate vocabulary, then the Railway, +Cloudflare and compose packs that read it, ADR-0070) and the API metadata first; the UI slice +after them. + +- **FR-029 (UI slice, after the deploy and API work)** — metadata API endpoint (all backends) → browser runtime metadata loader → runtime-driven dataGrid + create/edit forms → both-ways (codegen vs runtime) demo → backend-agnostic verification (the TS UI against all 5 backends). From cb9265f5acb72881a830da4949c612e5694d4400 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Sun, 6 Dec 2026 08:20:34 -0500 Subject: [PATCH 5/7] test(railway): a deployment.app beside a platform deployment for one app and environment loads Regression fixture for the duplicate-deployment check: only platform deployments are compared, so a deployment.app placing the same app in the same environment as a deployment.railway is not a duplicate. --- .../expected.json | 71 +++++++++++++++++++ .../input/meta.shop.json | 32 +++++++++ .../providers.json | 1 + 3 files changed, 104 insertions(+) create mode 100644 packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/expected.json create mode 100644 packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/input/meta.shop.json create mode 100644 packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/providers.json diff --git a/packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/expected.json b/packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/expected.json new file mode 100644 index 000000000..61548501b --- /dev/null +++ b/packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/expected.json @@ -0,0 +1,71 @@ +{ + "metadata.root": { + "package": "acme::shop", + "children": [ + { + "system.internal": { + "name": "Shop", + "children": [ + { + "app.service": { + "name": "server", + "children": [ + { + "runtime.process": { + "name": "web" + } + } + ] + } + } + ] + } + }, + { + "location.jurisdiction": { + "name": "EU", + "@countries": [ + "DE" + ], + "children": [ + { + "location.region": { + "name": "EuWest" + } + } + ] + } + }, + { + "environment.stage": { + "name": "production", + "@owner": "acme::shop::Acme", + "@purpose": "production" + } + }, + { + "deployment.app": { + "name": "server-placement", + "@app": "acme::shop::Shop.server", + "@environment": "acme::shop::production", + "@locations": [ + "acme::shop::EU.EuWest" + ] + } + }, + { + "deployment.railway": { + "name": "server-production", + "@app": "Shop.server", + "@environment": "acme::shop::production", + "@project": "acme-shop" + } + }, + { + "organization.company": { + "name": "Acme" + } + } + ] + } +} diff --git a/packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/input/meta.shop.json b/packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/input/meta.shop.json new file mode 100644 index 000000000..42a5dff42 --- /dev/null +++ b/packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/input/meta.shop.json @@ -0,0 +1,32 @@ +{ + "metadata.root": { + "package": "acme::shop", + "children": [ + { "system.internal": { + "name": "Shop", + "children": [ + { "app.service": { "name": "server", "children": [ { "runtime.process": { "name": "web" } } ] } } + ] + } }, + { "location.jurisdiction": { + "name": "EU", + "@countries": ["DE"], + "children": [ { "location.region": { "name": "EuWest" } } ] + } }, + { "environment.stage": { "name": "production", "@owner": "Acme", "@purpose": "production" } }, + { "deployment.app": { + "name": "server-placement", + "@app": "Shop.server", + "@environment": "production", + "@locations": ["EU.EuWest"] + } }, + { "deployment.railway": { + "name": "server-production", + "@app": "Shop.server", + "@environment": "production", + "@project": "acme-shop" + } }, + { "organization.company": { "name": "Acme" } } + ] + } +} diff --git a/packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/providers.json b/packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/providers.json new file mode 100644 index 000000000..894016a12 --- /dev/null +++ b/packs/railway/fixtures/conformance/railway-app-deployment-beside-platform/providers.json @@ -0,0 +1 @@ +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-railway"] From 755bfa79cf6ff947f8d232fae4e27be1884b85f2 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Sun, 6 Dec 2026 08:23:33 -0500 Subject: [PATCH 6/7] no-mistakes(review): Name FR-021/FR-024 in 1.4 roadmap, retarget both --- spec/roadmap.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/roadmap.md b/spec/roadmap.md index 9e889dba6..844c1db9b 100644 --- a/spec/roadmap.md +++ b/spec/roadmap.md @@ -140,10 +140,10 @@ under **Shipped**; planned FRs under **Planned** + the **Release plan**. ✅ shi | — | AI LLM-call trace persistence | 🔵 active | — | — | | FR-019 | Shared / externally-provided enums | 📋 | 1.1 | [#5](https://github.com/metaobjectsdev/metaobjects/issues/5) | | FR-020 | `@inheritance` joined strategy | 📋 | 1.x | [#6](https://github.com/metaobjectsdev/metaobjects/issues/6) | -| FR-021 | api metadata + contract projections | 📋 | 1.3 | [#7](https://github.com/metaobjectsdev/metaobjects/issues/7) | +| FR-021 | api metadata + contract projections | 📋 | 1.4 | [#7](https://github.com/metaobjectsdev/metaobjects/issues/7) | | FR-022 | Contract emitters (JSON Schema/OpenAPI/protobuf) | 🔵 JSON Schema and OpenAPI 1.2.1 · protobuf 1.3 | 1.2.1 | [#8](https://github.com/metaobjectsdev/metaobjects/issues/8) | | FR-023 | Metadata dependencies (cross-repo sharing: generated shared-model artifact, `meta deps sync`, committed snapshot + lock, default exclusion of imported metadata, consumer extend/overlay across the boundary) | 🟢 Phase 1a (TS + Python) **shipped** per DESIGN §11, Java/Kotlin consume (Phase 2 S3) — the usage-aware breaking-change classifier and the packaged transports (`npm`/`python`/`maven`/`nuget`) in the Python, Java and C# check are deferred (§11.4); C# consumer shipped in Phase 2 S6 | 1.1 | [#9](https://github.com/metaobjectsdev/metaobjects/issues/9) | -| FR-024 | Entity surfaces (projection/value + declared API) | 🟢 taxonomy + B3/B4a/B4b/B5/B6 validation parity + projection codegen **shipped 5 ports (1.0)**; declared-API surface (`api.operational`/`operation`/`binding.rest`) **registered in 1.3.0** with lifecycles (`transition.action`), loader rules and a `verify` rules gate in all five ports (ADR-0066); TypeScript's service generator enforces them (ADR-0067); the other ports' services are later 1.3.0 work | 1.0 · 1.3 | [#10](https://github.com/metaobjectsdev/metaobjects/issues/10) | +| FR-024 | Entity surfaces (projection/value + declared API) | 🟢 taxonomy + B3/B4a/B4b/B5/B6 validation parity + projection codegen **shipped 5 ports (1.0)**; declared-API surface (`api.operational`/`operation`/`binding.rest`) **registered in 1.3.0** with lifecycles (`transition.action`), loader rules and a `verify` rules gate in all five ports (ADR-0066); TypeScript's service generator enforces them (ADR-0067); the other ports' services are later 1.4 work | 1.0 · 1.4 | [#10](https://github.com/metaobjectsdev/metaobjects/issues/10) | | FR-025 | Cross-port package-binding codegen config | 📋 | 1.1 | [#11](https://github.com/metaobjectsdev/metaobjects/issues/11) | | FR-026 | Forms completeness (edit forms + view parity) | 🟢 edit forms + view-kind control dispatch **shipped**; renderer parity / validator wiring / `layout.form` **deferred to a later 1.x** (not in 1.1.0) | 1.x (later) | [#12](https://github.com/metaobjectsdev/metaobjects/issues/12) | | FR-027 | DataGrid downloads (CSV/XLSX/PDF/TXT) | 📋 | 1.2 | [#13](https://github.com/metaobjectsdev/metaobjects/issues/13) | @@ -693,7 +693,9 @@ the breaking half at `1.1`. The 1.4.0 work runs in this order: the deploy packs (the estate vocabulary, then the Railway, Cloudflare and compose packs that read it, ADR-0070) and the API metadata first; the UI slice -after them. +after them. The API metadata is FR-021 (api metadata + contract projections) together with +FR-024's declared-API port work: the V3 API vocabulary (shipped, PR #713) plus the H1/H2 API +rules. - **FR-029 (UI slice, after the deploy and API work)** — metadata API endpoint (all backends) → browser runtime metadata loader → runtime-driven dataGrid + create/edit forms → both-ways (codegen vs runtime) demo → From 1e2da97be6eb71b53072e39c2a8a431db9ebb048 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Sun, 6 Dec 2026 08:31:28 -0500 Subject: [PATCH 7/7] no-mistakes(document): Delivery README: platform abstract base note --- packs/delivery/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packs/delivery/README.md b/packs/delivery/README.md index 813da4380..c2db44768 100644 --- a/packs/delivery/README.md +++ b/packs/delivery/README.md @@ -116,9 +116,11 @@ The `railway` pack's `railway-worked-example` fixture is the whole example, both What is true of every environment (the app, the project, the service, the repository, the values that do not change) is written once, in an abstract deployment (`"abstract": true`, which is core's -structural keyword, not a new attribute). Each environment's deployment `extends` it and holds only -the differences: its `@environment`, `@branch`, `@domains`, `@replicas` and its own `value.*` -children. A child value that reuses the base value's name overrides it. An abstract deployment may +structural keyword, not a new attribute). The base is a platform pack's own `deployment.` +subtype, which declares `@app`, `@branch`, `@domains`, `@replicas` and its `value.*` children itself; +this pack's `deployment.base` holds only `@environment`. Each environment's deployment `extends` it +and holds only the differences: its `@environment`, `@branch`, `@domains`, `@replicas` and its own +`value.*` children. A child value that reuses the base value's name overrides it. An abstract deployment may omit `@app` and `@environment`, a concrete one must resolve both (its own or inherited), and an abstract one is never counted by the one-deployment-per-(`@app`, `@environment`) check or deployed. The `railway` pack's `railway-emit-environments` fixture shows it, and