diff --git a/AGENTS.md b/AGENTS.md index 2e9e6d140a..0842410041 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -48,7 +48,7 @@ number. Both patterns are the convergent-publishing rule working as intended. ** `dist-tag rm` 403s for every token we hold (`docs/RELEASING.md` §4). `metamodelVersion` read **`1.0`** through 1.0.13 — C4 landed and G4 shipped it, and no 1.0.x patch moved it (1.0.4 relaxed `@sourceRefField` onto `@cardinality: one` with a prose-only -manifest footprint, and was ruled a hold). `metamodelVersion` read **`1.1`** from 1.1.0 through 1.1.3 for the FR-044 reporting vocabulary and the requirements slice 1 (the first slice of two, covering existence gates and per-entity coverage). **It reads `1.2` from 1.1.4** through every published release since, for calendar-aligned relative report windows (`startOf` on a relative date). The merged tree claims **`1.3`** (`METAMODEL_VERSION` in every port) — main's 1.3.0 and the line's 1.2.4 both carry it, and neither is published. Per-release detail lives in **`CHANGELOG.md`** — it is the log, and this file does +manifest footprint, and was ruled a hold). `metamodelVersion` read **`1.1`** from 1.1.0 through 1.1.3 for the FR-044 reporting vocabulary and the requirements slice 1 (the first slice of two, covering existence gates and per-entity coverage). **It reads `1.2` from 1.1.4** through every published release since, for calendar-aligned relative report windows (`startOf` on a relative date). The merged tree claims **`1.4`** (`METAMODEL_VERSION` in every port), which is not published; main's 1.3.0 and the line's 1.2.4 both carry `1.3`, and neither is published. Per-release detail lives in **`CHANGELOG.md`** — it is the log, and this file does not duplicate it. The npm surface is **13 `@metaobjectsdev/*` packages in full lockstep** (`ai-runtime` left it in 1.3.0: its call loop is now written into the project by the `trace-helper` generator, ADR-0024 Amendment 2); the two `angular` @@ -74,7 +74,7 @@ PyPI has had no product change since `0.25.0` — nothing is broken. - **Kotlin** — `codegen-kotlin` (laid out by `KotlinWriter`, ADR-0063, on the JVM): entity + Exposed table + Spring controller + payload + relations + filter allowlist + validator + stored-proc + output-parser generators. `integration-tests-kotlin` runs the persistence-conformance corpus through Exposed against Testcontainers Postgres. **Cross-port conformance corpora** (every port runs the shared corpus): -- Metamodel: `fixtures/conformance/` (589 fixtures; 49 shared corpora in total — per-corpus counts + the corpus x port matrix live in `docs/CONFORMANCE.md`). TS / C# / Java / Python all green. +- Metamodel: `fixtures/conformance/` (596 fixtures; 49 shared corpora in total — per-corpus counts + the corpus x port matrix live in `docs/CONFORMANCE.md`). TS / C# / Java / Python all green. - Render: `fixtures/render-conformance/`. TS / Java / Kotlin / Python / C# / Rust byte-identical; the C# and Rust drift ledgers are empty (`docs/CONFORMANCE.md`). - Persistence: `fixtures/persistence-conformance/`. **Query** scenarios run on every port (TS / C# / Java / Kotlin / Python; `op: guardedUpdate` is TS-only until each port's 1.3.0 guarded update lands), each provisioning its test DB by executing the committed, TS-produced `canonical/schema.postgres.sql` (Postgres only — Derby dropped for the cross-port query corpus, ADR-0015; the FR-044 `report-*` scenarios also run on SQLite, MySQL and D1 where a port has the engine, see [docs/CONFORMANCE.md](docs/CONFORMANCE.md)). The **migration** scenarios are exercised by **TS only** (the Node reference helper writes them; a native tool is equally first-class, ADR-0015 Amendment 2). **The corpus now gates WRITES, not just reads (SP-H):** an `op: roundtrip` scenario type INSERTs through each port's runtime/ORM write codec (NOT raw SQL), reads the row back, and asserts the wire-normalized value. The `AllTypes` entity (`roundtrip-all-types.yaml`) carries one field of **every** persistable `field.*` subtype — string/int/long/double/float/decimal/boolean/date/time/timestamp(+tz)/currency/enum/uuid/object — plus an **array-of-VO** `field.object @isArray @storage:jsonb` column (`labels`, written as 2-element / empty-`[]` / single-element arrays across the three rows) — so every subtype write+read (incl. the array-of-value-object jsonb codec) round-trips through every port against Testcontainers PG. (`field.byte`/`field.short`/`field.class` were cut as non-functional registration-only stubs — the matrix tracks only genuinely-supported subtypes; see `fixtures/registry-conformance/README.md` → "Per-subtype write-round-trip matrix".) - API-contract: `fixtures/api-contract-conformance/`. TS / C# / Java / Kotlin / Python all green — each port runs **two lanes**: a hand-rolled reference server AND its **generated** API artifact booted over HTTP (the deployed controller/routes; TS+C# full-stack vs Testcontainers PG, Java/Kotlin/Python generated controller + in-memory repo behind the consumer seam). The generated fan-out found 10 real deployment bugs golden snapshots missed. Three sub-corpora run the **generated lane only, on all five ports** — `write-through/`, `projection/` (F22: a view-only `object.projection` serves GET list + GET by id and answers every write verb with `405 {"error": "method_not_allowed"}`) and `report/` (FR-044: a view-backed `object.report` serves GET list, answers `POST` with that same `405`, and mounts no `/{id}` route). That is deliberate, not a gap: what is under test is whether a port's GENERATOR emits those routes, and a hand-rolled reference server would answer every scenario by construction. The `m2m/` sub-corpus also gates **TPH x M:N together** (base-declared, subtype-declared, abstract-mid-declared, a non-subtype source onto a subtype TARGET, and the cross-subtype source id answering `200 []`) — the two corpora were originally built disjoint (`tph/` had no relationships, `m2m/` no discriminators), which is precisely how that defect class survived. diff --git a/README.md b/README.md index a00f83a8cb..fb7239b343 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ first-week wedge plan — and `meta init` picks up from there. | Kotlin | **Maven Central `8.3.1`** — codegen tier on top of Java: 17 generators (entity, Exposed table, names, relations, repository, output-parser, output-prompt, render-helper, extractor, filter-allowlist, validator, Spring config, storedProc, Spring controller, requirement-tests, api-docs, report-export); 24 / 24 persistence-conformance | [`docs/ports/kotlin.md`](docs/ports/kotlin.md) | [`server/java/codegen-kotlin/`](server/java/codegen-kotlin/) · [`server/java/metadata-ktx/`](server/java/metadata-ktx/) | | C# | **NuGet `1.3.1`** — loader + conformance + EF Core codegen + render engine + `dotnet meta` CLI all shipped | [`docs/ports/csharp.md`](docs/ports/csharp.md) | [`server/csharp/`](server/csharp/) | | Python | **PyPI `1.3.1`** — loader + conformance + render + entity-model codegen + ObjectManager runtime shipped; schema migrations in your own tool or the Node `meta migrate` reference helper (ADR-0015) | [`docs/ports/python.md`](docs/ports/python.md) | [`server/python/`](server/python/) | -| Rust | **Crates ready to publish, not yet published** — loader (JSON + YAML), project and source resolution, naming and all 41 validation passes; 589 / 589 metamodel conformance; prompt render and the reply parser (`metaobjects-render`); `cargo meta init` / `gen` / `verify` / `eject` with generators: the model crate through the sqlx store, the service and its opt-in axum routes (`service-routes`) to a typed client and its commands (ADR-0065). Schema migrations stay with the Node `meta` tool | [`docs/ports/rust.md`](docs/ports/rust.md) | [`server/rust/`](server/rust/) | +| Rust | **Crates ready to publish, not yet published** — loader (JSON + YAML), project and source resolution, naming and all 41 validation passes; 596 / 596 metamodel conformance; prompt render and the reply parser (`metaobjects-render`); `cargo meta init` / `gen` / `verify` / `eject` with generators: the model crate through the sqlx store, the service and its opt-in axum routes (`service-routes`) to a typed client and its commands (ADR-0065). Schema migrations stay with the Node `meta` tool | [`docs/ports/rust.md`](docs/ports/rust.md) | [`server/rust/`](server/rust/) | ## Capability matrix diff --git a/changelog.d/systems-vocabulary-core.md b/changelog.d/systems-vocabulary-core.md new file mode 100644 index 0000000000..a1868c27f6 --- /dev/null +++ b/changelog.d/systems-vocabulary-core.md @@ -0,0 +1,29 @@ +- **The systems vocabulary is core, in every port (ADR-0070, part 1).** A new bundled provider, + `metaobjects-systems-core` (`spec/metamodel/systems.json`), registers `organization.company` and + `.unit`; `system.software` with `@owner`; `app.service` (`@public`), `.client` (`@shell`) and + `.job` (`@schedule`), each with `@runsAs`; `build.image` (`@repository`); the resource kinds + `resource.rdb`, `.keyValue`, `.objectStore`, `.document`, `.search`, `.queue`, `.stream` and + `.volume`, with `@residency`, `@schemas`, `@volatile`, `@publicRead`, `@ordered` and + `@deadLetter`; and `role.service`, `.user`, `.group` and `.token`, with `@memberOf`, `@heldBy` + and `@credential`. It is in the default provider set of TypeScript, C#, Java and Kotlin, Python + and Rust, so a model that declares none of these types is unchanged. `@owner`, `@runsAs`, + `@memberOf` and `@heldBy` are checked by the reference facet with its default codes: a name + that resolves to nothing is `ERR_REF_UNRESOLVED`, and one that names the wrong kind of node is + `ERR_REF_WRONG_KIND`. `@heldBy` names an organization only for now: a token held by a system + raises `ERR_REF_WRONG_KIND` until the facet accepts more than one target type. New conformance + fixtures `systems-vocabulary`, `error-ref-wrong-kind-runsas` and `error-ref-unresolved-runsas` + pin the vocabulary and the facet's two worked cases. `@residency` is a closed set (`free`, + `confined`) in every port: any other value is `ERR_BAD_ATTR_VALUE` (fixture + `error-resource-residency-bad-value`). An app holds at most one build of any kind: every port's + loader now enforces a child rule's `max` on the parent's effective children, so a build the app + inherits through `extends` counts, and each build past the bound is `ERR_TOO_MANY_OCCURRENCES` + (fixtures `error-app-two-builds`, `error-app-three-builds` and + `error-app-build-beside-inherited`). `metamodelVersion` moves to `1.4`. + + Upgrading: a project that composes the independent `systems` or `delivery` pack needs + metamodel 1.4. The `systems` pack no longer registers `system.base`, `app.*` or + `resource.queue` / `.volume` (core does) and adds `@needs`, `@calls` and `@settings` to core's + apps; the `delivery` pack's builds extend core's `build.base`. A pack fixture or provider list + that names `metaobjects-systems` must also name `metaobjects-systems-core`. The pack's own + resource kinds map onto core's: `database` → `rdb`, `bucket` → `objectStore`, `keyvalue` and + `cache` → `keyValue`, and `system.internal` / `.external` → `system.software`. diff --git a/docs/CONFORMANCE.md b/docs/CONFORMANCE.md index 02b53fd212..08b1db0936 100644 --- a/docs/CONFORMANCE.md +++ b/docs/CONFORMANCE.md @@ -26,7 +26,7 @@ regenerate with `ls -d fixtures//*/ | wc -l` for directory-shaped corpor | Corpus | Fixtures | TS | Java | Kotlin | C# | Python | Rust | |---|---|---|---|---|---|---|---| -| [`fixtures/conformance/`](../fixtures/conformance/) (metamodel) | 589 | ✓ | ✓ | inherits via `metadata-ktx` | ✓ | ✓ | ✓ (589 / 589, empty ledger) | +| [`fixtures/conformance/`](../fixtures/conformance/) (metamodel) | 596 | ✓ | ✓ | inherits via `metadata-ktx` | ✓ | ✓ | ✓ (596 / 596, empty ledger) | | [`fixtures/yaml-conformance/`](../fixtures/yaml-conformance/) | 19 | 19 / 19 | 19 / 19 | inherits via Java | 18 / 19 (1 ledgered: `error-yaml-coerced-hex-in-string` — YamlDotNet doesn't coerce `0xFF`) | 19 / 19 | 19 / 19 | | [`fixtures/verify-conformance/`](../fixtures/verify-conformance/) | 45 | ✓ | ✓ | inherits via Java | ✓ | ✓ | ✓ | | [`fixtures/verify-strict-conformance/`](../fixtures/verify-strict-conformance/) | 1 | ✓ | — | — | — | ✓ | — | @@ -82,7 +82,7 @@ and render ledgers; the api-contract runner's list of sub-corpora not built yet) shrink, and the corpora without one assert each case outright. A new fixture that fails in Rust and is not on the ledger prints a warning and does not fail the lane; it becomes a hard failure when ADR-0065 turns the warning off. A regression still fails: the ledger's -`minPassing` (589) is the number of fixtures known to pass, and the run fails when fewer do. +`minPassing` (596) is the number of fixtures known to pass, and the run fails when fewer do. Beside the corpora it runs the codegen-compile gate (below) with every shipped generator, a scale gate over twenty copies of the fitness model, and `examples/rust-service/`'s HTTP test. [The Rust port page](ports/rust.md#conformance) has the detail. @@ -445,7 +445,7 @@ carry it, and a model that uses it fails there by name. There is no row per pack ## Fixture-to-doc mapping -### `fixtures/conformance/` — metamodel loader + canonical serializer (589) +### `fixtures/conformance/` — metamodel loader + canonical serializer (596) | Fixture prefix | Feature doc | |---|---| @@ -468,6 +468,7 @@ carry it, and a model that uses it fails there by name. There is no row per pack | `origin-*`, `error-origin-*` | [features/templates-and-payloads.md](features/templates-and-payloads.md) (payload origins) | | `projection-*`, `error-projection-*`, `field-readonly-on-view-projection` | [features/source-kinds.md](features/source-kinds.md) (projections + the object taxonomy, ADR-0028) | | `requirement-*`, `error-unknown-attr-requirement` | [features/requirements.md](features/requirements.md) (vocabulary only — the gate has its own corpus, `requirement-check-conformance/`; see "Split coverage" above) | +| `systems-vocabulary`, `error-ref-wrong-kind-runsas`, `error-ref-unresolved-runsas`, `error-resource-residency-bad-value`, `error-app-two-builds`, `error-app-three-builds`, `error-app-build-beside-inherited` | [spec/metamodel-definitions.md](../spec/metamodel-definitions.md) (the systems vocabulary, ADR-0070: the reference facet's two worked cases, the closed `@residency` set, and an app's one build, counting a build it inherits) | | `reporting-*`, `error-dimension-*`, `error-measure-*`, `error-ratio-*`, `error-segment-*`, `error-report-*`, `error-relative-date-*` | [features/reporting.md](features/reporting.md) (the `dimension` / `measure` / `segment` / `object.report` vocabulary and its load-time rules; design in the [FR-044 spec](superpowers/specs/2026-10-02-fr-044-core-reporting-design.md)) | | `rules-*`, `error-rules-*` | [features/business-rules.md](features/business-rules.md) (operations, permission names and lifecycles: the vocabulary and its load-time rules, ADR-0066; the `verify` gate has its own corpus, `rules-check-conformance/`) | | `provider-extension-*`, `provider-custom-vocabulary-*` | [features/extending-with-providers.md](features/extending-with-providers.md) (a project's own provider: a new subtype plus attributes on an existing type load with it and are refused without it, every port writing the provider in its own language) | @@ -960,7 +961,7 @@ shared input. ## Orphaned fixtures (tested but not yet documented) -The fixtures in the nine corpora mapped above (metamodel 589 + yaml 19 + verify 45 +The fixtures in the nine corpora mapped above (metamodel 596 + yaml 19 + verify 45 + render 26 + persistence 68 + api-contract 191 + source-resolution 30 + scope 10 + dependency 47) each map to a feature doc, and so do the two requirement corpora, `rules-check-conformance`, `shared-model-conformance`, the `cube-model` corpus, `explorer-conformance` and `list-query-conformance`, whose case lists live in their own READMEs. None are orphaned today. The remaining diff --git a/docs/ports/rust.md b/docs/ports/rust.md index d14de631a7..02c82b895a 100644 --- a/docs/ports/rust.md +++ b/docs/ports/rust.md @@ -651,7 +651,7 @@ outright. | Corpus | Rust today | |---|---| | `registry-conformance` | byte-identical manifest | -| `conformance` (the metamodel corpus) | **589 of 589**, and the ledger is empty | +| `conformance` (the metamodel corpus) | **596 of 596**, and the ledger is empty | | `yaml-conformance` | all 19, and the ledger is empty | | `source-resolution-conformance` | all 30 cases | | `reference-source-conformance` | all 6 cases: a `reference: true` source loads so references resolve against it, a node declared only in reference files is a reference node no generator emits, and a `template.*` declared only there is refused (`ERR_REFERENCE_SOURCE_TEMPLATE`) | diff --git a/examples/showcase/site-payload.json b/examples/showcase/site-payload.json index 61e5899853..e7ec69bd59 100644 --- a/examples/showcase/site-payload.json +++ b/examples/showcase/site-payload.json @@ -4,12 +4,12 @@ "pypi": "1.3.1", "nuget": "1.3.1", "maven": "8.3.1", - "metamodel": "1.3" + "metamodel": "1.4" }, "counts": { - "fixtures": 589, + "fixtures": 596, "corpora": 49, - "baseTypes": 21 + "baseTypes": 27 }, "snippets": { "showcase-model": { diff --git a/fixtures/conformance/ERROR-CODES.json b/fixtures/conformance/ERROR-CODES.json index 223217f0e0..d816b26a1f 100644 --- a/fixtures/conformance/ERROR-CODES.json +++ b/fixtures/conformance/ERROR-CODES.json @@ -12,7 +12,7 @@ "ERR_UNRESOLVED_SUPER": "An extends/super reference names a node that does not exist.", "ERR_EXTENDS_TARGET_MISMATCH": "FR-024: a dotted extends ref resolved to a node whose type or subtype does not match the extending node (a field may only extend a field of the same subtype; an identity only an identity).", "ERR_IDENTITY_NAME_REQUIRED": "FR-024: an identity.* node has no name. Identities are named, author-chosen (e.g. \"id\"), so the dotted by-name extends form can address them.", - "ERR_TOO_MANY_OCCURRENCES": "A type.subType declared with maxOccurs (e.g. identity.primary, maxOccurs:1) appears more times than allowed under one parent.", + "ERR_TOO_MANY_OCCURRENCES": "A type.subType declared with maxOccurs (e.g. identity.primary, maxOccurs:1) appears more times than allowed under one parent, or a parent holds more children matching a child rule than its max allows (e.g. a second build.* under an app, counting one it inherits through extends).", "ERR_PROJECTION_IDENTITY_NOT_EXTENDED": "FR-024: an identity.* on an object.projection lacks extends — a projection identity is a pass-through of an entity identity.", "ERR_IDENTITY_KEY_MISMATCH": "FR-024: identity key correspondence broken — an extended-identity field has no local pass-through field extending it, or an explicit @fields disagrees with the computed pass-through key.", "ERR_PROJECTION_SOURCE_WRITABLE": "FR-024 (ADR-0028): a source.* on an object.projection has a writable @kind (table, or @kind omitted which defaults to table) — a projection is a derived read-only representation; its sources must be read-only kinds (view, materializedView, storedProc, tableFunction).", diff --git a/fixtures/conformance/error-app-build-beside-inherited/expected-errors.json b/fixtures/conformance/error-app-build-beside-inherited/expected-errors.json new file mode 100644 index 0000000000..4e61744b42 --- /dev/null +++ b/fixtures/conformance/error-app-build-beside-inherited/expected-errors.json @@ -0,0 +1,15 @@ +{ + "errors": [ + { + "code": "ERR_TOO_MANY_OCCURRENCES", + "source": { + "format": "json", + "files": [ + "meta.parcels.json" + ], + "jsonPath": "$['metadata.root'].children[0]['system.software'].children[1]['app.service'].children[0]['build.image']" + } + } + ], + "warnings": [] +} diff --git a/fixtures/conformance/error-app-build-beside-inherited/input/meta.parcels.json b/fixtures/conformance/error-app-build-beside-inherited/input/meta.parcels.json new file mode 100644 index 0000000000..748228927e --- /dev/null +++ b/fixtures/conformance/error-app-build-beside-inherited/input/meta.parcels.json @@ -0,0 +1,41 @@ +{ + "metadata.root": { + "package": "acme::parcels", + "children": [ + { + "system.software": { + "name": "Parcels", + "children": [ + { + "app.service": { + "name": "base", + "children": [ + { + "build.image": { + "name": "image", + "@repository": "registry.example.com/acme/base" + } + } + ] + } + }, + { + "app.service": { + "name": "api", + "extends": "Parcels.base", + "children": [ + { + "build.image": { + "name": "own", + "@repository": "registry.example.com/acme/api" + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/fixtures/conformance/error-app-three-builds/expected-errors.json b/fixtures/conformance/error-app-three-builds/expected-errors.json new file mode 100644 index 0000000000..ff682cc8dd --- /dev/null +++ b/fixtures/conformance/error-app-three-builds/expected-errors.json @@ -0,0 +1,25 @@ +{ + "errors": [ + { + "code": "ERR_TOO_MANY_OCCURRENCES", + "source": { + "format": "json", + "files": [ + "meta.parcels.json" + ], + "jsonPath": "$['metadata.root'].children[0]['system.software'].children[0]['app.job'].children[1]['build.image']" + } + }, + { + "code": "ERR_TOO_MANY_OCCURRENCES", + "source": { + "format": "json", + "files": [ + "meta.parcels.json" + ], + "jsonPath": "$['metadata.root'].children[0]['system.software'].children[0]['app.job'].children[2]['build.image']" + } + } + ], + "warnings": [] +} diff --git a/fixtures/conformance/error-app-three-builds/input/meta.parcels.json b/fixtures/conformance/error-app-three-builds/input/meta.parcels.json new file mode 100644 index 0000000000..c5bcc96057 --- /dev/null +++ b/fixtures/conformance/error-app-three-builds/input/meta.parcels.json @@ -0,0 +1,39 @@ +{ + "metadata.root": { + "package": "acme::parcels", + "children": [ + { + "system.software": { + "name": "Parcels", + "children": [ + { + "app.job": { + "name": "nightly", + "children": [ + { + "build.image": { + "name": "first", + "@repository": "registry.example.com/acme/nightly" + } + }, + { + "build.image": { + "name": "second", + "@repository": "registry.example.com/acme/nightly-b" + } + }, + { + "build.image": { + "name": "third", + "@repository": "registry.example.com/acme/nightly-c" + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/fixtures/conformance/error-app-two-builds/expected-errors.json b/fixtures/conformance/error-app-two-builds/expected-errors.json new file mode 100644 index 0000000000..ec3081989f --- /dev/null +++ b/fixtures/conformance/error-app-two-builds/expected-errors.json @@ -0,0 +1,15 @@ +{ + "errors": [ + { + "code": "ERR_TOO_MANY_OCCURRENCES", + "source": { + "format": "json", + "files": [ + "meta.parcels.json" + ], + "jsonPath": "$['metadata.root'].children[0]['system.software'].children[0]['app.service'].children[1]['build.image']" + } + } + ], + "warnings": [] +} diff --git a/fixtures/conformance/error-app-two-builds/input/meta.parcels.json b/fixtures/conformance/error-app-two-builds/input/meta.parcels.json new file mode 100644 index 0000000000..70dd9dff88 --- /dev/null +++ b/fixtures/conformance/error-app-two-builds/input/meta.parcels.json @@ -0,0 +1,33 @@ +{ + "metadata.root": { + "package": "acme::parcels", + "children": [ + { + "system.software": { + "name": "Parcels", + "children": [ + { + "app.service": { + "name": "api", + "children": [ + { + "build.image": { + "name": "image", + "@repository": "registry.example.com/acme/api" + } + }, + { + "build.image": { + "name": "mirror", + "@repository": "mirror.example.com/acme/api" + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/fixtures/conformance/error-ref-unresolved-runsas/expected-errors.json b/fixtures/conformance/error-ref-unresolved-runsas/expected-errors.json new file mode 100644 index 0000000000..80a9945612 --- /dev/null +++ b/fixtures/conformance/error-ref-unresolved-runsas/expected-errors.json @@ -0,0 +1,15 @@ +{ + "errors": [ + { + "code": "ERR_REF_UNRESOLVED", + "source": { + "format": "json", + "files": [ + "meta.parcels.json" + ], + "jsonPath": "$['metadata.root'].children[0]['system.software'].children[0]['app.service']" + } + } + ], + "warnings": [] +} diff --git a/fixtures/conformance/error-ref-unresolved-runsas/input/meta.parcels.json b/fixtures/conformance/error-ref-unresolved-runsas/input/meta.parcels.json new file mode 100644 index 0000000000..3a96ed6c8c --- /dev/null +++ b/fixtures/conformance/error-ref-unresolved-runsas/input/meta.parcels.json @@ -0,0 +1,15 @@ +{ + "metadata.root": { + "package": "acme::parcels", + "children": [ + { + "system.software": { + "name": "Parcels", + "children": [ + { "app.service": { "name": "api", "@runsAs": "nobody" } } + ] + } + } + ] + } +} diff --git a/fixtures/conformance/error-ref-wrong-kind-runsas/expected-errors.json b/fixtures/conformance/error-ref-wrong-kind-runsas/expected-errors.json new file mode 100644 index 0000000000..e4c87e6706 --- /dev/null +++ b/fixtures/conformance/error-ref-wrong-kind-runsas/expected-errors.json @@ -0,0 +1,15 @@ +{ + "errors": [ + { + "code": "ERR_REF_WRONG_KIND", + "source": { + "format": "json", + "files": [ + "meta.parcels.json" + ], + "jsonPath": "$['metadata.root'].children[0]['system.software'].children[1]['app.service']" + } + } + ], + "warnings": [] +} diff --git a/fixtures/conformance/error-ref-wrong-kind-runsas/input/meta.parcels.json b/fixtures/conformance/error-ref-wrong-kind-runsas/input/meta.parcels.json new file mode 100644 index 0000000000..4903bb76fb --- /dev/null +++ b/fixtures/conformance/error-ref-wrong-kind-runsas/input/meta.parcels.json @@ -0,0 +1,16 @@ +{ + "metadata.root": { + "package": "acme::parcels", + "children": [ + { + "system.software": { + "name": "Parcels", + "children": [ + { "resource.rdb": { "name": "db" } }, + { "app.service": { "name": "api", "@runsAs": "db" } } + ] + } + } + ] + } +} diff --git a/fixtures/conformance/error-resource-residency-bad-value/expected-errors.json b/fixtures/conformance/error-resource-residency-bad-value/expected-errors.json new file mode 100644 index 0000000000..2fbc2cfba7 --- /dev/null +++ b/fixtures/conformance/error-resource-residency-bad-value/expected-errors.json @@ -0,0 +1,15 @@ +{ + "errors": [ + { + "code": "ERR_BAD_ATTR_VALUE", + "source": { + "format": "json", + "files": [ + "meta.parcels.json" + ], + "jsonPath": "$['metadata.root'].children[0]['system.software'].children[0]['resource.rdb']" + } + } + ], + "warnings": [] +} diff --git a/fixtures/conformance/error-resource-residency-bad-value/input/meta.parcels.json b/fixtures/conformance/error-resource-residency-bad-value/input/meta.parcels.json new file mode 100644 index 0000000000..d7eb5bfb30 --- /dev/null +++ b/fixtures/conformance/error-resource-residency-bad-value/input/meta.parcels.json @@ -0,0 +1,20 @@ +{ + "metadata.root": { + "package": "acme::parcels", + "children": [ + { + "system.software": { + "name": "Parcels", + "children": [ + { + "resource.rdb": { + "name": "db", + "@residency": "confned" + } + } + ] + } + } + ] + } +} diff --git a/fixtures/conformance/systems-vocabulary/expected.json b/fixtures/conformance/systems-vocabulary/expected.json new file mode 100644 index 0000000000..c4b1654de3 --- /dev/null +++ b/fixtures/conformance/systems-vocabulary/expected.json @@ -0,0 +1,152 @@ +{ + "metadata.root": { + "children": [ + { + "organization.company": { + "name": "Acme", + "package": "acme::common", + "children": [ + { + "organization.unit": { + "name": "Platform", + "children": [ + { + "organization.unit": { + "name": "Parcels" + } + } + ] + } + } + ] + } + }, + { + "organization.company": { + "name": "Tidewell", + "package": "acme::common" + } + }, + { + "system.software": { + "name": "Parcels", + "package": "acme::parcels", + "@owner": "acme::common::Acme.Platform.Parcels", + "children": [ + { + "resource.rdb": { + "name": "db", + "@residency": "confined", + "@schemas": [ + "app", + "reporting" + ] + } + }, + { + "resource.keyValue": { + "name": "cache", + "@volatile": true + } + }, + { + "resource.objectStore": { + "name": "documents", + "@publicRead": false + } + }, + { + "resource.document": { + "name": "tracking" + } + }, + { + "resource.search": { + "name": "search", + "@residency": "free" + } + }, + { + "resource.queue": { + "name": "labelJobs", + "@deadLetter": true, + "@ordered": true + } + }, + { + "resource.stream": { + "name": "events" + } + }, + { + "resource.volume": { + "name": "scratch" + } + }, + { + "role.group": { + "name": "support" + } + }, + { + "role.service": { + "name": "api" + } + }, + { + "role.service": { + "name": "exporter", + "@memberOf": [ + "acme::parcels::Parcels.support" + ] + } + }, + { + "role.user": { + "name": "dana", + "@memberOf": [ + "acme::parcels::Parcels.support" + ] + } + }, + { + "role.token": { + "name": "tidewellFeeds", + "@credential": "keys/TIDEWELL_FEEDS", + "@heldBy": "acme::common::Tidewell" + } + }, + { + "app.service": { + "name": "api", + "@public": true, + "@runsAs": "acme::parcels::Parcels.api" + } + }, + { + "app.client": { + "name": "tracker", + "@shell": "Tracker" + } + }, + { + "app.job": { + "name": "manifestExport", + "@runsAs": "acme::parcels::Parcels.exporter", + "@schedule": "0 2 * * *", + "children": [ + { + "build.image": { + "name": "image", + "@repository": "registry.example.com/acme/exporter" + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/fixtures/conformance/systems-vocabulary/input/meta.acme.json b/fixtures/conformance/systems-vocabulary/input/meta.acme.json new file mode 100644 index 0000000000..2f146c2ae2 --- /dev/null +++ b/fixtures/conformance/systems-vocabulary/input/meta.acme.json @@ -0,0 +1,23 @@ +{ + "metadata.root": { + "package": "acme::common", + "children": [ + { + "organization.company": { + "name": "Acme", + "children": [ + { + "organization.unit": { + "name": "Platform", + "children": [ + { "organization.unit": { "name": "Parcels" } } + ] + } + } + ] + } + }, + { "organization.company": { "name": "Tidewell" } } + ] + } +} diff --git a/fixtures/conformance/systems-vocabulary/input/meta.parcels.json b/fixtures/conformance/systems-vocabulary/input/meta.parcels.json new file mode 100644 index 0000000000..f363875871 --- /dev/null +++ b/fixtures/conformance/systems-vocabulary/input/meta.parcels.json @@ -0,0 +1,40 @@ +{ + "metadata.root": { + "package": "acme::parcels", + "children": [ + { + "system.software": { + "name": "Parcels", + "@owner": "acme::common::Acme.Platform.Parcels", + "children": [ + { "resource.rdb": { "name": "db", "@residency": "confined", "@schemas": ["app", "reporting"] } }, + { "resource.keyValue": { "name": "cache", "@volatile": true } }, + { "resource.objectStore": { "name": "documents", "@publicRead": false } }, + { "resource.document": { "name": "tracking" } }, + { "resource.search": { "name": "search", "@residency": "free" } }, + { "resource.queue": { "name": "labelJobs", "@ordered": true, "@deadLetter": true } }, + { "resource.stream": { "name": "events" } }, + { "resource.volume": { "name": "scratch" } }, + { "role.group": { "name": "support" } }, + { "role.service": { "name": "api" } }, + { "role.service": { "name": "exporter", "@memberOf": ["support"] } }, + { "role.user": { "name": "dana", "@memberOf": ["support"] } }, + { "role.token": { "name": "tidewellFeeds", "@heldBy": "acme::common::Tidewell", "@credential": "keys/TIDEWELL_FEEDS" } }, + { "app.service": { "name": "api", "@runsAs": "api", "@public": true } }, + { "app.client": { "name": "tracker", "@shell": "Tracker" } }, + { + "app.job": { + "name": "manifestExport", + "@runsAs": "exporter", + "@schedule": "0 2 * * *", + "children": [ + { "build.image": { "name": "image", "@repository": "registry.example.com/acme/exporter" } } + ] + } + } + ] + } + } + ] + } +} diff --git a/fixtures/metamodel-docs/data/INDEX.md.json b/fixtures/metamodel-docs/data/INDEX.md.json index 0990113b09..c6b239c5bb 100644 --- a/fixtures/metamodel-docs/data/INDEX.md.json +++ b/fixtures/metamodel-docs/data/INDEX.md.json @@ -10,6 +10,26 @@ "description": "A named, packaged request/response surface whose children are operations (ADR-0030). It is a wire contract: two of them (`v1`, `v2`) may declare the same operation side by side. The code behind it is one service per metadata package, whose surface is the package's operations (ADR-0067). Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).", "page": "types/api.md#apioperational" }, + { + "typeSubType": "app.base", + "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "page": "types/app.md#appbase" + }, + { + "typeSubType": "app.client", + "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", + "page": "types/app.md#appclient" + }, + { + "typeSubType": "app.job", + "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", + "page": "types/app.md#appjob" + }, + { + "typeSubType": "app.service", + "description": "A long-running process that answers requests: a web server, an API, a socket server.", + "page": "types/app.md#appservice" + }, { "typeSubType": "attr.base", "description": "Abstract base attribute — the polymorphic/unconstrained value-type marker. Stores its value type-preserved (never stringified), accepting any type; used for an untyped attr (e.g. a field's @default, whose value-type follows the owning field's subtype). Not authored directly: a `attr.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED) — this subtype is a registry anchor concrete subtypes inherit from, never a node in a document.", @@ -75,6 +95,16 @@ "description": "The HTTP method and path of an operation, declared only to override the derived ones. A query is `GET`, a command `POST`; the path is `//{id}/` for an operation with a target key and `//` without one. Most models never write it. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).", "page": "types/binding.md#bindingrest" }, + { + "typeSubType": "build.base", + "description": "Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "page": "types/build.md#buildbase" + }, + { + "typeSubType": "build.image", + "description": "The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here.", + "page": "types/build.md#buildimage" + }, { "typeSubType": "dimension.attribute", "description": "A named group-by attribute of the entity that declares it (FR-044). Groups report rows by a column value as-is. @of names Entity.field: the owning entity, or the @via terminal. @via may follow only to-one hops, so grouping by a related row's column can never multiply the measured rows.", @@ -270,6 +300,21 @@ "description": "A named operation that reads. Returns an `object.projection` (or an entity or value). It changes nothing. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).", "page": "types/operation.md#operationquery" }, + { + "typeSubType": "organization.base", + "description": "Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "page": "types/organization.md#organizationbase" + }, + { + "typeSubType": "organization.company", + "description": "A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company.", + "page": "types/organization.md#organizationcompany" + }, + { + "typeSubType": "organization.unit", + "description": "A team or division inside a company. Units nest: a unit is a child of a company or of another unit.", + "page": "types/organization.md#organizationunit" + }, { "typeSubType": "origin.aggregate", "description": "A value reduced from the related row-set reached along a relationship path (@via) from the base entity: count/sum/avg/min/max over a column (@of); any/all predicate quantifiers over a @filter; or collect (an array rollup — of the @of column, or of the carrying field.object's declared @objectRef value object when @of is omitted).", @@ -330,6 +375,76 @@ "description": "What the product does for a user, stated as one violable claim. Its check is EXISTENCE, run by `meta verify`: a live or partial claim with no implementing node anywhere in its subtree is a warning, and a named node that no longer exists is an error. Hierarchy is nesting — an L1 solution contains its L2 segments, which contain L3 services, and so on down to the levels that reference the model.", "page": "types/requirement.md#requirementfunctional" }, + { + "typeSubType": "resource.base", + "description": "Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "page": "types/resource.md#resourcebase" + }, + { + "typeSubType": "resource.document", + "description": "A document store: records kept and fetched as whole documents.", + "page": "types/resource.md#resourcedocument" + }, + { + "typeSubType": "resource.keyValue", + "description": "A store of values fetched by key.", + "page": "types/resource.md#resourcekeyvalue" + }, + { + "typeSubType": "resource.objectStore", + "description": "Files and blobs addressed by key.", + "page": "types/resource.md#resourceobjectstore" + }, + { + "typeSubType": "resource.queue", + "description": "A message queue: each message is handed to one consumer and gone once it is handled.", + "page": "types/resource.md#resourcequeue" + }, + { + "typeSubType": "resource.rdb", + "description": "A relational database: tables queried with SQL, the store of record.", + "page": "types/resource.md#resourcerdb" + }, + { + "typeSubType": "resource.search", + "description": "A search index: documents found by text and filters.", + "page": "types/resource.md#resourcesearch" + }, + { + "typeSubType": "resource.stream", + "description": "A retained, ordered log that many consumers read, each at its own position. A message can be read again.", + "page": "types/resource.md#resourcestream" + }, + { + "typeSubType": "resource.volume", + "description": "A disk attached to an app that survives a restart.", + "page": "types/resource.md#resourcevolume" + }, + { + "typeSubType": "role.base", + "description": "Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "page": "types/role.md#rolebase" + }, + { + "typeSubType": "role.group", + "description": "Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in.", + "page": "types/role.md#rolegroup" + }, + { + "typeSubType": "role.service", + "description": "A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs).", + "page": "types/role.md#roleservice" + }, + { + "typeSubType": "role.token", + "description": "Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer.", + "page": "types/role.md#roletoken" + }, + { + "typeSubType": "role.user", + "description": "A named person, or an agent acting for one. No shared secret is generated or stored for it.", + "page": "types/role.md#roleuser" + }, { "typeSubType": "segment.filter", "description": "A named, reusable row filter on the declaring entity (FR-044). Measures and reports reference it by name; exporters emit it as a named segment.", @@ -345,6 +460,16 @@ "description": "The relational-database paradigm source (ADR-0007): binds an object to a physical relational object. Its physical name is the @table attr (not the structural `name`), and read-only-ness is DERIVED from @kind — table is writable; view, materializedView, storedProc, and tableFunction are read-only. The @table/@kind/@role/@schema/@parameterRef attrs are contributed by the db domain provider, not by core-types.", "page": "types/source.md#sourcerdb" }, + { + "typeSubType": "system.base", + "description": "Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "page": "types/system.md#systembase" + }, + { + "typeSubType": "system.software", + "description": "A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package.", + "page": "types/system.md#systemsoftware" + }, { "typeSubType": "template.base", "description": "Abstract base template — the shared root subtype for the fourth pillar (FR-004, ADR-0011). A template is a typed payload bound to either a rendered text artifact (prompt/output) or a tool-call envelope. The base carries no attrs of its own; concrete subtypes add their reference + governance attrs. Not authored directly: a `template.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED) — this subtype is a registry anchor concrete subtypes inherit from, never a node in a document.", diff --git a/fixtures/metamodel-docs/data/providers.md.json b/fixtures/metamodel-docs/data/providers.md.json index dc66a89c92..79fd51111f 100644 --- a/fixtures/metamodel-docs/data/providers.md.json +++ b/fixtures/metamodel-docs/data/providers.md.json @@ -498,6 +498,69 @@ } ] }, + { + "id": "metaobjects-systems-core", + "hasDescription": true, + "description": "Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role.", + "hasOwns": true, + "owns": "`app.base`, `app.client`, `app.job`, `app.service`, `build.base`, `build.image`, `organization.base`, `organization.company`, `organization.unit`, `resource.base`, `resource.document`, `resource.keyValue`, `resource.objectStore`, `resource.queue`, `resource.rdb`, `resource.search`, `resource.stream`, `resource.volume`, `role.base`, `role.group`, `role.service`, `role.token`, `role.user`, `system.base`, `system.software`", + "hasUniversal": false, + "hasContributes": true, + "contributes": [ + { + "typeSubType": "app.base", + "attrs": "`@runsAs`" + }, + { + "typeSubType": "app.client", + "attrs": "`@shell`" + }, + { + "typeSubType": "app.job", + "attrs": "`@schedule`" + }, + { + "typeSubType": "app.service", + "attrs": "`@public`" + }, + { + "typeSubType": "build.image", + "attrs": "`@repository`" + }, + { + "typeSubType": "resource.base", + "attrs": "`@residency`" + }, + { + "typeSubType": "resource.keyValue", + "attrs": "`@volatile`" + }, + { + "typeSubType": "resource.objectStore", + "attrs": "`@publicRead`" + }, + { + "typeSubType": "resource.queue", + "attrs": "`@deadLetter`, `@ordered`" + }, + { + "typeSubType": "resource.rdb", + "attrs": "`@schemas`" + }, + { + "typeSubType": "role.base", + "attrs": "`@credential`, `@memberOf`" + }, + { + "typeSubType": "role.token", + "attrs": "`@heldBy`" + }, + { + "typeSubType": "system.base", + "attrs": "`@owner`" + } + ] + }, { "id": "metaobjects-ui", "hasDescription": true, diff --git a/fixtures/metamodel-docs/data/types/app.md.json b/fixtures/metamodel-docs/data/types/app.md.json new file mode 100644 index 0000000000..df7708d127 --- /dev/null +++ b/fixtures/metamodel-docs/data/types/app.md.json @@ -0,0 +1,147 @@ +{ + "family": "app", + "sections": [ + { + "typeSubType": "app.base", + "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": false, + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "runsAs", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND." + } + ], + "hasChildren": true, + "children": [ + "`build.*` — 0..1" + ], + "hasParents": false + }, + { + "typeSubType": "app.client", + "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "A front end built and shipped as files, whatever serves them.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "runsAs", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND." + }, + { + "name": "shell", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here." + } + ], + "hasChildren": true, + "children": [ + "`build.*` — 0..1" + ], + "hasParents": false + }, + { + "typeSubType": "app.job", + "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "A cron job, a nightly import, a queue drain that is not a long-running service.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "runsAs", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND." + }, + { + "name": "schedule", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered." + } + ], + "hasChildren": true, + "children": [ + "`build.*` — 0..1" + ], + "hasParents": false + }, + { + "typeSubType": "app.service", + "description": "A long-running process that answers requests: a web server, an API, a socket server.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Anything that listens on a port and stays up.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "public", + "type": "boolean", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The service is meant to be reached from outside every system: from browsers or from parties holding no role in the model. Absent means it is reached only by the apps and roles the model names." + }, + { + "name": "runsAs", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND." + } + ], + "hasChildren": true, + "children": [ + "`build.*` — 0..1" + ], + "hasParents": false + } + ] +} diff --git a/fixtures/metamodel-docs/data/types/build.md.json b/fixtures/metamodel-docs/data/types/build.md.json new file mode 100644 index 0000000000..2b661ddc8e --- /dev/null +++ b/fixtures/metamodel-docs/data/types/build.md.json @@ -0,0 +1,48 @@ +{ + "family": "build", + "sections": [ + { + "typeSubType": "build.base", + "description": "Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": false, + "hasExample": false, + "hasAttrs": false, + "attrs": [], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "build.image", + "description": "The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "An app whose image someone else builds: a product sold as images that the buyer deploys.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "repository", + "type": "string", + "required": "yes", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "Where the publisher keeps the image, without a tag (`registry.example.com/team/app`)." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + } + ] +} diff --git a/fixtures/metamodel-docs/data/types/metadata.md.json b/fixtures/metamodel-docs/data/types/metadata.md.json index 634987280d..e73948037e 100644 --- a/fixtures/metamodel-docs/data/types/metadata.md.json +++ b/fixtures/metamodel-docs/data/types/metadata.md.json @@ -17,7 +17,9 @@ "`api.*` — 0..*", "`field.*` — 0..*", "`object.*` — 0..*", + "`organization.company` — 0..*", "`requirement.*` — 0..*", + "`system.software` — 0..*", "`template.*` — 0..*", "`validator.*` — 0..*" ], diff --git a/fixtures/metamodel-docs/data/types/organization.md.json b/fixtures/metamodel-docs/data/types/organization.md.json new file mode 100644 index 0000000000..065d7bb814 --- /dev/null +++ b/fixtures/metamodel-docs/data/types/organization.md.json @@ -0,0 +1,60 @@ +{ + "family": "organization", + "sections": [ + { + "typeSubType": "organization.base", + "description": "Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": false, + "hasExample": false, + "hasAttrs": false, + "attrs": [], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "organization.company", + "description": "A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": true, + "rules": "Lives at the document root. Its units are its children, addressed `Company.unit` (`pkg::Company.unit` from another package).", + "hasWhenToUse": true, + "whenToUse": "Every party that owns a system or holds a token. A party that publishes no metadata is written down by whoever depends on it, under the party's own package name.", + "hasExample": false, + "hasAttrs": false, + "attrs": [], + "hasChildren": true, + "children": [ + "`organization.unit` — 0..*" + ], + "hasParents": false + }, + { + "typeSubType": "organization.unit", + "description": "A team or division inside a company. Units nest: a unit is a child of a company or of another unit.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "When a system's owner is a team rather than the whole company.", + "hasExample": false, + "hasAttrs": false, + "attrs": [], + "hasChildren": true, + "children": [ + "`organization.unit` — 0..*" + ], + "hasParents": false + } + ] +} diff --git a/fixtures/metamodel-docs/data/types/resource.md.json b/fixtures/metamodel-docs/data/types/resource.md.json new file mode 100644 index 0000000000..9bea5586f7 --- /dev/null +++ b/fixtures/metamodel-docs/data/types/resource.md.json @@ -0,0 +1,292 @@ +{ + "family": "resource", + "sections": [ + { + "typeSubType": "resource.base", + "description": "Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": false, + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "residency", + "type": "string", + "required": "no", + "default": "`free`", + "allowed": "`free`, `confined`", + "provider": "metaobjects-systems-core", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "resource.document", + "description": "A document store: records kept and fetched as whole documents.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Records whose shape is a document rather than a row.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "residency", + "type": "string", + "required": "no", + "default": "`free`", + "allowed": "`free`, `confined`", + "provider": "metaobjects-systems-core", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "resource.keyValue", + "description": "A store of values fetched by key.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "A key-value store that is the source of its data, or a cache (@volatile).", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "residency", + "type": "string", + "required": "no", + "default": "`free`", + "allowed": "`free`, `confined`", + "provider": "metaobjects-systems-core", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + }, + { + "name": "volatile", + "type": "boolean", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The contents may be lost at any moment without losing data: a cache. Absent means the store is durable." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "resource.objectStore", + "description": "Files and blobs addressed by key.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Uploaded images, exports, static assets kept outside the app.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "publicRead", + "type": "boolean", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "Anyone may read the objects without a credential. Absent means every read needs a grant." + }, + { + "name": "residency", + "type": "string", + "required": "no", + "default": "`free`", + "allowed": "`free`, `confined`", + "provider": "metaobjects-systems-core", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "resource.queue", + "description": "A message queue: each message is handed to one consumer and gone once it is handled.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Work handed from one app to another to run later.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "deadLetter", + "type": "boolean", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "A message that keeps failing is set aside rather than dropped. How many attempts come first is a setting." + }, + { + "name": "ordered", + "type": "boolean", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "Messages with the same key are delivered in the order they were sent. Absent means no order is promised." + }, + { + "name": "residency", + "type": "string", + "required": "no", + "default": "`free`", + "allowed": "`free`, `confined`", + "provider": "metaobjects-systems-core", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "resource.rdb", + "description": "A relational database: tables queried with SQL, the store of record.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Any store an app queries with SQL, whatever the product.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "residency", + "type": "string", + "required": "no", + "default": "`free`", + "allowed": "`free`, `confined`", + "provider": "metaobjects-systems-core", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + }, + { + "name": "schemas", + "type": "string[]", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The schema names the database holds. Optional and usually absent: the set can be computed from the entities' source.rdb @schema. Declaring it closes the list." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "resource.search", + "description": "A search index: documents found by text and filters.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Full-text search over records kept elsewhere.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "residency", + "type": "string", + "required": "no", + "default": "`free`", + "allowed": "`free`, `confined`", + "provider": "metaobjects-systems-core", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "resource.stream", + "description": "A retained, ordered log that many consumers read, each at its own position. A message can be read again.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Events several consumers read independently, or read again.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "residency", + "type": "string", + "required": "no", + "default": "`free`", + "allowed": "`free`, `confined`", + "provider": "metaobjects-systems-core", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "resource.volume", + "description": "A disk attached to an app that survives a restart.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "A file system path an app writes to and must keep.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "residency", + "type": "string", + "required": "no", + "default": "`free`", + "allowed": "`free`, `confined`", + "provider": "metaobjects-systems-core", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + } + ] +} diff --git a/fixtures/metamodel-docs/data/types/role.md.json b/fixtures/metamodel-docs/data/types/role.md.json new file mode 100644 index 0000000000..cfb86275ad --- /dev/null +++ b/fixtures/metamodel-docs/data/types/role.md.json @@ -0,0 +1,193 @@ +{ + "family": "role", + "sections": [ + { + "typeSubType": "role.base", + "description": "Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": false, + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "credential", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "memberOf", + "type": "string[]", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "role.group", + "description": "Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Several roles that share the same access.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "credential", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "memberOf", + "type": "string[]", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "role.service", + "description": "A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs).", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Every identity an app or job of the system acts as.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "credential", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "memberOf", + "type": "string[]", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "role.token", + "description": "Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "Access handed to something that is not one of the system's apps.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "credential", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "heldBy", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "Who was handed the token: an organization node, by name (`tidewell::Tidewell`). Optional. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node is ERR_REF_WRONG_KIND. ADR-0070 call 9 also admits a system here; that waits on the reference facet accepting more than one target type." + }, + { + "name": "memberOf", + "type": "string[]", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "role.user", + "description": "A named person, or an agent acting for one. No shared secret is generated or stored for it.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": true, + "whenToUse": "A person who signs in to a resource directly.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "credential", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "memberOf", + "type": "string[]", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + } + ] +} diff --git a/fixtures/metamodel-docs/data/types/system.md.json b/fixtures/metamodel-docs/data/types/system.md.json new file mode 100644 index 0000000000..4333f4a00d --- /dev/null +++ b/fixtures/metamodel-docs/data/types/system.md.json @@ -0,0 +1,63 @@ +{ + "family": "system", + "sections": [ + { + "typeSubType": "system.base", + "description": "Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": false, + "hasWhenToUse": false, + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "owner", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources." + } + ], + "hasChildren": false, + "children": [], + "hasParents": false + }, + { + "typeSubType": "system.software", + "description": "A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package.", + "hasOwner": true, + "owner": "metaobjects-systems-core", + "hasImplementedIn": false, + "hasPorts": false, + "hasRules": true, + "rules": "Lives at the document root. Names are unique per type within the system, so an app and a role may share a name: every reference names the type it wants.", + "hasWhenToUse": true, + "whenToUse": "Every product or service, including one somebody else runs that an app calls: write it down under its owner's package name.", + "hasExample": false, + "hasAttrs": true, + "attrs": [ + { + "name": "owner", + "type": "string", + "required": "no", + "default": "", + "allowed": "", + "provider": "metaobjects-systems-core", + "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources." + } + ], + "hasChildren": true, + "children": [ + "`app.*` — 0..*", + "`resource.*` — 0..*", + "`role.*` — 0..*" + ], + "hasParents": false + } + ] +} diff --git a/fixtures/metamodel-docs/expected/INDEX.md b/fixtures/metamodel-docs/expected/INDEX.md index 92f88f1b3e..08fd2c6d61 100644 --- a/fixtures/metamodel-docs/expected/INDEX.md +++ b/fixtures/metamodel-docs/expected/INDEX.md @@ -17,6 +17,10 @@ children and the cardinality of that subtype. Documentation attributes | --- | --- | --- | | `api.base` | Registry anchor for the declared API surface (ADR-0030, ADR-0054): not authorable. The `api` subtype axis is the interaction model, never the protocol; protocol lives in `binding.*` on each operation. | [types/api.md#apibase](types/api.md#apibase) | | `api.operational` | A named, packaged request/response surface whose children are operations (ADR-0030). It is a wire contract: two of them (`v1`, `v2`) may declare the same operation side by side. The code behind it is one service per metadata package, whose surface is the package's operations (ADR-0067). Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md). | [types/api.md#apioperational](types/api.md#apioperational) | +| `app.base` | Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). | [types/app.md#appbase](types/app.md#appbase) | +| `app.client` | Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself. | [types/app.md#appclient](types/app.md#appclient) | +| `app.job` | Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it. | [types/app.md#appjob](types/app.md#appjob) | +| `app.service` | A long-running process that answers requests: a web server, an API, a socket server. | [types/app.md#appservice](types/app.md#appservice) | | `attr.base` | Abstract base attribute — the polymorphic/unconstrained value-type marker. Stores its value type-preserved (never stringified), accepting any type; used for an untyped attr (e.g. a field's @default, whose value-type follows the owning field's subtype). Not authored directly: a `attr.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED) — this subtype is a registry anchor concrete subtypes inherit from, never a node in a document. | [types/attr.md#attrbase](types/attr.md#attrbase) | | `attr.boolean` | A boolean-valued metadata attribute. Coerces to and validates as true/false. | [types/attr.md#attrboolean](types/attr.md#attrboolean) | | `attr.class` | A class-/type-reference-valued metadata attribute. String-backed (a fully-qualified class or type name) used by binding facets. | [types/attr.md#attrclass](types/attr.md#attrclass) | @@ -30,6 +34,8 @@ children and the cardinality of that subtype. Documentation attributes | `attr.string` | A string-valued metadata attribute. Coerces to and validates as text; the default value-type for inline @-syntax attrs (array-of-string is the same subtype with isArray). | [types/attr.md#attrstring](types/attr.md#attrstring) | | `binding.base` | Registry anchor for protocol bindings (ADR-0030, ADR-0054): not authorable. | [types/binding.md#bindingbase](types/binding.md#bindingbase) | | `binding.rest` | The HTTP method and path of an operation, declared only to override the derived ones. A query is `GET`, a command `POST`; the path is `//{id}/` for an operation with a target key and `//` without one. Most models never write it. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md). | [types/binding.md#bindingrest](types/binding.md#bindingrest) | +| `build.base` | Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). | [types/build.md#buildbase](types/build.md#buildbase) | +| `build.image` | The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here. | [types/build.md#buildimage](types/build.md#buildimage) | | `dimension.attribute` | A named group-by attribute of the entity that declares it (FR-044). Groups report rows by a column value as-is. @of names Entity.field: the owning entity, or the @via terminal. @via may follow only to-one hops, so grouping by a related row's column can never multiply the measured rows. | [types/dimension.md#dimensionattribute](types/dimension.md#dimensionattribute) | | `dimension.time` | A named time dimension (FR-044): groups report rows by a date or timestamp column truncated to a grain. @of names a field.date or field.timestamp. Weeks start on Monday (ISO-8601) in every lowering. A report names it as 'dimension:grain' and the derived report field is (e.g. purchasedAtDay). | [types/dimension.md#dimensiontime](types/dimension.md#dimensiontime) | | `field.base` | Abstract base field — the shared root subtype that concrete field subtypes specialize. Carries the attrs common to every field but binds no concrete data type of its own (falls back to string). Not authored directly: a `field.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED) — this subtype is a registry anchor concrete subtypes inherit from, never a node in a document. | [types/field.md#fieldbase](types/field.md#fieldbase) | @@ -69,6 +75,9 @@ children and the cardinality of that subtype. Documentation attributes | `operation.base` | Registry anchor for the attributes every operation shares (ADR-0054): not authorable. | [types/operation.md#operationbase](types/operation.md#operationbase) | | `operation.command` | A named operation that changes state. Takes an `object.value` (ADR-0030). Its body is hand-written. The contract (ADR-0066) is that a generated shell around it loads the row, checks the permission and the current state, runs the body, and makes the guarded update in one transaction. No shell is generated yet: this vocabulary is registered, loaded and checked, and nothing is generated from it. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md). | [types/operation.md#operationcommand](types/operation.md#operationcommand) | | `operation.query` | A named operation that reads. Returns an `object.projection` (or an entity or value). It changes nothing. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md). | [types/operation.md#operationquery](types/operation.md#operationquery) | +| `organization.base` | Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). | [types/organization.md#organizationbase](types/organization.md#organizationbase) | +| `organization.company` | A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company. | [types/organization.md#organizationcompany](types/organization.md#organizationcompany) | +| `organization.unit` | A team or division inside a company. Units nest: a unit is a child of a company or of another unit. | [types/organization.md#organizationunit](types/organization.md#organizationunit) | | `origin.aggregate` | A value reduced from the related row-set reached along a relationship path (@via) from the base entity: count/sum/avg/min/max over a column (@of); any/all predicate quantifiers over a @filter; or collect (an array rollup — of the @of column, or of the carrying field.object's declared @objectRef value object when @of is omitted). | [types/origin.md#originaggregate](types/origin.md#originaggregate) | | `origin.base` | Abstract base origin — the shared root subtype for field-level provenance. A field carrying any origin.* is derived ⇒ read-only wherever it lives. The base carries no attrs of its own; concrete subtypes add their provenance attrs. Not authored directly: a `origin.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED) — this subtype is a registry anchor concrete subtypes inherit from, never a node in a document. | [types/origin.md#originbase](types/origin.md#originbase) | | `origin.computed` | A row-level value computed from the base entity's own fields via a structured expression tree (@expr). No related rows, no @via. Read-only; the expression's inferred type must equal the field's declared subType. | [types/origin.md#origincomputed](types/origin.md#origincomputed) | @@ -81,9 +90,25 @@ children and the cardinality of that subtype. Documentation attributes | `relationship.composition` | An owned containment — the parent owns the target's lifecycle; deleting the parent deletes the children (default @onDelete cascade). | [types/relationship.md#relationshipcomposition](types/relationship.md#relationshipcomposition) | | `requirement.architectural` | How the system is built, applied uniformly across the model. Its check is UNIVERSALITY, the opposite polarity to a functional requirement. What `meta verify` enforces is that a live or partial policy is applied at all — one claiming nothing is an error — not that each node it claims complies. Flat by default and object-independent; it may optionally sit in a levelled tree when a quality taxonomy is being used to organise non-functional requirements. | [types/requirement.md#requirementarchitectural](types/requirement.md#requirementarchitectural) | | `requirement.functional` | What the product does for a user, stated as one violable claim. Its check is EXISTENCE, run by `meta verify`: a live or partial claim with no implementing node anywhere in its subtree is a warning, and a named node that no longer exists is an error. Hierarchy is nesting — an L1 solution contains its L2 segments, which contain L3 services, and so on down to the levels that reference the model. | [types/requirement.md#requirementfunctional](types/requirement.md#requirementfunctional) | +| `resource.base` | Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). | [types/resource.md#resourcebase](types/resource.md#resourcebase) | +| `resource.document` | A document store: records kept and fetched as whole documents. | [types/resource.md#resourcedocument](types/resource.md#resourcedocument) | +| `resource.keyValue` | A store of values fetched by key. | [types/resource.md#resourcekeyvalue](types/resource.md#resourcekeyvalue) | +| `resource.objectStore` | Files and blobs addressed by key. | [types/resource.md#resourceobjectstore](types/resource.md#resourceobjectstore) | +| `resource.queue` | A message queue: each message is handed to one consumer and gone once it is handled. | [types/resource.md#resourcequeue](types/resource.md#resourcequeue) | +| `resource.rdb` | A relational database: tables queried with SQL, the store of record. | [types/resource.md#resourcerdb](types/resource.md#resourcerdb) | +| `resource.search` | A search index: documents found by text and filters. | [types/resource.md#resourcesearch](types/resource.md#resourcesearch) | +| `resource.stream` | A retained, ordered log that many consumers read, each at its own position. A message can be read again. | [types/resource.md#resourcestream](types/resource.md#resourcestream) | +| `resource.volume` | A disk attached to an app that survives a restart. | [types/resource.md#resourcevolume](types/resource.md#resourcevolume) | +| `role.base` | Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). | [types/role.md#rolebase](types/role.md#rolebase) | +| `role.group` | Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in. | [types/role.md#rolegroup](types/role.md#rolegroup) | +| `role.service` | A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs). | [types/role.md#roleservice](types/role.md#roleservice) | +| `role.token` | Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer. | [types/role.md#roletoken](types/role.md#roletoken) | +| `role.user` | A named person, or an agent acting for one. No shared secret is generated or stored for it. | [types/role.md#roleuser](types/role.md#roleuser) | | `segment.filter` | A named, reusable row filter on the declaring entity (FR-044). Measures and reports reference it by name; exporters emit it as a named segment. | [types/segment.md#segmentfilter](types/segment.md#segmentfilter) | | `source.base` | Abstract base source — the shared root subtype for declaring where an object's data lives (Project E). The base carries no attrs of its own; the concrete paradigm subtype (rdb) carries the physical-storage attrs, which are contributed by the db domain provider. Not authored directly: a `source.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED) — this subtype is a registry anchor concrete subtypes inherit from, never a node in a document. | [types/source.md#sourcebase](types/source.md#sourcebase) | | `source.rdb` | The relational-database paradigm source (ADR-0007): binds an object to a physical relational object. Its physical name is the @table attr (not the structural `name`), and read-only-ness is DERIVED from @kind — table is writable; view, materializedView, storedProc, and tableFunction are read-only. The @table/@kind/@role/@schema/@parameterRef attrs are contributed by the db domain provider, not by core-types. | [types/source.md#sourcerdb](types/source.md#sourcerdb) | +| `system.base` | Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). | [types/system.md#systembase](types/system.md#systembase) | +| `system.software` | A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package. | [types/system.md#systemsoftware](types/system.md#systemsoftware) | | `template.base` | Abstract base template — the shared root subtype for the fourth pillar (FR-004, ADR-0011). A template is a typed payload bound to either a rendered text artifact (prompt/output) or a tool-call envelope. The base carries no attrs of its own; concrete subtypes add their reference + governance attrs. Not authored directly: a `template.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED) — this subtype is a registry anchor concrete subtypes inherit from, never a node in a document. | [types/template.md#templatebase](types/template.md#templatebase) | | `template.output` | An output / serialization template (FR-004): every rendered artifact other than an LLM prompt — a document (email, export, docs, config) or an email. Carries the generic reference + governance attrs and the @kind + email part-refs. OUTBOUND ONLY (ADR-0052) — it renders, and generates no parser. | [types/template.md#templateoutput](types/template.md#templateoutput) | | `template.prompt` | An LLM-targeted renderable prompt template (FR-004). Carries the generic reference + governance attrs plus the LLM overlay (@maxTokens / @requiredSlots / @model / @responseRef). Its renderable body is required via @textRef. A prompt declaring @responseRef also owns the INBOUND half (ADR-0052): the parser-on-receipt, the FR-010 response-format fragment (@promptStyle), and the reply syntax (@responseFormat). | [types/template.md#templateprompt](types/template.md#templateprompt) | diff --git a/fixtures/metamodel-docs/expected/providers.md b/fixtures/metamodel-docs/expected/providers.md index 31fcd397b0..e1893b0a06 100644 --- a/fixtures/metamodel-docs/expected/providers.md +++ b/fixtures/metamodel-docs/expected/providers.md @@ -171,6 +171,28 @@ Business rules (ADR-0066, experimental): the declared API surface (api / operati - `transition.action`: `@condition`, `@from`, `@to` - `transition.base`: `@permission`, `@public` +## metaobjects-systems-core + +Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role. + +**Owns (registers):** `app.base`, `app.client`, `app.job`, `app.service`, `build.base`, `build.image`, `organization.base`, `organization.company`, `organization.unit`, `resource.base`, `resource.document`, `resource.keyValue`, `resource.objectStore`, `resource.queue`, `resource.rdb`, `resource.search`, `resource.stream`, `resource.volume`, `role.base`, `role.group`, `role.service`, `role.token`, `role.user`, `system.base`, `system.software` + +**Contributes attributes:** + +- `app.base`: `@runsAs` +- `app.client`: `@shell` +- `app.job`: `@schedule` +- `app.service`: `@public` +- `build.image`: `@repository` +- `resource.base`: `@residency` +- `resource.keyValue`: `@volatile` +- `resource.objectStore`: `@publicRead` +- `resource.queue`: `@deadLetter`, `@ordered` +- `resource.rdb`: `@schemas` +- `role.base`: `@credential`, `@memberOf` +- `role.token`: `@heldBy` +- `system.base`: `@owner` + ## metaobjects-ui UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D). diff --git a/fixtures/metamodel-docs/expected/types/app.md b/fixtures/metamodel-docs/expected/types/app.md new file mode 100644 index 0000000000..8fbcfc1ec1 --- /dev/null +++ b/fixtures/metamodel-docs/expected/types/app.md @@ -0,0 +1,85 @@ + + +# Metamodel — `app` types + +Each section below is one `app.`. The **Attributes** table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see [providers.md](../providers.md)). +**Allowed children** lists the structural child rules with their cardinality +(`min..max`, `*` = unbounded). + +### app.base + +Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). + +**Owning provider:** metaobjects-systems-core + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@runsAs` | string | no | | | metaobjects-systems-core | The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND. | + +**Allowed children** + +- `build.*` — 0..1 + +### app.client + +Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself. + +**Owning provider:** metaobjects-systems-core + +**When to use:** A front end built and shipped as files, whatever serves them. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@runsAs` | string | no | | | metaobjects-systems-core | The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND. | +| `@shell` | string | no | | | metaobjects-systems-core | The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here. | + +**Allowed children** + +- `build.*` — 0..1 + +### app.job + +Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it. + +**Owning provider:** metaobjects-systems-core + +**When to use:** A cron job, a nightly import, a queue drain that is not a long-running service. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@runsAs` | string | no | | | metaobjects-systems-core | The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND. | +| `@schedule` | string | no | | | metaobjects-systems-core | When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered. | + +**Allowed children** + +- `build.*` — 0..1 + +### app.service + +A long-running process that answers requests: a web server, an API, a socket server. + +**Owning provider:** metaobjects-systems-core + +**When to use:** Anything that listens on a port and stays up. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@public` | boolean | no | | | metaobjects-systems-core | The service is meant to be reached from outside every system: from browsers or from parties holding no role in the model. Absent means it is reached only by the apps and roles the model names. | +| `@runsAs` | string | no | | | metaobjects-systems-core | The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND. | + +**Allowed children** + +- `build.*` — 0..1 + diff --git a/fixtures/metamodel-docs/expected/types/build.md b/fixtures/metamodel-docs/expected/types/build.md new file mode 100644 index 0000000000..a9fed323bf --- /dev/null +++ b/fixtures/metamodel-docs/expected/types/build.md @@ -0,0 +1,44 @@ + + +# Metamodel — `build` types + +Each section below is one `build.`. The **Attributes** table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see [providers.md](../providers.md)). +**Allowed children** lists the structural child rules with their cardinality +(`min..max`, `*` = unbounded). + +### build.base + +Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). + +**Owning provider:** metaobjects-systems-core + +**Attributes** + +_No subtype-specific attributes._ + +**Allowed children** + +_No structural children._ + +### build.image + +The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here. + +**Owning provider:** metaobjects-systems-core + +**When to use:** An app whose image someone else builds: a product sold as images that the buyer deploys. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@repository` | string | yes | | | metaobjects-systems-core | Where the publisher keeps the image, without a tag (`registry.example.com/team/app`). | + +**Allowed children** + +_No structural children._ + diff --git a/fixtures/metamodel-docs/expected/types/metadata.md b/fixtures/metamodel-docs/expected/types/metadata.md index af784b718b..26b9ae07f6 100644 --- a/fixtures/metamodel-docs/expected/types/metadata.md +++ b/fixtures/metamodel-docs/expected/types/metadata.md @@ -23,7 +23,9 @@ _No subtype-specific attributes._ - `api.*` — 0..* - `field.*` — 0..* - `object.*` — 0..* +- `organization.company` — 0..* - `requirement.*` — 0..* +- `system.software` — 0..* - `template.*` — 0..* - `validator.*` — 0..* diff --git a/fixtures/metamodel-docs/expected/types/organization.md b/fixtures/metamodel-docs/expected/types/organization.md new file mode 100644 index 0000000000..d7b6dbc93d --- /dev/null +++ b/fixtures/metamodel-docs/expected/types/organization.md @@ -0,0 +1,60 @@ + + +# Metamodel — `organization` types + +Each section below is one `organization.`. The **Attributes** table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see [providers.md](../providers.md)). +**Allowed children** lists the structural child rules with their cardinality +(`min..max`, `*` = unbounded). + +### organization.base + +Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). + +**Owning provider:** metaobjects-systems-core + +**Attributes** + +_No subtype-specific attributes._ + +**Allowed children** + +_No structural children._ + +### organization.company + +A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company. + +**Owning provider:** metaobjects-systems-core + +**Rules:** Lives at the document root. Its units are its children, addressed `Company.unit` (`pkg::Company.unit` from another package). + +**When to use:** Every party that owns a system or holds a token. A party that publishes no metadata is written down by whoever depends on it, under the party's own package name. + +**Attributes** + +_No subtype-specific attributes._ + +**Allowed children** + +- `organization.unit` — 0..* + +### organization.unit + +A team or division inside a company. Units nest: a unit is a child of a company or of another unit. + +**Owning provider:** metaobjects-systems-core + +**When to use:** When a system's owner is a team rather than the whole company. + +**Attributes** + +_No subtype-specific attributes._ + +**Allowed children** + +- `organization.unit` — 0..* + diff --git a/fixtures/metamodel-docs/expected/types/resource.md b/fixtures/metamodel-docs/expected/types/resource.md new file mode 100644 index 0000000000..1063ea9314 --- /dev/null +++ b/fixtures/metamodel-docs/expected/types/resource.md @@ -0,0 +1,177 @@ + + +# Metamodel — `resource` types + +Each section below is one `resource.`. The **Attributes** table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see [providers.md](../providers.md)). +**Allowed children** lists the structural child rules with their cardinality +(`min..max`, `*` = unbounded). + +### resource.base + +Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). + +**Owning provider:** metaobjects-systems-core + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@residency` | string | no | `free` | `free`, `confined` | metaobjects-systems-core | Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit. | + +**Allowed children** + +_No structural children._ + +### resource.document + +A document store: records kept and fetched as whole documents. + +**Owning provider:** metaobjects-systems-core + +**When to use:** Records whose shape is a document rather than a row. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@residency` | string | no | `free` | `free`, `confined` | metaobjects-systems-core | Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit. | + +**Allowed children** + +_No structural children._ + +### resource.keyValue + +A store of values fetched by key. + +**Owning provider:** metaobjects-systems-core + +**When to use:** A key-value store that is the source of its data, or a cache (@volatile). + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@residency` | string | no | `free` | `free`, `confined` | metaobjects-systems-core | Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit. | +| `@volatile` | boolean | no | | | metaobjects-systems-core | The contents may be lost at any moment without losing data: a cache. Absent means the store is durable. | + +**Allowed children** + +_No structural children._ + +### resource.objectStore + +Files and blobs addressed by key. + +**Owning provider:** metaobjects-systems-core + +**When to use:** Uploaded images, exports, static assets kept outside the app. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@publicRead` | boolean | no | | | metaobjects-systems-core | Anyone may read the objects without a credential. Absent means every read needs a grant. | +| `@residency` | string | no | `free` | `free`, `confined` | metaobjects-systems-core | Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit. | + +**Allowed children** + +_No structural children._ + +### resource.queue + +A message queue: each message is handed to one consumer and gone once it is handled. + +**Owning provider:** metaobjects-systems-core + +**When to use:** Work handed from one app to another to run later. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@deadLetter` | boolean | no | | | metaobjects-systems-core | A message that keeps failing is set aside rather than dropped. How many attempts come first is a setting. | +| `@ordered` | boolean | no | | | metaobjects-systems-core | Messages with the same key are delivered in the order they were sent. Absent means no order is promised. | +| `@residency` | string | no | `free` | `free`, `confined` | metaobjects-systems-core | Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit. | + +**Allowed children** + +_No structural children._ + +### resource.rdb + +A relational database: tables queried with SQL, the store of record. + +**Owning provider:** metaobjects-systems-core + +**When to use:** Any store an app queries with SQL, whatever the product. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@residency` | string | no | `free` | `free`, `confined` | metaobjects-systems-core | Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit. | +| `@schemas` | string[] | no | | | metaobjects-systems-core | The schema names the database holds. Optional and usually absent: the set can be computed from the entities' source.rdb @schema. Declaring it closes the list. | + +**Allowed children** + +_No structural children._ + +### resource.search + +A search index: documents found by text and filters. + +**Owning provider:** metaobjects-systems-core + +**When to use:** Full-text search over records kept elsewhere. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@residency` | string | no | `free` | `free`, `confined` | metaobjects-systems-core | Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit. | + +**Allowed children** + +_No structural children._ + +### resource.stream + +A retained, ordered log that many consumers read, each at its own position. A message can be read again. + +**Owning provider:** metaobjects-systems-core + +**When to use:** Events several consumers read independently, or read again. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@residency` | string | no | `free` | `free`, `confined` | metaobjects-systems-core | Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit. | + +**Allowed children** + +_No structural children._ + +### resource.volume + +A disk attached to an app that survives a restart. + +**Owning provider:** metaobjects-systems-core + +**When to use:** A file system path an app writes to and must keep. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@residency` | string | no | `free` | `free`, `confined` | metaobjects-systems-core | Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit. | + +**Allowed children** + +_No structural children._ + diff --git a/fixtures/metamodel-docs/expected/types/role.md b/fixtures/metamodel-docs/expected/types/role.md new file mode 100644 index 0000000000..24a6a92f6a --- /dev/null +++ b/fixtures/metamodel-docs/expected/types/role.md @@ -0,0 +1,106 @@ + + +# Metamodel — `role` types + +Each section below is one `role.`. The **Attributes** table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see [providers.md](../providers.md)). +**Allowed children** lists the structural child rules with their cardinality +(`min..max`, `*` = unbounded). + +### role.base + +Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). + +**Owning provider:** metaobjects-systems-core + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@credential` | string | no | | | metaobjects-systems-core | The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name. | +| `@memberOf` | string[] | no | | | metaobjects-systems-core | The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND. | + +**Allowed children** + +_No structural children._ + +### role.group + +Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in. + +**Owning provider:** metaobjects-systems-core + +**When to use:** Several roles that share the same access. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@credential` | string | no | | | metaobjects-systems-core | The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name. | +| `@memberOf` | string[] | no | | | metaobjects-systems-core | The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND. | + +**Allowed children** + +_No structural children._ + +### role.service + +A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs). + +**Owning provider:** metaobjects-systems-core + +**When to use:** Every identity an app or job of the system acts as. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@credential` | string | no | | | metaobjects-systems-core | The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name. | +| `@memberOf` | string[] | no | | | metaobjects-systems-core | The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND. | + +**Allowed children** + +_No structural children._ + +### role.token + +Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer. + +**Owning provider:** metaobjects-systems-core + +**When to use:** Access handed to something that is not one of the system's apps. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@credential` | string | no | | | metaobjects-systems-core | The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name. | +| `@heldBy` | string | no | | | metaobjects-systems-core | Who was handed the token: an organization node, by name (`tidewell::Tidewell`). Optional. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node is ERR_REF_WRONG_KIND. ADR-0070 call 9 also admits a system here; that waits on the reference facet accepting more than one target type. | +| `@memberOf` | string[] | no | | | metaobjects-systems-core | The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND. | + +**Allowed children** + +_No structural children._ + +### role.user + +A named person, or an agent acting for one. No shared secret is generated or stored for it. + +**Owning provider:** metaobjects-systems-core + +**When to use:** A person who signs in to a resource directly. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@credential` | string | no | | | metaobjects-systems-core | The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name. | +| `@memberOf` | string[] | no | | | metaobjects-systems-core | The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND. | + +**Allowed children** + +_No structural children._ + diff --git a/fixtures/metamodel-docs/expected/types/system.md b/fixtures/metamodel-docs/expected/types/system.md new file mode 100644 index 0000000000..a3e3705bfe --- /dev/null +++ b/fixtures/metamodel-docs/expected/types/system.md @@ -0,0 +1,50 @@ + + +# Metamodel — `system` types + +Each section below is one `system.`. The **Attributes** table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see [providers.md](../providers.md)). +**Allowed children** lists the structural child rules with their cardinality +(`min..max`, `*` = unbounded). + +### system.base + +Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). + +**Owning provider:** metaobjects-systems-core + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@owner` | string | no | | | metaobjects-systems-core | The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources. | + +**Allowed children** + +_No structural children._ + +### system.software + +A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package. + +**Owning provider:** metaobjects-systems-core + +**Rules:** Lives at the document root. Names are unique per type within the system, so an app and a role may share a name: every reference names the type it wants. + +**When to use:** Every product or service, including one somebody else runs that an app calls: write it down under its owner's package name. + +**Attributes** + +| Attribute | Type | Required | Default | Allowed values | Provider | Description | +| --- | --- | --- | --- | --- | --- | --- | +| `@owner` | string | no | | | metaobjects-systems-core | The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources. | + +**Allowed children** + +- `app.*` — 0..* +- `resource.*` — 0..* +- `role.*` — 0..* + diff --git a/fixtures/registry-conformance/coverage-report.json b/fixtures/registry-conformance/coverage-report.json index 8ab7726a43..5495f572d1 100644 --- a/fixtures/registry-conformance/coverage-report.json +++ b/fixtures/registry-conformance/coverage-report.json @@ -1,6 +1,6 @@ { - "registeredSubTypeCount": 86, - "exercisedSubTypeCount": 78, + "registeredSubTypeCount": 106, + "exercisedSubTypeCount": 98, "untestedSubTypes": [ "attr.boolean", "attr.class", @@ -12,6 +12,12 @@ "attr.long" ], "untestedAttrsByExercisedSubType": [ + { + "key": "app.client", + "untestedAttrs": [ + "runsAs" + ] + }, { "key": "field.boolean", "untestedAttrs": [ @@ -279,7 +285,6 @@ "formExclude", "instruction", "mutability", - "sortable", "sortableDefaultOrder", "xmlText" ] @@ -328,6 +333,67 @@ "symmetric" ] }, + { + "key": "resource.document", + "untestedAttrs": [ + "residency" + ] + }, + { + "key": "resource.keyValue", + "untestedAttrs": [ + "residency" + ] + }, + { + "key": "resource.objectStore", + "untestedAttrs": [ + "residency" + ] + }, + { + "key": "resource.queue", + "untestedAttrs": [ + "residency" + ] + }, + { + "key": "resource.stream", + "untestedAttrs": [ + "residency" + ] + }, + { + "key": "resource.volume", + "untestedAttrs": [ + "residency" + ] + }, + { + "key": "role.group", + "untestedAttrs": [ + "credential", + "memberOf" + ] + }, + { + "key": "role.service", + "untestedAttrs": [ + "credential" + ] + }, + { + "key": "role.token", + "untestedAttrs": [ + "memberOf" + ] + }, + { + "key": "role.user", + "untestedAttrs": [ + "credential" + ] + }, { "key": "template.output", "untestedAttrs": [ diff --git a/fixtures/registry-conformance/expected-registry.json b/fixtures/registry-conformance/expected-registry.json index fa91431504..6ec4e0cd79 100644 --- a/fixtures/registry-conformance/expected-registry.json +++ b/fixtures/registry-conformance/expected-registry.json @@ -1,5 +1,5 @@ { - "metamodelVersion": "1.3", + "metamodelVersion": "1.4", "types": [ { "type": "api", @@ -25,6 +25,146 @@ } ] }, + { + "type": "app", + "subType": "base", + "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "attrs": [ + { + "name": "runsAs", + "valueType": "string", + "isArray": false, + "required": false, + "ref": { + "targetType": "role", + "targetSubTypes": [ + "service" + ] + }, + "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND." + } + ], + "children": [ + { + "childType": "build", + "childSubType": "*", + "childName": "*", + "min": 0, + "max": 1 + } + ] + }, + { + "type": "app", + "subType": "client", + "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", + "whenToUse": "A front end built and shipped as files, whatever serves them.", + "attrs": [ + { + "name": "runsAs", + "valueType": "string", + "isArray": false, + "required": false, + "ref": { + "targetType": "role", + "targetSubTypes": [ + "service" + ] + }, + "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND." + }, + { + "name": "shell", + "valueType": "string", + "isArray": false, + "required": false, + "description": "The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here." + } + ], + "children": [ + { + "childType": "build", + "childSubType": "*", + "childName": "*", + "min": 0, + "max": 1 + } + ] + }, + { + "type": "app", + "subType": "job", + "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", + "whenToUse": "A cron job, a nightly import, a queue drain that is not a long-running service.", + "attrs": [ + { + "name": "runsAs", + "valueType": "string", + "isArray": false, + "required": false, + "ref": { + "targetType": "role", + "targetSubTypes": [ + "service" + ] + }, + "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND." + }, + { + "name": "schedule", + "valueType": "string", + "isArray": false, + "required": false, + "description": "When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered." + } + ], + "children": [ + { + "childType": "build", + "childSubType": "*", + "childName": "*", + "min": 0, + "max": 1 + } + ] + }, + { + "type": "app", + "subType": "service", + "description": "A long-running process that answers requests: a web server, an API, a socket server.", + "whenToUse": "Anything that listens on a port and stays up.", + "attrs": [ + { + "name": "public", + "valueType": "boolean", + "isArray": false, + "required": false, + "description": "The service is meant to be reached from outside every system: from browsers or from parties holding no role in the model. Absent means it is reached only by the apps and roles the model names." + }, + { + "name": "runsAs", + "valueType": "string", + "isArray": false, + "required": false, + "ref": { + "targetType": "role", + "targetSubTypes": [ + "service" + ] + }, + "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND." + } + ], + "children": [ + { + "childType": "build", + "childSubType": "*", + "childName": "*", + "min": 0, + "max": 1 + } + ] + }, { "type": "attr", "subType": "base", @@ -139,6 +279,29 @@ ], "children": [] }, + { + "type": "build", + "subType": "base", + "description": "Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "attrs": [], + "children": [] + }, + { + "type": "build", + "subType": "image", + "description": "The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here.", + "whenToUse": "An app whose image someone else builds: a product sold as images that the buyer deploys.", + "attrs": [ + { + "name": "repository", + "valueType": "string", + "isArray": false, + "required": true, + "description": "Where the publisher keeps the image, without a tag (`registry.example.com/team/app`)." + } + ], + "children": [] + }, { "type": "dimension", "subType": "attribute", @@ -3450,6 +3613,13 @@ "childSubType": "*", "childName": "*" }, + { + "childType": "organization", + "childSubType": "company", + "childName": "*", + "min": 0, + "max": null + }, { "childType": "requirement", "childSubType": "*", @@ -3457,6 +3627,13 @@ "min": 0, "max": null }, + { + "childType": "system", + "childSubType": "software", + "childName": "*", + "min": 0, + "max": null + }, { "childType": "template", "childSubType": "*", @@ -4203,6 +4380,46 @@ } ] }, + { + "type": "organization", + "subType": "base", + "description": "Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "attrs": [], + "children": [] + }, + { + "type": "organization", + "subType": "company", + "description": "A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company.", + "rules": "Lives at the document root. Its units are its children, addressed `Company.unit` (`pkg::Company.unit` from another package).", + "whenToUse": "Every party that owns a system or holds a token. A party that publishes no metadata is written down by whoever depends on it, under the party's own package name.", + "attrs": [], + "children": [ + { + "childType": "organization", + "childSubType": "unit", + "childName": "*", + "min": 0, + "max": null + } + ] + }, + { + "type": "organization", + "subType": "unit", + "description": "A team or division inside a company. Units nest: a unit is a child of a company or of another unit.", + "whenToUse": "When a system's owner is a team rather than the whole company.", + "attrs": [], + "children": [ + { + "childType": "organization", + "childSubType": "unit", + "childName": "*", + "min": 0, + "max": null + } + ] + }, { "type": "origin", "subType": "aggregate", @@ -4884,6 +5101,374 @@ } ] }, + { + "type": "resource", + "subType": "base", + "description": "Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "attrs": [ + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "children": [] + }, + { + "type": "resource", + "subType": "document", + "description": "A document store: records kept and fetched as whole documents.", + "whenToUse": "Records whose shape is a document rather than a row.", + "attrs": [ + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "children": [] + }, + { + "type": "resource", + "subType": "keyValue", + "description": "A store of values fetched by key.", + "whenToUse": "A key-value store that is the source of its data, or a cache (@volatile).", + "attrs": [ + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + }, + { + "name": "volatile", + "valueType": "boolean", + "isArray": false, + "required": false, + "description": "The contents may be lost at any moment without losing data: a cache. Absent means the store is durable." + } + ], + "children": [] + }, + { + "type": "resource", + "subType": "objectStore", + "description": "Files and blobs addressed by key.", + "whenToUse": "Uploaded images, exports, static assets kept outside the app.", + "attrs": [ + { + "name": "publicRead", + "valueType": "boolean", + "isArray": false, + "required": false, + "description": "Anyone may read the objects without a credential. Absent means every read needs a grant." + }, + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "children": [] + }, + { + "type": "resource", + "subType": "queue", + "description": "A message queue: each message is handed to one consumer and gone once it is handled.", + "whenToUse": "Work handed from one app to another to run later.", + "attrs": [ + { + "name": "deadLetter", + "valueType": "boolean", + "isArray": false, + "required": false, + "description": "A message that keeps failing is set aside rather than dropped. How many attempts come first is a setting." + }, + { + "name": "ordered", + "valueType": "boolean", + "isArray": false, + "required": false, + "description": "Messages with the same key are delivered in the order they were sent. Absent means no order is promised." + }, + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "children": [] + }, + { + "type": "resource", + "subType": "rdb", + "description": "A relational database: tables queried with SQL, the store of record.", + "whenToUse": "Any store an app queries with SQL, whatever the product.", + "attrs": [ + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + }, + { + "name": "schemas", + "valueType": "string", + "isArray": true, + "required": false, + "description": "The schema names the database holds. Optional and usually absent: the set can be computed from the entities' source.rdb @schema. Declaring it closes the list." + } + ], + "children": [] + }, + { + "type": "resource", + "subType": "search", + "description": "A search index: documents found by text and filters.", + "whenToUse": "Full-text search over records kept elsewhere.", + "attrs": [ + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "children": [] + }, + { + "type": "resource", + "subType": "stream", + "description": "A retained, ordered log that many consumers read, each at its own position. A message can be read again.", + "whenToUse": "Events several consumers read independently, or read again.", + "attrs": [ + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "children": [] + }, + { + "type": "resource", + "subType": "volume", + "description": "A disk attached to an app that survives a restart.", + "whenToUse": "A file system path an app writes to and must keep.", + "attrs": [ + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ], + "children": [] + }, + { + "type": "role", + "subType": "base", + "description": "Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "attrs": [ + { + "name": "credential", + "valueType": "string", + "isArray": false, + "required": false, + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "memberOf", + "valueType": "string", + "isArray": true, + "required": false, + "ref": { + "targetType": "role", + "targetSubTypes": [ + "group" + ] + }, + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "children": [] + }, + { + "type": "role", + "subType": "group", + "description": "Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in.", + "whenToUse": "Several roles that share the same access.", + "attrs": [ + { + "name": "credential", + "valueType": "string", + "isArray": false, + "required": false, + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "memberOf", + "valueType": "string", + "isArray": true, + "required": false, + "ref": { + "targetType": "role", + "targetSubTypes": [ + "group" + ] + }, + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "children": [] + }, + { + "type": "role", + "subType": "service", + "description": "A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs).", + "whenToUse": "Every identity an app or job of the system acts as.", + "attrs": [ + { + "name": "credential", + "valueType": "string", + "isArray": false, + "required": false, + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "memberOf", + "valueType": "string", + "isArray": true, + "required": false, + "ref": { + "targetType": "role", + "targetSubTypes": [ + "group" + ] + }, + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "children": [] + }, + { + "type": "role", + "subType": "token", + "description": "Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer.", + "whenToUse": "Access handed to something that is not one of the system's apps.", + "attrs": [ + { + "name": "credential", + "valueType": "string", + "isArray": false, + "required": false, + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "heldBy", + "valueType": "string", + "isArray": false, + "required": false, + "ref": { + "targetType": "organization" + }, + "description": "Who was handed the token: an organization node, by name (`tidewell::Tidewell`). Optional. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node is ERR_REF_WRONG_KIND. ADR-0070 call 9 also admits a system here; that waits on the reference facet accepting more than one target type." + }, + { + "name": "memberOf", + "valueType": "string", + "isArray": true, + "required": false, + "ref": { + "targetType": "role", + "targetSubTypes": [ + "group" + ] + }, + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "children": [] + }, + { + "type": "role", + "subType": "user", + "description": "A named person, or an agent acting for one. No shared secret is generated or stored for it.", + "whenToUse": "A person who signs in to a resource directly.", + "attrs": [ + { + "name": "credential", + "valueType": "string", + "isArray": false, + "required": false, + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + }, + { + "name": "memberOf", + "valueType": "string", + "isArray": true, + "required": false, + "ref": { + "targetType": "role", + "targetSubTypes": [ + "group" + ] + }, + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND." + } + ], + "children": [] + }, { "type": "segment", "subType": "filter", @@ -5005,6 +5590,66 @@ ], "children": [] }, + { + "type": "system", + "subType": "base", + "description": "Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "attrs": [ + { + "name": "owner", + "valueType": "string", + "isArray": false, + "required": false, + "ref": { + "targetType": "organization" + }, + "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources." + } + ], + "children": [] + }, + { + "type": "system", + "subType": "software", + "description": "A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package.", + "rules": "Lives at the document root. Names are unique per type within the system, so an app and a role may share a name: every reference names the type it wants.", + "whenToUse": "Every product or service, including one somebody else runs that an app calls: write it down under its owner's package name.", + "attrs": [ + { + "name": "owner", + "valueType": "string", + "isArray": false, + "required": false, + "ref": { + "targetType": "organization" + }, + "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources." + } + ], + "children": [ + { + "childType": "app", + "childSubType": "*", + "childName": "*", + "min": 0, + "max": null + }, + { + "childType": "resource", + "childSubType": "*", + "childName": "*", + "min": 0, + "max": null + }, + { + "childType": "role", + "childSubType": "*", + "childName": "*", + "min": 0, + "max": null + } + ] + }, { "type": "template", "subType": "base", diff --git a/fixtures/registry-conformance/providers.json b/fixtures/registry-conformance/providers.json index fee207043c..4199b7c224 100644 --- a/fixtures/registry-conformance/providers.json +++ b/fixtures/registry-conformance/providers.json @@ -77,6 +77,12 @@ "metadata.root" ] }, + "metaobjects-systems-core": { + "declaresTypes": true, + "projectsOnto": [ + "metadata.root" + ] + }, "metaobjects-ui": { "declaresTypes": false, "projectsOnto": [ diff --git a/fixtures/requirement-harness/csharp/RequirementHarnessTests.cs b/fixtures/requirement-harness/csharp/RequirementHarnessTests.cs index e11dd100f6..b64d472065 100644 --- a/fixtures/requirement-harness/csharp/RequirementHarnessTests.cs +++ b/fixtures/requirement-harness/csharp/RequirementHarnessTests.cs @@ -1,6 +1,6 @@ // @generated by scripts/generate-requirement-harness.ts — DO NOT EDIT IN PLACE. // -// One slot per authored promise in metaobjects/meta.requirements.yaml (124 of them). +// One slot per authored promise in metaobjects/meta.requirements.yaml (143 of them). // Every slot is SKIPPED: this is a to-do list with a drift gate behind it, not a // claim that nothing is verified — the conformance corpora already check many of // these. To FILL one, move it into C#'s own suite and write the assertion the @@ -388,6 +388,82 @@ public void declare_reporting_measureRatio() { /* metaobjects.declare.reporting. [Fact(Skip = "planned — not built yet")] public void declare_reporting_segmentFilter() { /* metaobjects.declare.reporting.segmentFilter */ } + // Client — A client is code that runs on the user's device, and names the shell that presents it. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A client app modelled as a service, so every rule meant for a server is applied to a browser bundle.")] + public void declare_systemsAndRoles_appClient() { /* metaobjects.declare.systemsAndRoles.appClient */ } + + // Job — A job is work that runs to completion, on a cron schedule read in UTC. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A nightly job that runs at two different hours in two regions.")] + public void declare_systemsAndRoles_appJob() { /* metaobjects.declare.systemsAndRoles.appJob */ } + + // Service — A service is a long-running process that answers requests, and says whether it is public. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A public endpoint nobody can find in the model because only its deploy file says so.")] + public void declare_systemsAndRoles_appService() { /* metaobjects.declare.systemsAndRoles.appService */ } + + // Image build — An image build names the repository an app's image is pulled from, which is all a platform needs to run an image built elsewhere. + [Fact(Skip = "unfilled slot — write an assertion that fails when: An app with no recorded build, deployed from whichever image tag someone last pushed.")] + public void declare_systemsAndRoles_buildImage() { /* metaobjects.declare.systemsAndRoles.buildImage */ } + + // Company — A company is the top of an ownership tree, so a system names who answers for it. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A system whose owner is a free-text team name nobody can check.")] + public void declare_systemsAndRoles_organizationCompany() { /* metaobjects.declare.systemsAndRoles.organizationCompany */ } + + // Organizational unit — A unit nests inside a company or another unit, and a reference to it names the whole path. + [Fact(Skip = "unfilled slot — write an assertion that fails when: An owner that still resolves after the team it named was folded into another.")] + public void declare_systemsAndRoles_organizationUnit() { /* metaobjects.declare.systemsAndRoles.organizationUnit */ } + + // Document store — A document store is a resource holding documents by key, distinct from a relational database. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A document store modelled as a relational database, so a migration tool proposes tables for it.")] + public void declare_systemsAndRoles_resourceDocument() { /* metaobjects.declare.systemsAndRoles.resourceDocument */ } + + // Key-value store — A key-value store is a resource that says whether its contents can be lost without losing data. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A cache treated as the source of record because the model did not say it was volatile.")] + public void declare_systemsAndRoles_resourceKeyValue() { /* metaobjects.declare.systemsAndRoles.resourceKeyValue */ } + + // Object store — An object store holds files by key and says whether anyone may read them without credentials. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A bucket made public by a console click, with nothing in the model to catch it.")] + public void declare_systemsAndRoles_resourceObjectStore() { /* metaobjects.declare.systemsAndRoles.resourceObjectStore */ } + + // Queue — A queue is a resource that says whether it keeps order and whether undelivered messages go to a dead-letter queue. + [Fact(Skip = "unfilled slot — write an assertion that fails when: Messages lost after their last retry because nothing declared where they go.")] + public void declare_systemsAndRoles_resourceQueue() { /* metaobjects.declare.systemsAndRoles.resourceQueue */ } + + // Relational database — A relational database is a resource with named schemas, which may be confined to its residency. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A database confined by policy, copied out because nothing in the model said so.")] + public void declare_systemsAndRoles_resourceRdb() { /* metaobjects.declare.systemsAndRoles.resourceRdb */ } + + // Search index — A search index is a resource derived from other data, so it can be rebuilt rather than restored. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A search index backed up and restored as though it were the source of its data.")] + public void declare_systemsAndRoles_resourceSearch() { /* metaobjects.declare.systemsAndRoles.resourceSearch */ } + + // Stream — A stream is a resource whose records are read in order by more than one consumer. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A stream modelled as a queue, so a second consumer silently takes messages from the first.")] + public void declare_systemsAndRoles_resourceStream() { /* metaobjects.declare.systemsAndRoles.resourceStream */ } + + // Volume — A volume is a resource of disk mounted into an app's process. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A process writing files it expects to keep onto a filesystem that is discarded on restart.")] + public void declare_systemsAndRoles_resourceVolume() { /* metaobjects.declare.systemsAndRoles.resourceVolume */ } + + // Group role — A group role collects other roles, and memberOf may name only a group. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A role listed as a member of another person's role, granting that person's access.")] + public void declare_systemsAndRoles_roleGroup() { /* metaobjects.declare.systemsAndRoles.roleGroup */ } + + // Service role — A service role is the identity an app runs as, and an app's runsAs must name one. + [Fact(Skip = "unfilled slot — write an assertion that fails when: An app whose runsAs names a database, accepted because a node of that name existed.")] + public void declare_systemsAndRoles_roleService() { /* metaobjects.declare.systemsAndRoles.roleService */ } + + // Token role — A token role is a credential held by an organization, recorded by where the secret lives rather than by its value. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A shared API token whose holder is unknown when it has to be rotated.")] + public void declare_systemsAndRoles_roleToken() { /* metaobjects.declare.systemsAndRoles.roleToken */ } + + // User role — A user role is a person's identity, which may belong to groups. + [Fact(Skip = "unfilled slot — write an assertion that fails when: A person granted access under a service identity, so the audit trail names a process.")] + public void declare_systemsAndRoles_roleUser() { /* metaobjects.declare.systemsAndRoles.roleUser */ } + + // Software system — A software system holds the apps, resources and roles that make it up, and names the organization that owns it. + [Fact(Skip = "unfilled slot — write an assertion that fails when: An owner that names a resource, accepted because the name happened to exist.")] + public void declare_systemsAndRoles_systemSoftware() { /* metaobjects.declare.systemsAndRoles.systemSoftware */ } + // Boolean — A boolean field holds exactly true or false, and never a third state standing in for absent. [Fact(Skip = "unfilled slot — write an assertion that fails when: An unanswered question stored as false, so nobody can tell it apart from an answer of no.")] public void declare_typedFieldVocabulary_fieldBoolean() { /* metaobjects.declare.typedFieldVocabulary.fieldBoolean */ } diff --git a/fixtures/requirement-harness/java/RequirementHarnessTest.java b/fixtures/requirement-harness/java/RequirementHarnessTest.java index fb187f2e09..ceb001128b 100644 --- a/fixtures/requirement-harness/java/RequirementHarnessTest.java +++ b/fixtures/requirement-harness/java/RequirementHarnessTest.java @@ -1,6 +1,6 @@ // @generated by scripts/generate-requirement-harness.ts — DO NOT EDIT IN PLACE. // -// One slot per authored promise in metaobjects/meta.requirements.yaml (124 of them). +// One slot per authored promise in metaobjects/meta.requirements.yaml (143 of them). // Every slot is SKIPPED: this is a to-do list with a drift gate behind it, not a // claim that nothing is verified — the conformance corpora already check many of // these. To FILL one, move it into Java's own suite and write the assertion the @@ -482,6 +482,101 @@ void declare_reporting_measureRatio() { /* metaobjects.declare.reporting.measure @Disabled("planned — not built yet") void declare_reporting_segmentFilter() { /* metaobjects.declare.reporting.segmentFilter */ } + // Client — A client is code that runs on the user's device, and names the shell that presents it. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A client app modelled as a service, so every rule meant for a server is applied to a browser bundle.") + void declare_systemsAndRoles_appClient() { /* metaobjects.declare.systemsAndRoles.appClient */ } + + // Job — A job is work that runs to completion, on a cron schedule read in UTC. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A nightly job that runs at two different hours in two regions.") + void declare_systemsAndRoles_appJob() { /* metaobjects.declare.systemsAndRoles.appJob */ } + + // Service — A service is a long-running process that answers requests, and says whether it is public. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A public endpoint nobody can find in the model because only its deploy file says so.") + void declare_systemsAndRoles_appService() { /* metaobjects.declare.systemsAndRoles.appService */ } + + // Image build — An image build names the repository an app's image is pulled from, which is all a platform needs to run an image built elsewhere. + @Test + @Disabled("unfilled slot — write an assertion that fails when: An app with no recorded build, deployed from whichever image tag someone last pushed.") + void declare_systemsAndRoles_buildImage() { /* metaobjects.declare.systemsAndRoles.buildImage */ } + + // Company — A company is the top of an ownership tree, so a system names who answers for it. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A system whose owner is a free-text team name nobody can check.") + void declare_systemsAndRoles_organizationCompany() { /* metaobjects.declare.systemsAndRoles.organizationCompany */ } + + // Organizational unit — A unit nests inside a company or another unit, and a reference to it names the whole path. + @Test + @Disabled("unfilled slot — write an assertion that fails when: An owner that still resolves after the team it named was folded into another.") + void declare_systemsAndRoles_organizationUnit() { /* metaobjects.declare.systemsAndRoles.organizationUnit */ } + + // Document store — A document store is a resource holding documents by key, distinct from a relational database. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A document store modelled as a relational database, so a migration tool proposes tables for it.") + void declare_systemsAndRoles_resourceDocument() { /* metaobjects.declare.systemsAndRoles.resourceDocument */ } + + // Key-value store — A key-value store is a resource that says whether its contents can be lost without losing data. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A cache treated as the source of record because the model did not say it was volatile.") + void declare_systemsAndRoles_resourceKeyValue() { /* metaobjects.declare.systemsAndRoles.resourceKeyValue */ } + + // Object store — An object store holds files by key and says whether anyone may read them without credentials. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A bucket made public by a console click, with nothing in the model to catch it.") + void declare_systemsAndRoles_resourceObjectStore() { /* metaobjects.declare.systemsAndRoles.resourceObjectStore */ } + + // Queue — A queue is a resource that says whether it keeps order and whether undelivered messages go to a dead-letter queue. + @Test + @Disabled("unfilled slot — write an assertion that fails when: Messages lost after their last retry because nothing declared where they go.") + void declare_systemsAndRoles_resourceQueue() { /* metaobjects.declare.systemsAndRoles.resourceQueue */ } + + // Relational database — A relational database is a resource with named schemas, which may be confined to its residency. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A database confined by policy, copied out because nothing in the model said so.") + void declare_systemsAndRoles_resourceRdb() { /* metaobjects.declare.systemsAndRoles.resourceRdb */ } + + // Search index — A search index is a resource derived from other data, so it can be rebuilt rather than restored. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A search index backed up and restored as though it were the source of its data.") + void declare_systemsAndRoles_resourceSearch() { /* metaobjects.declare.systemsAndRoles.resourceSearch */ } + + // Stream — A stream is a resource whose records are read in order by more than one consumer. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A stream modelled as a queue, so a second consumer silently takes messages from the first.") + void declare_systemsAndRoles_resourceStream() { /* metaobjects.declare.systemsAndRoles.resourceStream */ } + + // Volume — A volume is a resource of disk mounted into an app's process. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A process writing files it expects to keep onto a filesystem that is discarded on restart.") + void declare_systemsAndRoles_resourceVolume() { /* metaobjects.declare.systemsAndRoles.resourceVolume */ } + + // Group role — A group role collects other roles, and memberOf may name only a group. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A role listed as a member of another person's role, granting that person's access.") + void declare_systemsAndRoles_roleGroup() { /* metaobjects.declare.systemsAndRoles.roleGroup */ } + + // Service role — A service role is the identity an app runs as, and an app's runsAs must name one. + @Test + @Disabled("unfilled slot — write an assertion that fails when: An app whose runsAs names a database, accepted because a node of that name existed.") + void declare_systemsAndRoles_roleService() { /* metaobjects.declare.systemsAndRoles.roleService */ } + + // Token role — A token role is a credential held by an organization, recorded by where the secret lives rather than by its value. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A shared API token whose holder is unknown when it has to be rotated.") + void declare_systemsAndRoles_roleToken() { /* metaobjects.declare.systemsAndRoles.roleToken */ } + + // User role — A user role is a person's identity, which may belong to groups. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A person granted access under a service identity, so the audit trail names a process.") + void declare_systemsAndRoles_roleUser() { /* metaobjects.declare.systemsAndRoles.roleUser */ } + + // Software system — A software system holds the apps, resources and roles that make it up, and names the organization that owns it. + @Test + @Disabled("unfilled slot — write an assertion that fails when: An owner that names a resource, accepted because the name happened to exist.") + void declare_systemsAndRoles_systemSoftware() { /* metaobjects.declare.systemsAndRoles.systemSoftware */ } + // Boolean — A boolean field holds exactly true or false, and never a third state standing in for absent. @Test @Disabled("unfilled slot — write an assertion that fails when: An unanswered question stored as false, so nobody can tell it apart from an answer of no.") diff --git a/fixtures/requirement-harness/kotlin/RequirementHarnessTest.kt b/fixtures/requirement-harness/kotlin/RequirementHarnessTest.kt index e34981c758..1ec1c8e1fd 100644 --- a/fixtures/requirement-harness/kotlin/RequirementHarnessTest.kt +++ b/fixtures/requirement-harness/kotlin/RequirementHarnessTest.kt @@ -1,6 +1,6 @@ // @generated by scripts/generate-requirement-harness.ts — DO NOT EDIT IN PLACE. // -// One slot per authored promise in metaobjects/meta.requirements.yaml (124 of them). +// One slot per authored promise in metaobjects/meta.requirements.yaml (143 of them). // Every slot is SKIPPED: this is a to-do list with a drift gate behind it, not a // claim that nothing is verified — the conformance corpora already check many of // these. To FILL one, move it into Kotlin's own suite and write the assertion the @@ -482,6 +482,101 @@ class RequirementHarnessTest { @Disabled("planned — not built yet") fun declare_reporting_segmentFilter() { /* metaobjects.declare.reporting.segmentFilter */ } + // Client — A client is code that runs on the user's device, and names the shell that presents it. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A client app modelled as a service, so every rule meant for a server is applied to a browser bundle.") + fun declare_systemsAndRoles_appClient() { /* metaobjects.declare.systemsAndRoles.appClient */ } + + // Job — A job is work that runs to completion, on a cron schedule read in UTC. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A nightly job that runs at two different hours in two regions.") + fun declare_systemsAndRoles_appJob() { /* metaobjects.declare.systemsAndRoles.appJob */ } + + // Service — A service is a long-running process that answers requests, and says whether it is public. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A public endpoint nobody can find in the model because only its deploy file says so.") + fun declare_systemsAndRoles_appService() { /* metaobjects.declare.systemsAndRoles.appService */ } + + // Image build — An image build names the repository an app's image is pulled from, which is all a platform needs to run an image built elsewhere. + @Test + @Disabled("unfilled slot — write an assertion that fails when: An app with no recorded build, deployed from whichever image tag someone last pushed.") + fun declare_systemsAndRoles_buildImage() { /* metaobjects.declare.systemsAndRoles.buildImage */ } + + // Company — A company is the top of an ownership tree, so a system names who answers for it. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A system whose owner is a free-text team name nobody can check.") + fun declare_systemsAndRoles_organizationCompany() { /* metaobjects.declare.systemsAndRoles.organizationCompany */ } + + // Organizational unit — A unit nests inside a company or another unit, and a reference to it names the whole path. + @Test + @Disabled("unfilled slot — write an assertion that fails when: An owner that still resolves after the team it named was folded into another.") + fun declare_systemsAndRoles_organizationUnit() { /* metaobjects.declare.systemsAndRoles.organizationUnit */ } + + // Document store — A document store is a resource holding documents by key, distinct from a relational database. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A document store modelled as a relational database, so a migration tool proposes tables for it.") + fun declare_systemsAndRoles_resourceDocument() { /* metaobjects.declare.systemsAndRoles.resourceDocument */ } + + // Key-value store — A key-value store is a resource that says whether its contents can be lost without losing data. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A cache treated as the source of record because the model did not say it was volatile.") + fun declare_systemsAndRoles_resourceKeyValue() { /* metaobjects.declare.systemsAndRoles.resourceKeyValue */ } + + // Object store — An object store holds files by key and says whether anyone may read them without credentials. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A bucket made public by a console click, with nothing in the model to catch it.") + fun declare_systemsAndRoles_resourceObjectStore() { /* metaobjects.declare.systemsAndRoles.resourceObjectStore */ } + + // Queue — A queue is a resource that says whether it keeps order and whether undelivered messages go to a dead-letter queue. + @Test + @Disabled("unfilled slot — write an assertion that fails when: Messages lost after their last retry because nothing declared where they go.") + fun declare_systemsAndRoles_resourceQueue() { /* metaobjects.declare.systemsAndRoles.resourceQueue */ } + + // Relational database — A relational database is a resource with named schemas, which may be confined to its residency. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A database confined by policy, copied out because nothing in the model said so.") + fun declare_systemsAndRoles_resourceRdb() { /* metaobjects.declare.systemsAndRoles.resourceRdb */ } + + // Search index — A search index is a resource derived from other data, so it can be rebuilt rather than restored. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A search index backed up and restored as though it were the source of its data.") + fun declare_systemsAndRoles_resourceSearch() { /* metaobjects.declare.systemsAndRoles.resourceSearch */ } + + // Stream — A stream is a resource whose records are read in order by more than one consumer. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A stream modelled as a queue, so a second consumer silently takes messages from the first.") + fun declare_systemsAndRoles_resourceStream() { /* metaobjects.declare.systemsAndRoles.resourceStream */ } + + // Volume — A volume is a resource of disk mounted into an app's process. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A process writing files it expects to keep onto a filesystem that is discarded on restart.") + fun declare_systemsAndRoles_resourceVolume() { /* metaobjects.declare.systemsAndRoles.resourceVolume */ } + + // Group role — A group role collects other roles, and memberOf may name only a group. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A role listed as a member of another person's role, granting that person's access.") + fun declare_systemsAndRoles_roleGroup() { /* metaobjects.declare.systemsAndRoles.roleGroup */ } + + // Service role — A service role is the identity an app runs as, and an app's runsAs must name one. + @Test + @Disabled("unfilled slot — write an assertion that fails when: An app whose runsAs names a database, accepted because a node of that name existed.") + fun declare_systemsAndRoles_roleService() { /* metaobjects.declare.systemsAndRoles.roleService */ } + + // Token role — A token role is a credential held by an organization, recorded by where the secret lives rather than by its value. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A shared API token whose holder is unknown when it has to be rotated.") + fun declare_systemsAndRoles_roleToken() { /* metaobjects.declare.systemsAndRoles.roleToken */ } + + // User role — A user role is a person's identity, which may belong to groups. + @Test + @Disabled("unfilled slot — write an assertion that fails when: A person granted access under a service identity, so the audit trail names a process.") + fun declare_systemsAndRoles_roleUser() { /* metaobjects.declare.systemsAndRoles.roleUser */ } + + // Software system — A software system holds the apps, resources and roles that make it up, and names the organization that owns it. + @Test + @Disabled("unfilled slot — write an assertion that fails when: An owner that names a resource, accepted because the name happened to exist.") + fun declare_systemsAndRoles_systemSoftware() { /* metaobjects.declare.systemsAndRoles.systemSoftware */ } + // Boolean — A boolean field holds exactly true or false, and never a third state standing in for absent. @Test @Disabled("unfilled slot — write an assertion that fails when: An unanswered question stored as false, so nobody can tell it apart from an answer of no.") diff --git a/fixtures/requirement-harness/python/test_requirement_harness.py b/fixtures/requirement-harness/python/test_requirement_harness.py index f8be0373e5..956fbe96e3 100644 --- a/fixtures/requirement-harness/python/test_requirement_harness.py +++ b/fixtures/requirement-harness/python/test_requirement_harness.py @@ -1,6 +1,6 @@ # @generated by scripts/generate-requirement-harness.ts — DO NOT EDIT IN PLACE. # -# One slot per authored promise in metaobjects/meta.requirements.yaml (124 of them). +# One slot per authored promise in metaobjects/meta.requirements.yaml (143 of them). # Every slot is SKIPPED: this is a to-do list with a drift gate behind it, not a # claim that nothing is verified — the conformance corpora already check many of # these. To FILL one, move it into Python's own suite and write the assertion the @@ -477,6 +477,101 @@ def test_declare_reporting_measureRatio(): def test_declare_reporting_segmentFilter(): """metaobjects.declare.reporting.segmentFilter""" +# Client — A client is code that runs on the user's device, and names the shell that presents it. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A client app modelled as a service, so every rule meant for a server is applied to a browser bundle.") +def test_declare_systemsAndRoles_appClient(): + """metaobjects.declare.systemsAndRoles.appClient""" + +# Job — A job is work that runs to completion, on a cron schedule read in UTC. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A nightly job that runs at two different hours in two regions.") +def test_declare_systemsAndRoles_appJob(): + """metaobjects.declare.systemsAndRoles.appJob""" + +# Service — A service is a long-running process that answers requests, and says whether it is public. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A public endpoint nobody can find in the model because only its deploy file says so.") +def test_declare_systemsAndRoles_appService(): + """metaobjects.declare.systemsAndRoles.appService""" + +# Image build — An image build names the repository an app's image is pulled from, which is all a platform needs to run an image built elsewhere. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: An app with no recorded build, deployed from whichever image tag someone last pushed.") +def test_declare_systemsAndRoles_buildImage(): + """metaobjects.declare.systemsAndRoles.buildImage""" + +# Company — A company is the top of an ownership tree, so a system names who answers for it. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A system whose owner is a free-text team name nobody can check.") +def test_declare_systemsAndRoles_organizationCompany(): + """metaobjects.declare.systemsAndRoles.organizationCompany""" + +# Organizational unit — A unit nests inside a company or another unit, and a reference to it names the whole path. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: An owner that still resolves after the team it named was folded into another.") +def test_declare_systemsAndRoles_organizationUnit(): + """metaobjects.declare.systemsAndRoles.organizationUnit""" + +# Document store — A document store is a resource holding documents by key, distinct from a relational database. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A document store modelled as a relational database, so a migration tool proposes tables for it.") +def test_declare_systemsAndRoles_resourceDocument(): + """metaobjects.declare.systemsAndRoles.resourceDocument""" + +# Key-value store — A key-value store is a resource that says whether its contents can be lost without losing data. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A cache treated as the source of record because the model did not say it was volatile.") +def test_declare_systemsAndRoles_resourceKeyValue(): + """metaobjects.declare.systemsAndRoles.resourceKeyValue""" + +# Object store — An object store holds files by key and says whether anyone may read them without credentials. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A bucket made public by a console click, with nothing in the model to catch it.") +def test_declare_systemsAndRoles_resourceObjectStore(): + """metaobjects.declare.systemsAndRoles.resourceObjectStore""" + +# Queue — A queue is a resource that says whether it keeps order and whether undelivered messages go to a dead-letter queue. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: Messages lost after their last retry because nothing declared where they go.") +def test_declare_systemsAndRoles_resourceQueue(): + """metaobjects.declare.systemsAndRoles.resourceQueue""" + +# Relational database — A relational database is a resource with named schemas, which may be confined to its residency. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A database confined by policy, copied out because nothing in the model said so.") +def test_declare_systemsAndRoles_resourceRdb(): + """metaobjects.declare.systemsAndRoles.resourceRdb""" + +# Search index — A search index is a resource derived from other data, so it can be rebuilt rather than restored. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A search index backed up and restored as though it were the source of its data.") +def test_declare_systemsAndRoles_resourceSearch(): + """metaobjects.declare.systemsAndRoles.resourceSearch""" + +# Stream — A stream is a resource whose records are read in order by more than one consumer. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A stream modelled as a queue, so a second consumer silently takes messages from the first.") +def test_declare_systemsAndRoles_resourceStream(): + """metaobjects.declare.systemsAndRoles.resourceStream""" + +# Volume — A volume is a resource of disk mounted into an app's process. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A process writing files it expects to keep onto a filesystem that is discarded on restart.") +def test_declare_systemsAndRoles_resourceVolume(): + """metaobjects.declare.systemsAndRoles.resourceVolume""" + +# Group role — A group role collects other roles, and memberOf may name only a group. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A role listed as a member of another person's role, granting that person's access.") +def test_declare_systemsAndRoles_roleGroup(): + """metaobjects.declare.systemsAndRoles.roleGroup""" + +# Service role — A service role is the identity an app runs as, and an app's runsAs must name one. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: An app whose runsAs names a database, accepted because a node of that name existed.") +def test_declare_systemsAndRoles_roleService(): + """metaobjects.declare.systemsAndRoles.roleService""" + +# Token role — A token role is a credential held by an organization, recorded by where the secret lives rather than by its value. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A shared API token whose holder is unknown when it has to be rotated.") +def test_declare_systemsAndRoles_roleToken(): + """metaobjects.declare.systemsAndRoles.roleToken""" + +# User role — A user role is a person's identity, which may belong to groups. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: A person granted access under a service identity, so the audit trail names a process.") +def test_declare_systemsAndRoles_roleUser(): + """metaobjects.declare.systemsAndRoles.roleUser""" + +# Software system — A software system holds the apps, resources and roles that make it up, and names the organization that owns it. +@pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: An owner that names a resource, accepted because the name happened to exist.") +def test_declare_systemsAndRoles_systemSoftware(): + """metaobjects.declare.systemsAndRoles.systemSoftware""" + # Boolean — A boolean field holds exactly true or false, and never a third state standing in for absent. @pytest.mark.skip(reason="unfilled slot — write an assertion that fails when: An unanswered question stored as false, so nobody can tell it apart from an answer of no.") def test_declare_typedFieldVocabulary_fieldBoolean(): diff --git a/fixtures/requirement-harness/typescript/requirement-harness.test.ts b/fixtures/requirement-harness/typescript/requirement-harness.test.ts index 3ec4b2aa72..eb772c11dc 100644 --- a/fixtures/requirement-harness/typescript/requirement-harness.test.ts +++ b/fixtures/requirement-harness/typescript/requirement-harness.test.ts @@ -1,6 +1,6 @@ // @generated by scripts/generate-requirement-harness.ts — DO NOT EDIT IN PLACE. // -// One slot per authored promise in metaobjects/meta.requirements.yaml (124 of them). +// One slot per authored promise in metaobjects/meta.requirements.yaml (143 of them). // Every slot is SKIPPED: this is a to-do list with a drift gate behind it, not a // claim that nothing is verified — the conformance corpora already check many of // these. To FILL one, move it into TypeScript's own suite and write the assertion the @@ -477,6 +477,101 @@ test.skip("metaobjects.declare.reporting.segmentFilter", () => { // planned — not built yet }); +// Client — A client is code that runs on the user's device, and names the shell that presents it. +test.skip("metaobjects.declare.systemsAndRoles.appClient", () => { + // unfilled slot — write an assertion that fails when: A client app modelled as a service, so every rule meant for a server is applied to a browser bundle. +}); + +// Job — A job is work that runs to completion, on a cron schedule read in UTC. +test.skip("metaobjects.declare.systemsAndRoles.appJob", () => { + // unfilled slot — write an assertion that fails when: A nightly job that runs at two different hours in two regions. +}); + +// Service — A service is a long-running process that answers requests, and says whether it is public. +test.skip("metaobjects.declare.systemsAndRoles.appService", () => { + // unfilled slot — write an assertion that fails when: A public endpoint nobody can find in the model because only its deploy file says so. +}); + +// Image build — An image build names the repository an app's image is pulled from, which is all a platform needs to run an image built elsewhere. +test.skip("metaobjects.declare.systemsAndRoles.buildImage", () => { + // unfilled slot — write an assertion that fails when: An app with no recorded build, deployed from whichever image tag someone last pushed. +}); + +// Company — A company is the top of an ownership tree, so a system names who answers for it. +test.skip("metaobjects.declare.systemsAndRoles.organizationCompany", () => { + // unfilled slot — write an assertion that fails when: A system whose owner is a free-text team name nobody can check. +}); + +// Organizational unit — A unit nests inside a company or another unit, and a reference to it names the whole path. +test.skip("metaobjects.declare.systemsAndRoles.organizationUnit", () => { + // unfilled slot — write an assertion that fails when: An owner that still resolves after the team it named was folded into another. +}); + +// Document store — A document store is a resource holding documents by key, distinct from a relational database. +test.skip("metaobjects.declare.systemsAndRoles.resourceDocument", () => { + // unfilled slot — write an assertion that fails when: A document store modelled as a relational database, so a migration tool proposes tables for it. +}); + +// Key-value store — A key-value store is a resource that says whether its contents can be lost without losing data. +test.skip("metaobjects.declare.systemsAndRoles.resourceKeyValue", () => { + // unfilled slot — write an assertion that fails when: A cache treated as the source of record because the model did not say it was volatile. +}); + +// Object store — An object store holds files by key and says whether anyone may read them without credentials. +test.skip("metaobjects.declare.systemsAndRoles.resourceObjectStore", () => { + // unfilled slot — write an assertion that fails when: A bucket made public by a console click, with nothing in the model to catch it. +}); + +// Queue — A queue is a resource that says whether it keeps order and whether undelivered messages go to a dead-letter queue. +test.skip("metaobjects.declare.systemsAndRoles.resourceQueue", () => { + // unfilled slot — write an assertion that fails when: Messages lost after their last retry because nothing declared where they go. +}); + +// Relational database — A relational database is a resource with named schemas, which may be confined to its residency. +test.skip("metaobjects.declare.systemsAndRoles.resourceRdb", () => { + // unfilled slot — write an assertion that fails when: A database confined by policy, copied out because nothing in the model said so. +}); + +// Search index — A search index is a resource derived from other data, so it can be rebuilt rather than restored. +test.skip("metaobjects.declare.systemsAndRoles.resourceSearch", () => { + // unfilled slot — write an assertion that fails when: A search index backed up and restored as though it were the source of its data. +}); + +// Stream — A stream is a resource whose records are read in order by more than one consumer. +test.skip("metaobjects.declare.systemsAndRoles.resourceStream", () => { + // unfilled slot — write an assertion that fails when: A stream modelled as a queue, so a second consumer silently takes messages from the first. +}); + +// Volume — A volume is a resource of disk mounted into an app's process. +test.skip("metaobjects.declare.systemsAndRoles.resourceVolume", () => { + // unfilled slot — write an assertion that fails when: A process writing files it expects to keep onto a filesystem that is discarded on restart. +}); + +// Group role — A group role collects other roles, and memberOf may name only a group. +test.skip("metaobjects.declare.systemsAndRoles.roleGroup", () => { + // unfilled slot — write an assertion that fails when: A role listed as a member of another person's role, granting that person's access. +}); + +// Service role — A service role is the identity an app runs as, and an app's runsAs must name one. +test.skip("metaobjects.declare.systemsAndRoles.roleService", () => { + // unfilled slot — write an assertion that fails when: An app whose runsAs names a database, accepted because a node of that name existed. +}); + +// Token role — A token role is a credential held by an organization, recorded by where the secret lives rather than by its value. +test.skip("metaobjects.declare.systemsAndRoles.roleToken", () => { + // unfilled slot — write an assertion that fails when: A shared API token whose holder is unknown when it has to be rotated. +}); + +// User role — A user role is a person's identity, which may belong to groups. +test.skip("metaobjects.declare.systemsAndRoles.roleUser", () => { + // unfilled slot — write an assertion that fails when: A person granted access under a service identity, so the audit trail names a process. +}); + +// Software system — A software system holds the apps, resources and roles that make it up, and names the organization that owns it. +test.skip("metaobjects.declare.systemsAndRoles.systemSoftware", () => { + // unfilled slot — write an assertion that fails when: An owner that names a resource, accepted because the name happened to exist. +}); + // Boolean — A boolean field holds exactly true or false, and never a third state standing in for absent. test.skip("metaobjects.declare.typedFieldVocabulary.fieldBoolean", () => { // unfilled slot — write an assertion that fails when: An unanswered question stored as false, so nobody can tell it apart from an answer of no. diff --git a/metaobjects/meta.requirements.yaml b/metaobjects/meta.requirements.yaml index 927e8a6e7a..6cd9e4f590 100644 --- a/metaobjects/meta.requirements.yaml +++ b/metaobjects/meta.requirements.yaml @@ -1269,6 +1269,195 @@ metadata.root: measures, three of which are updated when the definition changes. + - requirement.functional: + name: systemsAndRoles + title: Systems, resources and roles + level: 3 + status: live + statement: >- + What software exists, who owns it, what it runs as and what it + stores is declared once, so that a reference between them is + checked rather than trusted. + counterexample: >- + An inventory of services kept in a spreadsheet beside the code, + true on the day it was written. + description: >- + Covers organizations, systems, apps, builds, resources and roles, + and the references between them. Where each app is deployed and + what it may do to a resource are separate concerns. + children: + - requirement.functional: + name: organizationCompany + title: Company + level: 4 + status: live + statement: >- + A company is the top of an ownership tree, so a system names who answers for it. + counterexample: >- + A system whose owner is a free-text team name nobody can check. + - requirement.functional: + name: organizationUnit + title: Organizational unit + level: 4 + status: live + statement: >- + A unit nests inside a company or another unit, and a reference to it names the whole path. + counterexample: >- + An owner that still resolves after the team it named was folded into another. + - requirement.functional: + name: systemSoftware + title: Software system + level: 4 + status: live + statement: >- + A software system holds the apps, resources and roles that make it up, and names the organization that owns it. + counterexample: >- + An owner that names a resource, accepted because the name happened to exist. + - requirement.functional: + name: appService + title: Service + level: 4 + status: live + statement: >- + A service is a long-running process that answers requests, and says whether it is public. + counterexample: >- + A public endpoint nobody can find in the model because only its deploy file says so. + - requirement.functional: + name: appClient + title: Client + level: 4 + status: live + statement: >- + A client is code that runs on the user's device, and names the shell that presents it. + counterexample: >- + A client app modelled as a service, so every rule meant for a server is applied to a browser bundle. + - requirement.functional: + name: appJob + title: Job + level: 4 + status: live + statement: >- + A job is work that runs to completion, on a cron schedule read in UTC. + counterexample: >- + A nightly job that runs at two different hours in two regions. + - requirement.functional: + name: buildImage + title: Image build + level: 4 + status: live + statement: >- + An image build names the repository an app's image is pulled from, which is all a platform needs to run an image built elsewhere. + counterexample: >- + An app with no recorded build, deployed from whichever image tag someone last pushed. + - requirement.functional: + name: resourceRdb + title: Relational database + level: 4 + status: live + statement: >- + A relational database is a resource with named schemas, which may be confined to its residency. + counterexample: >- + A database confined by policy, copied out because nothing in the model said so. + - requirement.functional: + name: resourceKeyValue + title: Key-value store + level: 4 + status: live + statement: >- + A key-value store is a resource that says whether its contents can be lost without losing data. + counterexample: >- + A cache treated as the source of record because the model did not say it was volatile. + - requirement.functional: + name: resourceObjectStore + title: Object store + level: 4 + status: live + statement: >- + An object store holds files by key and says whether anyone may read them without credentials. + counterexample: >- + A bucket made public by a console click, with nothing in the model to catch it. + - requirement.functional: + name: resourceDocument + title: Document store + level: 4 + status: live + statement: >- + A document store is a resource holding documents by key, distinct from a relational database. + counterexample: >- + A document store modelled as a relational database, so a migration tool proposes tables for it. + - requirement.functional: + name: resourceSearch + title: Search index + level: 4 + status: live + statement: >- + A search index is a resource derived from other data, so it can be rebuilt rather than restored. + counterexample: >- + A search index backed up and restored as though it were the source of its data. + - requirement.functional: + name: resourceQueue + title: Queue + level: 4 + status: live + statement: >- + A queue is a resource that says whether it keeps order and whether undelivered messages go to a dead-letter queue. + counterexample: >- + Messages lost after their last retry because nothing declared where they go. + - requirement.functional: + name: resourceStream + title: Stream + level: 4 + status: live + statement: >- + A stream is a resource whose records are read in order by more than one consumer. + counterexample: >- + A stream modelled as a queue, so a second consumer silently takes messages from the first. + - requirement.functional: + name: resourceVolume + title: Volume + level: 4 + status: live + statement: >- + A volume is a resource of disk mounted into an app's process. + counterexample: >- + A process writing files it expects to keep onto a filesystem that is discarded on restart. + - requirement.functional: + name: roleService + title: Service role + level: 4 + status: live + statement: >- + A service role is the identity an app runs as, and an app's runsAs must name one. + counterexample: >- + An app whose runsAs names a database, accepted because a node of that name existed. + - requirement.functional: + name: roleUser + title: User role + level: 4 + status: live + statement: >- + A user role is a person's identity, which may belong to groups. + counterexample: >- + A person granted access under a service identity, so the audit trail names a process. + - requirement.functional: + name: roleGroup + title: Group role + level: 4 + status: live + statement: >- + A group role collects other roles, and memberOf may name only a group. + counterexample: >- + A role listed as a member of another person's role, granting that person's access. + - requirement.functional: + name: roleToken + title: Token role + level: 4 + status: live + statement: >- + A token role is a credential held by an organization, recorded by where the secret lives rather than by its value. + counterexample: >- + A shared API token whose holder is unknown when it has to be rotated. + - requirement.functional: name: businessRules title: Business rules diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/providers.json b/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/providers.json index 139d854348..a384fa1060 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/providers.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-pages-secrets/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/providers.json b/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/providers.json index 139d854348..a384fa1060 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/providers.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-pages-site/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/providers.json b/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/providers.json index 139d854348..a384fa1060 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/providers.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-worker-cron-ratelimits/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] diff --git a/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/providers.json b/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/providers.json index 139d854348..a384fa1060 100644 --- a/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/providers.json +++ b/packs/cloudflare/fixtures/conformance/cloudflare-worker-environments/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] diff --git a/packs/cloudflare/fixtures/conformance/error-binding-base-authored/providers.json b/packs/cloudflare/fixtures/conformance/error-binding-base-authored/providers.json index 139d854348..a384fa1060 100644 --- a/packs/cloudflare/fixtures/conformance/error-binding-base-authored/providers.json +++ b/packs/cloudflare/fixtures/conformance/error-binding-base-authored/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] diff --git a/packs/cloudflare/fixtures/conformance/error-binding-on-pages/providers.json b/packs/cloudflare/fixtures/conformance/error-binding-on-pages/providers.json index 139d854348..a384fa1060 100644 --- a/packs/cloudflare/fixtures/conformance/error-binding-on-pages/providers.json +++ b/packs/cloudflare/fixtures/conformance/error-binding-on-pages/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] diff --git a/packs/cloudflare/fixtures/conformance/error-not-found-not-allowed/providers.json b/packs/cloudflare/fixtures/conformance/error-not-found-not-allowed/providers.json index 139d854348..a384fa1060 100644 --- a/packs/cloudflare/fixtures/conformance/error-not-found-not-allowed/providers.json +++ b/packs/cloudflare/fixtures/conformance/error-not-found-not-allowed/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] diff --git a/packs/cloudflare/fixtures/conformance/error-worker-app-unresolved/providers.json b/packs/cloudflare/fixtures/conformance/error-worker-app-unresolved/providers.json index 139d854348..a384fa1060 100644 --- a/packs/cloudflare/fixtures/conformance/error-worker-app-unresolved/providers.json +++ b/packs/cloudflare/fixtures/conformance/error-worker-app-unresolved/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] diff --git a/packs/cloudflare/fixtures/conformance/error-worker-missing-compatibility-date/providers.json b/packs/cloudflare/fixtures/conformance/error-worker-missing-compatibility-date/providers.json index 139d854348..a384fa1060 100644 --- a/packs/cloudflare/fixtures/conformance/error-worker-missing-compatibility-date/providers.json +++ b/packs/cloudflare/fixtures/conformance/error-worker-missing-compatibility-date/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-cloudflare"] diff --git a/packs/delivery/CHANGELOG.md b/packs/delivery/CHANGELOG.md index 1055c18484..eb9ef88984 100644 --- a/packs/delivery/CHANGELOG.md +++ b/packs/delivery/CHANGELOG.md @@ -4,6 +4,14 @@ This pack's own changelog (ADR-0069). The root `CHANGELOG.md` records core only. ## [0.1.0] - unreleased +- **`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 + `@watchInclude` and `@watchExclude`, and an app still has at most one build of any kind: core's + loader now enforces that bound (`ERR_TOO_MANY_OCCURRENCES`, counting a build the app inherits + through `extends`), so the pack no longer checks it itself. `readBuild` also reads + `build.image @repository`. + - **First version.** `environment.standing`, `.ephemeral`, `.local`; `build.dockerfile`, `.command`, `.static` (at most one per app); `runtime.process`; the abstract `deployment.base` a platform pack specialises; `value.literal` and `value.ref`. A deployment's `@app` and diff --git a/packs/delivery/README.md b/packs/delivery/README.md index 1cd7b29357..884012a0d6 100644 --- a/packs/delivery/README.md +++ b/packs/delivery/README.md @@ -21,7 +21,8 @@ in one environment on one platform, and holds only what differs there. | `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` | -`deployment.base` is the abstract anchor platform packs specialise (`extendsBase: true`); this pack +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 diff --git a/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/providers.json b/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/providers.json index f6baea0511..a956b47c34 100644 --- a/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/providers.json +++ b/packs/delivery/fixtures/conformance/delivery-builds-runtime-environments/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/conformance/error-build-beside-inherited/providers.json b/packs/delivery/fixtures/conformance/error-build-beside-inherited/providers.json index f6baea0511..a956b47c34 100644 --- a/packs/delivery/fixtures/conformance/error-build-beside-inherited/providers.json +++ b/packs/delivery/fixtures/conformance/error-build-beside-inherited/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/conformance/error-deployment-base-authored/providers.json b/packs/delivery/fixtures/conformance/error-deployment-base-authored/providers.json index f6baea0511..a956b47c34 100644 --- a/packs/delivery/fixtures/conformance/error-deployment-base-authored/providers.json +++ b/packs/delivery/fixtures/conformance/error-deployment-base-authored/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/conformance/error-restart-not-allowed/providers.json b/packs/delivery/fixtures/conformance/error-restart-not-allowed/providers.json index f6baea0511..a956b47c34 100644 --- a/packs/delivery/fixtures/conformance/error-restart-not-allowed/providers.json +++ b/packs/delivery/fixtures/conformance/error-restart-not-allowed/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery"] diff --git a/packs/delivery/fixtures/conformance/error-two-builds/providers.json b/packs/delivery/fixtures/conformance/error-two-builds/providers.json index f6baea0511..a956b47c34 100644 --- a/packs/delivery/fixtures/conformance/error-two-builds/providers.json +++ b/packs/delivery/fixtures/conformance/error-two-builds/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery"] +["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 c2b1aa7099..7f929a57dd 100644 --- a/packs/delivery/fixtures/expected-vocabulary.json +++ b/packs/delivery/fixtures/expected-vocabulary.json @@ -1,28 +1,6 @@ { "pack": "metaobjects-delivery", "types": [ - { - "type": "build", - "subType": "base", - "description": "Abstract build base: the attributes every build.* shares. A build is a child of an app and says how its deployable is made, the same in every environment. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", - "attrs": [ - { - "name": "watchExclude", - "valueType": "string", - "isArray": true, - "required": false, - "description": "Repository path globs whose change must not start a new build (`docs/**`, `/*.md`), written as gitignore-style globs from the repository root; an exclusion wins over an inclusion. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." - }, - { - "name": "watchInclude", - "valueType": "string", - "isArray": true, - "required": false, - "description": "Repository path globs whose change starts a new build (`api/**`), written as gitignore-style globs from the repository root. Absent means every path: a monorepo app names only its own directories. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." - } - ], - "children": [] - }, { "type": "build", "subType": "command", @@ -373,17 +351,6 @@ "subType": "client", "attrs": [], "children": [ - { - "childType": "build", - "childSubType": [ - "dockerfile", - "command", - "static" - ], - "childName": "*", - "min": 0, - "max": 1 - }, { "childType": "runtime", "childSubType": "process", @@ -398,17 +365,6 @@ "subType": "job", "attrs": [], "children": [ - { - "childType": "build", - "childSubType": [ - "dockerfile", - "command", - "static" - ], - "childName": "*", - "min": 0, - "max": 1 - }, { "childType": "runtime", "childSubType": "process", @@ -423,17 +379,6 @@ "subType": "service", "attrs": [], "children": [ - { - "childType": "build", - "childSubType": [ - "dockerfile", - "command", - "static" - ], - "childName": "*", - "min": 0, - "max": 1 - }, { "childType": "runtime", "childSubType": "process", diff --git a/packs/delivery/metamodel/delivery.json b/packs/delivery/metamodel/delivery.json index 55da30d740..ecb29c935f 100644 --- a/packs/delivery/metamodel/delivery.json +++ b/packs/delivery/metamodel/delivery.json @@ -6,17 +6,26 @@ "subType": "base", "description": "Abstract environment base. Not authored directly: an `environment.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." }, - { "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": "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": "environment", "subType": "local", "extendsBase": true, "description": "A developer's own machine.", "whenToUse": "The settings and resources a project needs to run on a workstation." }, { - "type": "build", - "subType": "base", - "description": "Abstract build base: the attributes every build.* shares. A build is a child of an app and says how its deployable is made, the same in every environment. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", - "children": [ - { "type": "attr", "subType": "string", "name": "watchInclude", "isArray": true, "min": 0, "max": 1, "description": "Repository path globs whose change starts a new build (`api/**`), written as gitignore-style globs from the repository root. Absent means every path: a monorepo app names only its own directories. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." }, - { "type": "attr", "subType": "string", "name": "watchExclude", "isArray": true, "min": 0, "max": 1, "description": "Repository path globs whose change must not start a new build (`docs/**`, `/*.md`), written as gitignore-style globs from the repository root; an exclusion wins over an inclusion. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." } - ] + "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": "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": "environment", + "subType": "local", + "extendsBase": true, + "description": "A developer's own machine.", + "whenToUse": "The settings and resources a project needs to run on a workstation." }, { "type": "build", @@ -25,8 +34,40 @@ "description": "The app is built as a container image from a Dockerfile.", "whenToUse": "Any app whose image is described by a Dockerfile in the repository.", "children": [ - { "type": "attr", "subType": "string", "name": "path", "min": 0, "max": 1, "description": "The Dockerfile's path from the repository root. Absent means `Dockerfile`." }, - { "type": "attr", "subType": "string", "name": "context", "min": 0, "max": 1, "description": "The build context directory from the repository root. Absent means the root." } + { + "type": "attr", + "subType": "string", + "name": "watchInclude", + "isArray": true, + "min": 0, + "max": 1, + "description": "Repository path globs whose change starts a new build (`api/**`), written as gitignore-style globs from the repository root. Absent means every path: a monorepo app names only its own directories. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." + }, + { + "type": "attr", + "subType": "string", + "name": "watchExclude", + "isArray": true, + "min": 0, + "max": 1, + "description": "Repository path globs whose change must not start a new build (`docs/**`, `/*.md`), written as gitignore-style globs from the repository root; an exclusion wins over an inclusion. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." + }, + { + "type": "attr", + "subType": "string", + "name": "path", + "min": 0, + "max": 1, + "description": "The Dockerfile's path from the repository root. Absent means `Dockerfile`." + }, + { + "type": "attr", + "subType": "string", + "name": "context", + "min": 0, + "max": 1, + "description": "The build context directory from the repository root. Absent means the root." + } ] }, { @@ -36,7 +77,32 @@ "description": "The app is built by a command the platform's own builder runs, with no Dockerfile.", "whenToUse": "A buildpack-style build: `npm run build`, `./gradlew bootJar`.", "children": [ - { "type": "attr", "subType": "string", "name": "command", "min": 1, "max": 1, "description": "The build command, run from the repository root." } + { + "type": "attr", + "subType": "string", + "name": "watchInclude", + "isArray": true, + "min": 0, + "max": 1, + "description": "Repository path globs whose change starts a new build (`api/**`), written as gitignore-style globs from the repository root. Absent means every path: a monorepo app names only its own directories. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." + }, + { + "type": "attr", + "subType": "string", + "name": "watchExclude", + "isArray": true, + "min": 0, + "max": 1, + "description": "Repository path globs whose change must not start a new build (`docs/**`, `/*.md`), written as gitignore-style globs from the repository root; an exclusion wins over an inclusion. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." + }, + { + "type": "attr", + "subType": "string", + "name": "command", + "min": 1, + "max": 1, + "description": "The build command, run from the repository root." + } ] }, { @@ -46,8 +112,40 @@ "description": "The app is a directory of files served as they are, optionally produced by a command first.", "whenToUse": "A static site or a single-page client served by a CDN.", "children": [ - { "type": "attr", "subType": "string", "name": "directory", "min": 1, "max": 1, "description": "The directory of files to serve, from the repository root (`dist`)." }, - { "type": "attr", "subType": "string", "name": "command", "min": 0, "max": 1, "description": "The command that produces the directory. Absent means the directory is committed as it is." } + { + "type": "attr", + "subType": "string", + "name": "watchInclude", + "isArray": true, + "min": 0, + "max": 1, + "description": "Repository path globs whose change starts a new build (`api/**`), written as gitignore-style globs from the repository root. Absent means every path: a monorepo app names only its own directories. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." + }, + { + "type": "attr", + "subType": "string", + "name": "watchExclude", + "isArray": true, + "min": 0, + "max": 1, + "description": "Repository path globs whose change must not start a new build (`docs/**`, `/*.md`), written as gitignore-style globs from the repository root; an exclusion wins over an inclusion. A platform that has no place for them in its own file gets them as a fact to set by hand, which its generator lists." + }, + { + "type": "attr", + "subType": "string", + "name": "directory", + "min": 1, + "max": 1, + "description": "The directory of files to serve, from the repository root (`dist`)." + }, + { + "type": "attr", + "subType": "string", + "name": "command", + "min": 0, + "max": 1, + "description": "The command that produces the directory. Absent means the directory is committed as it is." + } ] }, { @@ -56,12 +154,59 @@ "description": "How one of an app's processes runs, the same in every environment: its start command, port, health check, shutdown drain and restart policy. A platform generator writes what its platform's file can hold and lists the rest.", "whenToUse": "Every app that runs as a process. A second runtime.process is a second process of the same app (a worker beside the web server).", "children": [ - { "type": "attr", "subType": "string", "name": "command", "min": 0, "max": 1, "description": "The start command. Absent means the image's or the builder's default." }, - { "type": "attr", "subType": "int", "name": "port", "min": 0, "max": 1, "description": "The port the process listens on." }, - { "type": "attr", "subType": "string", "name": "healthPath", "min": 0, "max": 1, "description": "The HTTP path that answers 2xx when the process is ready (`/health`)." }, - { "type": "attr", "subType": "int", "name": "healthTimeoutSeconds", "min": 0, "max": 1, "description": "How long a new deployment may take to pass its health check before it is failed." }, - { "type": "attr", "subType": "int", "name": "drainSeconds", "min": 0, "max": 1, "description": "How long the old process keeps running after the new one is healthy, so requests in flight finish." }, - { "type": "attr", "subType": "string", "name": "restart", "min": 0, "max": 1, "allowedValues": ["always", "onFailure", "never"], "description": "When the platform restarts the process after it exits: always, onFailure (a non-zero exit) or never." } + { + "type": "attr", + "subType": "string", + "name": "command", + "min": 0, + "max": 1, + "description": "The start command. Absent means the image's or the builder's default." + }, + { + "type": "attr", + "subType": "int", + "name": "port", + "min": 0, + "max": 1, + "description": "The port the process listens on." + }, + { + "type": "attr", + "subType": "string", + "name": "healthPath", + "min": 0, + "max": 1, + "description": "The HTTP path that answers 2xx when the process is ready (`/health`)." + }, + { + "type": "attr", + "subType": "int", + "name": "healthTimeoutSeconds", + "min": 0, + "max": 1, + "description": "How long a new deployment may take to pass its health check before it is failed." + }, + { + "type": "attr", + "subType": "int", + "name": "drainSeconds", + "min": 0, + "max": 1, + "description": "How long the old process keeps running after the new one is healthy, so requests in flight finish." + }, + { + "type": "attr", + "subType": "string", + "name": "restart", + "min": 0, + "max": 1, + "allowedValues": [ + "always", + "onFailure", + "never" + ], + "description": "When the platform restarts the process after it exits: always, onFailure (a non-zero exit) or never." + } ] }, { @@ -69,14 +214,73 @@ "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).", "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": "environment", "min": 1, "max": 1, "description": "The environment.* node it deploys to, by name (or `pkg::name`). It must resolve (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). Recorded by name only: this pack does not require the config pack." }, - { "type": "value", "subType": ["literal", "ref"], "name": "*", "min": 0, "max": null } + { + "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": "environment", + "min": 1, + "max": 1, + "description": "The environment.* node it deploys to, by name (or `pkg::name`). It must resolve (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). Recorded by name only: this pack does not require the config pack." + }, + { + "type": "value", + "subType": [ + "literal", + "ref" + ], + "name": "*", + "min": 0, + "max": null + } ] }, { @@ -84,7 +288,14 @@ "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).", "children": [ - { "type": "attr", "subType": "string", "name": "setting", "min": 1, "max": 1, "description": "The setting this value is for, as `Group.field` (a field of an object.settings of the config pack). Recorded by name only: this pack does not require the config pack." } + { + "type": "attr", + "subType": "string", + "name": "setting", + "min": 1, + "max": 1, + "description": "The setting this value is for, as `Group.field` (a field of an object.settings of the config pack). Recorded by name only: this pack does not require the config pack." + } ] }, { @@ -94,7 +305,14 @@ "description": "The setting takes a fixed value in this deployment.", "whenToUse": "A non-secret value that differs per environment: a profile name, a feature flag, a log level.", "children": [ - { "type": "attr", "subType": "string", "name": "literal", "min": 1, "max": 1, "description": "The value, as a string (the setting's type parses it). Named @literal because `value` is a reserved structural key." } + { + "type": "attr", + "subType": "string", + "name": "literal", + "min": 1, + "max": 1, + "description": "The value, as a string (the setting's type parses it). Named @literal because `value` is a reserved structural key." + } ] }, { @@ -104,20 +322,83 @@ "description": "The setting takes a value another node produces at deploy time: a database's connection URL, another app's private address. This is how an address stays out of a repository: it is named, never written.", "whenToUse": "A setting whose value only the platform knows once the resource or app exists.", "children": [ - { "type": "attr", "subType": "string", "name": "producedBy", "min": 1, "max": 1, "description": "The node that produces the value: a resource.* or app.*, as `System.child` (`Shop.db`, or `pkg::System.child`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." }, - { "type": "attr", "subType": "string", "name": "output", "min": 1, "max": 1, "allowedValues": ["url", "host", "port", "user", "password", "privateUrl", "publicUrl"], "description": "Which of its values: url, host, port, user, password, privateUrl, publicUrl. A platform generator maps the name to the platform's own reference and refuses one it cannot supply." }, - { "type": "attr", "subType": "string", "name": "path", "min": 0, "max": 1, "description": "A path appended to a URL output (`/api`): the address of one context of the producing app. Only on a url, privateUrl or publicUrl output; a platform generator refuses it on another." } + { + "type": "attr", + "subType": "string", + "name": "producedBy", + "min": 1, + "max": 1, + "description": "The node that produces the value: a resource.* or app.*, as `System.child` (`Shop.db`, or `pkg::System.child`). It must resolve (ERR_DELIVERY_UNRESOLVED_REF)." + }, + { + "type": "attr", + "subType": "string", + "name": "output", + "min": 1, + "max": 1, + "allowedValues": [ + "url", + "host", + "port", + "user", + "password", + "privateUrl", + "publicUrl" + ], + "description": "Which of its values: url, host, port, user, password, privateUrl, publicUrl. A platform generator maps the name to the platform's own reference and refuses one it cannot supply." + }, + { + "type": "attr", + "subType": "string", + "name": "path", + "min": 0, + "max": 1, + "description": "A path appended to a URL output (`/api`): the address of one context of the producing app. Only on a url, privateUrl or publicUrl output; a platform generator refuses it on another." + } ] } ], "extends": [ - { "type": "metadata", "subType": "root", "children": [ - { "type": "environment", "subType": ["standing", "ephemeral", "local"], "name": "*", "min": 0, "max": null }, - { "type": "deployment", "subType": "*", "name": "*", "min": 0, "max": null } - ] }, - { "type": "app", "subType": ["service", "client", "job"], "children": [ - { "type": "build", "subType": ["dockerfile", "command", "static"], "name": "*", "min": 0, "max": 1 }, - { "type": "runtime", "subType": "process", "name": "*", "min": 0, "max": null } - ] } + { + "type": "metadata", + "subType": "root", + "children": [ + { + "type": "environment", + "subType": [ + "standing", + "ephemeral", + "local" + ], + "name": "*", + "min": 0, + "max": null + }, + { + "type": "deployment", + "subType": "*", + "name": "*", + "min": 0, + "max": null + } + ] + }, + { + "type": "app", + "subType": [ + "service", + "client", + "job" + ], + "children": [ + { + "type": "runtime", + "subType": "process", + "name": "*", + "min": 0, + "max": null + } + ] + } ] } diff --git a/packs/delivery/pack.json b/packs/delivery/pack.json index 229b07c576..42dae5105b 100644 --- a/packs/delivery/pack.json +++ b/packs/delivery/pack.json @@ -3,7 +3,7 @@ "version": "0.1.0", "stability": "preview", "description": "What runs where, and what differs per environment: environments, builds, runtime processes, deployments and value bindings.", - "requires": { "metamodel": ">=1.3 <2", "packs": { "metaobjects-systems": ">=0.1.0 <0.2.0" } }, + "requires": { "metamodel": ">=1.4 <2", "packs": { "metaobjects-systems": ">=0.1.0 <0.2.0" } }, "ports": { "typescript": { "package": "@metaobjectsdev/pack-delivery", "core": ">=1.3.0 <2.0.0", "publish": false } } diff --git a/packs/delivery/typescript/src/index.ts b/packs/delivery/typescript/src/index.ts index 3a15689b54..bbb8ef810e 100644 --- a/packs/delivery/typescript/src/index.ts +++ b/packs/delivery/typescript/src/index.ts @@ -31,7 +31,6 @@ import { ERR_DELIVERY_UNRESOLVED_REF, ERR_DELIVERY_UNSUPPORTED_OUTPUT, PORT_OUTPUTS, - TYPE_BUILD, TYPE_DEPLOYMENT, TYPE_ENVIRONMENT, TYPE_VALUE, @@ -101,29 +100,6 @@ const refuseAbstractDeployment: NodeValidator = (node, ctx) => { ); }; -// An app has at most one build. The registry enforces a child rule's upper bound only per -// subtype (`maxOccurs`), and a dockerfile beside a build command is two subtypes, so the -// bound across build.* is checked here. The bound is on the app's effective builds: one it -// declares beside one it inherits through `extends` is two. The error lands on the declared -// build that makes the second: the later of two declared here, or one declared beside an -// inherited build. -const validateBuild: NodeValidator = (node, ctx) => { - const app = node.parent; - if (app === undefined) return; - // ADR-0039: resolving, so a build inherited through `extends` counts. - const others = app.children().filter((c) => c.type === TYPE_BUILD && c !== node); - // ADR-0039: own: the builds this app declares, to find the first of them. - const declared = app.ownChildren().filter((c) => c.type === TYPE_BUILD); - const inherited = others.some((c) => !declared.includes(c)); - if (inherited || declared[0] !== node) { - ctx.error( - "ERR_TOO_MANY_OCCURRENCES", - node, - `${node.type}.${node.subType} "${node.name}" is a second build of ${app.type}.${app.subType} "${app.name}": an app has at most one build.`, - ); - } -}; - // A deployment sets each setting once. An estate overlay that overrides a value must reuse // the value node's name so the overlay merges into it; a second, differently named value // for the same @setting would sit beside the first, so it is an error. It lands on the later. @@ -172,7 +148,6 @@ export const provider: MetaDataTypeProvider = { "Delivery: environment.*, build.*, runtime.process, deployment.base (a platform pack adds the concrete subtype) and value.literal / value.ref.", registerTypes(registry: TypeRegistry): void { const { factories, validators } = packTypeMaps(DELIVERY_DEFINITION, { - [TYPE_BUILD]: validateBuild, [TYPE_VALUE]: validateValue, [TYPE_DEPLOYMENT]: refuseAbstractDeployment, }); diff --git a/packs/delivery/typescript/src/readers.ts b/packs/delivery/typescript/src/readers.ts index a3712cc144..f8405649f7 100644 --- a/packs/delivery/typescript/src/readers.ts +++ b/packs/delivery/typescript/src/readers.ts @@ -4,7 +4,7 @@ // Accessors are the resolving ones (ADR-0039): a build or process an app inherits through // `extends` counts. -import type { MetaData } from "@metaobjectsdev/metadata"; +import { BUILD_ATTR_REPOSITORY, type MetaData } from "@metaobjectsdev/metadata"; import { refList } from "@metaobjectsdev/pack-systems"; import { BUILD_ATTR_COMMAND, @@ -24,7 +24,7 @@ import { } from "./constants.js"; export interface Build { - /** The build subtype: dockerfile, command or static. */ + /** The build subtype: dockerfile, command, static or core's image. */ readonly kind: string; readonly watchInclude: readonly string[]; readonly watchExclude: readonly string[]; @@ -32,6 +32,8 @@ export interface Build { readonly context?: string; readonly command?: string; readonly directory?: string; + /** build.image: where the publisher keeps the image. */ + readonly repository?: string; } export interface Process { @@ -76,6 +78,7 @@ export function readBuild(app: MetaData): Build | undefined { context: text(b.attr(BUILD_ATTR_CONTEXT)), command: text(b.attr(BUILD_ATTR_COMMAND)), directory: text(b.attr(BUILD_ATTR_DIRECTORY)), + repository: text(b.attr(BUILD_ATTR_REPOSITORY)), }); } diff --git a/packs/railway/CHANGELOG.md b/packs/railway/CHANGELOG.md index f944696866..6ba125f435 100644 --- a/packs/railway/CHANGELOG.md +++ b/packs/railway/CHANGELOG.md @@ -14,6 +14,8 @@ This pack's own changelog (ADR-0069). The root `CHANGELOG.md` records core only. loads a base that names an environment beside its concrete child. - `deploy/unexpressed.md` also lists `@branch` and `@checkSuites` on an `@image` source, and a `runtime.process @port` on a deployment with no domain to carry it. +- `deploy/unexpressed.md` lists an app's core `build.image`: the file takes the service's source + only from `deployment.railway @repo` or `@image`, so it never deploys from that image. - **Generators**: `.railway/railway.ts` in Railway's Infrastructure as Code format (the `railway` npm package 3.17.0's `railway/iac` DSL, a named partial), `deploy/unexpressed.md` (the facts the file does not hold), `deploy/sync-secrets.sh` (vault to Railway through `keys-axi`), diff --git a/packs/railway/fixtures/conformance/abstract-deployment-with-environment/providers.json b/packs/railway/fixtures/conformance/abstract-deployment-with-environment/providers.json index 916757f190..894016a124 100644 --- a/packs/railway/fixtures/conformance/abstract-deployment-with-environment/providers.json +++ b/packs/railway/fixtures/conformance/abstract-deployment-with-environment/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/error-deployment-missing-app/providers.json b/packs/railway/fixtures/conformance/error-deployment-missing-app/providers.json index aac0d894bc..bd6ae0f374 100644 --- a/packs/railway/fixtures/conformance/error-deployment-missing-app/providers.json +++ b/packs/railway/fixtures/conformance/error-deployment-missing-app/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/error-deployment-refs/providers.json b/packs/railway/fixtures/conformance/error-deployment-refs/providers.json index aac0d894bc..bd6ae0f374 100644 --- a/packs/railway/fixtures/conformance/error-deployment-refs/providers.json +++ b/packs/railway/fixtures/conformance/error-deployment-refs/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/error-duplicate-deployment/providers.json b/packs/railway/fixtures/conformance/error-duplicate-deployment/providers.json index aac0d894bc..bd6ae0f374 100644 --- a/packs/railway/fixtures/conformance/error-duplicate-deployment/providers.json +++ b/packs/railway/fixtures/conformance/error-duplicate-deployment/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/error-duplicate-setting/providers.json b/packs/railway/fixtures/conformance/error-duplicate-setting/providers.json index aac0d894bc..bd6ae0f374 100644 --- a/packs/railway/fixtures/conformance/error-duplicate-setting/providers.json +++ b/packs/railway/fixtures/conformance/error-duplicate-setting/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/error-value-ref-bare-producedby-and-bad-output/providers.json b/packs/railway/fixtures/conformance/error-value-ref-bare-producedby-and-bad-output/providers.json index aac0d894bc..bd6ae0f374 100644 --- a/packs/railway/fixtures/conformance/error-value-ref-bare-producedby-and-bad-output/providers.json +++ b/packs/railway/fixtures/conformance/error-value-ref-bare-producedby-and-bad-output/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/error-value-ref-unresolved/providers.json b/packs/railway/fixtures/conformance/error-value-ref-unresolved/providers.json index aac0d894bc..bd6ae0f374 100644 --- a/packs/railway/fixtures/conformance/error-value-ref-unresolved/providers.json +++ b/packs/railway/fixtures/conformance/error-value-ref-unresolved/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/error-value-ref-unsupported-output/providers.json b/packs/railway/fixtures/conformance/error-value-ref-unsupported-output/providers.json index aac0d894bc..bd6ae0f374 100644 --- a/packs/railway/fixtures/conformance/error-value-ref-unsupported-output/providers.json +++ b/packs/railway/fixtures/conformance/error-value-ref-unsupported-output/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/railway-emit-environments/providers.json b/packs/railway/fixtures/conformance/railway-emit-environments/providers.json index 916757f190..894016a124 100644 --- a/packs/railway/fixtures/conformance/railway-emit-environments/providers.json +++ b/packs/railway/fixtures/conformance/railway-emit-environments/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/railway-emit-one-service/providers.json b/packs/railway/fixtures/conformance/railway-emit-one-service/providers.json index 916757f190..894016a124 100644 --- a/packs/railway/fixtures/conformance/railway-emit-one-service/providers.json +++ b/packs/railway/fixtures/conformance/railway-emit-one-service/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/railway-emit-two-services/providers.json b/packs/railway/fixtures/conformance/railway-emit-two-services/providers.json index 916757f190..894016a124 100644 --- a/packs/railway/fixtures/conformance/railway-emit-two-services/providers.json +++ b/packs/railway/fixtures/conformance/railway-emit-two-services/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-config", "metaobjects-railway"] diff --git a/packs/railway/fixtures/conformance/railway-worked-example/providers.json b/packs/railway/fixtures/conformance/railway-worked-example/providers.json index aac0d894bc..bd6ae0f374 100644 --- a/packs/railway/fixtures/conformance/railway-worked-example/providers.json +++ b/packs/railway/fixtures/conformance/railway-worked-example/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems", "metaobjects-delivery", "metaobjects-railway"] diff --git a/packs/railway/typescript/src/files.ts b/packs/railway/typescript/src/files.ts index eb30a81d67..ec00889cd4 100644 --- a/packs/railway/typescript/src/files.ts +++ b/packs/railway/typescript/src/files.ts @@ -7,6 +7,7 @@ * into `railway variable set --stdin`: no script prints one or puts one on a command line. */ import { RAILWAY_SDK_VERSION } from "./constants.js"; +import { BUILD_SUBTYPE_IMAGE } from "@metaobjectsdev/metadata"; import { BUILD_SUBTYPE_STATIC } from "@metaobjectsdev/pack-delivery"; import type { RailwayDeployment, RailwayProject } from "./model.js"; @@ -42,6 +43,12 @@ export function unexpressedFacts(d: RailwayDeployment, manageVariables: boolean) how: "Railway has no setting that serves a directory of files. Serve it with a process (runtime.process @command), or deploy the app on a static host.", }); } + if (b?.kind === BUILD_SUBTYPE_IMAGE && b.repository !== undefined) { + out.push({ + fact: `Image ${md(b.repository)} (build.image)`, + how: "The file takes the service's source only from deployment.railway @repo or @image, so it does not use the app's build.image. Set @image on the deployment to deploy this image.", + }); + } for (const p of d.processes.slice(1)) { out.push({ fact: `Second process ${md(p.name)} (runtime.process)`, diff --git a/packs/railway/typescript/test/model.test.ts b/packs/railway/typescript/test/model.test.ts index 746cbbae18..efe4f342e4 100644 --- a/packs/railway/typescript/test/model.test.ts +++ b/packs/railway/typescript/test/model.test.ts @@ -207,6 +207,20 @@ describe("a declared fact the file cannot hold is listed, not dropped", () => { expect(facts.some((f) => f.includes("8080") && f.includes("@port"))).toBe(true); }); + test("an app's build.image, which the file never deploys from", async () => { + const project = await readFixture("railway-emit-one-service", (c) => { + const system = c.find((n) => "system.internal" in n)!["system.internal"]!; + const app = (system["children"] as Record>[])[0]!["app.service"]!; + (app["children"] as Record[])[0] = { + "build.image": { name: "image", "@repository": "registry.example.com/acme/game" }, + }; + }); + const d = project.deployments[0]!; + expect(d.repo).toBe("acme/game"); + const facts = unexpressedFacts(d, project.manageVariables).map((f) => f.fact); + expect(facts.filter((f) => f.includes("build.image"))).toEqual(["Image `registry.example.com/acme/game` (build.image)"]); + }); + test("no port row when a domain carries the port, and no branch row on a repository source", async () => { const project = await readFixture("railway-emit-two-services"); const java = project.deployments.find((d) => d.service === "java")!; diff --git a/packs/systems/CHANGELOG.md b/packs/systems/CHANGELOG.md index 5f1859a39e..18877bdf2b 100644 --- a/packs/systems/CHANGELOG.md +++ b/packs/systems/CHANGELOG.md @@ -4,6 +4,17 @@ This pack's own changelog (ADR-0069). The root `CHANGELOG.md` records core only. ## [0.1.0] - unreleased +- **Core owns the shared types from metamodel 1.4.** Core's `metaobjects-systems-core` provider + now registers `system.base`, `app.service`, `.client`, `.job` and `resource.queue`, `.volume` + (ADR-0070), so this pack stops registering them and requires metamodel 1.4. It adds `@needs`, + `@calls` and `@settings` to core's apps and `@engine`, `@version`, `@managedBy` to core's queue + and volume. `@shell` and `@schedule` are core's now, with the same meaning. The pack keeps + `system.internal`, `system.external` and `resource.database`, `.cache`, `.bucket`, `.keyvalue` + until they move onto core's names: `database` → `rdb`, `bucket` → `objectStore`, `keyvalue` and + `cache` → `keyValue`, `internal` and `external` → `software`. `@needs` and `@calls` are checked + only for apps under `system.internal`; under core's `system.software` they are carried but not + checked until D2 replaces this pack. + - **First version.** `system.internal`, `system.external`; `app.service`, `app.client`, `app.job` (replacing the earlier design's `container.*`); `resource.database`, `.cache`, `.bucket`, `.keyvalue`, `.queue`, `.volume`. An app's `@needs` and `@calls` are resolved at diff --git a/packs/systems/README.md b/packs/systems/README.md index 6258facc04..d683d2f889 100644 --- a/packs/systems/README.md +++ b/packs/systems/README.md @@ -10,16 +10,25 @@ documentation explorer can use this pack alone. ## Vocabulary +Core registers the shared systems vocabulary from 1.4.0 ([ADR-0070](../../spec/decisions/ADR-0070-systems-estates-and-apis.md)): +`system.base`, `app.service`, `.client`, `.job` (with `@runsAs`, `@public`, `@shell`, `@schedule`) +and the resource kinds, `resource.queue` and `resource.volume` among them. This pack no longer +registers those; it adds to them. + | Node | What it is | Attributes | |---|---|---| | `system.internal` | A system this team builds and runs. Holds `app.*`, `resource.*` and `system.external` | (documentation only) | | `system.external` | A system someone else runs that an app calls. Inside a system, or at the document root when several share it | (documentation only) | -| `app.service` | A long-running process that answers requests | `@needs`, `@calls`, `@settings` | -| `app.client` | Code that runs on the user's device | the same, plus `@shell` | -| `app.job` | Work that runs to completion | the same, plus `@schedule` (cron, UTC) | -| `resource.database`, `.cache`, `.bucket`, `.keyvalue`, `.queue`, `.volume` | Something an app uses | `@engine`, `@version`, `@managedBy` (`platform` or `external`) | +| core's `app.service`, `.client`, `.job` | An app | this pack adds `@needs`, `@calls`, `@settings` | +| `resource.database`, `.cache`, `.bucket`, `.keyvalue` | A product resource an app uses | `@engine`, `@version`, `@managedBy` (`platform` or `external`) | +| core's `resource.queue`, `.volume` | A queue or a disk an app uses | this pack adds `@engine`, `@version`, `@managedBy` | + +The pack's own resource kinds map onto core's as follows, and move there in a later release: +`database` is core's `rdb`, `bucket` is `objectStore`, `keyvalue` and `cache` are `keyValue` (a +cache with `@volatile: true`), and `system.internal` and `system.external` are both core's +`system.software`. -`app.base`, `resource.base` and `system.base` are abstract anchors and fail to load if authored. +`system.base` is core's abstract anchor and fails to load if authored. The full definition, with every attribute's description, is [`metamodel/systems.json`](metamodel/systems.json). ## References @@ -32,8 +41,10 @@ referrer's package. The systems packs apply this rule in their own validators, n loader's [reference facet](../../spec/metamodel-definitions.md#the-reference-facet). - `@needs` must name `resource.*` nodes, and `@calls` must name `app.*` or `system.external` nodes. - A name that resolves to nothing, or to the wrong kind of node, fails the load with - `ERR_SYSTEMS_UNRESOLVED_REF`. A rename therefore breaks the build rather than going stale. + They are checked only for apps under `system.internal`: there a name that resolves to nothing, + or to the wrong kind of node, fails the load with `ERR_SYSTEMS_UNRESOLVED_REF`, so a rename + breaks the build rather than going stale. Under core's `system.software` they are carried but + not checked until D2 replaces this pack. - `@settings` (an `object.settings` of the config pack) and `@shell` (a UI pack's `nav.shell`) are recorded by name only. This pack requires neither pack, so it does not resolve them. diff --git a/packs/systems/fixtures/conformance/error-app-outside-system/providers.json b/packs/systems/fixtures/conformance/error-app-outside-system/providers.json index 8a10a47fbc..43bda70935 100644 --- a/packs/systems/fixtures/conformance/error-app-outside-system/providers.json +++ b/packs/systems/fixtures/conformance/error-app-outside-system/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems"] diff --git a/packs/systems/fixtures/conformance/error-calls-wrong-kind/providers.json b/packs/systems/fixtures/conformance/error-calls-wrong-kind/providers.json index 8a10a47fbc..43bda70935 100644 --- a/packs/systems/fixtures/conformance/error-calls-wrong-kind/providers.json +++ b/packs/systems/fixtures/conformance/error-calls-wrong-kind/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems"] diff --git a/packs/systems/fixtures/conformance/error-needs-unresolved/providers.json b/packs/systems/fixtures/conformance/error-needs-unresolved/providers.json index 8a10a47fbc..43bda70935 100644 --- a/packs/systems/fixtures/conformance/error-needs-unresolved/providers.json +++ b/packs/systems/fixtures/conformance/error-needs-unresolved/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems"] diff --git a/packs/systems/fixtures/conformance/systems-apps-and-resources/providers.json b/packs/systems/fixtures/conformance/systems-apps-and-resources/providers.json index 8a10a47fbc..43bda70935 100644 --- a/packs/systems/fixtures/conformance/systems-apps-and-resources/providers.json +++ b/packs/systems/fixtures/conformance/systems-apps-and-resources/providers.json @@ -1 +1 @@ -["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems"] +["metaobjects-core-types", "metaobjects-documentation", "metaobjects-systems-core", "metaobjects-systems"] diff --git a/packs/systems/fixtures/expected-vocabulary.json b/packs/systems/fixtures/expected-vocabulary.json index 50130337fb..72288fbd23 100644 --- a/packs/systems/fixtures/expected-vocabulary.json +++ b/packs/systems/fixtures/expected-vocabulary.json @@ -2,142 +2,100 @@ "pack": "metaobjects-systems", "types": [ { - "type": "app", - "subType": "base", - "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", - "attrs": [ - { - "name": "calls", - "valueType": "string", - "isArray": true, - "required": false, - "description": "The apps and outside systems this app calls. Each entry names an app.* or system.external node: a bare name is one in the same system (an outside system may also be declared at the document root); `System.child` names one in another system. A name that resolves to nothing, or to another kind of node, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Who may reach whom is derived from this list, so it is the list to keep current." - }, - { - "name": "needs", - "valueType": "string", - "isArray": true, - "required": false, - "description": "The resources this app uses. Each entry names a resource.* node: a bare name is a resource of the same system; `System.resource` (or `pkg::System.resource`) names one in another. A name that resolves to nothing, or to a node that is not a resource, fails the load (ERR_SYSTEMS_UNRESOLVED_REF)." - }, - { - "name": "settings", - "valueType": "string", - "isArray": true, - "required": false, - "description": "The settings groups this app reads, by name (an object.settings of the config pack). Recorded by name only: this pack does not require the config pack, so the name is not resolved here." - } - ], - "children": [] - }, - { - "type": "app", - "subType": "client", - "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", - "whenToUse": "A front end built and shipped as files, whatever serves them.", + "type": "resource", + "subType": "bucket", + "description": "Object storage: files addressed by key. Core registers this kind as `resource.objectStore` (ADR-0070); this pack keeps the old name until the estate packs move onto core's.", + "whenToUse": "Uploaded images, exports, static assets kept outside the app.", "attrs": [ { - "name": "calls", + "name": "engine", "valueType": "string", - "isArray": true, + "isArray": false, "required": false, - "description": "The apps and outside systems this app calls. Each entry names an app.* or system.external node: a bare name is one in the same system (an outside system may also be declared at the document root); `System.child` names one in another system. A name that resolves to nothing, or to another kind of node, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Who may reach whom is derived from this list, so it is the list to keep current." + "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." }, { - "name": "needs", + "name": "managedBy", "valueType": "string", - "isArray": true, + "isArray": false, "required": false, - "description": "The resources this app uses. Each entry names a resource.* node: a bare name is a resource of the same system; `System.resource` (or `pkg::System.resource`) names one in another. A name that resolves to nothing, or to a node that is not a resource, fails the load (ERR_SYSTEMS_UNRESOLVED_REF)." + "allowedValues": [ + "platform", + "external" + ], + "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." }, { - "name": "settings", + "name": "residency", "valueType": "string", - "isArray": true, + "isArray": false, "required": false, - "description": "The settings groups this app reads, by name (an object.settings of the config pack). Recorded by name only: this pack does not require the config pack, so the name is not resolved here." + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." }, { - "name": "shell", + "name": "version", "valueType": "string", "isArray": false, "required": false, - "description": "The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here." + "description": "The engine's major version, as a string (`18`)." } ], "children": [] }, { - "type": "app", - "subType": "job", - "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", - "whenToUse": "A cron job, a nightly import, a queue drain that is not a long-running service.", + "type": "resource", + "subType": "cache", + "description": "A cache whose contents can be lost without losing data. Core registers this kind as `resource.keyValue with @volatile` (ADR-0070); this pack keeps the old name until the estate packs move onto core's.", + "whenToUse": "Redis or Memcached used for speed, sessions or rate limits.", "attrs": [ { - "name": "calls", - "valueType": "string", - "isArray": true, - "required": false, - "description": "The apps and outside systems this app calls. Each entry names an app.* or system.external node: a bare name is one in the same system (an outside system may also be declared at the document root); `System.child` names one in another system. A name that resolves to nothing, or to another kind of node, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Who may reach whom is derived from this list, so it is the list to keep current." - }, - { - "name": "needs", - "valueType": "string", - "isArray": true, - "required": false, - "description": "The resources this app uses. Each entry names a resource.* node: a bare name is a resource of the same system; `System.resource` (or `pkg::System.resource`) names one in another. A name that resolves to nothing, or to a node that is not a resource, fails the load (ERR_SYSTEMS_UNRESOLVED_REF)." - }, - { - "name": "schedule", + "name": "engine", "valueType": "string", "isArray": false, "required": false, - "description": "When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered." + "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." }, { - "name": "settings", - "valueType": "string", - "isArray": true, - "required": false, - "description": "The settings groups this app reads, by name (an object.settings of the config pack). Recorded by name only: this pack does not require the config pack, so the name is not resolved here." - } - ], - "children": [] - }, - { - "type": "app", - "subType": "service", - "description": "A long-running process that answers requests: a web server, an API, a socket server. Where and how it runs (build, process, health check, deployments) is the delivery pack's, declared as children it admits.", - "whenToUse": "Anything that listens on a port and stays up.", - "attrs": [ - { - "name": "calls", + "name": "managedBy", "valueType": "string", - "isArray": true, + "isArray": false, "required": false, - "description": "The apps and outside systems this app calls. Each entry names an app.* or system.external node: a bare name is one in the same system (an outside system may also be declared at the document root); `System.child` names one in another system. A name that resolves to nothing, or to another kind of node, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Who may reach whom is derived from this list, so it is the list to keep current." + "allowedValues": [ + "platform", + "external" + ], + "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." }, { - "name": "needs", + "name": "residency", "valueType": "string", - "isArray": true, + "isArray": false, "required": false, - "description": "The resources this app uses. Each entry names a resource.* node: a bare name is a resource of the same system; `System.resource` (or `pkg::System.resource`) names one in another. A name that resolves to nothing, or to a node that is not a resource, fails the load (ERR_SYSTEMS_UNRESOLVED_REF)." + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." }, { - "name": "settings", + "name": "version", "valueType": "string", - "isArray": true, + "isArray": false, "required": false, - "description": "The settings groups this app reads, by name (an object.settings of the config pack). Recorded by name only: this pack does not require the config pack, so the name is not resolved here." + "description": "The engine's major version, as a string (`18`)." } ], "children": [] }, { "type": "resource", - "subType": "base", - "description": "Abstract resource base: the attributes every resource.* shares. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "subType": "database", + "description": "A database an app stores records in. Core registers this kind as `resource.rdb` (ADR-0070); this pack keeps the old name until the estate packs move onto core's.", + "whenToUse": "Postgres, MySQL, SQLite or any store an app queries.", "attrs": [ { "name": "engine", @@ -157,6 +115,17 @@ ], "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." }, + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + }, { "name": "version", "valueType": "string", @@ -169,9 +138,9 @@ }, { "type": "resource", - "subType": "bucket", - "description": "Object storage: files addressed by key.", - "whenToUse": "Uploaded images, exports, static assets kept outside the app.", + "subType": "keyvalue", + "description": "A durable key-value store that is the source of its data, unlike a cache. Core registers this kind as `resource.keyValue` (ADR-0070); this pack keeps the old name until the estate packs move onto core's.", + "whenToUse": "A platform key-value namespace an app reads and writes as its store.", "attrs": [ { "name": "engine", @@ -191,6 +160,17 @@ ], "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." }, + { + "name": "residency", + "valueType": "string", + "isArray": false, + "required": false, + "allowedValues": [ + "free", + "confined" + ], + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + }, { "name": "version", "valueType": "string", @@ -202,112 +182,171 @@ "children": [] }, { - "type": "resource", - "subType": "cache", - "description": "A cache whose contents can be lost without losing data.", - "whenToUse": "Redis or Memcached used for speed, sessions or rate limits.", + "type": "system", + "subType": "external", + "description": "A system someone else runs that an app calls: a payment provider, a chat platform, a model API. Named so an app's @calls can resolve to it; its address and credentials are settings, never attributes here.", + "whenToUse": "Any third-party service an app depends on. Declare it inside the system that calls it, or at the document root when several systems share it.", "attrs": [ { - "name": "engine", + "name": "owner", "valueType": "string", "isArray": false, "required": false, - "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." - }, + "ref": { + "targetType": "organization" + }, + "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources." + } + ], + "children": [] + }, + { + "type": "system", + "subType": "internal", + "description": "A system this team builds and runs: the apps it is made of, the resources they use, and the outside systems they call. It answers what exists and what talks to what, and holds no deploy facts (those are the delivery pack's). Its apps and resources are addressed from outside it as `System.child` (`Shop.web`), or `pkg::System.child` from another package.", + "whenToUse": "Every product or service that has at least one app. One system per product; a system documentation explorer and every deploy generator start here.", + "attrs": [ { - "name": "managedBy", + "name": "owner", "valueType": "string", "isArray": false, "required": false, - "allowedValues": [ - "platform", - "external" - ], - "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." + "ref": { + "targetType": "organization" + }, + "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources." + } + ], + "children": [ + { + "childType": "app", + "childSubType": "*", + "childName": "*", + "min": 0, + "max": null }, { - "name": "version", + "childType": "resource", + "childSubType": "*", + "childName": "*", + "min": 0, + "max": null + }, + { + "childType": "system", + "childSubType": "external", + "childName": "*", + "min": 0, + "max": null + } + ] + } + ], + "extends": [ + { + "type": "app", + "subType": "client", + "attrs": [ + { + "name": "calls", "valueType": "string", - "isArray": false, + "isArray": true, "required": false, - "description": "The engine's major version, as a string (`18`)." + "description": "The apps and outside systems this app calls. Each entry names an app.* or system.external node: a bare name is one in the same system (an outside system may also be declared at the document root); `System.child` names one in another system. Checked only for apps under system.internal: there a name that resolves to nothing, or to another kind of node, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Under core's system.software it is carried but not checked until D2 replaces this pack. Who may reach whom is derived from this list, so it is the list to keep current." + }, + { + "name": "needs", + "valueType": "string", + "isArray": true, + "required": false, + "description": "The resources this app uses. Each entry names a resource.* node: a bare name is a resource of the same system; `System.resource` (or `pkg::System.resource`) names one in another. Checked only for apps under system.internal: there a name that resolves to nothing, or to a node that is not a resource, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Under core's system.software it is carried but not checked until D2 replaces this pack." + }, + { + "name": "settings", + "valueType": "string", + "isArray": true, + "required": false, + "description": "The settings groups this app reads, by name (an object.settings of the config pack). Recorded by name only: this pack does not require the config pack, so the name is not resolved here." } ], "children": [] }, { - "type": "resource", - "subType": "database", - "description": "A database an app stores records in.", - "whenToUse": "Postgres, MySQL, SQLite or any store an app queries.", + "type": "app", + "subType": "job", "attrs": [ { - "name": "engine", + "name": "calls", "valueType": "string", - "isArray": false, + "isArray": true, "required": false, - "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." + "description": "The apps and outside systems this app calls. Each entry names an app.* or system.external node: a bare name is one in the same system (an outside system may also be declared at the document root); `System.child` names one in another system. Checked only for apps under system.internal: there a name that resolves to nothing, or to another kind of node, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Under core's system.software it is carried but not checked until D2 replaces this pack. Who may reach whom is derived from this list, so it is the list to keep current." }, { - "name": "managedBy", + "name": "needs", "valueType": "string", - "isArray": false, + "isArray": true, "required": false, - "allowedValues": [ - "platform", - "external" - ], - "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." + "description": "The resources this app uses. Each entry names a resource.* node: a bare name is a resource of the same system; `System.resource` (or `pkg::System.resource`) names one in another. Checked only for apps under system.internal: there a name that resolves to nothing, or to a node that is not a resource, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Under core's system.software it is carried but not checked until D2 replaces this pack." }, { - "name": "version", + "name": "settings", "valueType": "string", - "isArray": false, + "isArray": true, "required": false, - "description": "The engine's major version, as a string (`18`)." + "description": "The settings groups this app reads, by name (an object.settings of the config pack). Recorded by name only: this pack does not require the config pack, so the name is not resolved here." } ], "children": [] }, { - "type": "resource", - "subType": "keyvalue", - "description": "A durable key-value store that is the source of its data, unlike a cache.", - "whenToUse": "A platform key-value namespace an app reads and writes as its store.", + "type": "app", + "subType": "service", "attrs": [ { - "name": "engine", + "name": "calls", "valueType": "string", - "isArray": false, + "isArray": true, "required": false, - "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." + "description": "The apps and outside systems this app calls. Each entry names an app.* or system.external node: a bare name is one in the same system (an outside system may also be declared at the document root); `System.child` names one in another system. Checked only for apps under system.internal: there a name that resolves to nothing, or to another kind of node, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Under core's system.software it is carried but not checked until D2 replaces this pack. Who may reach whom is derived from this list, so it is the list to keep current." }, { - "name": "managedBy", + "name": "needs", "valueType": "string", - "isArray": false, + "isArray": true, "required": false, - "allowedValues": [ - "platform", - "external" - ], - "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." + "description": "The resources this app uses. Each entry names a resource.* node: a bare name is a resource of the same system; `System.resource` (or `pkg::System.resource`) names one in another. Checked only for apps under system.internal: there a name that resolves to nothing, or to a node that is not a resource, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Under core's system.software it is carried but not checked until D2 replaces this pack." }, { - "name": "version", + "name": "settings", "valueType": "string", - "isArray": false, + "isArray": true, "required": false, - "description": "The engine's major version, as a string (`18`)." + "description": "The settings groups this app reads, by name (an object.settings of the config pack). Recorded by name only: this pack does not require the config pack, so the name is not resolved here." } ], "children": [] }, + { + "type": "metadata", + "subType": "root", + "attrs": [], + "children": [ + { + "childType": "system", + "childSubType": [ + "internal", + "external" + ], + "childName": "*", + "min": 0, + "max": null + } + ] + }, { "type": "resource", "subType": "queue", - "description": "A message queue apps send work through.", - "whenToUse": "Work handed from one app to another to run later.", "attrs": [ { "name": "engine", @@ -340,8 +379,6 @@ { "type": "resource", "subType": "volume", - "description": "A disk attached to an app that survives a restart.", - "whenToUse": "A file system path an app writes to and must keep.", "attrs": [ { "name": "engine", @@ -370,70 +407,6 @@ } ], "children": [] - }, - { - "type": "system", - "subType": "base", - "description": "Abstract system base: the shared root of system.internal and system.external. Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", - "attrs": [], - "children": [] - }, - { - "type": "system", - "subType": "external", - "description": "A system someone else runs that an app calls: a payment provider, a chat platform, a model API. Named so an app's @calls can resolve to it; its address and credentials are settings, never attributes here.", - "whenToUse": "Any third-party service an app depends on. Declare it inside the system that calls it, or at the document root when several systems share it.", - "attrs": [], - "children": [] - }, - { - "type": "system", - "subType": "internal", - "description": "A system this team builds and runs: the apps it is made of, the resources they use, and the outside systems they call. It answers what exists and what talks to what, and holds no deploy facts (those are the delivery pack's). Its apps and resources are addressed from outside it as `System.child` (`Shop.web`), or `pkg::System.child` from another package.", - "whenToUse": "Every product or service that has at least one app. One system per product; a system documentation explorer and every deploy generator start here.", - "attrs": [], - "children": [ - { - "childType": "app", - "childSubType": "*", - "childName": "*", - "min": 0, - "max": null - }, - { - "childType": "resource", - "childSubType": "*", - "childName": "*", - "min": 0, - "max": null - }, - { - "childType": "system", - "childSubType": "external", - "childName": "*", - "min": 0, - "max": null - } - ] - } - ], - "extends": [ - { - "type": "metadata", - "subType": "root", - "attrs": [], - "children": [ - { - "childType": "system", - "childSubType": [ - "internal", - "external" - ], - "childName": "*", - "min": 0, - "max": null - } - ] } ], "commonAttrs": [], diff --git a/packs/systems/metamodel/systems.json b/packs/systems/metamodel/systems.json index 69c8562cad..c930e30c73 100644 --- a/packs/systems/metamodel/systems.json +++ b/packs/systems/metamodel/systems.json @@ -1,11 +1,6 @@ { "provider": "metaobjects-systems", "types": [ - { - "type": "system", - "subType": "base", - "description": "Abstract system base: the shared root of system.internal and system.external. Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." - }, { "type": "system", "subType": "internal", @@ -13,9 +8,27 @@ "description": "A system this team builds and runs: the apps it is made of, the resources they use, and the outside systems they call. It answers what exists and what talks to what, and holds no deploy facts (those are the delivery pack's). Its apps and resources are addressed from outside it as `System.child` (`Shop.web`), or `pkg::System.child` from another package.", "whenToUse": "Every product or service that has at least one app. One system per product; a system documentation explorer and every deploy generator start here.", "children": [ - { "type": "app", "subType": "*", "name": "*", "min": 0, "max": null }, - { "type": "resource", "subType": "*", "name": "*", "min": 0, "max": null }, - { "type": "system", "subType": "external", "name": "*", "min": 0, "max": null } + { + "type": "app", + "subType": "*", + "name": "*", + "min": 0, + "max": null + }, + { + "type": "resource", + "subType": "*", + "name": "*", + "min": 0, + "max": null + }, + { + "type": "system", + "subType": "external", + "name": "*", + "min": 0, + "max": null + } ] }, { @@ -26,62 +39,244 @@ "whenToUse": "Any third-party service an app depends on. Declare it inside the system that calls it, or at the document root when several systems share it." }, { - "type": "app", - "subType": "base", - "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "type": "resource", + "subType": "database", + "extendsBase": true, + "description": "A database an app stores records in. Core registers this kind as `resource.rdb` (ADR-0070); this pack keeps the old name until the estate packs move onto core's.", + "whenToUse": "Postgres, MySQL, SQLite or any store an app queries.", "children": [ - { "type": "attr", "subType": "string", "name": "needs", "isArray": true, "min": 0, "max": 1, "description": "The resources this app uses. Each entry names a resource.* node: a bare name is a resource of the same system; `System.resource` (or `pkg::System.resource`) names one in another. A name that resolves to nothing, or to a node that is not a resource, fails the load (ERR_SYSTEMS_UNRESOLVED_REF)." }, - { "type": "attr", "subType": "string", "name": "calls", "isArray": true, "min": 0, "max": 1, "description": "The apps and outside systems this app calls. Each entry names an app.* or system.external node: a bare name is one in the same system (an outside system may also be declared at the document root); `System.child` names one in another system. A name that resolves to nothing, or to another kind of node, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Who may reach whom is derived from this list, so it is the list to keep current." }, - { "type": "attr", "subType": "string", "name": "settings", "isArray": true, "min": 0, "max": 1, "description": "The settings groups this app reads, by name (an object.settings of the config pack). Recorded by name only: this pack does not require the config pack, so the name is not resolved here." } + { + "type": "attr", + "subType": "string", + "name": "engine", + "min": 0, + "max": 1, + "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." + }, + { + "type": "attr", + "subType": "string", + "name": "version", + "min": 0, + "max": 1, + "description": "The engine's major version, as a string (`18`)." + }, + { + "type": "attr", + "subType": "string", + "name": "managedBy", + "min": 0, + "max": 1, + "allowedValues": [ + "platform", + "external" + ], + "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." + } ] }, { - "type": "app", - "subType": "service", + "type": "resource", + "subType": "cache", "extendsBase": true, - "description": "A long-running process that answers requests: a web server, an API, a socket server. Where and how it runs (build, process, health check, deployments) is the delivery pack's, declared as children it admits.", - "whenToUse": "Anything that listens on a port and stays up." + "description": "A cache whose contents can be lost without losing data. Core registers this kind as `resource.keyValue with @volatile` (ADR-0070); this pack keeps the old name until the estate packs move onto core's.", + "whenToUse": "Redis or Memcached used for speed, sessions or rate limits.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "engine", + "min": 0, + "max": 1, + "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." + }, + { + "type": "attr", + "subType": "string", + "name": "version", + "min": 0, + "max": 1, + "description": "The engine's major version, as a string (`18`)." + }, + { + "type": "attr", + "subType": "string", + "name": "managedBy", + "min": 0, + "max": 1, + "allowedValues": [ + "platform", + "external" + ], + "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." + } + ] }, { - "type": "app", - "subType": "client", + "type": "resource", + "subType": "bucket", "extendsBase": true, - "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", - "whenToUse": "A front end built and shipped as files, whatever serves them.", + "description": "Object storage: files addressed by key. Core registers this kind as `resource.objectStore` (ADR-0070); this pack keeps the old name until the estate packs move onto core's.", + "whenToUse": "Uploaded images, exports, static assets kept outside the app.", "children": [ - { "type": "attr", "subType": "string", "name": "shell", "min": 0, "max": 1, "description": "The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here." } + { + "type": "attr", + "subType": "string", + "name": "engine", + "min": 0, + "max": 1, + "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." + }, + { + "type": "attr", + "subType": "string", + "name": "version", + "min": 0, + "max": 1, + "description": "The engine's major version, as a string (`18`)." + }, + { + "type": "attr", + "subType": "string", + "name": "managedBy", + "min": 0, + "max": 1, + "allowedValues": [ + "platform", + "external" + ], + "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." + } ] }, { - "type": "app", - "subType": "job", + "type": "resource", + "subType": "keyvalue", "extendsBase": true, - "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", - "whenToUse": "A cron job, a nightly import, a queue drain that is not a long-running service.", + "description": "A durable key-value store that is the source of its data, unlike a cache. Core registers this kind as `resource.keyValue` (ADR-0070); this pack keeps the old name until the estate packs move onto core's.", + "whenToUse": "A platform key-value namespace an app reads and writes as its store.", "children": [ - { "type": "attr", "subType": "string", "name": "schedule", "min": 0, "max": 1, "description": "When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered." } + { + "type": "attr", + "subType": "string", + "name": "engine", + "min": 0, + "max": 1, + "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." + }, + { + "type": "attr", + "subType": "string", + "name": "version", + "min": 0, + "max": 1, + "description": "The engine's major version, as a string (`18`)." + }, + { + "type": "attr", + "subType": "string", + "name": "managedBy", + "min": 0, + "max": 1, + "allowedValues": [ + "platform", + "external" + ], + "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." + } + ] + } + ], + "extends": [ + { + "type": "metadata", + "subType": "root", + "children": [ + { + "type": "system", + "subType": [ + "internal", + "external" + ], + "name": "*", + "min": 0, + "max": null + } ] }, { - "type": "resource", - "subType": "base", - "description": "Abstract resource base: the attributes every resource.* shares. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "type": "app", + "subType": [ + "service", + "client", + "job" + ], "children": [ - { "type": "attr", "subType": "string", "name": "engine", "min": 0, "max": 1, "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." }, - { "type": "attr", "subType": "string", "name": "version", "min": 0, "max": 1, "description": "The engine's major version, as a string (`18`)." }, - { "type": "attr", "subType": "string", "name": "managedBy", "min": 0, "max": 1, "allowedValues": ["platform", "external"], "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." } + { + "type": "attr", + "subType": "string", + "name": "needs", + "isArray": true, + "min": 0, + "max": 1, + "description": "The resources this app uses. Each entry names a resource.* node: a bare name is a resource of the same system; `System.resource` (or `pkg::System.resource`) names one in another. Checked only for apps under system.internal: there a name that resolves to nothing, or to a node that is not a resource, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Under core's system.software it is carried but not checked until D2 replaces this pack." + }, + { + "type": "attr", + "subType": "string", + "name": "calls", + "isArray": true, + "min": 0, + "max": 1, + "description": "The apps and outside systems this app calls. Each entry names an app.* or system.external node: a bare name is one in the same system (an outside system may also be declared at the document root); `System.child` names one in another system. Checked only for apps under system.internal: there a name that resolves to nothing, or to another kind of node, fails the load (ERR_SYSTEMS_UNRESOLVED_REF). Under core's system.software it is carried but not checked until D2 replaces this pack. Who may reach whom is derived from this list, so it is the list to keep current." + }, + { + "type": "attr", + "subType": "string", + "name": "settings", + "isArray": true, + "min": 0, + "max": 1, + "description": "The settings groups this app reads, by name (an object.settings of the config pack). Recorded by name only: this pack does not require the config pack, so the name is not resolved here." + } ] }, - { "type": "resource", "subType": "database", "extendsBase": true, "description": "A database an app stores records in.", "whenToUse": "Postgres, MySQL, SQLite or any store an app queries." }, - { "type": "resource", "subType": "cache", "extendsBase": true, "description": "A cache whose contents can be lost without losing data.", "whenToUse": "Redis or Memcached used for speed, sessions or rate limits." }, - { "type": "resource", "subType": "bucket", "extendsBase": true, "description": "Object storage: files addressed by key.", "whenToUse": "Uploaded images, exports, static assets kept outside the app." }, - { "type": "resource", "subType": "keyvalue", "extendsBase": true, "description": "A durable key-value store that is the source of its data, unlike a cache.", "whenToUse": "A platform key-value namespace an app reads and writes as its store." }, - { "type": "resource", "subType": "queue", "extendsBase": true, "description": "A message queue apps send work through.", "whenToUse": "Work handed from one app to another to run later." }, - { "type": "resource", "subType": "volume", "extendsBase": true, "description": "A disk attached to an app that survives a restart.", "whenToUse": "A file system path an app writes to and must keep." } - ], - "extends": [ - { "type": "metadata", "subType": "root", "children": [ - { "type": "system", "subType": ["internal", "external"], "name": "*", "min": 0, "max": null } - ] } + { + "type": "resource", + "subType": [ + "queue", + "volume" + ], + "children": [ + { + "type": "attr", + "subType": "string", + "name": "engine", + "min": 0, + "max": 1, + "description": "The product behind the resource, lower case: postgres, mysql, sqlite, redis, s3, r2. A platform generator reads it to pick the platform's own resource; this pack does not close the list." + }, + { + "type": "attr", + "subType": "string", + "name": "version", + "min": 0, + "max": 1, + "description": "The engine's major version, as a string (`18`)." + }, + { + "type": "attr", + "subType": "string", + "name": "managedBy", + "min": 0, + "max": 1, + "allowedValues": [ + "platform", + "external" + ], + "description": "Who provisions it. platform: the platform an app deploys to creates it beside the app (a platform database). external: it exists outside that platform and is reached by settings (a bucket at another provider). Absent means platform." + } + ] + } ] } diff --git a/packs/systems/pack.json b/packs/systems/pack.json index e18034ecea..9296cf0e5d 100644 --- a/packs/systems/pack.json +++ b/packs/systems/pack.json @@ -3,7 +3,7 @@ "version": "0.1.0", "stability": "preview", "description": "What exists and what talks to what: systems, apps (service, client, job) and the resources they use.", - "requires": { "metamodel": ">=1.3 <2", "packs": {} }, + "requires": { "metamodel": ">=1.4 <2", "packs": {} }, "ports": { "typescript": { "package": "@metaobjectsdev/pack-systems", "core": ">=1.3.0 <2.0.0", "publish": false } } diff --git a/packs/systems/typescript/src/index.ts b/packs/systems/typescript/src/index.ts index 1b93a3afde..2e7f753dc1 100644 --- a/packs/systems/typescript/src/index.ts +++ b/packs/systems/typescript/src/index.ts @@ -20,6 +20,7 @@ import { ERR_SYSTEMS_UNRESOLVED_REF, SYSTEMS_PROVIDER_ID, SYSTEM_SUBTYPE_EXTERNAL, + SYSTEM_SUBTYPE_INTERNAL, TYPE_APP, TYPE_RESOURCE, TYPE_SYSTEM, @@ -34,12 +35,23 @@ export class MetaSystemNode extends MetaData {} export const SYSTEMS_DEFINITION = definition as ProviderDefinition; -const validateApp: NodeValidator = (node, ctx) => { - checkRefs(node, APP_ATTR_NEEDS, [TYPE_RESOURCE], ERR_SYSTEMS_UNRESOLVED_REF, ctx); - checkRefs(node, APP_ATTR_CALLS, [TYPE_APP, `${TYPE_SYSTEM}.${SYSTEM_SUBTYPE_EXTERNAL}`], ERR_SYSTEMS_UNRESOLVED_REF, ctx); +/** + * An app's @needs and @calls name real nodes. Core owns `app.*` since 1.4.0 (ADR-0070), so + * the pack cannot hang a validator on it; it checks the apps of its own `system.internal` + * instead. @needs and @calls are checked only for apps under `system.internal`; under core's + * `system.software` they are carried but not checked until D2 replaces this pack. + */ +const validateInternalSystem: NodeValidator = (node, ctx) => { + for (const app of node.children().filter((c) => c.type === TYPE_APP)) { + checkRefs(app, APP_ATTR_NEEDS, [TYPE_RESOURCE], ERR_SYSTEMS_UNRESOLVED_REF, ctx); + checkRefs(app, APP_ATTR_CALLS, [TYPE_APP, `${TYPE_SYSTEM}.${SYSTEM_SUBTYPE_EXTERNAL}`], ERR_SYSTEMS_UNRESOLVED_REF, ctx); + } }; -/** A factory for every type a definition declares, and a validator for each of `validated`'s types. */ +/** + * A factory for every type a definition declares, and a validator for each of `validated`'s + * entries, keyed by a type (every subtype of it) or by one `type.subType`. + */ export function packTypeMaps( data: ProviderDefinition, validated: Readonly>, @@ -49,7 +61,7 @@ export function packTypeMaps( for (const def of data.types ?? []) { const key = `${def.type}.${def.subType}`; factories[key] = (typeId: TypeId, name: string) => new MetaSystemNode(typeId, name); - const validate = validated[def.type]; + const validate = validated[key] ?? validated[def.type]; if (validate !== undefined) validators[key] = validate; } return { factories, validators }; @@ -57,10 +69,13 @@ export function packTypeMaps( export const provider: MetaDataTypeProvider = { id: SYSTEMS_PROVIDER_ID, - dependencies: ["metaobjects-core-types"], - description: "Systems: system.internal / system.external, app.service / app.client / app.job and resource.*.", + dependencies: ["metaobjects-core-types", "metaobjects-systems-core"], + description: + "Systems: system.internal / system.external, the product resources (database, cache, bucket, keyvalue), and @needs / @calls / @settings on core's apps.", registerTypes(registry: TypeRegistry): void { - const { factories, validators } = packTypeMaps(SYSTEMS_DEFINITION, { [TYPE_APP]: validateApp }); + const { factories, validators } = packTypeMaps(SYSTEMS_DEFINITION, { + [`${TYPE_SYSTEM}.${SYSTEM_SUBTYPE_INTERNAL}`]: validateInternalSystem, + }); applyProviderDefinition(registry, SYSTEMS_DEFINITION, factories, validators); }, }; diff --git a/scripts/check-requirements-ledger.ts b/scripts/check-requirements-ledger.ts index e7f6873403..b31a529208 100644 --- a/scripts/check-requirements-ledger.ts +++ b/scripts/check-requirements-ledger.ts @@ -48,7 +48,7 @@ const EXPECTED_WARNING = "WARN_REQUIREMENT_NOTHING_IMPLEMENTS"; * the neighbour — became `Number("metaobjects")`, i.e. NaN. Every comparison against * NaN is unequal, so the gate failed reporting "expected NaN" and a remedy paragraph * about updating the pin. */ -const DEFAULT_EXPECTED_WARNING_COUNT = 157; +const DEFAULT_EXPECTED_WARNING_COUNT = 177; function expectedWarnings(argv: readonly string[]): number { const flag = argv.find((a) => a.startsWith("--expect-warnings=")); diff --git a/scripts/generate-embedded-metamodel.ts b/scripts/generate-embedded-metamodel.ts index fe08fde727..e50bf7d958 100644 --- a/scripts/generate-embedded-metamodel.ts +++ b/scripts/generate-embedded-metamodel.ts @@ -86,6 +86,8 @@ const CONCEPT_DIRS: Record = { requirement: "core/requirement", // FR-044: dimension / measure / segment (the object.report vocabulary) reporting: "core/reporting", + // ADR-0070: organizations, systems, apps, builds, resources and roles + systems: "core/systems", // ADR-0066: the declared API surface (api / operation / binding) and lifecycle moves api: "core/api", transition: "core/transition", diff --git a/scripts/site/reference.test.ts b/scripts/site/reference.test.ts index 4b7f06fa59..37c7bfb1c2 100644 --- a/scripts/site/reference.test.ts +++ b/scripts/site/reference.test.ts @@ -50,7 +50,7 @@ describe("renderReference", () => { test("renders every metamodel markdown page", () => { expect(existsSync(MD_DIR)).toBe(true); const p = pages(); - expect(Object.keys(p).length).toBe(23); + expect(Object.keys(p).length).toBe(29); expect(Object.keys(p)).toContain("index.html"); expect(Object.keys(p)).toContain("types/field.html"); }); @@ -153,7 +153,7 @@ describe("build-site-reference --check", () => { test("a freshly rendered tree checks clean", () => { const r = run("--check", "--out", rendered()); - expect(r.out).toContain("is fresh (23 page(s))"); + expect(r.out).toContain("is fresh (29 page(s))"); expect(r.code).toBe(0); }); diff --git a/server/csharp/MetaObjects.Codegen.Tests/MetamodelDocsTests.cs b/server/csharp/MetaObjects.Codegen.Tests/MetamodelDocsTests.cs index e22f2e4ad2..e6e0680a73 100644 --- a/server/csharp/MetaObjects.Codegen.Tests/MetamodelDocsTests.cs +++ b/server/csharp/MetaObjects.Codegen.Tests/MetamodelDocsTests.cs @@ -65,7 +65,7 @@ public void Default_sub_directory_is_metamodel() { Entities = load.Root.Objects(), Root = load.Root, Config = new GenConfig { OutDir = "/tmp", Namespace = "Acme" }, }).ToList(); - Assert.Equal(23, files.Count); + Assert.Equal(29, files.Count); Assert.All(files, f => Assert.StartsWith("metamodel/", f.Path)); } } diff --git a/server/csharp/MetaObjects.Codegen/Templates/metamodel/provider-descriptions.json b/server/csharp/MetaObjects.Codegen/Templates/metamodel/provider-descriptions.json index 4cbe8f7f5c..a4241a7a6a 100644 --- a/server/csharp/MetaObjects.Codegen/Templates/metamodel/provider-descriptions.json +++ b/server/csharp/MetaObjects.Codegen/Templates/metamodel/provider-descriptions.json @@ -6,6 +6,7 @@ "metaobjects-reporting": "Reporting (FR-044): object.report, dimension / measure / segment on an entity, and @segment on origin.aggregate and origin.first.", "metaobjects-requirements": "Requirements: requirement.functional and requirement.architectural, declared at the document root and checked by meta verify.", "metaobjects-rules": "Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).", + "metaobjects-systems-core": "Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role.", "metaobjects-ui": "UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D).", "metaobjects-ui-web": "Web presentation view attrs — @rows (view.textarea) and the view.image control attrs. Every port applies this provider and loads them strictly; only TypeScript acts on them so far.", "metaobjects-view-expressions": "View expressions (rc.21): origin.function plus the projection @union / @unionAll / @grain / @grainOrdinal attributes." diff --git a/server/csharp/MetaObjects.Conformance.Tests/ConformanceAdapter.cs b/server/csharp/MetaObjects.Conformance.Tests/ConformanceAdapter.cs index 7617444f9c..f81f385899 100644 --- a/server/csharp/MetaObjects.Conformance.Tests/ConformanceAdapter.cs +++ b/server/csharp/MetaObjects.Conformance.Tests/ConformanceAdapter.cs @@ -170,6 +170,7 @@ public static class ConformanceAdapter ["metaobjects-view-expressions"] = MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance, ["metaobjects-reporting"] = MetaObjects.Core.Reporting.ReportingMetaDataProvider.Instance, ["metaobjects-requirements"] = MetaObjects.Core.Requirement.RequirementsMetaDataProvider.Instance, + ["metaobjects-systems-core"] = MetaObjects.Core.Systems.SystemsMetaDataProvider.Instance, ["metaobjects-prompt"] = MetaObjects.Template.PromptMetaDataProvider.Instance, // Back-compat alias: pre-rename fixtures (and other ports' fixtures) still name the // provider "metaobjects-template"; map it to the renamed prompt provider — the same diff --git a/server/csharp/MetaObjects.Conformance.Tests/FixtureDiscovery.cs b/server/csharp/MetaObjects.Conformance.Tests/FixtureDiscovery.cs index 5b339a88d0..154c0c49af 100644 --- a/server/csharp/MetaObjects.Conformance.Tests/FixtureDiscovery.cs +++ b/server/csharp/MetaObjects.Conformance.Tests/FixtureDiscovery.cs @@ -100,6 +100,7 @@ public static class FixtureDiscovery "metaobjects-view-expressions", "metaobjects-reporting", "metaobjects-requirements", + "metaobjects-systems-core", }; /// diff --git a/server/csharp/MetaObjects.Conformance.Tests/FullCoreRegistry.cs b/server/csharp/MetaObjects.Conformance.Tests/FullCoreRegistry.cs index 36836b8c5c..70bf90df5a 100644 --- a/server/csharp/MetaObjects.Conformance.Tests/FullCoreRegistry.cs +++ b/server/csharp/MetaObjects.Conformance.Tests/FullCoreRegistry.cs @@ -31,6 +31,7 @@ internal static class FullCoreRegistry MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance, MetaObjects.Core.Reporting.ReportingMetaDataProvider.Instance, MetaObjects.Core.Requirement.RequirementsMetaDataProvider.Instance, + MetaObjects.Core.Systems.SystemsMetaDataProvider.Instance, }; /// Compose a fresh registry from the full core bundle. diff --git a/server/csharp/MetaObjects.Conformance.Tests/ReferenceFacetTests.cs b/server/csharp/MetaObjects.Conformance.Tests/ReferenceFacetTests.cs index 733cb8af8e..aab87d5129 100644 --- a/server/csharp/MetaObjects.Conformance.Tests/ReferenceFacetTests.cs +++ b/server/csharp/MetaObjects.Conformance.Tests/ReferenceFacetTests.cs @@ -63,31 +63,79 @@ private sealed class TestProvider : IMetaDataTypeProvider public void RegisterTypes(TypeRegistry registry) { - Type("system", "software", "app", "role", "resource"); + Type("system", "software"); Type("app", "service"); - Type("role", "service", "grant", "resource"); + Type("role", "service"); Type("grant", "rdb"); Type("resource", "rdb"); Type("resource", "queue"); Type("deployment", "test"); + // The children go on as extensions: the strict pass rebuilds a type the shipped + // definitions declare from those definitions, and an extension survives it. + registry.Extend("system", "software", childRules: new[] { "app", "role", "resource" }.Select(Any).ToList()); + registry.Extend("role", "service", childRules: new[] { "grant", "resource" }.Select(Any).ToList()); registry.Extend(TYPE_METADATA, "root", childRules: new[] { "system", "deployment", "app", "resource" }.Select(Any).ToList()); registry.ApplyProviderExtends(SpecMetamodelReader.FromJson(Definition), ProviderId); - void Type(string type, string subType, params string[] children) => + // The systems pack registers some of these names itself (a shared-model build + // composes this provider on top of the default bundle), so skip a registered one. + void Type(string type, string subType) + { + if (registry.Find(type, subType) is not null) return; registry.Register(new TypeDefinition( typeId: new TypeId(type, subType), description: $"A test {type}.", - childRules: [new ChildRule(TYPE_ATTR, CHILD_RULE_WILDCARD, CHILD_RULE_WILDCARD), .. children.Select(Any)], + childRules: [new ChildRule(TYPE_ATTR, CHILD_RULE_WILDCARD, CHILD_RULE_WILDCARD)], factory: (typeId, name) => new SystemTestNode(typeId, name), attributes: [])); + } } private static ChildRule Any(string type) => new(type, CHILD_RULE_WILDCARD, CHILD_RULE_WILDCARD); } + /// + /// Only `grant.rdb`, on top of the shipped systems vocabulary: a shared-model build composes + /// its provider over the default bundle, which already registers the system types. + /// + private const string GrantDefinition = """ + { + "provider": "test-reference-facet-grant", + "extends": [ + { "type": "grant", "subType": "rdb", "children": [ + { "type": "attr", "subType": "string", "name": "resource", "min": 0, "max": 1, "description": "Test.", + "ref": { "targetType": "resource", "targetSubTypes": ["rdb"], "sameSystem": true, + "wrongSystemCode": "ERR_GRANT_CROSSES_SYSTEM" } } + ] } + ] + } + """; + + private sealed class GrantProvider : IMetaDataTypeProvider + { + public string Id => "test-reference-facet-grant"; + public IReadOnlyList Dependencies => ["metaobjects-core-types", MetaObjects.Core.Systems.SystemsMetaDataProvider.ProviderId]; + + public void RegisterTypes(TypeRegistry registry) + { + registry.Register(new TypeDefinition( + typeId: new TypeId("grant", "rdb"), + description: "A test grant.", + childRules: [new ChildRule(TYPE_ATTR, CHILD_RULE_WILDCARD, CHILD_RULE_WILDCARD)], + factory: (typeId, name) => new SystemTestNode(typeId, name), + attributes: [])); + registry.Extend("role", "service", childRules: [new ChildRule("grant", CHILD_RULE_WILDCARD, CHILD_RULE_WILDCARD)]); + registry.ApplyProviderExtends(SpecMetamodelReader.FromJson(GrantDefinition), "test-reference-facet-grant"); + } + } + private static TypeRegistry Registry() => - Provider.ComposeRegistry([.. CoreTypes.LibraryProviders, new TestProvider()]); + Provider.ComposeRegistry([.. BaseProviders, new TestProvider()]); + + /// Core without the systems provider, whose type names the test vocabulary reuses. + private static readonly IReadOnlyList BaseProviders = + CoreTypes.LibraryProviders.Where(p => p.Id != MetaObjects.Core.Systems.SystemsMetaDataProvider.ProviderId).ToList(); private static LoadResult Load(string text, MetaDataFormat format = MetaDataFormat.Yaml) => new MetaDataLoader(Registry(), strict: true) @@ -202,9 +250,26 @@ public void The_reader_carries_a_facet_on_a_types_entry_attr() Assert.Equal(["b", "a"], facet!.TargetSubTypes!); } - // The seven attributes that carry a facet in the core definitions. Only core's four older - // references carry one (spec/metamodel-definitions.md, "Existing references keep their - // codes"), each naming its existing code. + // The attributes that carry a facet in the shipped definitions: core's four older + // references (spec/metamodel-definitions.md, "Existing references keep their codes"), + // each naming its existing code, and the systems vocabulary's four (ADR-0070), each + // written on every subtype that inherits it. Checked on the bundled registry below. + private static readonly string[] SystemsFacets = + [ + "app.base @runsAs role False ", + "app.client @runsAs role False ", + "app.job @runsAs role False ", + "app.service @runsAs role False ", + "role.base @memberOf role False ", + "role.group @memberOf role False ", + "role.service @memberOf role False ", + "role.token @heldBy organization False ", + "role.token @memberOf role False ", + "role.user @memberOf role False ", + "system.base @owner organization False ", + "system.software @owner organization False ", + ]; + private static readonly string[] CoreFacets = [ "field.map @objectRef object False ERR_UNRESOLVED_OBJECT_REF", @@ -226,13 +291,20 @@ public void The_core_definitions_declare_exactly_the_four_core_references() foreach (var a in registry.AttrsOf(id.Type, id.SubType)) { if (a.Ref is not { } f) continue; + if (id.Type is "app" or "role" or "system") + { + // The systems vocabulary: no sameSystem, no custom codes. + Assert.False(f.SameSystem); + found.Add($"{id.Type}.{id.SubType} @{a.Name} {f.TargetType} {f.FieldPath} {f.ErrorCode}"); + continue; + } Assert.Null(f.TargetSubTypes); Assert.False(f.SameSystem); found.Add($"{id.Type}.{id.SubType} @{a.Name} {f.TargetType} {f.FieldPath} {f.ErrorCode}"); } } found.Sort(StringComparer.Ordinal); - Assert.Equal(CoreFacets, found); + Assert.Equal(CoreFacets.Concat(SystemsFacets).Order(StringComparer.Ordinal).ToList(), found); Assert.All(registry.GetCommonAttrs(), a => Assert.Null(a.Ref)); } @@ -339,7 +411,7 @@ public void A_shared_model_refusal_keeps_the_provider_code() try { var ex = Assert.Throws(() => MetaObjects.Config.SharedModel.Build( - new MetaObjects.Config.SharedModelInput("acme", [file], Providers: [new TestProvider()]))); + new MetaObjects.Config.SharedModelInput("acme", [file], Providers: [new GrantProvider()]))); Assert.StartsWith("ERR_GRANT_CROSSES_SYSTEM: ", ex.Message); } finally @@ -695,8 +767,8 @@ public void The_manifest_writes_ref_only_on_an_attribute_that_has_one_in_the_fix [Fact] public void An_attribute_with_no_facet_writes_no_ref_key() { - // One "ref" per facet in the core definitions, and none anywhere else. + // One "ref" per facet in the shipped definitions (core's and the systems vocabulary's), and none anywhere else. var manifest = RegistryManifest.Emit(Provider.ComposeRegistry(CoreTypes.LibraryProviders)); - Assert.Equal(CoreFacets.Length, manifest.Split("\"ref\"").Length - 1); + Assert.Equal(CoreFacets.Length + SystemsFacets.Length, manifest.Split("\"ref\"").Length - 1); } } diff --git a/server/csharp/MetaObjects.Conformance.Tests/RegistryManifestConformanceTests.cs b/server/csharp/MetaObjects.Conformance.Tests/RegistryManifestConformanceTests.cs index 3558da1ec1..d75da88ed5 100644 --- a/server/csharp/MetaObjects.Conformance.Tests/RegistryManifestConformanceTests.cs +++ b/server/csharp/MetaObjects.Conformance.Tests/RegistryManifestConformanceTests.cs @@ -37,6 +37,7 @@ public void Emit_matches_the_committed_cross_port_canonical() MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance, MetaObjects.Core.Reporting.ReportingMetaDataProvider.Instance, MetaObjects.Core.Requirement.RequirementsMetaDataProvider.Instance, + MetaObjects.Core.Systems.SystemsMetaDataProvider.Instance, DocumentationTypes.DocTypesProvider, }); @@ -78,6 +79,7 @@ public void Every_registered_per_type_attr_is_explicitly_classified() MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance, MetaObjects.Core.Reporting.ReportingMetaDataProvider.Instance, MetaObjects.Core.Requirement.RequirementsMetaDataProvider.Instance, + MetaObjects.Core.Systems.SystemsMetaDataProvider.Instance, DocumentationTypes.DocTypesProvider, }); diff --git a/server/csharp/MetaObjects/Core/Systems/SystemsMetaDataProvider.cs b/server/csharp/MetaObjects/Core/Systems/SystemsMetaDataProvider.cs new file mode 100644 index 0000000000..59137b6df1 --- /dev/null +++ b/server/csharp/MetaObjects/Core/Systems/SystemsMetaDataProvider.cs @@ -0,0 +1,69 @@ +// The metaobjects-systems-core pack (ADR-0070): organization, system, app, build, resource +// and role. Its own provider, in the default bundle so every port loads it. The whole +// vocabulary is declared in the embedded systems.json (attrs, child cardinality, the +// reference facets on @owner / @runsAs / @memberOf / @heldBy, and the `extends` that admits +// organization.company and system.software under metadata.root); this provider only +// lowers that data. Mirrors the TS systemsCoreProvider. + +using MetaObjects.Meta; +using MetaObjects.Registry.Spec; +using static MetaObjects.Shared.BaseTypes; + +namespace MetaObjects.Core.Systems; + +/// The systems vocabulary node: no subtype carries behaviour of its own. +public class MetaSystemsNode(TypeId typeId, string name) : MetaData(typeId, name) +{ +} + +/// The systems pack provider (metaobjects-systems-core). +public sealed class SystemsMetaDataProvider : IMetaDataTypeProvider +{ + /// The shared singleton — composed into the default registry. + public static readonly IMetaDataTypeProvider Instance = new SystemsMetaDataProvider(); + + /// The provider id — matches systems.json's "provider" field. + public const string ProviderId = "metaobjects-systems-core"; + + private static readonly Lazy Reader = new(SpecMetamodelReader.Load); + + public string Id => ProviderId; + + public string? Description => + "Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role."; + + public IReadOnlyList Dependencies => ["metaobjects-core-types"]; + + public void RegisterTypes(TypeRegistry registry) + { + SpecMetamodelReader reader = Reader.Value; + foreach ((string type, string subType) in reader.ProviderTypes(ProviderId)) + { + List attrs = reader.ComposedAttrs(type, subType) + .Select(a => new AttrSchema( + Name: a.Name, + ValueType: a.SubType, + Required: a.Required, + Default: a.Default, + AllowedValues: a.AllowedValues?.Cast().ToList(), + IsArray: a.IsArray, + Ref: a.Ref)) + .ToList(); + List rules = reader.StructuralChildren(type, subType) + .Select(sc => new ChildRule(sc.ChildType, sc.ChildSubType, sc.ChildName, sc.Min, sc.Max, sc.MaxIsNull, sc.Named)) + .ToList(); + rules.Insert(0, new ChildRule(TYPE_ATTR, CHILD_RULE_WILDCARD, CHILD_RULE_WILDCARD)); + registry.Register(new TypeDefinition( + typeId: new TypeId(type, subType), + description: $"{type}.{subType}", + childRules: rules, + factory: (tid, n) => new MetaSystemsNode(tid, n), + attributes: attrs)); + } + + registry.ApplyProviderExtends( + reader, + ProviderId, + new Dictionary>(StringComparer.Ordinal)); + } +} diff --git a/server/csharp/MetaObjects/CoreTypes.cs b/server/csharp/MetaObjects/CoreTypes.cs index a11faa87a3..f72b8b1ce2 100644 --- a/server/csharp/MetaObjects/CoreTypes.cs +++ b/server/csharp/MetaObjects/CoreTypes.cs @@ -86,6 +86,7 @@ public static class CoreTypes MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance, MetaObjects.Core.Reporting.ReportingMetaDataProvider.Instance, MetaObjects.Core.Requirement.RequirementsMetaDataProvider.Instance, + MetaObjects.Core.Systems.SystemsMetaDataProvider.Instance, ]; /// diff --git a/server/csharp/MetaObjects/Loader/ValidationPasses.cs b/server/csharp/MetaObjects/Loader/ValidationPasses.cs index a306e6d50a..5d23cdc06d 100644 --- a/server/csharp/MetaObjects/Loader/ValidationPasses.cs +++ b/server/csharp/MetaObjects/Loader/ValidationPasses.cs @@ -2329,12 +2329,45 @@ private static void WalkMaxOccurs(MetaData node, TypeRegistry registry, List errors) + { + TypeDefinition? def = registry.Find(node.Type, node.SubType); + if (def is null) return; + foreach (ChildRule rule in def.ChildRules) + { + if (rule.Max is not int max || rule.ChildType == MetaObjects.Shared.BaseTypes.TYPE_ATTR) continue; + // ADR-0039: resolving, so a child inherited through extends counts against the bound. + var matching = node.Children() + .Where(c => ChildRuleHelper.ChildRuleMatches(rule, c.Type, c.SubType, c.Name)) + .ToList(); + if (matching.Count <= max) continue; + // ADR-0039: own — the declared children are the ones this node can be blamed for. + var own = new HashSet(node.OwnChildren(), ReferenceEqualityComparer.Instance); + var ordered = matching.Where(c => !own.Contains(c)).Concat(matching.Where(own.Contains)).ToList(); + string owner = node.Name != "" ? $" '{node.Name}'" : ""; + foreach (MetaData extra in ordered.Skip(max)) + { + if (!own.Contains(extra)) continue; + errors.Add(new MetaError( + $"{extra.Type}.{extra.SubType} '{extra.Name}' is one too many under " + + $"{node.Type}.{node.SubType}{owner}: at most {max} {rule.ChildType}.{rule.ChildSubType} is allowed", + ErrorCode.ERR_TOO_MANY_OCCURRENCES, + Envelope: extra.Source)); + } + } + } + // ========================================================================= // Pass 7: ValidateDataGridFilterValues // - @filter over a non-@filterable field → ERR_BAD_ATTR_FILTER diff --git a/server/csharp/MetaObjects/MetamodelDocsPages.cs b/server/csharp/MetaObjects/MetamodelDocsPages.cs index b07a0b2529..b127b259e3 100644 --- a/server/csharp/MetaObjects/MetamodelDocsPages.cs +++ b/server/csharp/MetaObjects/MetamodelDocsPages.cs @@ -38,7 +38,7 @@ public static class MetamodelDocsPages [ "field", "object", "attr", "validator", "identity", "index", "relationship", "documentation", "origin", "source", "db", "view", "layout", "ui", "ui-web", "template", "prompt", "api", - "transition", "view-expressions", "reporting", "requirement", + "transition", "view-expressions", "reporting", "requirement", "systems", ]; private const string ResourcePrefix = "MetaObjects.SpecMetamodel."; diff --git a/server/csharp/MetaObjects/Registry/Spec/SpecMetamodelReader.cs b/server/csharp/MetaObjects/Registry/Spec/SpecMetamodelReader.cs index a252220b9b..7de31bc5e8 100644 --- a/server/csharp/MetaObjects/Registry/Spec/SpecMetamodelReader.cs +++ b/server/csharp/MetaObjects/Registry/Spec/SpecMetamodelReader.cs @@ -1,6 +1,6 @@ // FR-033 — the C# reader for the shared spec/metamodel/*.json provider files. // -// The 22 JSON files (one per concern provider) are the cross-port single source of +// The 23 JSON files (one per concern provider) are the cross-port single source of // truth for every type / attr / common-attr DESCRIPTION (+ optional rules/example/ // whenToUse). They are byte-identical across the ports by design, so each port READS // them rather than hand-copying the prose — the exact duplication FR-033 kills. @@ -126,12 +126,12 @@ public sealed record SpecExtendsDirective( /// public sealed class SpecMetamodelReader { - /// The 22 shared provider-definition file names (keep in lockstep with spec/metamodel/). + /// The 23 shared provider-definition file names (keep in lockstep with spec/metamodel/). public static readonly IReadOnlyList SpecFiles = new[] { "api.json", "attr.json", "db.json", "documentation.json", "field.json", "identity.json", "index.json", "layout.json", "object.json", "origin.json", "prompt.json", - "relationship.json", "reporting.json", "requirement.json", "source.json", "template.json", + "relationship.json", "reporting.json", "requirement.json", "source.json", "systems.json", "template.json", "transition.json", "ui.json", "ui-web.json", "validator.json", "view-expressions.json", "view.json", }; @@ -177,14 +177,44 @@ private sealed record ExtendsBlock( private readonly Dictionary> _providerExtends = new(StringComparer.Ordinal); + // provider name -> the (type, subType) pairs its `types` declare, in file order. A + // data-driven pack registers its own vocabulary from these. + private readonly Dictionary> _providerTypes = + new(StringComparer.Ordinal); + // (type.subType) -> the type's own attr entries, in declared order + private readonly Dictionary> _typeAttrList = new(StringComparer.Ordinal); + private SpecMetamodelReader() { } + /// The (type, subType) pairs the named provider's definition declares, in file order. + public IReadOnlyList<(string Type, string SubType)> ProviderTypes(string providerName) => + _providerTypes.TryGetValue(providerName, out var l) ? l : []; + + /// + /// The attrs a type registers: its own, then (for an extendsBase subtype) the + /// <type>.base attrs it does not redeclare, mirroring the TypeScript + /// composeWithBase. + /// + public IReadOnlyList ComposedAttrs(string type, string subType) + { + var result = new List( + _typeAttrList.TryGetValue(Key(type, subType), out var own) ? own : []); + bool extendsBase = _typeExtendsBase.TryGetValue(Key(type, subType), out bool eb) && eb; + if (extendsBase && subType != BaseSubType + && _typeAttrList.TryGetValue(Key(type, BaseSubType), out var baseAttrs)) + { + var have = result.Select(a => a.Name).ToHashSet(StringComparer.Ordinal); + result.AddRange(baseAttrs.Where(a => have.Add(a.Name))); + } + return result; + } + // ------------------------------------------------------------------ // Loading // ------------------------------------------------------------------ /// - /// Load + parse the 22 embedded spec/metamodel/*.json files off this + /// Load + parse the 23 embedded spec/metamodel/*.json files off this /// assembly's manifest resources (AOT-safe). /// /// If a spec file is missing or unparseable. @@ -270,14 +300,24 @@ private void Parse(JsonElement provider) } string key = Key(type, subType); _declaredKeys.Add(key); + if (providerName is not null) + { + if (!_providerTypes.TryGetValue(providerName, out var pt)) + { + _providerTypes[providerName] = pt = []; + } + pt.Add((type, subType)); + } _typeDocs[key] = new SpecDocFacet( Str(t, "description"), Str(t, "rules"), Str(t, "example"), Str(t, "whenToUse"), StrList(t, "implementedIn"), StrList(t, "ports")); var attrs = new Dictionary(StringComparer.Ordinal); - foreach (SpecAttrEntry a in ParseAttrChildren(t, providerName, key)) + var attrList = ParseAttrChildren(t, providerName, key); + foreach (SpecAttrEntry a in attrList) { attrs[a.Name] = a; } + _typeAttrList[key] = attrList; _typeAttrDocs[key] = attrs; _typeStructChildren[key] = ParseStructChildren(t, providerName, key); _typeExtendsBase[key] = Bool(t, "extendsBase"); diff --git a/server/csharp/MetaObjects/RegistryManifest.cs b/server/csharp/MetaObjects/RegistryManifest.cs index fa4d64c5d0..71726846e0 100644 --- a/server/csharp/MetaObjects/RegistryManifest.cs +++ b/server/csharp/MetaObjects/RegistryManifest.cs @@ -377,7 +377,7 @@ private static ManifestType ToManifestType(TypeDefinition def) => /// unstable (semver major-0). The 1.0 cut flips this to "1.0". /// Emitted as the FIRST top-level key in the registry manifest (C4). /// - public const string MetamodelVersion = "1.3"; + public const string MetamodelVersion = "1.4"; /// /// Emit the canonical registry manifest as a byte-stable JSON string. diff --git a/server/csharp/MetaObjects/Shared/BaseTypes.cs b/server/csharp/MetaObjects/Shared/BaseTypes.cs index 3633480845..c6fd87db0d 100644 --- a/server/csharp/MetaObjects/Shared/BaseTypes.cs +++ b/server/csharp/MetaObjects/Shared/BaseTypes.cs @@ -56,11 +56,16 @@ public static class BaseTypes /// ADR-0066 — an allowed move between two members of a field.enum (transition.action). public const string TYPE_TRANSITION = "transition"; /// - /// ADR-0070 — the system type. Not a registered base type yet (core registers it in - /// 1.4.0, so it is not in ): the reference facet's sameSystem - /// check reads it to find a node's system, its nearest ancestor of this type. + /// ADR-0070 — the systems vocabulary (metaobjects-systems-core): organization, system, + /// app, build, resource and role. The reference facet's sameSystem check reads + /// to find a node's system, its nearest ancestor of this type. /// + public const string TYPE_ORGANIZATION = "organization"; public const string TYPE_SYSTEM = "system"; + public const string TYPE_APP = "app"; + public const string TYPE_BUILD = "build"; + public const string TYPE_RESOURCE = "resource"; + public const string TYPE_ROLE = "role"; public static readonly string[] BASE_TYPES = [ @@ -85,6 +90,12 @@ public static class BaseTypes TYPE_OPERATION, TYPE_BINDING, TYPE_TRANSITION, + TYPE_ORGANIZATION, + TYPE_SYSTEM, + TYPE_APP, + TYPE_BUILD, + TYPE_RESOURCE, + TYPE_ROLE, ]; // ----------------------------------------------------------------------- diff --git a/server/csharp/MetaObjects/SpecMetamodel/systems.json b/server/csharp/MetaObjects/SpecMetamodel/systems.json new file mode 100644 index 0000000000..8ff1f9e598 --- /dev/null +++ b/server/csharp/MetaObjects/SpecMetamodel/systems.json @@ -0,0 +1,233 @@ +{ + "provider": "metaobjects-systems-core", + "types": [ + { + "type": "organization", + "subType": "base", + "description": "Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "organization", + "subType": "company", + "extendsBase": true, + "description": "A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company.", + "whenToUse": "Every party that owns a system or holds a token. A party that publishes no metadata is written down by whoever depends on it, under the party's own package name.", + "rules": "Lives at the document root. Its units are its children, addressed `Company.unit` (`pkg::Company.unit` from another package).", + "children": [ + { "type": "organization", "subType": "unit", "name": "*", "min": 0, "max": null, "description": "The teams or divisions inside the company." } + ] + }, + { + "type": "organization", + "subType": "unit", + "extendsBase": true, + "description": "A team or division inside a company. Units nest: a unit is a child of a company or of another unit.", + "whenToUse": "When a system's owner is a team rather than the whole company.", + "children": [ + { "type": "organization", "subType": "unit", "name": "*", "min": 0, "max": null, "description": "The units inside this one." } + ] + }, + { + "type": "system", + "subType": "base", + "description": "Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "owner", "min": 0, "max": 1, "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources.", "ref": { "targetType": "organization" } } + ] + }, + { + "type": "system", + "subType": "software", + "extendsBase": true, + "description": "A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package.", + "whenToUse": "Every product or service, including one somebody else runs that an app calls: write it down under its owner's package name.", + "rules": "Lives at the document root. Names are unique per type within the system, so an app and a role may share a name: every reference names the type it wants.", + "children": [ + { "type": "app", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The system's apps." }, + { "type": "resource", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The system's resources." }, + { "type": "role", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The identities that act in the system." } + ] + }, + { + "type": "app", + "subType": "base", + "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "runsAs", "min": 0, "max": 1, "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND.", "ref": { "targetType": "role", "targetSubTypes": ["service"] } }, + { "type": "build", "subType": "*", "name": "*", "min": 0, "max": 1, "description": "How the app's deployable is made. At most one, of any kind." } + ] + }, + { + "type": "app", + "subType": "service", + "extendsBase": true, + "description": "A long-running process that answers requests: a web server, an API, a socket server.", + "whenToUse": "Anything that listens on a port and stays up.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "public", "min": 0, "max": 1, "description": "The service is meant to be reached from outside every system: from browsers or from parties holding no role in the model. Absent means it is reached only by the apps and roles the model names." } + ] + }, + { + "type": "app", + "subType": "client", + "extendsBase": true, + "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", + "whenToUse": "A front end built and shipped as files, whatever serves them.", + "children": [ + { "type": "attr", "subType": "string", "name": "shell", "min": 0, "max": 1, "description": "The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here." } + ] + }, + { + "type": "app", + "subType": "job", + "extendsBase": true, + "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", + "whenToUse": "A cron job, a nightly import, a queue drain that is not a long-running service.", + "children": [ + { "type": "attr", "subType": "string", "name": "schedule", "min": 0, "max": 1, "description": "When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered." } + ] + }, + { + "type": "build", + "subType": "base", + "description": "Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "build", + "subType": "image", + "extendsBase": true, + "description": "The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here.", + "whenToUse": "An app whose image someone else builds: a product sold as images that the buyer deploys.", + "children": [ + { "type": "attr", "subType": "string", "name": "repository", "min": 1, "max": 1, "description": "Where the publisher keeps the image, without a tag (`registry.example.com/team/app`)." } + ] + }, + { + "type": "resource", + "subType": "base", + "description": "Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "residency", "min": 0, "max": 1, "allowedValues": ["free", "confined"], "default": "free", "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." } + ] + }, + { + "type": "resource", + "subType": "rdb", + "extendsBase": true, + "description": "A relational database: tables queried with SQL, the store of record.", + "whenToUse": "Any store an app queries with SQL, whatever the product.", + "children": [ + { "type": "attr", "subType": "string", "name": "schemas", "isArray": true, "min": 0, "max": 1, "description": "The schema names the database holds. Optional and usually absent: the set can be computed from the entities' source.rdb @schema. Declaring it closes the list." } + ] + }, + { + "type": "resource", + "subType": "keyValue", + "extendsBase": true, + "description": "A store of values fetched by key.", + "whenToUse": "A key-value store that is the source of its data, or a cache (@volatile).", + "children": [ + { "type": "attr", "subType": "boolean", "name": "volatile", "min": 0, "max": 1, "description": "The contents may be lost at any moment without losing data: a cache. Absent means the store is durable." } + ] + }, + { + "type": "resource", + "subType": "objectStore", + "extendsBase": true, + "description": "Files and blobs addressed by key.", + "whenToUse": "Uploaded images, exports, static assets kept outside the app.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "publicRead", "min": 0, "max": 1, "description": "Anyone may read the objects without a credential. Absent means every read needs a grant." } + ] + }, + { + "type": "resource", + "subType": "document", + "extendsBase": true, + "description": "A document store: records kept and fetched as whole documents.", + "whenToUse": "Records whose shape is a document rather than a row." + }, + { + "type": "resource", + "subType": "search", + "extendsBase": true, + "description": "A search index: documents found by text and filters.", + "whenToUse": "Full-text search over records kept elsewhere." + }, + { + "type": "resource", + "subType": "queue", + "extendsBase": true, + "description": "A message queue: each message is handed to one consumer and gone once it is handled.", + "whenToUse": "Work handed from one app to another to run later.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "ordered", "min": 0, "max": 1, "description": "Messages with the same key are delivered in the order they were sent. Absent means no order is promised." }, + { "type": "attr", "subType": "boolean", "name": "deadLetter", "min": 0, "max": 1, "description": "A message that keeps failing is set aside rather than dropped. How many attempts come first is a setting." } + ] + }, + { + "type": "resource", + "subType": "stream", + "extendsBase": true, + "description": "A retained, ordered log that many consumers read, each at its own position. A message can be read again.", + "whenToUse": "Events several consumers read independently, or read again." + }, + { + "type": "resource", + "subType": "volume", + "extendsBase": true, + "description": "A disk attached to an app that survives a restart.", + "whenToUse": "A file system path an app writes to and must keep." + }, + { + "type": "role", + "subType": "base", + "description": "Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "memberOf", "isArray": true, "min": 0, "max": 1, "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.", "ref": { "targetType": "role", "targetSubTypes": ["group"] } }, + { "type": "attr", "subType": "string", "name": "credential", "min": 0, "max": 1, "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." } + ] + }, + { + "type": "role", + "subType": "service", + "extendsBase": true, + "description": "A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs).", + "whenToUse": "Every identity an app or job of the system acts as." + }, + { + "type": "role", + "subType": "user", + "extendsBase": true, + "description": "A named person, or an agent acting for one. No shared secret is generated or stored for it.", + "whenToUse": "A person who signs in to a resource directly." + }, + { + "type": "role", + "subType": "group", + "extendsBase": true, + "description": "Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in.", + "whenToUse": "Several roles that share the same access." + }, + { + "type": "role", + "subType": "token", + "extendsBase": true, + "description": "Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer.", + "whenToUse": "Access handed to something that is not one of the system's apps.", + "children": [ + { "type": "attr", "subType": "string", "name": "heldBy", "min": 0, "max": 1, "description": "Who was handed the token: an organization node, by name (`tidewell::Tidewell`). Optional. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node is ERR_REF_WRONG_KIND. ADR-0070 call 9 also admits a system here; that waits on the reference facet accepting more than one target type.", "ref": { "targetType": "organization" } } + ] + } + ], + "extends": [ + { + "type": "metadata", + "subType": "root", + "children": [ + { "type": "organization", "subType": "company", "name": "*", "min": 0, "max": null, "description": "An organization: a top-level, packaged node." }, + { "type": "system", "subType": "software", "name": "*", "min": 0, "max": null, "description": "A system: a top-level, packaged node." } + ] + } + ] +} diff --git a/server/java/codegen-base/src/main/java/com/metaobjects/docs/metamodel/MetamodelDocsPages.java b/server/java/codegen-base/src/main/java/com/metaobjects/docs/metamodel/MetamodelDocsPages.java index 9c2f966a0f..e662085a9e 100644 --- a/server/java/codegen-base/src/main/java/com/metaobjects/docs/metamodel/MetamodelDocsPages.java +++ b/server/java/codegen-base/src/main/java/com/metaobjects/docs/metamodel/MetamodelDocsPages.java @@ -50,7 +50,7 @@ public record Page(String path, String template, Map data) {} static final List DEFINITION_FILES = List.of( "field", "object", "attr", "validator", "identity", "index", "relationship", "documentation", "origin", "source", "db", "view", "layout", "ui", "ui-web", - "template", "prompt", "api", "transition", "view-expressions", "reporting", "requirement"); + "template", "prompt", "api", "transition", "view-expressions", "reporting", "requirement", "systems"); private static final String WILDCARD = "*"; private static final String ATTR = "attr"; diff --git a/server/java/codegen-base/src/main/resources/metaobjects/templates/metamodel/provider-descriptions.json b/server/java/codegen-base/src/main/resources/metaobjects/templates/metamodel/provider-descriptions.json index 4cbe8f7f5c..a4241a7a6a 100644 --- a/server/java/codegen-base/src/main/resources/metaobjects/templates/metamodel/provider-descriptions.json +++ b/server/java/codegen-base/src/main/resources/metaobjects/templates/metamodel/provider-descriptions.json @@ -6,6 +6,7 @@ "metaobjects-reporting": "Reporting (FR-044): object.report, dimension / measure / segment on an entity, and @segment on origin.aggregate and origin.first.", "metaobjects-requirements": "Requirements: requirement.functional and requirement.architectural, declared at the document root and checked by meta verify.", "metaobjects-rules": "Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).", + "metaobjects-systems-core": "Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role.", "metaobjects-ui": "UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D).", "metaobjects-ui-web": "Web presentation view attrs — @rows (view.textarea) and the view.image control attrs. Every port applies this provider and loads them strictly; only TypeScript acts on them so far.", "metaobjects-view-expressions": "View expressions (rc.21): origin.function plus the projection @union / @unionAll / @grain / @grainOrdinal attributes." diff --git a/server/java/metadata/src/main/java/com/metaobjects/loader/ValidationPhase.java b/server/java/metadata/src/main/java/com/metaobjects/loader/ValidationPhase.java index de3b206457..8d265d6618 100644 --- a/server/java/metadata/src/main/java/com/metaobjects/loader/ValidationPhase.java +++ b/server/java/metadata/src/main/java/com/metaobjects/loader/ValidationPhase.java @@ -55,6 +55,7 @@ import com.metaobjects.origin.MetaOrigin; import com.metaobjects.origin.PassthroughOrigin; import com.metaobjects.origin.ViewExpressionsTypesMetaDataProvider; +import com.metaobjects.systems.SystemsNode; import com.metaobjects.relationship.M2MFields; import com.metaobjects.relationship.MetaRelationship; import com.metaobjects.relationship.RelationshipReferences; @@ -185,6 +186,10 @@ public static void run(MetaRoot root, MetaDataLoader loader) { // of a registered maxOccurs==1 type.subType than allowed fires // ERR_TOO_MANY_OCCURRENCES (e.g. two identity.primary on one object). pass(collected, () -> validateMaxOccurs(root, loader)); + validateChildRuleMax(root, loader, collected); + // The closed set of resource.* @residency (ADR-0070): the attr builder's enum is not + // enforced on an attribute, so the loader checks it here. + pass(collected, () -> validateResidency(root)); pass(collected, () -> validateEnumValues(root)); pass(collected, () -> validateFieldDefaults(root)); pass(collected, () -> validateDbColumnType(root)); @@ -555,6 +560,100 @@ private static void validateMaxOccursNode(MetaData parent, MetaDataRegistry regi } } + // ========================================================================= + // Child-rule max validation + // + // A child rule's max (an app has at most one build.*, of any kind) bounds the + // parent's EFFECTIVE children, so a child inherited through extends counts: + // inherited children are taken first, and each declared child past the bound + // fires ERR_TOO_MANY_OCCURRENCES against that child's source. + // ========================================================================= + + static void validateChildRuleMax(MetaRoot root, MetaDataLoader loader, + java.util.List collected) { + if (loader == null) return; + MetaDataRegistry registry = loader.getTypeRegistry(); + if (registry == null) return; + walkChildRuleMax(root, registry, collected); + } + + private static void walkChildRuleMax(MetaData node, MetaDataRegistry registry, + java.util.List collected) { + validateChildRuleMaxNode(node, registry, collected); + for (MetaData child : node.getChildren(MetaData.class, false)) { + walkChildRuleMax(child, registry, collected); + } + } + + private static void validateChildRuleMaxNode(MetaData parent, MetaDataRegistry registry, + java.util.List collected) { + if (parent.getType() == null || parent.getSubType() == null) return; + TypeDefinition def = registry.getTypeDefinition(parent.getType(), parent.getSubType()); + if (def == null) return; + Set seen = new java.util.HashSet<>(); + for (ChildRequirement rule : def.getChildRequirements()) { + Integer max = rule.getMax(); + if (max == null || rule.isPlacementConstraint() || rule.isValidationConstraint() + || MetaAttribute.TYPE_ATTR.equals(rule.getExpectedType())) continue; + if (!seen.add(rule.getExpectedType() + " " + rule.getExpectedSubType() + " " + rule.getName())) continue; + // ADR-0039: resolving, so a child inherited through extends counts against the bound. + List matching = new java.util.ArrayList<>(); + for (MetaData c : parent.getChildren(MetaData.class, true)) { + if (rule.matches(c.getType(), c.getSubType(), c.getName())) matching.add(c); + } + if (matching.size() <= max) continue; + // ADR-0039: own — the declared children are the ones this node can be blamed for. + Set own = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); + own.addAll(parent.getChildren(MetaData.class, false)); + List ordered = new java.util.ArrayList<>(); + for (MetaData c : matching) if (!own.contains(c)) ordered.add(c); + for (MetaData c : matching) if (own.contains(c)) ordered.add(c); + String owner = parent.getName() != null && !parent.getName().isEmpty() + ? " '" + parent.getName() + "'" : ""; + for (MetaData extra : ordered.subList(max, ordered.size())) { + if (!own.contains(extra)) continue; + collected.add(new MetaDataException( + ErrorMessageConstants.ERR_TOO_MANY_OCCURRENCES + ": " + + extra.getType() + "." + extra.getSubType() + " '" + extra.getName() + + "' is one too many under " + parent.getType() + "." + parent.getSubType() + + owner + ": at most " + max + " " + rule.getExpectedType() + "." + + rule.getExpectedSubType() + " is allowed", + ErrorCode.ERR_TOO_MANY_OCCURRENCES, extra.getSource())); + } + } + } + + // ========================================================================= + // resource.* @residency validation (ADR-0070) + // + // @residency is a closed set (free | confined) on every concrete resource kind. + // Own attribute only: an inherited value was checked on its declaring node. + // ========================================================================= + + static void validateResidency(MetaRoot root) { + walkResidency(root); + } + + private static void walkResidency(MetaData node) { + if (SystemsNode.TYPE_RESOURCE.equals(node.getType()) + && SystemsNode.RESOURCE_KINDS.contains(node.getSubType()) + && node.hasMetaAttr(SystemsNode.ATTR_RESIDENCY, false)) { + String residency = node.getMetaAttr(SystemsNode.ATTR_RESIDENCY, false).getValueAsString(); + if (!SystemsNode.RESIDENCIES.contains(residency)) { + throw new MetaDataException( + ErrorMessageConstants.ERR_BAD_ATTR_VALUE + + ": " + node.getType() + "." + node.getSubType() + " '" + node.getName() + + "' @" + SystemsNode.ATTR_RESIDENCY + " '" + residency + + "' is not a valid value; allowed: " + + String.join(", ", SystemsNode.RESIDENCIES), + ErrorCode.ERR_BAD_ATTR_VALUE, node.getSource()); + } + } + for (MetaData child : node.getChildren(MetaData.class, false)) { + walkResidency(child); + } + } + // ========================================================================= // Enum @values validation // diff --git a/server/java/metadata/src/main/java/com/metaobjects/registry/RegistryManifest.java b/server/java/metadata/src/main/java/com/metaobjects/registry/RegistryManifest.java index 3b51b00b61..3c2ceb210b 100644 --- a/server/java/metadata/src/main/java/com/metaobjects/registry/RegistryManifest.java +++ b/server/java/metadata/src/main/java/com/metaobjects/registry/RegistryManifest.java @@ -306,7 +306,8 @@ public static List metamodelProviders() { // view.textarea @rows and the view.image attrs (ui-web.json). new com.metaobjects.presentation.ui.UiWebTypesMetaDataProvider(), new com.metaobjects.template.PromptTypesMetaDataProvider(), - new com.metaobjects.object.CoreObjectsMetaDataProvider()); + new com.metaobjects.object.CoreObjectsMetaDataProvider(), + new com.metaobjects.systems.SystemsTypesMetaDataProvider()); } /** @@ -328,7 +329,7 @@ public static List metamodelProviders() { * the 1.0 cut will flip it to {@code "1.0"}. Mirrors the TS reference's * {@code METAMODEL_VERSION} constant. */ - public static final String METAMODEL_VERSION = "1.3"; + public static final String METAMODEL_VERSION = "1.4"; // ------------------------------------------------------------------ // SP-G Phase1 Units2-3 — manifest emitter exclusions (documented, uniform diff --git a/server/java/metadata/src/main/java/com/metaobjects/registry/spec/SpecMetamodelReader.java b/server/java/metadata/src/main/java/com/metaobjects/registry/spec/SpecMetamodelReader.java index 8ce397cb72..9db4644d34 100644 --- a/server/java/metadata/src/main/java/com/metaobjects/registry/spec/SpecMetamodelReader.java +++ b/server/java/metadata/src/main/java/com/metaobjects/registry/spec/SpecMetamodelReader.java @@ -74,12 +74,12 @@ public final class SpecMetamodelReader { /** Classpath directory the metadata jar embeds the spec files under. */ public static final String EMBED_DIR = "spec/metamodel"; - /** The 22 shared provider-definition file names (keep in lockstep with {@code spec/metamodel/}). */ + /** The 23 shared provider-definition file names (keep in lockstep with {@code spec/metamodel/}). */ public static final List SPEC_FILES = List.of( "api.json", "attr.json", "db.json", "documentation.json", "field.json", "identity.json", "index.json", "layout.json", "object.json", "origin.json", "prompt.json", "relationship.json", "reporting.json", "requirement.json", "source.json", - "template.json", "transition.json", "ui.json", "ui-web.json", "validator.json", "view.json", + "systems.json", "template.json", "transition.json", "ui.json", "ui-web.json", "validator.json", "view.json", "view-expressions.json"); /** Wildcard token used in the JSON for "any type / any subType". */ diff --git a/server/java/metadata/src/main/java/com/metaobjects/systems/SystemsNode.java b/server/java/metadata/src/main/java/com/metaobjects/systems/SystemsNode.java new file mode 100644 index 0000000000..6bcd2b27fc --- /dev/null +++ b/server/java/metadata/src/main/java/com/metaobjects/systems/SystemsNode.java @@ -0,0 +1,62 @@ +/* + * Copyright 2003 Doug Mealing LLC dba Meta Objects + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.metaobjects.systems; + +import com.metaobjects.MetaData; + +import java.util.List; +import java.util.Set; + +/** + * Node class shared by every systems-pack type ({@code organization.*}, {@code system.*}, + * {@code app.*}, {@code build.*}, {@code resource.*}, {@code role.*}; ADR-0070). The pack is + * pure vocabulary on the Java port: the nodes carry no behaviour of their own, so one class + * serves every (type, subType) pair and the loader constructs it through the 3-argument form. + */ +@SuppressWarnings("serial") +public class SystemsNode extends MetaData { + + /** The type every resource kind shares. */ + public static final String TYPE_RESOURCE = "resource"; + + /** The concrete resource kinds; {@code resource.base} is abstract and never authored. */ + public static final Set RESOURCE_KINDS = Set.of( + "rdb", "keyValue", "objectStore", "document", "search", "queue", "stream", "volume"); + + /** Where a resource's data may be kept: a closed set. */ + public static final String ATTR_RESIDENCY = "residency"; + + /** The values {@code @residency} admits. */ + public static final List RESIDENCIES = List.of("free", "confined"); + + public SystemsNode(String type, String subType, String name) { + super(type, subType, name); + } + + /** + * An organization unit nests inside a company or another unit, which is what + * {@code spec/metamodel/systems.json} declares; {@link MetaData#checkValidChild} refuses a + * child of the parent's own type, so the one declared self-nesting type is let through. + * Every other same-type combination still hits the base refusal. + */ + @Override + protected void checkValidChild(MetaData data) { + if (data != null && "organization".equals(getType()) && "organization".equals(data.getType())) { + return; + } + super.checkValidChild(data); + } +} diff --git a/server/java/metadata/src/main/java/com/metaobjects/systems/SystemsTypesMetaDataProvider.java b/server/java/metadata/src/main/java/com/metaobjects/systems/SystemsTypesMetaDataProvider.java new file mode 100644 index 0000000000..cfbf3a12eb --- /dev/null +++ b/server/java/metadata/src/main/java/com/metaobjects/systems/SystemsTypesMetaDataProvider.java @@ -0,0 +1,156 @@ +/* + * Copyright 2003 Doug Mealing LLC dba Meta Objects + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.metaobjects.systems; + +import com.metaobjects.MetaData; +import com.metaobjects.attr.BooleanAttribute; +import com.metaobjects.attr.StringAttribute; +import com.metaobjects.constraint.CustomConstraint; +import com.metaobjects.registry.MetaDataRegistry; +import com.metaobjects.registry.MetaDataTypeProvider; +import com.metaobjects.registry.TypeDefinitionBuilder; +import com.metaobjects.registry.spec.SpecMetamodelReader; + +import java.util.Map; +import java.util.function.Consumer; + +/** + * Systems pack ({@code metaobjects-systems-core}, ADR-0070): the vocabulary that describes who + * owns a system and what it is made of. {@code organization.*}, {@code system.*}, {@code app.*}, + * {@code build.*}, {@code resource.*} and {@code role.*}. Descriptions, structural children and + * the reference facet on {@code @owner} / {@code @runsAs} / {@code @memberOf} / {@code @heldBy} + * come from {@code spec/metamodel/systems.json}; this class registers the shape the loader + * needs. The pack's {@code extends} (an organization and a system under {@code metadata.root}) + * is applied under the logical id, so leaving the pack out leaves neither the types nor the rule. + */ +public class SystemsTypesMetaDataProvider implements MetaDataTypeProvider { + + /** The pack's cross-port logical id, the {@code provider} of systems.json. */ + public static final String LOGICAL_ID = "metaobjects-systems-core"; + + @Override + public void registerTypes(MetaDataRegistry registry) { + // organization + base(registry, "organization", d -> { }); + sub(registry, "organization", "company", d -> d.optionalChild("organization", "unit", "*")); + sub(registry, "organization", "unit", d -> d.optionalChild("organization", "unit", "*")); + + // system + base(registry, "system", d -> str(d, "owner")); + sub(registry, "system", "software", d -> { + d.optionalChild("app", "*", "*"); + d.optionalChild("resource", "*", "*"); + d.optionalChild("role", "*", "*"); + }); + + // app + base(registry, "app", d -> { + str(d, "runsAs"); + d.optionalChild("build", "*", "*"); + }); + sub(registry, "app", "service", d -> bool(d, "public")); + sub(registry, "app", "client", d -> str(d, "shell")); + sub(registry, "app", "job", d -> str(d, "schedule")); + + // build + base(registry, "build", d -> { }); + sub(registry, "build", "image", d -> + d.requiredAttributeWithConstraints("repository").ofType(StringAttribute.SUBTYPE_STRING).asSingle()); + + // resource + base(registry, "resource", d -> + d.optionalAttributeWithConstraints("residency").ofType(StringAttribute.SUBTYPE_STRING) + .withEnum("free", "confined")); + sub(registry, "resource", "rdb", d -> + d.optionalAttributeWithConstraints("schemas").ofType(StringAttribute.SUBTYPE_STRING).asArray()); + sub(registry, "resource", "keyValue", d -> bool(d, "volatile")); + sub(registry, "resource", "objectStore", d -> bool(d, "publicRead")); + sub(registry, "resource", "document", d -> { }); + sub(registry, "resource", "search", d -> { }); + sub(registry, "resource", "queue", d -> { + bool(d, "ordered"); + bool(d, "deadLetter"); + }); + sub(registry, "resource", "stream", d -> { }); + sub(registry, "resource", "volume", d -> { }); + + // role + base(registry, "role", d -> { + d.optionalAttributeWithConstraints("memberOf").ofType(StringAttribute.SUBTYPE_STRING).asArray(); + str(d, "credential"); + }); + sub(registry, "role", "service", d -> { }); + sub(registry, "role", "user", d -> { }); + sub(registry, "role", "group", d -> { }); + sub(registry, "role", "token", d -> str(d, "heldBy")); + + // The array-shape constraint a `.asArray()` attr generates is keyed on the DECLARING + // subtype, and the loader's bare-string sugar looks it up by the node's OWN subtype. + // @memberOf is declared once on role.base, so each concrete role subtype needs its key. + for (String sub : new String[]{"service", "user", "group", "token"}) { + registry.addConstraint(new CustomConstraint( + "role." + sub + ".memberOf.array", + "memberOf attribute must be an array on role." + sub, + m -> "role".equals(m.getType()) && sub.equals(m.getSubType()), + (m, v) -> true, + "Array constraint validation")); + } + + registry.applyProviderExtends(SpecMetamodelReader.load(), LOGICAL_ID, Map.of()); + } + + private static void str(TypeDefinitionBuilder d, String name) { + d.optionalAttributeWithConstraints(name).ofType(StringAttribute.SUBTYPE_STRING).asSingle(); + } + + private static void bool(TypeDefinitionBuilder d, String name) { + d.optionalAttributeWithConstraints(name).ofType(BooleanAttribute.SUBTYPE_BOOLEAN).asSingle(); + } + + private static void base(MetaDataRegistry registry, String type, Consumer body) { + registry.registerType(SystemsNode.class, d -> { + d.type(type).subType(MetaData.SUBTYPE_BASE) + .description("Registry anchor for " + type + " nodes (ADR-0070)") + .inheritsFrom(MetaData.TYPE_METADATA, MetaData.SUBTYPE_BASE); + body.accept(d); + }); + } + + private static void sub(MetaDataRegistry registry, String type, String subType, + Consumer body) { + registry.registerType(SystemsNode.class, d -> { + d.type(type).subType(subType) + .description(type + "." + subType + " (ADR-0070)") + .inheritsFrom(type, MetaData.SUBTYPE_BASE); + body.accept(d); + }); + } + + @Override + public String getProviderId() { + return "systems-types"; + } + + @Override + public String[] getDependencies() { + return new String[]{"core-types"}; + } + + @Override + public String getDescription() { + return "Systems Types (organization, system, app, build, resource, role) — ADR-0070"; + } +} diff --git a/server/java/metadata/src/main/resources/META-INF/services/com.metaobjects.registry.MetaDataTypeProvider b/server/java/metadata/src/main/resources/META-INF/services/com.metaobjects.registry.MetaDataTypeProvider index 1bdea5d8a1..4dffaa80b7 100644 --- a/server/java/metadata/src/main/resources/META-INF/services/com.metaobjects.registry.MetaDataTypeProvider +++ b/server/java/metadata/src/main/resources/META-INF/services/com.metaobjects.registry.MetaDataTypeProvider @@ -21,3 +21,4 @@ com.metaobjects.presentation.ui.UiTypesMetaDataProvider com.metaobjects.presentation.ui.UiWebTypesMetaDataProvider com.metaobjects.template.PromptTypesMetaDataProvider com.metaobjects.object.CoreObjectsMetaDataProvider +com.metaobjects.systems.SystemsTypesMetaDataProvider diff --git a/server/java/metadata/src/test/java/com/metaobjects/conformance/ConformanceTest.java b/server/java/metadata/src/test/java/com/metaobjects/conformance/ConformanceTest.java index b642db8037..7bd89c9b5d 100644 --- a/server/java/metadata/src/test/java/com/metaobjects/conformance/ConformanceTest.java +++ b/server/java/metadata/src/test/java/com/metaobjects/conformance/ConformanceTest.java @@ -156,6 +156,12 @@ public class ConformanceTest { java.util.Map.entry("metaobjects-requirements", List.of( "requirement-types" )), + // The systems vocabulary (ADR-0070: organization / system / app / build / resource / + // role) is its own pack, last in the default bundle, left out of a fixture that does + // not name it. + java.util.Map.entry("metaobjects-systems-core", List.of( + "systems-types" + )), // ADR-0066 business-rules pack (api / operation / binding / transition) and the // rc.21 view-expressions pack (origin.function, @union / @grain on a projection): // their own providers, in the default bundle, left out of a fixture that does not @@ -402,6 +408,9 @@ static void runConformanceChecks(FixtureDiscovery.Fixture fix, if (!fix.requiredProviders.contains("metaobjects-view-expressions")) { packsLeftOut.add("view-expressions-types"); } + if (!fix.requiredProviders.contains("metaobjects-systems-core")) { + packsLeftOut.add("systems-types"); + } } if (!packsLeftOut.isEmpty() && !handledByCompose) { loader.setTypeRegistry(com.metaobjects.registry.RegistryManifest.composeLoaderRegistry( diff --git a/server/java/metadata/src/test/java/com/metaobjects/validation/ReferenceFacetTest.java b/server/java/metadata/src/test/java/com/metaobjects/validation/ReferenceFacetTest.java index e6fb739776..d82bc429d9 100644 --- a/server/java/metadata/src/test/java/com/metaobjects/validation/ReferenceFacetTest.java +++ b/server/java/metadata/src/test/java/com/metaobjects/validation/ReferenceFacetTest.java @@ -68,8 +68,8 @@ public SystemTestNode(String type, String subType, String name) { { "type": "app", "subType": "*", "name": "*", "min": 0, "max": null }, { "type": "resource", "subType": "*", "name": "*", "min": 0, "max": null } ] }, - { "type": "app", "subType": "service", "children": [ - { "type": "attr", "subType": "string", "name": "runsAs", "min": 0, "max": 1, "description": "Test.", + { "type": "app", "subType": "web", "children": [ + { "type": "attr", "subType": "string", "name": "actsAs", "min": 0, "max": 1, "description": "Test.", "ref": { "targetType": "role", "sameSystem": true, "wrongSystemCode": "ERR_RUNSAS_OTHER_SYSTEM" } }, { "type": "attr", "subType": "string", "name": "calls", "isArray": true, "min": 0, "max": 1, "description": "Test.", "ref": { "targetType": "app" } }, @@ -78,7 +78,7 @@ public SystemTestNode(String type, String subType, String name) { ] }, { "type": "grant", "subType": "rdb", "children": [ { "type": "attr", "subType": "string", "name": "resource", "min": 0, "max": 1, "description": "Test.", - "ref": { "targetType": "resource", "targetSubTypes": ["rdb"], "sameSystem": true, + "ref": { "targetType": "resource", "targetSubTypes": ["pg"], "sameSystem": true, "wrongSystemCode": "ERR_GRANT_CROSSES_SYSTEM" } } ] }, { "type": "deployment", "subType": "test", "children": [ @@ -100,12 +100,12 @@ public SystemTestNode(String type, String subType, String name) { @Override public String[] getDependencies() { return new String[]{"core-types", "attribute-types"}; } @Override public String getDescription() { return "Test-only: a small system vocabulary with reference attrs."; } @Override public void registerTypes(MetaDataRegistry registry) { - type(registry, "system", "software", "app", "role", "resource"); - type(registry, "app", "service"); - type(registry, "role", "service", "grant", "resource"); + type(registry, "system", "test", "app", "role", "resource"); + type(registry, "app", "web"); + type(registry, "role", "agent", "grant", "resource"); type(registry, "grant", "rdb"); - type(registry, "resource", "rdb"); - type(registry, "resource", "queue"); + type(registry, "resource", "pg"); + type(registry, "resource", "mq"); type(registry, "deployment", "test"); registry.applyProviderExtends(SpecMetamodelReader.fromJson(DEFINITION), PROVIDER_ID, Map.of()); } @@ -120,9 +120,13 @@ private static void type(MetaDataRegistry registry, String type, String subType, } private static MetaDataRegistry registry() { - return RegistryManifest.composeLoaderRegistry(List.of(PROVIDER)); + return RegistryManifest.composeLoaderRegistry(List.of(PROVIDER), List.of(SYSTEMS_PROVIDER_ID)); } + /** The shipped systems pack registers the same type names as the test vocabulary, so the + * tests compose core without it; the shipped vocabulary is held by the conformance corpus. */ + private static final String SYSTEMS_PROVIDER_ID = "systems-types"; + /** A load's root and every error it raised (the recorded ones plus the thrown one). */ private record Result(MetaData root, List errors) {} @@ -133,6 +137,7 @@ private static Result load(String text) { private static Result load(String text, MetaDataSource.MetaDataFormat format) { LoaderOptions options = LoaderOptions.create(false, false, true).setProviders(List.of(PROVIDER)); MetaDataLoader loader = new MetaDataLoader(options, MetaDataLoader.SUBTYPE_MANUAL, "referenceFacet"); + loader.setTypeRegistry(registry()); loader.init(); List errors = new ArrayList<>(); try { @@ -166,25 +171,25 @@ private static String model(String parcelsExtra, String outside) { metadata.root: package: acme children: - - system.software: + - system.test: name: Parcels children: - - resource.rdb: { name: db } - - resource.queue: { name: jobs } - - role.service: + - resource.pg: { name: db } + - resource.mq: { name: jobs } + - role.agent: name: api children: - grant.rdb: { name: g1, resource: db } - - app.service: + - app.web: name: api - runsAs: api + actsAs: api """ + parcelsExtra + "\n" + """ - - system.software: + - system.test: name: Ledger children: - - resource.rdb: { name: books } - - role.service: { name: clerk } - - app.service: { name: web, runsAs: clerk } + - resource.pg: { name: books } + - role.agent: { name: clerk } + - app.web: { name: web, actsAs: clerk } """ + outside + "\n"; } @@ -230,7 +235,7 @@ public void theReaderLowersRefOntoTheAttributeRequirement() { ReferenceFacet ref = req.getRef(); assertNotNull(ref); assertEquals("resource", ref.targetType()); - assertEquals(List.of("rdb"), ref.targetSubTypes()); + assertEquals(List.of("pg"), ref.targetSubTypes()); assertTrue(ref.sameSystem()); assertFalse(ref.fieldPath()); assertNull(ref.errorCode()); @@ -302,15 +307,31 @@ public void theReaderCarriesAFacetOnATypesEntryAttr() { "relationship.base @objectRef object false ERR_INVALID_RELATIONSHIP", "relationship.composition @objectRef object false ERR_INVALID_RELATIONSHIP"); + /** The systems vocabulary's four references (ADR-0070), each written on every subtype that + * inherits it. They name a target subtype or a system boundary, which core's four do not. */ + private static final List SYSTEMS_FACETS = List.of( + "app.base @runsAs", "app.client @runsAs", "app.job @runsAs", "app.service @runsAs", + "role.base @memberOf", "role.group @memberOf", "role.service @memberOf", + "role.token @heldBy", "role.token @memberOf", "role.user @memberOf", + "system.base @owner", "system.software @owner"); + + private static final java.util.Set SYSTEMS_TYPES = + java.util.Set.of("app", "build", "organization", "resource", "role", "system"); + @Test public void theCoreDefinitionsDeclareExactlyTheFourCoreReferences() { MetaDataRegistry registry = RegistryManifest.defaultLoaderRegistry(); List found = new java.util.ArrayList<>(); + List systems = new java.util.ArrayList<>(); for (MetaDataTypeId id : registry.getRegisteredTypes()) { TypeDefinition def = registry.getTypeDefinition(id.type(), id.subType()); for (ChildRequirement req : def.getChildRequirements()) { ReferenceFacet f = req.getRef(); if (f == null) continue; + if (SYSTEMS_TYPES.contains(id.type())) { + systems.add(id.type() + "." + id.subType() + " @" + req.getName()); + continue; + } assertNull(f.targetSubTypes()); assertFalse(f.sameSystem()); found.add(id.type() + "." + id.subType() + " @" + req.getName() + " " + f.targetType() @@ -319,6 +340,8 @@ public void theCoreDefinitionsDeclareExactlyTheFourCoreReferences() { } java.util.Collections.sort(found); assertEquals(CORE_FACETS, found); + java.util.Collections.sort(systems); + assertEquals(SYSTEMS_FACETS, systems); for (CommonAttributeDef common : registry.getCommonAttributes()) { assertNull(common.name(), common.ref()); } @@ -335,12 +358,12 @@ public void aValidModelLoadsClean() { @Test public void aRoleAndAnAppBothNamedApiTheLookupIsKindTyped() { - Result r = load(model(" - app.service: { name: worker, runsAs: api, calls: [api, Parcels.api] }")); + Result r = load(model(" - app.web: { name: worker, actsAs: api, calls: [api, Parcels.api] }")); clean(r); MetaData worker = at(r.root(), "Parcels", "worker"); - // runsAs targets a role: the role `api`, not the app `api`. - assertEquals("role", boundTo(worker, "runsAs").getType()); - assertEquals("acme::Parcels.api", value(worker, "runsAs")); + // actsAs targets a role: the role `api`, not the app `api`. + assertEquals("role", boundTo(worker, "actsAs").getType()); + assertEquals("acme::Parcels.api", value(worker, "actsAs")); // calls targets an app: both spellings bind the app `api`. assertEquals(List.of("acme::Parcels.api", "acme::Parcels.api"), value(worker, "calls")); for (Object t : (List) worker.getMetaAttr("calls").getResolvedTarget()) { @@ -350,7 +373,7 @@ public void aRoleAndAnAppBothNamedApiTheLookupIsKindTyped() { @Test public void unresolvedAValueNamingNoNode() { - Result r = load(model(" - app.service: { name: worker, calls: [nobody] }")); + Result r = load(model(" - app.web: { name: worker, calls: [nobody] }")); assertEquals(List.of("ERR_REF_UNRESOLVED"), codes(r)); assertEquals(ErrorCode.ERR_REF_UNRESOLVED, r.errors().get(0).getCode().orElseThrow()); assertTrue(message(r, 0), message(r, 0).contains("@calls \"nobody\"")); @@ -358,43 +381,43 @@ public void unresolvedAValueNamingNoNode() { @Test public void wrongKindNormativeCaseA() { - Result r = load(model(" - app.service: { name: worker, runsAs: db }")); + Result r = load(model(" - app.web: { name: worker, actsAs: db }")); assertEquals(List.of("ERR_REF_WRONG_KIND"), codes(r)); assertEquals(ErrorCode.ERR_REF_WRONG_KIND, r.errors().get(0).getCode().orElseThrow()); - assertTrue(message(r, 0), message(r, 0).contains("resource.rdb")); + assertTrue(message(r, 0), message(r, 0).contains("resource.pg")); } @Test public void unresolvedNormativeCaseB() { assertEquals(List.of("ERR_REF_UNRESOLVED"), - codes(load(model(" - app.service: { name: worker, runsAs: nobody }")))); + codes(load(model(" - app.web: { name: worker, actsAs: nobody }")))); } @Test public void wrongKindWhenTwoTopLevelNodesOfOtherTypesShareTheName() { String outside = """ - - system.software: { name: Shared } + - system.test: { name: Shared } - deployment.test: { name: Shared } """; assertEquals(List.of("ERR_REF_WRONG_KIND"), - codes(load(model(" - app.service: { name: worker, runsAs: Shared }", outside)))); + codes(load(model(" - app.web: { name: worker, actsAs: Shared }", outside)))); } @Test public void wrongSubtypeAGrantRdbNamingAResourceQueue() { Result r = load(model(""" - - role.service: + - role.agent: name: mover children: - grant.rdb: { name: g2, resource: jobs } """)); assertEquals(List.of("ERR_REF_WRONG_KIND"), codes(r)); - assertTrue(message(r, 0), message(r, 0).contains("resource.queue")); + assertTrue(message(r, 0), message(r, 0).contains("resource.mq")); assertTrue(message(r, 0), message(r, 0).contains("system \"acme::Parcels\"")); } private static final String CROSSES = """ - - role.service: + - role.agent: name: auditor children: - grant.rdb: { name: g3, resource: Ledger.books } @@ -491,45 +514,45 @@ private static Object roundTrip(String yaml, String[] referrer, String attr, Str @Test public void anInheritedReferenceIsLookedUpWhereItWasWritten() { - // Ledger has no role `api`: `web` inherits `runsAs: api` from Parcels' `base`. + // Ledger has no role `api`: `web` inherits `actsAs: api` from Parcels' `base`. Result r = load(""" metadata.root: package: acme children: - - system.software: + - system.test: name: Parcels children: - - role.service: { name: api } - - app.service: { name: base, runsAs: api } - - system.software: + - role.agent: { name: api } + - app.web: { name: base, actsAs: api } + - system.test: name: Ledger children: - - app.service: { name: web, extends: acme::Parcels.base } + - app.web: { name: web, extends: acme::Parcels.base } """); clean(r); - assertSame(at(r.root(), "Parcels", "api"), boundTo(at(r.root(), "Ledger", "web"), "runsAs")); + assertSame(at(r.root(), "Parcels", "api"), boundTo(at(r.root(), "Ledger", "web"), "actsAs")); } @Test public void anInheritedSameSystemReferenceIsJudgedWhereItWasWritten() { - // Ledger has its own role `api`, but `web`'s `runsAs: api` was written in Parcels. + // Ledger has its own role `api`, but `web`'s `actsAs: api` was written in Parcels. Result r = load(""" metadata.root: package: acme children: - - system.software: + - system.test: name: Parcels children: - - role.service: { name: api } - - app.service: { name: base, runsAs: api } - - system.software: + - role.agent: { name: api } + - app.web: { name: base, actsAs: api } + - system.test: name: Ledger children: - - role.service: { name: api } - - app.service: { name: web, extends: acme::Parcels.base } + - role.agent: { name: api } + - app.web: { name: web, extends: acme::Parcels.base } """); clean(r); - assertSame(at(r.root(), "Parcels", "role:api"), boundTo(at(r.root(), "Ledger", "web"), "runsAs")); + assertSame(at(r.root(), "Parcels", "role:api"), boundTo(at(r.root(), "Ledger", "web"), "actsAs")); } private static String inheriting(String extra) { @@ -537,15 +560,15 @@ private static String inheriting(String extra) { metadata.root: package: acme children: - - system.software: + - system.test: name: Parcels children: - - role.service: { name: clerk } - - system.software: + - role.agent: { name: clerk } + - system.test: name: Ledger extends: Parcels children: - - app.service: { name: web, runsAs: clerk } + - app.web: { name: web, actsAs: clerk } """ + extra + "\n"; } @@ -558,7 +581,7 @@ public void anInheritedChildKeepsThePathItWasAddressedByAndIsInThatSystem() { // `web` reaches the inherited `clerk` through its own system, so sameSystem holds. Result r = load(inheriting("")); clean(r); - assertEquals("acme::Ledger.clerk", value(at(r.root(), "Ledger", "web"), "runsAs")); + assertEquals("acme::Ledger.clerk", value(at(r.root(), "Ledger", "web"), "actsAs")); } @Test @@ -567,14 +590,14 @@ public void aPathThroughASharedIntermediateNameKeepsTheValueAsWritten() { metadata.root: package: acme children: - - system.software: + - system.test: name: Parcels children: - - app.service: { name: api } - - role.service: + - app.web: { name: api } + - role.agent: name: api children: - - resource.rdb: { name: local } + - resource.pg: { name: local } - grant.rdb: { name: g1, resource: local } """, new String[]{"Parcels", "role:api", "g1"}, "resource", new String[]{"Parcels", "role:api", "local"}); @@ -588,13 +611,13 @@ public void aTopLevelKeySharedByTwoTypesKeepsTheValueAsWritten() { package: acme children: - deployment.test: { name: Shared } - - system.software: + - system.test: name: Shared children: - - role.service: { name: r } - - app.service: { name: a, runsAs: r } + - role.agent: { name: r } + - app.web: { name: a, actsAs: r } """, - new String[]{"system:Shared", "a"}, "runsAs", new String[]{"system:Shared", "r"}); + new String[]{"system:Shared", "a"}, "actsAs", new String[]{"system:Shared", "r"}); assertEquals("r", written); } @@ -603,12 +626,12 @@ public void aRootAbsoluteValueAContainerChildWouldShadowKeepsItsRootPrefix() { Object written = roundTrip(""" metadata.root: children: - - app.service: { name: api } - - system.software: + - app.web: { name: api } + - system.test: name: S children: - - app.service: { name: api } - - app.service: { name: worker, calls: ["::api"] } + - app.web: { name: api } + - app.web: { name: worker, calls: ["::api"] } """, new String[]{"S", "worker"}, "calls", new String[]{"app:api"}); assertEquals(List.of("::api"), written); @@ -616,7 +639,7 @@ public void aRootAbsoluteValueAContainerChildWouldShadowKeepsItsRootPrefix() { @Test public void aFieldPathValueNamesATopLevelTargetNeverAContainerChild() { - Result r = load(model(" - app.service: { name: worker, reads: db.name }", " - resource.rdb: { name: db }")); + Result r = load(model(" - app.web: { name: worker, reads: db.name }", " - resource.pg: { name: db }")); clean(r); MetaData worker = at(r.root(), "Parcels", "worker"); assertSame(at(r.root(), "db"), boundTo(worker, "reads")); @@ -877,18 +900,18 @@ public void theManifestWritesRefOnlyOnAnAttributeThatHasOneInTheFixedKeyOrder() new ArrayList<>(resource.keySet())); Gson gson = new Gson(); assertEquals( - "{\"targetType\":\"resource\",\"targetSubTypes\":[\"rdb\"],\"sameSystem\":true,\"wrongSystemCode\":\"ERR_GRANT_CROSSES_SYSTEM\"}", + "{\"targetType\":\"resource\",\"targetSubTypes\":[\"pg\"],\"sameSystem\":true,\"wrongSystemCode\":\"ERR_GRANT_CROSSES_SYSTEM\"}", gson.toJson(resource.get("ref"))); assertEquals("{\"targetType\":\"role\",\"errorCode\":\"ERR_TEST_ROLE\"}", gson.toJson(manifestAttr(manifest, "deployment", "test", "anyRole").get("ref"))); assertEquals("{\"targetType\":\"resource\",\"fieldPath\":true}", - gson.toJson(manifestAttr(manifest, "app", "service", "reads").get("ref"))); + gson.toJson(manifestAttr(manifest, "app", "web", "reads").get("ref"))); } @Test public void anAttributeWithNoFacetWritesNoRefKey() { - // One "ref" per facet in the core definitions, and none anywhere else. + // One "ref" per facet in the core and systems definitions, and none anywhere else. String manifest = RegistryManifest.emit(RegistryManifest.defaultLoaderRegistry()); - assertEquals(CORE_FACETS.size(), manifest.split("\"ref\"", -1).length - 1); + assertEquals(CORE_FACETS.size() + SYSTEMS_FACETS.size(), manifest.split("\"ref\"", -1).length - 1); } } diff --git a/server/python/src/metaobjects/codegen/runtime/docs_metamodel.py b/server/python/src/metaobjects/codegen/runtime/docs_metamodel.py index faba6e190d..095a98c3b0 100644 --- a/server/python/src/metaobjects/codegen/runtime/docs_metamodel.py +++ b/server/python/src/metaobjects/codegen/runtime/docs_metamodel.py @@ -29,6 +29,7 @@ "field", "object", "attr", "validator", "identity", "index", "relationship", "documentation", "origin", "source", "db", "view", "layout", "ui", "ui-web", "template", "prompt", "api", "transition", "view-expressions", "reporting", "requirement", + "systems", ) _WILDCARD = "*" diff --git a/server/python/src/metaobjects/core_types.py b/server/python/src/metaobjects/core_types.py index 1bfe01f1aa..03a588d10a 100644 --- a/server/python/src/metaobjects/core_types.py +++ b/server/python/src/metaobjects/core_types.py @@ -1031,6 +1031,7 @@ def _register_subtypes( ) from .meta.core.reporting.reporting_provider import reporting_provider # noqa: E402 from .meta.core.requirement.requirements_provider import requirements_provider # noqa: E402 +from .meta.core.systems.systems_provider import systems_provider # noqa: E402 core_providers: list[Provider] = [ core_provider, @@ -1048,6 +1049,8 @@ def _register_subtypes( # Reporting (FR-044) and requirements are their own packs too, in the default bundle. reporting_provider, requirements_provider, + # Systems (ADR-0070): organization, system, app, build, resource, role -- appended last. + systems_provider, ] # #265 — the ids of the LIBRARY providers above, as a frozen set. Consulted by diff --git a/server/python/src/metaobjects/loader/validation_passes.py b/server/python/src/metaobjects/loader/validation_passes.py index 7ea328dbd5..c97a83c540 100644 --- a/server/python/src/metaobjects/loader/validation_passes.py +++ b/server/python/src/metaobjects/loader/validation_passes.py @@ -95,6 +95,7 @@ ) from ..registry import AttrSchema, ChildRule, TypeRegistry from ..shared.base_types import ( + TYPE_ATTR, TYPE_FIELD, TYPE_IDENTITY, TYPE_INDEX, @@ -4382,6 +4383,44 @@ def _validate_max_occurs( envelope=offender.source, ) ) + _check_child_rule_max(node, registry, errors) + + +def _check_child_rule_max( + node: MetaData, + registry: TypeRegistry, + errors: list[MetaError], +) -> None: + """Enforce a child rule's ``max`` (an app has at most one ``build.*``, of any + kind). The bound is on the parent's EFFECTIVE children, so a child inherited + through ``extends`` counts: inherited children are taken first, and each + declared child past the bound is reported.""" + definition = registry.find(node.type, node.sub_type) + if definition is None: + return + for rule in definition.child_rules: + if rule.max is None or rule.child_type == TYPE_ATTR: + continue + # ADR-0039: resolving, so a child inherited through extends counts against the bound. + matching = [c for c in node.children() if _child_rule_admits(rule, c)] + if len(matching) <= rule.max: + continue + # ADR-0039 sanctioned own: the declared children are the ones this node can be blamed for. + own = {id(c) for c in node.own_children()} + ordered = [c for c in matching if id(c) not in own] + [c for c in matching if id(c) in own] + owner = f" '{node.name}'" if node.name else "" + for extra in ordered[rule.max:]: + if id(extra) not in own: + continue + errors.append( + MetaError( + f"{extra.type}.{extra.sub_type} '{extra.name}' is one too many under " + f"{node.type}.{node.sub_type}{owner}: at most {rule.max} " + f"{rule.child_type}.{rule.child_sub_type} is allowed", + ErrorCode.ERR_TOO_MANY_OCCURRENCES, + envelope=extra.source, + ) + ) # FR-024 value purity (ADR-0028): a value object owns NO identity and NO source. diff --git a/server/python/src/metaobjects/meta/core/systems/__init__.py b/server/python/src/metaobjects/meta/core/systems/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/server/python/src/metaobjects/meta/core/systems/meta_systems_node.py b/server/python/src/metaobjects/meta/core/systems/meta_systems_node.py new file mode 100644 index 0000000000..b645c18765 --- /dev/null +++ b/server/python/src/metaobjects/meta/core/systems/meta_systems_node.py @@ -0,0 +1,11 @@ +"""MetaSystemsNode -- the node class behind the systems vocabulary (ADR-0070): +``organization.*``, ``system.*``, ``app.*``, ``build.*``, ``resource.*`` and ``role.*``. +No subtype carries behaviour of its own; attributes are read with the resolving +accessors (ADR-0039).""" +from __future__ import annotations + +from ...meta_data import MetaData + + +class MetaSystemsNode(MetaData): + """A node of the systems vocabulary.""" diff --git a/server/python/src/metaobjects/meta/core/systems/systems_provider.py b/server/python/src/metaobjects/meta/core/systems/systems_provider.py new file mode 100644 index 0000000000..9206071c14 --- /dev/null +++ b/server/python/src/metaobjects/meta/core/systems/systems_provider.py @@ -0,0 +1,45 @@ +"""systems_provider -- the systems vocabulary (cross-port ``metaobjects-systems-core``). + +ADR-0070, new in 1.4.0: organizations, systems, apps, builds, resources and roles, read +from ``spec/metamodel/systems.json`` so the types, their attrs, their structural children +and their reference facets (``system @owner``, ``app @runsAs``, ``role @memberOf``, +``role.token @heldBy``) are single-sourced from the shared definition. The references are +enforced by the generic reference resolver; this provider adds no code checks. It is its +OWN provider, in the default bundle after requirements, and admits ``organization.company`` +and ``system.software`` on a document root through the file's ``extends``. Mirrors the TS +``systemsCoreProvider``. +""" +from __future__ import annotations + +from ....provider import Provider +from ....registry import ChildRule, TypeDefinition, TypeRegistry +from ....shared.base_types import TYPE_ATTR +from ....spec_metamodel import load_provider_types +from ...provider_extends import attr_schema_from_entry, register_extends +from .meta_systems_node import MetaSystemsNode + +SYSTEMS_CORE_PROVIDER_ID = "metaobjects-systems-core" +_SYSTEMS_FILE = "systems.json" + +systems_provider = Provider(SYSTEMS_CORE_PROVIDER_ID, dependencies=("metaobjects-core-types",)) + +for _t in load_provider_types(_SYSTEMS_FILE): + systems_provider.add( + TypeDefinition( + type=_t.type, + sub_type=_t.sub_type, + factory=MetaSystemsNode, + extends_base=_t.extends_base, + attrs=[attr_schema_from_entry(a) for a in _t.attrs], + # Structural children are re-derived from systems.json by the strict + # structural pass; the any-attr wildcard is the only rule declared here. + child_rules=[ChildRule(TYPE_ATTR, "*")], + ) + ) + + +def _register(registry: TypeRegistry) -> None: + register_extends(registry, _SYSTEMS_FILE) + + +systems_provider.on_register(_register) diff --git a/server/python/src/metaobjects/registry_manifest.py b/server/python/src/metaobjects/registry_manifest.py index 2db6a171c4..05012d038b 100644 --- a/server/python/src/metaobjects/registry_manifest.py +++ b/server/python/src/metaobjects/registry_manifest.py @@ -273,7 +273,7 @@ def _sorted_children(definition: TypeDefinition) -> list[dict[str, object]]: return children -METAMODEL_VERSION = "1.3" +METAMODEL_VERSION = "1.4" """Rolled-up spec-version for the cross-port registry manifest. ``"0"`` = pre-1.0 / unstable (semver major-0). Flips to ``"1.0"`` at the diff --git a/server/python/src/metaobjects/render/bundled_templates/metamodel/provider-descriptions.json b/server/python/src/metaobjects/render/bundled_templates/metamodel/provider-descriptions.json index 4cbe8f7f5c..a4241a7a6a 100644 --- a/server/python/src/metaobjects/render/bundled_templates/metamodel/provider-descriptions.json +++ b/server/python/src/metaobjects/render/bundled_templates/metamodel/provider-descriptions.json @@ -6,6 +6,7 @@ "metaobjects-reporting": "Reporting (FR-044): object.report, dimension / measure / segment on an entity, and @segment on origin.aggregate and origin.first.", "metaobjects-requirements": "Requirements: requirement.functional and requirement.architectural, declared at the document root and checked by meta verify.", "metaobjects-rules": "Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).", + "metaobjects-systems-core": "Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role.", "metaobjects-ui": "UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D).", "metaobjects-ui-web": "Web presentation view attrs — @rows (view.textarea) and the view.image control attrs. Every port applies this provider and loads them strictly; only TypeScript acts on them so far.", "metaobjects-view-expressions": "View expressions (rc.21): origin.function plus the projection @union / @unionAll / @grain / @grainOrdinal attributes." diff --git a/server/python/src/metaobjects/spec_metamodel/__init__.py b/server/python/src/metaobjects/spec_metamodel/__init__.py index 4170bdd15e..64b89260b3 100644 --- a/server/python/src/metaobjects/spec_metamodel/__init__.py +++ b/server/python/src/metaobjects/spec_metamodel/__init__.py @@ -65,6 +65,7 @@ "reporting.json", "requirement.json", "source.json", + "systems.json", "template.json", "transition.json", "ui.json", @@ -560,6 +561,41 @@ class ExtendsTarget: children: tuple[StructChild, ...] = () +@dataclass(frozen=True) +class TypeTarget: + """One ``types[]`` entry of a provider file that registers NEW types (a pack whose + vocabulary is data, such as ``systems.json``): the ``(type, subType)``, whether it + folds ``.base`` (``extendsBase``), and its attr and structural child entries + in document order.""" + + type: str + sub_type: str + extends_base: bool + attrs: tuple[AttrEntry, ...] + children: tuple[StructChild, ...] + + +def load_provider_types(file_name: str) -> list[TypeTarget]: + """Parse ONE embedded provider file and return its ``types[]`` entries as + :class:`TypeTarget`s, in document order.""" + pkg = resources.files(__package__) + provider = json.loads((pkg / file_name).read_text(encoding="utf-8")) + provider_id = provider.get("provider") + out: list[TypeTarget] = [] + for t in provider.get("types") or []: + key_name = _type_key(t.get("type"), t.get("subType")) + out.append( + TypeTarget( + type=t["type"], + sub_type=t["subType"], + extends_base=bool(t.get("extendsBase")), + attrs=tuple(SpecMetamodelReader._parse_attr_children(t, provider_id, key_name)), + children=tuple(SpecMetamodelReader._parse_struct_children(t, provider_id, key_name)), + ) + ) + return out + + def load_provider_extends(file_name: str) -> list[ExtendsTarget]: """Parse ONE embedded ``spec/metamodel/`` provider file and return its ordered ``extends`` directives as :class:`ExtendsTarget`s (one per concrete diff --git a/server/python/src/metaobjects/spec_metamodel/systems.json b/server/python/src/metaobjects/spec_metamodel/systems.json new file mode 100644 index 0000000000..8ff1f9e598 --- /dev/null +++ b/server/python/src/metaobjects/spec_metamodel/systems.json @@ -0,0 +1,233 @@ +{ + "provider": "metaobjects-systems-core", + "types": [ + { + "type": "organization", + "subType": "base", + "description": "Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "organization", + "subType": "company", + "extendsBase": true, + "description": "A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company.", + "whenToUse": "Every party that owns a system or holds a token. A party that publishes no metadata is written down by whoever depends on it, under the party's own package name.", + "rules": "Lives at the document root. Its units are its children, addressed `Company.unit` (`pkg::Company.unit` from another package).", + "children": [ + { "type": "organization", "subType": "unit", "name": "*", "min": 0, "max": null, "description": "The teams or divisions inside the company." } + ] + }, + { + "type": "organization", + "subType": "unit", + "extendsBase": true, + "description": "A team or division inside a company. Units nest: a unit is a child of a company or of another unit.", + "whenToUse": "When a system's owner is a team rather than the whole company.", + "children": [ + { "type": "organization", "subType": "unit", "name": "*", "min": 0, "max": null, "description": "The units inside this one." } + ] + }, + { + "type": "system", + "subType": "base", + "description": "Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "owner", "min": 0, "max": 1, "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources.", "ref": { "targetType": "organization" } } + ] + }, + { + "type": "system", + "subType": "software", + "extendsBase": true, + "description": "A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package.", + "whenToUse": "Every product or service, including one somebody else runs that an app calls: write it down under its owner's package name.", + "rules": "Lives at the document root. Names are unique per type within the system, so an app and a role may share a name: every reference names the type it wants.", + "children": [ + { "type": "app", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The system's apps." }, + { "type": "resource", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The system's resources." }, + { "type": "role", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The identities that act in the system." } + ] + }, + { + "type": "app", + "subType": "base", + "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "runsAs", "min": 0, "max": 1, "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND.", "ref": { "targetType": "role", "targetSubTypes": ["service"] } }, + { "type": "build", "subType": "*", "name": "*", "min": 0, "max": 1, "description": "How the app's deployable is made. At most one, of any kind." } + ] + }, + { + "type": "app", + "subType": "service", + "extendsBase": true, + "description": "A long-running process that answers requests: a web server, an API, a socket server.", + "whenToUse": "Anything that listens on a port and stays up.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "public", "min": 0, "max": 1, "description": "The service is meant to be reached from outside every system: from browsers or from parties holding no role in the model. Absent means it is reached only by the apps and roles the model names." } + ] + }, + { + "type": "app", + "subType": "client", + "extendsBase": true, + "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", + "whenToUse": "A front end built and shipped as files, whatever serves them.", + "children": [ + { "type": "attr", "subType": "string", "name": "shell", "min": 0, "max": 1, "description": "The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here." } + ] + }, + { + "type": "app", + "subType": "job", + "extendsBase": true, + "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", + "whenToUse": "A cron job, a nightly import, a queue drain that is not a long-running service.", + "children": [ + { "type": "attr", "subType": "string", "name": "schedule", "min": 0, "max": 1, "description": "When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered." } + ] + }, + { + "type": "build", + "subType": "base", + "description": "Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "build", + "subType": "image", + "extendsBase": true, + "description": "The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here.", + "whenToUse": "An app whose image someone else builds: a product sold as images that the buyer deploys.", + "children": [ + { "type": "attr", "subType": "string", "name": "repository", "min": 1, "max": 1, "description": "Where the publisher keeps the image, without a tag (`registry.example.com/team/app`)." } + ] + }, + { + "type": "resource", + "subType": "base", + "description": "Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "residency", "min": 0, "max": 1, "allowedValues": ["free", "confined"], "default": "free", "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." } + ] + }, + { + "type": "resource", + "subType": "rdb", + "extendsBase": true, + "description": "A relational database: tables queried with SQL, the store of record.", + "whenToUse": "Any store an app queries with SQL, whatever the product.", + "children": [ + { "type": "attr", "subType": "string", "name": "schemas", "isArray": true, "min": 0, "max": 1, "description": "The schema names the database holds. Optional and usually absent: the set can be computed from the entities' source.rdb @schema. Declaring it closes the list." } + ] + }, + { + "type": "resource", + "subType": "keyValue", + "extendsBase": true, + "description": "A store of values fetched by key.", + "whenToUse": "A key-value store that is the source of its data, or a cache (@volatile).", + "children": [ + { "type": "attr", "subType": "boolean", "name": "volatile", "min": 0, "max": 1, "description": "The contents may be lost at any moment without losing data: a cache. Absent means the store is durable." } + ] + }, + { + "type": "resource", + "subType": "objectStore", + "extendsBase": true, + "description": "Files and blobs addressed by key.", + "whenToUse": "Uploaded images, exports, static assets kept outside the app.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "publicRead", "min": 0, "max": 1, "description": "Anyone may read the objects without a credential. Absent means every read needs a grant." } + ] + }, + { + "type": "resource", + "subType": "document", + "extendsBase": true, + "description": "A document store: records kept and fetched as whole documents.", + "whenToUse": "Records whose shape is a document rather than a row." + }, + { + "type": "resource", + "subType": "search", + "extendsBase": true, + "description": "A search index: documents found by text and filters.", + "whenToUse": "Full-text search over records kept elsewhere." + }, + { + "type": "resource", + "subType": "queue", + "extendsBase": true, + "description": "A message queue: each message is handed to one consumer and gone once it is handled.", + "whenToUse": "Work handed from one app to another to run later.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "ordered", "min": 0, "max": 1, "description": "Messages with the same key are delivered in the order they were sent. Absent means no order is promised." }, + { "type": "attr", "subType": "boolean", "name": "deadLetter", "min": 0, "max": 1, "description": "A message that keeps failing is set aside rather than dropped. How many attempts come first is a setting." } + ] + }, + { + "type": "resource", + "subType": "stream", + "extendsBase": true, + "description": "A retained, ordered log that many consumers read, each at its own position. A message can be read again.", + "whenToUse": "Events several consumers read independently, or read again." + }, + { + "type": "resource", + "subType": "volume", + "extendsBase": true, + "description": "A disk attached to an app that survives a restart.", + "whenToUse": "A file system path an app writes to and must keep." + }, + { + "type": "role", + "subType": "base", + "description": "Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "memberOf", "isArray": true, "min": 0, "max": 1, "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.", "ref": { "targetType": "role", "targetSubTypes": ["group"] } }, + { "type": "attr", "subType": "string", "name": "credential", "min": 0, "max": 1, "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." } + ] + }, + { + "type": "role", + "subType": "service", + "extendsBase": true, + "description": "A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs).", + "whenToUse": "Every identity an app or job of the system acts as." + }, + { + "type": "role", + "subType": "user", + "extendsBase": true, + "description": "A named person, or an agent acting for one. No shared secret is generated or stored for it.", + "whenToUse": "A person who signs in to a resource directly." + }, + { + "type": "role", + "subType": "group", + "extendsBase": true, + "description": "Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in.", + "whenToUse": "Several roles that share the same access." + }, + { + "type": "role", + "subType": "token", + "extendsBase": true, + "description": "Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer.", + "whenToUse": "Access handed to something that is not one of the system's apps.", + "children": [ + { "type": "attr", "subType": "string", "name": "heldBy", "min": 0, "max": 1, "description": "Who was handed the token: an organization node, by name (`tidewell::Tidewell`). Optional. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node is ERR_REF_WRONG_KIND. ADR-0070 call 9 also admits a system here; that waits on the reference facet accepting more than one target type.", "ref": { "targetType": "organization" } } + ] + } + ], + "extends": [ + { + "type": "metadata", + "subType": "root", + "children": [ + { "type": "organization", "subType": "company", "name": "*", "min": 0, "max": null, "description": "An organization: a top-level, packaged node." }, + { "type": "system", "subType": "software", "name": "*", "min": 0, "max": null, "description": "A system: a top-level, packaged node." } + ] + } + ] +} diff --git a/server/python/tests/conformance/conformance_adapter.py b/server/python/tests/conformance/conformance_adapter.py index b318efcd1d..aca8a5abdc 100644 --- a/server/python/tests/conformance/conformance_adapter.py +++ b/server/python/tests/conformance/conformance_adapter.py @@ -13,6 +13,7 @@ from metaobjects.meta.core.reporting.reporting_provider import reporting_provider from metaobjects.meta.core.requirement.requirements_provider import requirements_provider from metaobjects.meta.core.rules.rules_provider import rules_provider +from metaobjects.meta.core.systems.systems_provider import systems_provider from metaobjects.meta.persistence.db.db_provider import db_provider from metaobjects.meta.persistence.view_expressions.view_expressions_provider import ( view_expressions_provider, @@ -142,6 +143,7 @@ def _noop_provider(provider_id: str, *deps: str) -> Provider: # Reporting (dimension / measure / segment / object.report) and requirements. reporting_provider.id: reporting_provider, # "metaobjects-reporting" requirements_provider.id: requirements_provider, # "metaobjects-requirements" + systems_provider.id: systems_provider, # "metaobjects-systems-core" # Back-compat alias: pre-rename fixtures (and other ports' fixtures) still name the # provider "metaobjects-template"; map it to the renamed prompt provider — the same # alias the TS adapter keeps (adapter.ts: "metaobjects-template": promptProvider). diff --git a/server/python/tests/conformance/fixture_discovery.py b/server/python/tests/conformance/fixture_discovery.py index e866228f9b..fff1435059 100644 --- a/server/python/tests/conformance/fixture_discovery.py +++ b/server/python/tests/conformance/fixture_discovery.py @@ -30,6 +30,8 @@ # Reporting and requirements are their own packs, in the default bundle. "metaobjects-reporting", "metaobjects-requirements", + # The systems vocabulary (ADR-0070) is the last pack in the default bundle. + "metaobjects-systems-core", ) diff --git a/server/python/tests/unit/test_reference_facet.py b/server/python/tests/unit/test_reference_facet.py index 76ecd0f81e..810bd70916 100644 --- a/server/python/tests/unit/test_reference_facet.py +++ b/server/python/tests/unit/test_reference_facet.py @@ -33,6 +33,10 @@ PROVIDER_ID = "test-reference-facet" +#: Core without the systems provider, whose type names the test vocabulary reuses. The +#: shipped systems vocabulary is held by the conformance corpus and the test at the end. +_BASE_PROVIDERS = [p for p in core_providers if p.id != "metaobjects-systems-core"] + #: The reference attributes, as a provider definition: an ``extends`` entry per type. DEFINITION = """ { @@ -93,6 +97,10 @@ def type_(t: str, sub: str, *children: str) -> None: type_("deployment", "test") def hook(registry: TypeRegistry) -> None: + # The shared spec declares these two types, so its strict graph replaces the child + # rules they were registered with; a rule added with ``extend`` survives it. + registry.extend("system", "software", child_rules=[_any(c) for c in ("app", "role", "resource")]) + registry.extend("role", "service", child_rules=[_any(c) for c in ("grant", "resource")]) registry.extend( TYPE_METADATA, SUBTYPE_ROOT, child_rules=[_any(t) for t in ("system", "deployment", "app", "resource")], @@ -104,12 +112,12 @@ def hook(registry: TypeRegistry) -> None: def _registry() -> TypeRegistry: - return compose_registry([*core_providers, _test_provider()]) + return compose_registry([*_BASE_PROVIDERS, _test_provider()]) def _load(text: str, fmt: MetaDataFormat = MetaDataFormat.YAML) -> LoadResult: source_id = "systems.yaml" if fmt == MetaDataFormat.YAML else "systems.json" - loader = MetaDataLoader(providers=[*core_providers, _test_provider()], strict=True) + loader = MetaDataLoader(providers=[*_BASE_PROVIDERS, _test_provider()], strict=True) return loader.load([InMemoryStringSource(text, id=source_id, format=fmt)]) @@ -275,7 +283,7 @@ def test_the_reader_carries_a_facet_on_a_types_entry_attr() -> None: def test_the_core_definitions_declare_exactly_the_four_core_references() -> None: - registry = compose_registry(list(core_providers)) + registry = compose_registry(list(_BASE_PROVIDERS)) found = [] for definition in registry._defs.values(): # noqa: SLF001 (no public iterator) for a in definition.attrs: @@ -372,7 +380,12 @@ def test_a_provider_code_is_named_in_the_error_repr() -> None: assert MetaError("y", ErrorCode.ERR_REF_UNRESOLVED).code_name == "ERR_REF_UNRESOLVED" -def test_a_shared_model_refusal_keeps_the_provider_code(tmp_path: Path) -> None: +def test_a_shared_model_refusal_keeps_the_provider_code( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + # build_shared_model composes the default bundle under the test provider; take the + # systems pack out, since the test vocabulary reuses its type names. + monkeypatch.setattr("metaobjects.shared_model.core_providers", _BASE_PROVIDERS) file = tmp_path / "systems.yaml" file.write_text(_model(_CROSSES), encoding="utf-8") with pytest.raises(ValueError) as exc: @@ -383,7 +396,7 @@ def test_a_shared_model_refusal_keeps_the_provider_code(tmp_path: Path) -> None: def test_fmt_refuses_an_unloadable_project_naming_the_provider_code(tmp_path: Path) -> None: file = tmp_path / "systems.yaml" file.write_text(_model(_CROSSES), encoding="utf-8") - providers = [*core_providers, _test_provider()] + providers = [*_BASE_PROVIDERS, _test_provider()] result = fmt_run( [file], [file], {}, compose_registry(providers), [], check=True, providers=list(providers) ) @@ -688,5 +701,24 @@ def test_the_manifest_writes_ref_only_on_an_attribute_that_has_one_in_the_fixed_ def test_an_attribute_with_no_facet_writes_no_ref_key() -> None: # One "ref" per facet in the core definitions, and none anywhere else. - manifest = emit_registry_manifest(compose_registry(list(core_providers))) + manifest = emit_registry_manifest(compose_registry(list(_BASE_PROVIDERS))) assert manifest.count('"ref"') == len(_CORE_FACETS) + + +def test_the_shipped_systems_definition_declares_the_four_systems_references() -> None: + registry = compose_registry(list(core_providers)) + found = sorted( + { + (d.type, a.name, a.ref.target_type) + for d in registry._defs.values() # noqa: SLF001 (no public iterator) + if d.type in {"organization", "system", "app", "build", "resource", "role"} + for a in d.attrs + if a.ref is not None + } + ) + assert found == [ + ("app", "runsAs", "role"), + ("role", "heldBy", "organization"), + ("role", "memberOf", "role"), + ("system", "owner", "organization"), + ] diff --git a/server/rust/metaobjects-codegen/templates/metamodel/provider-descriptions.json b/server/rust/metaobjects-codegen/templates/metamodel/provider-descriptions.json index 4cbe8f7f5c..a4241a7a6a 100644 --- a/server/rust/metaobjects-codegen/templates/metamodel/provider-descriptions.json +++ b/server/rust/metaobjects-codegen/templates/metamodel/provider-descriptions.json @@ -6,6 +6,7 @@ "metaobjects-reporting": "Reporting (FR-044): object.report, dimension / measure / segment on an entity, and @segment on origin.aggregate and origin.first.", "metaobjects-requirements": "Requirements: requirement.functional and requirement.architectural, declared at the document root and checked by meta verify.", "metaobjects-rules": "Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).", + "metaobjects-systems-core": "Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role.", "metaobjects-ui": "UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D).", "metaobjects-ui-web": "Web presentation view attrs — @rows (view.textarea) and the view.image control attrs. Every port applies this provider and loads them strictly; only TypeScript acts on them so far.", "metaobjects-view-expressions": "View expressions (rc.21): origin.function plus the projection @union / @unionAll / @grain / @grainOrdinal attributes." diff --git a/server/rust/metaobjects/data/ERROR-CODES.json b/server/rust/metaobjects/data/ERROR-CODES.json index 223217f0e0..d816b26a1f 100644 --- a/server/rust/metaobjects/data/ERROR-CODES.json +++ b/server/rust/metaobjects/data/ERROR-CODES.json @@ -12,7 +12,7 @@ "ERR_UNRESOLVED_SUPER": "An extends/super reference names a node that does not exist.", "ERR_EXTENDS_TARGET_MISMATCH": "FR-024: a dotted extends ref resolved to a node whose type or subtype does not match the extending node (a field may only extend a field of the same subtype; an identity only an identity).", "ERR_IDENTITY_NAME_REQUIRED": "FR-024: an identity.* node has no name. Identities are named, author-chosen (e.g. \"id\"), so the dotted by-name extends form can address them.", - "ERR_TOO_MANY_OCCURRENCES": "A type.subType declared with maxOccurs (e.g. identity.primary, maxOccurs:1) appears more times than allowed under one parent.", + "ERR_TOO_MANY_OCCURRENCES": "A type.subType declared with maxOccurs (e.g. identity.primary, maxOccurs:1) appears more times than allowed under one parent, or a parent holds more children matching a child rule than its max allows (e.g. a second build.* under an app, counting one it inherits through extends).", "ERR_PROJECTION_IDENTITY_NOT_EXTENDED": "FR-024: an identity.* on an object.projection lacks extends — a projection identity is a pass-through of an entity identity.", "ERR_IDENTITY_KEY_MISMATCH": "FR-024: identity key correspondence broken — an extended-identity field has no local pass-through field extending it, or an explicit @fields disagrees with the computed pass-through key.", "ERR_PROJECTION_SOURCE_WRITABLE": "FR-024 (ADR-0028): a source.* on an object.projection has a writable @kind (table, or @kind omitted which defaults to table) — a projection is a derived read-only representation; its sources must be read-only kinds (view, materializedView, storedProc, tableFunction).", diff --git a/server/rust/metaobjects/data/metamodel/systems.json b/server/rust/metaobjects/data/metamodel/systems.json new file mode 100644 index 0000000000..8ff1f9e598 --- /dev/null +++ b/server/rust/metaobjects/data/metamodel/systems.json @@ -0,0 +1,233 @@ +{ + "provider": "metaobjects-systems-core", + "types": [ + { + "type": "organization", + "subType": "base", + "description": "Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "organization", + "subType": "company", + "extendsBase": true, + "description": "A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company.", + "whenToUse": "Every party that owns a system or holds a token. A party that publishes no metadata is written down by whoever depends on it, under the party's own package name.", + "rules": "Lives at the document root. Its units are its children, addressed `Company.unit` (`pkg::Company.unit` from another package).", + "children": [ + { "type": "organization", "subType": "unit", "name": "*", "min": 0, "max": null, "description": "The teams or divisions inside the company." } + ] + }, + { + "type": "organization", + "subType": "unit", + "extendsBase": true, + "description": "A team or division inside a company. Units nest: a unit is a child of a company or of another unit.", + "whenToUse": "When a system's owner is a team rather than the whole company.", + "children": [ + { "type": "organization", "subType": "unit", "name": "*", "min": 0, "max": null, "description": "The units inside this one." } + ] + }, + { + "type": "system", + "subType": "base", + "description": "Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "owner", "min": 0, "max": 1, "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources.", "ref": { "targetType": "organization" } } + ] + }, + { + "type": "system", + "subType": "software", + "extendsBase": true, + "description": "A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package.", + "whenToUse": "Every product or service, including one somebody else runs that an app calls: write it down under its owner's package name.", + "rules": "Lives at the document root. Names are unique per type within the system, so an app and a role may share a name: every reference names the type it wants.", + "children": [ + { "type": "app", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The system's apps." }, + { "type": "resource", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The system's resources." }, + { "type": "role", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The identities that act in the system." } + ] + }, + { + "type": "app", + "subType": "base", + "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "runsAs", "min": 0, "max": 1, "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND.", "ref": { "targetType": "role", "targetSubTypes": ["service"] } }, + { "type": "build", "subType": "*", "name": "*", "min": 0, "max": 1, "description": "How the app's deployable is made. At most one, of any kind." } + ] + }, + { + "type": "app", + "subType": "service", + "extendsBase": true, + "description": "A long-running process that answers requests: a web server, an API, a socket server.", + "whenToUse": "Anything that listens on a port and stays up.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "public", "min": 0, "max": 1, "description": "The service is meant to be reached from outside every system: from browsers or from parties holding no role in the model. Absent means it is reached only by the apps and roles the model names." } + ] + }, + { + "type": "app", + "subType": "client", + "extendsBase": true, + "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", + "whenToUse": "A front end built and shipped as files, whatever serves them.", + "children": [ + { "type": "attr", "subType": "string", "name": "shell", "min": 0, "max": 1, "description": "The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here." } + ] + }, + { + "type": "app", + "subType": "job", + "extendsBase": true, + "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", + "whenToUse": "A cron job, a nightly import, a queue drain that is not a long-running service.", + "children": [ + { "type": "attr", "subType": "string", "name": "schedule", "min": 0, "max": 1, "description": "When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered." } + ] + }, + { + "type": "build", + "subType": "base", + "description": "Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "build", + "subType": "image", + "extendsBase": true, + "description": "The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here.", + "whenToUse": "An app whose image someone else builds: a product sold as images that the buyer deploys.", + "children": [ + { "type": "attr", "subType": "string", "name": "repository", "min": 1, "max": 1, "description": "Where the publisher keeps the image, without a tag (`registry.example.com/team/app`)." } + ] + }, + { + "type": "resource", + "subType": "base", + "description": "Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "residency", "min": 0, "max": 1, "allowedValues": ["free", "confined"], "default": "free", "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." } + ] + }, + { + "type": "resource", + "subType": "rdb", + "extendsBase": true, + "description": "A relational database: tables queried with SQL, the store of record.", + "whenToUse": "Any store an app queries with SQL, whatever the product.", + "children": [ + { "type": "attr", "subType": "string", "name": "schemas", "isArray": true, "min": 0, "max": 1, "description": "The schema names the database holds. Optional and usually absent: the set can be computed from the entities' source.rdb @schema. Declaring it closes the list." } + ] + }, + { + "type": "resource", + "subType": "keyValue", + "extendsBase": true, + "description": "A store of values fetched by key.", + "whenToUse": "A key-value store that is the source of its data, or a cache (@volatile).", + "children": [ + { "type": "attr", "subType": "boolean", "name": "volatile", "min": 0, "max": 1, "description": "The contents may be lost at any moment without losing data: a cache. Absent means the store is durable." } + ] + }, + { + "type": "resource", + "subType": "objectStore", + "extendsBase": true, + "description": "Files and blobs addressed by key.", + "whenToUse": "Uploaded images, exports, static assets kept outside the app.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "publicRead", "min": 0, "max": 1, "description": "Anyone may read the objects without a credential. Absent means every read needs a grant." } + ] + }, + { + "type": "resource", + "subType": "document", + "extendsBase": true, + "description": "A document store: records kept and fetched as whole documents.", + "whenToUse": "Records whose shape is a document rather than a row." + }, + { + "type": "resource", + "subType": "search", + "extendsBase": true, + "description": "A search index: documents found by text and filters.", + "whenToUse": "Full-text search over records kept elsewhere." + }, + { + "type": "resource", + "subType": "queue", + "extendsBase": true, + "description": "A message queue: each message is handed to one consumer and gone once it is handled.", + "whenToUse": "Work handed from one app to another to run later.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "ordered", "min": 0, "max": 1, "description": "Messages with the same key are delivered in the order they were sent. Absent means no order is promised." }, + { "type": "attr", "subType": "boolean", "name": "deadLetter", "min": 0, "max": 1, "description": "A message that keeps failing is set aside rather than dropped. How many attempts come first is a setting." } + ] + }, + { + "type": "resource", + "subType": "stream", + "extendsBase": true, + "description": "A retained, ordered log that many consumers read, each at its own position. A message can be read again.", + "whenToUse": "Events several consumers read independently, or read again." + }, + { + "type": "resource", + "subType": "volume", + "extendsBase": true, + "description": "A disk attached to an app that survives a restart.", + "whenToUse": "A file system path an app writes to and must keep." + }, + { + "type": "role", + "subType": "base", + "description": "Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "memberOf", "isArray": true, "min": 0, "max": 1, "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.", "ref": { "targetType": "role", "targetSubTypes": ["group"] } }, + { "type": "attr", "subType": "string", "name": "credential", "min": 0, "max": 1, "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." } + ] + }, + { + "type": "role", + "subType": "service", + "extendsBase": true, + "description": "A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs).", + "whenToUse": "Every identity an app or job of the system acts as." + }, + { + "type": "role", + "subType": "user", + "extendsBase": true, + "description": "A named person, or an agent acting for one. No shared secret is generated or stored for it.", + "whenToUse": "A person who signs in to a resource directly." + }, + { + "type": "role", + "subType": "group", + "extendsBase": true, + "description": "Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in.", + "whenToUse": "Several roles that share the same access." + }, + { + "type": "role", + "subType": "token", + "extendsBase": true, + "description": "Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer.", + "whenToUse": "Access handed to something that is not one of the system's apps.", + "children": [ + { "type": "attr", "subType": "string", "name": "heldBy", "min": 0, "max": 1, "description": "Who was handed the token: an organization node, by name (`tidewell::Tidewell`). Optional. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node is ERR_REF_WRONG_KIND. ADR-0070 call 9 also admits a system here; that waits on the reference facet accepting more than one target type.", "ref": { "targetType": "organization" } } + ] + } + ], + "extends": [ + { + "type": "metadata", + "subType": "root", + "children": [ + { "type": "organization", "subType": "company", "name": "*", "min": 0, "max": null, "description": "An organization: a top-level, packaged node." }, + { "type": "system", "subType": "software", "name": "*", "min": 0, "max": null, "description": "A system: a top-level, packaged node." } + ] + } + ] +} diff --git a/server/rust/metaobjects/src/manifest.rs b/server/rust/metaobjects/src/manifest.rs index 93dfa169f6..1e05ab1b82 100644 --- a/server/rust/metaobjects/src/manifest.rs +++ b/server/rust/metaobjects/src/manifest.rs @@ -9,7 +9,7 @@ use crate::registry::{ }; /// The metamodel version this build implements. -pub const METAMODEL_VERSION: &str = "1.3"; +pub const METAMODEL_VERSION: &str = "1.4"; /// Per-type attrs that are structural keywords or common-attr duplicates, so they /// stay out of the manifest's per-type rows. diff --git a/server/rust/metaobjects/src/providers.rs b/server/rust/metaobjects/src/providers.rs index 2829a3a181..48bfbb1715 100644 --- a/server/rust/metaobjects/src/providers.rs +++ b/server/rust/metaobjects/src/providers.rs @@ -30,6 +30,7 @@ pub const DB_ID: &str = "metaobjects-db"; pub const DOCUMENTATION_ID: &str = "metaobjects-documentation"; pub const REPORTING_ID: &str = "metaobjects-reporting"; pub const REQUIREMENTS_ID: &str = "metaobjects-requirements"; +pub const SYSTEMS_CORE_ID: &str = "metaobjects-systems-core"; pub const RULES_ID: &str = "metaobjects-rules"; pub const VIEW_EXPRESSIONS_ID: &str = "metaobjects-view-expressions"; pub const PROMPT_ID: &str = "metaobjects-prompt"; @@ -100,6 +101,7 @@ const CORE_FAMILIES: &[(&str, &str)] = &[ const RULES_FAMILIES: &[(&str, &str)] = &[spec!("api"), spec!("transition")]; const REPORTING_SPEC: (&str, &str) = spec!("reporting"); const REQUIREMENT_SPEC: (&str, &str) = spec!("requirement"); +const SYSTEMS_SPEC: (&str, &str) = spec!("systems"); const VIEW_EXPRESSIONS_SPEC: (&str, &str) = spec!("view-expressions"); const DB_SPEC: (&str, &str) = spec!("db"); const DOCUMENTATION_SPEC: (&str, &str) = spec!("documentation"); @@ -133,6 +135,7 @@ pub const DEFINITION_SOURCES: &[(&str, &str)] = &[ spec!("view-expressions"), spec!("reporting"), spec!("requirement"), + spec!("systems"), ]; /// One child entry of a provider definition: an attr, or a structural child rule. @@ -302,6 +305,7 @@ struct Definitions { view_expressions: ProviderDefinition, reporting: ProviderDefinition, requirements: ProviderDefinition, + systems: ProviderDefinition, db: ProviderDefinition, documentation: ProviderDefinition, prompt: ProviderDefinition, @@ -319,6 +323,7 @@ fn definitions() -> &'static Definitions { view_expressions: p(VIEW_EXPRESSIONS_SPEC), reporting: p(REPORTING_SPEC), requirements: p(REQUIREMENT_SPEC), + systems: p(SYSTEMS_SPEC), db: p(DB_SPEC), documentation: p(DOCUMENTATION_SPEC), prompt: p(PROMPT_SPEC), @@ -773,6 +778,16 @@ pub fn requirements_provider() -> Provider { ) } +/// The systems pack (ADR-0070): organization, system, app, build, resource and role. +pub fn systems_core_provider() -> Provider { + Provider::new( + SYSTEMS_CORE_ID, + &[CORE_TYPES_ID], + "Systems: organization, system, app, build, resource and role, declared at the document root with reference-checked owner, runsAs, memberOf and heldBy.", + |r| apply_definition(r, &definitions().systems), + ) +} + /// View expressions: `origin.function` and the projection `@union`/`@grain` attrs. pub fn view_expressions_provider() -> Provider { Provider::new( @@ -841,6 +856,7 @@ pub fn core_providers() -> Vec { ui_web_provider(), reporting_provider(), requirements_provider(), + systems_core_provider(), ] } diff --git a/server/rust/metaobjects/src/validate/refs_tests.rs b/server/rust/metaobjects/src/validate/refs_tests.rs index 63570875c6..b3ccae8503 100644 --- a/server/rust/metaobjects/src/validate/refs_tests.rs +++ b/server/rust/metaobjects/src/validate/refs_tests.rs @@ -82,8 +82,19 @@ fn register_test_types(r: &mut TypeRegistry) -> Result<(), MetaError> { apply_provider_definition(r, &definition()) } +/// The built-in providers without the systems pack, which declares reference facets of its own. +fn core_only_registry() -> TypeRegistry { + let mut providers = core_providers(); + providers.retain(|p| p.id != crate::providers::SYSTEMS_CORE_ID); + let mut r = compose_registry(&providers).expect("the core registry composes"); + r.seal(); + r +} + fn registry() -> TypeRegistry { + // The bundled systems provider registers these same types; this test stands in its own. let mut providers = core_providers(); + providers.retain(|p| p.id != crate::providers::SYSTEMS_CORE_ID); providers.push(Provider::new( PROVIDER_ID, &[crate::providers::CORE_TYPES_ID], @@ -365,7 +376,7 @@ fn core_facets() -> Vec { #[test] fn the_core_definitions_declare_exactly_the_four_core_references() { - let r = crate::providers::default_registry().unwrap(); + let r = core_only_registry(); let mut found = Vec::new(); for def in r.all() { for a in &def.attributes { @@ -948,7 +959,7 @@ fn the_manifest_writes_ref_only_on_an_attribute_that_has_one_in_the_fixed_key_or #[test] fn an_attribute_with_no_facet_writes_no_ref_key() { - let manifest = emit_manifest(&crate::providers::default_registry().unwrap()); + let manifest = emit_manifest(&core_only_registry()); // One `"ref"` per facet in the core definitions, and none anywhere else. assert_eq!(manifest.matches("\"ref\"").count(), core_facets().len()); } diff --git a/server/rust/metaobjects/src/validate/structure.rs b/server/rust/metaobjects/src/validate/structure.rs index 68ce6d7ccc..5671a5aafb 100644 --- a/server/rust/metaobjects/src/validate/structure.rs +++ b/server/rust/metaobjects/src/validate/structure.rs @@ -12,6 +12,7 @@ use serde_json::Value; use crate::errors::{MetaError, WARN_LEGACY}; use crate::json::{js_display, js_number}; use crate::node::{NodeId, Tree}; +use crate::parser::TYPE_ATTR; use crate::source::ErrorSource; use crate::validate::util::error_at; use crate::validate::{Ctx, Findings}; @@ -255,6 +256,7 @@ pub fn max_occurs(ctx: &Ctx<'_>, out: &mut Findings) { let tree = ctx.tree; let mut limits: HashMap<(&str, &str), Option> = HashMap::new(); for id in preorder(tree, ctx.root) { + child_rule_max(ctx, id, out); // ADR-0039: own: maxOccurs constrains the declared layer; inherited children // were counted at their declaring parent. let children = tree.own_children(id); @@ -304,6 +306,73 @@ pub fn max_occurs(ctx: &Ctx<'_>, out: &mut Findings) { } } +/// A child rule's `max` (an app has at most one `build.*`, of any kind) bounds the +/// parent's EFFECTIVE children, so a child inherited through `extends` counts: +/// inherited children are taken first, and each declared child past the bound is +/// reported. +fn child_rule_max(ctx: &Ctx<'_>, id: NodeId, out: &mut Findings) { + let tree = ctx.tree; + let parent = tree.node(id); + let Some(def) = ctx.registry.find(&parent.type_name, &parent.sub_type) else { + return; + }; + for rule in &def.child_rules { + let Some(Some(max)) = rule.max else { continue }; + if rule.child_type == TYPE_ATTR { + continue; + } + let Ok(limit) = usize::try_from(max) else { + continue; + }; + // ADR-0039: resolving, so a child inherited through `extends` counts against the bound. + let effective = tree.children(id); + let matching: Vec = effective + .iter() + .copied() + .filter(|&c| { + let n = tree.node(c); + rule.matches(&n.type_name, &n.sub_type, &n.name) + }) + .collect(); + if matching.len() <= limit { + continue; + } + // ADR-0039: own: the declared children are the ones this node can be blamed for. + let own = tree.own_children(id); + let ordered: Vec = matching + .iter() + .copied() + .filter(|c| !own.contains(c)) + .chain(matching.iter().copied().filter(|c| own.contains(c))) + .collect(); + let owner = if parent.name.is_empty() { + String::new() + } else { + format!(" '{}'", parent.name) + }; + for &extra in &ordered[limit..] { + if !own.contains(&extra) { + continue; + } + let e = tree.node(extra); + out.errors.push(error_at( + tree, + extra, + ERR_TOO_MANY_OCCURRENCES, + format!( + "{}.{} '{}' is one too many under {}.{}{owner}: at most {max} {} is allowed", + e.type_name, + e.sub_type, + e.name, + parent.type_name, + parent.sub_type, + rule.child_type + ), + )); + } + } +} + // ---- projection identity pass-through --------------------------------------- /// An identity's `@fields` as a list: an array, or a comma string. diff --git a/server/rust/metaobjects/tests/conformance-expected-failures.json b/server/rust/metaobjects/tests/conformance-expected-failures.json index ab0870a23f..61a82748f7 100644 --- a/server/rust/metaobjects/tests/conformance-expected-failures.json +++ b/server/rust/metaobjects/tests/conformance-expected-failures.json @@ -1,6 +1,6 @@ { "language": "rust", "notes": "The Rust port passes every fixture of the shared metamodel corpus, so the ledger is empty. The ledger may only shrink and is kept for the day a new fixture lands that Rust does not pass yet: list it here with the reason, and it leaves when the work that covers it lands. minPassing is the number of fixtures known to pass; the run fails when fewer do, and it may only rise.", - "minPassing": 589, + "minPassing": 596, "fixtures": [] } diff --git a/server/rust/metaobjects/tests/metamodel_conformance.rs b/server/rust/metaobjects/tests/metamodel_conformance.rs index ade2ad5e48..caee4d01a3 100644 --- a/server/rust/metaobjects/tests/metamodel_conformance.rs +++ b/server/rust/metaobjects/tests/metamodel_conformance.rs @@ -37,6 +37,7 @@ const DEFAULT_PROVIDERS: &[&str] = &[ "metaobjects-ui-web", "metaobjects-reporting", "metaobjects-requirements", + "metaobjects-systems-core", ]; fn corpus() -> PathBuf { diff --git a/server/typescript/packages/codegen-ts/templates/metamodel/provider-descriptions.json b/server/typescript/packages/codegen-ts/templates/metamodel/provider-descriptions.json index 4cbe8f7f5c..a4241a7a6a 100644 --- a/server/typescript/packages/codegen-ts/templates/metamodel/provider-descriptions.json +++ b/server/typescript/packages/codegen-ts/templates/metamodel/provider-descriptions.json @@ -6,6 +6,7 @@ "metaobjects-reporting": "Reporting (FR-044): object.report, dimension / measure / segment on an entity, and @segment on origin.aggregate and origin.first.", "metaobjects-requirements": "Requirements: requirement.functional and requirement.architectural, declared at the document root and checked by meta verify.", "metaobjects-rules": "Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).", + "metaobjects-systems-core": "Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role.", "metaobjects-ui": "UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D).", "metaobjects-ui-web": "Web presentation view attrs — @rows (view.textarea) and the view.image control attrs. Every port applies this provider and loads them strictly; only TypeScript acts on them so far.", "metaobjects-view-expressions": "View expressions (rc.21): origin.function plus the projection @union / @unionAll / @grain / @grainOrdinal attributes." diff --git a/server/typescript/packages/codegen-ts/test/shared-model-file.test.ts b/server/typescript/packages/codegen-ts/test/shared-model-file.test.ts index 0031dd31d1..83de4dd853 100644 --- a/server/typescript/packages/codegen-ts/test/shared-model-file.test.ts +++ b/server/typescript/packages/codegen-ts/test/shared-model-file.test.ts @@ -208,7 +208,7 @@ describe("sharedModelFile()", () => { schema_version: 1, name: "acme-common", version: "1.0.0", - metamodelVersion: "1.3", + metamodelVersion: "1.4", artifact: "acme-common.metaobjects.json", integrity: PINNED_HASH, packages: ["acme::common"], diff --git a/server/typescript/packages/conformance/src/fixture.ts b/server/typescript/packages/conformance/src/fixture.ts index 8d3c088d23..d7f1f170e2 100644 --- a/server/typescript/packages/conformance/src/fixture.ts +++ b/server/typescript/packages/conformance/src/fixture.ts @@ -65,6 +65,8 @@ const DEFAULT_PROVIDERS = [ "metaobjects-view-expressions", "metaobjects-reporting", "metaobjects-requirements", + // The systems vocabulary (ADR-0070) is in the default bundle from 1.4.0. + "metaobjects-systems-core", ]; export interface Fixture { diff --git a/server/typescript/packages/metadata/src/constants.ts b/server/typescript/packages/metadata/src/constants.ts index 77a14f0766..d7556ecab0 100644 --- a/server/typescript/packages/metadata/src/constants.ts +++ b/server/typescript/packages/metadata/src/constants.ts @@ -38,6 +38,7 @@ export * from "./shared/base-types.js"; export * from "./shared/structural.js"; export * from "./core/api/api-constants.js"; +export * from "./core/systems/systems-constants.js"; export * from "./core/attr/attr-constants.js"; export * from "./core/documentation/doc-constants.js"; export * from "./core/field/field-constants.js"; diff --git a/server/typescript/packages/metadata/src/core-types.ts b/server/typescript/packages/metadata/src/core-types.ts index 015c51729e..2d42cfe824 100644 --- a/server/typescript/packages/metadata/src/core-types.ts +++ b/server/typescript/packages/metadata/src/core-types.ts @@ -9,6 +9,7 @@ import { uiWebProvider } from "./presentation/ui-web/ui-web-provider.js"; import { rulesProvider } from "./core/rules/rules-provider.js"; import { viewExpressionsProvider } from "./persistence/view-expressions/view-expressions-provider.js"; import { reportingProvider } from "./core/reporting/reporting-provider.js"; +import { systemsCoreProvider } from "./core/systems/systems-provider.js"; import { requirementsProvider } from "./core/requirement/requirements-provider.js"; import { type DataType } from "./data-type.js"; import type { MetaData } from "./shared/meta-data.js"; @@ -523,8 +524,8 @@ export const coreTypesProvider: MetaDataTypeProvider = { /** The default provider bundle — core metamodel types, the five concern * providers (DB-domain attrs, documentation common-attrs, prompt/AI, the - * UI/query-surface markers, and the TS-web presentation view attrs), and the four - * vocabulary packs (business rules, view expressions, reporting, requirements), each + * UI/query-surface markers, and the TS-web presentation view attrs), and the five + * vocabulary packs (business rules, view expressions, reporting, requirements, systems), each * of which an embedder may leave out. * FR-033 S1-field-A re-homed the field's filter/sort/teaching/extract/storage * attrs out of core into db/ui/prompt; the composed set is unchanged. uiWebProvider @@ -542,6 +543,7 @@ export const coreProviders: readonly MetaDataTypeProvider[] = [ viewExpressionsProvider, reportingProvider, requirementsProvider, + systemsCoreProvider, ]; /** diff --git a/server/typescript/packages/metadata/src/core/systems/meta-system-node.ts b/server/typescript/packages/metadata/src/core/systems/meta-system-node.ts new file mode 100644 index 0000000000..2755cc6034 --- /dev/null +++ b/server/typescript/packages/metadata/src/core/systems/meta-system-node.ts @@ -0,0 +1,8 @@ +// The node class behind the systems vocabulary (ADR-0070): `organization.*`, +// `system.*`, `app.*`, `build.*`, `resource.*` and `role.*`. No subtype carries +// behaviour of its own; attributes are read with the resolving accessors (ADR-0039). + +import { MetaData } from "../../shared/meta-data.js"; + +/** A node of the systems vocabulary. */ +export class MetaSystemsNode extends MetaData {} diff --git a/server/typescript/packages/metadata/src/core/systems/systems-constants.ts b/server/typescript/packages/metadata/src/core/systems/systems-constants.ts new file mode 100644 index 0000000000..1eddd686ba --- /dev/null +++ b/server/typescript/packages/metadata/src/core/systems/systems-constants.ts @@ -0,0 +1,106 @@ +// Systems vocabulary constants (ADR-0070) — subtypes and attribute keys for +// `organization.*`, `system.*`, `app.*`, `build.*`, `resource.*` and `role.*`. +// +// The type-name constants live in shared/base-types.ts beside every other base type +// and are re-exported here so a consumer has one import site. + +import { + TYPE_APP, + TYPE_BUILD, + TYPE_ORGANIZATION, + TYPE_RESOURCE, + TYPE_ROLE, + TYPE_SYSTEM, +} from "../../shared/base-types.js"; + +export { TYPE_APP, TYPE_BUILD, TYPE_ORGANIZATION, TYPE_RESOURCE, TYPE_ROLE, TYPE_SYSTEM }; + +// --------------------------------------------------------------------------- +// Subtypes +// --------------------------------------------------------------------------- + +export const ORGANIZATION_SUBTYPE_COMPANY = "company"; +export const ORGANIZATION_SUBTYPE_UNIT = "unit"; +export const ORGANIZATION_SUBTYPES = [ORGANIZATION_SUBTYPE_COMPANY, ORGANIZATION_SUBTYPE_UNIT] as const; +export type OrganizationSubType = (typeof ORGANIZATION_SUBTYPES)[number]; + +/** The one kind of system (ADR-0070, call 1). */ +export const SYSTEM_SUBTYPE_SOFTWARE = "software"; +export const SYSTEM_SUBTYPES = [SYSTEM_SUBTYPE_SOFTWARE] as const; +export type SystemSubType = (typeof SYSTEM_SUBTYPES)[number]; + +export const APP_SUBTYPE_SERVICE = "service"; +export const APP_SUBTYPE_CLIENT = "client"; +export const APP_SUBTYPE_JOB = "job"; +export const APP_SUBTYPES = [APP_SUBTYPE_SERVICE, APP_SUBTYPE_CLIENT, APP_SUBTYPE_JOB] as const; +export type AppSubType = (typeof APP_SUBTYPES)[number]; + +export const BUILD_SUBTYPE_IMAGE = "image"; +export const BUILD_SUBTYPES = [BUILD_SUBTYPE_IMAGE] as const; +export type BuildSubType = (typeof BUILD_SUBTYPES)[number]; + +export const RESOURCE_SUBTYPE_RDB = "rdb"; +export const RESOURCE_SUBTYPE_KEY_VALUE = "keyValue"; +export const RESOURCE_SUBTYPE_OBJECT_STORE = "objectStore"; +export const RESOURCE_SUBTYPE_DOCUMENT = "document"; +export const RESOURCE_SUBTYPE_SEARCH = "search"; +export const RESOURCE_SUBTYPE_QUEUE = "queue"; +export const RESOURCE_SUBTYPE_STREAM = "stream"; +export const RESOURCE_SUBTYPE_VOLUME = "volume"; +export const RESOURCE_SUBTYPES = [ + RESOURCE_SUBTYPE_RDB, + RESOURCE_SUBTYPE_KEY_VALUE, + RESOURCE_SUBTYPE_OBJECT_STORE, + RESOURCE_SUBTYPE_DOCUMENT, + RESOURCE_SUBTYPE_SEARCH, + RESOURCE_SUBTYPE_QUEUE, + RESOURCE_SUBTYPE_STREAM, + RESOURCE_SUBTYPE_VOLUME, +] as const; +export type ResourceSubType = (typeof RESOURCE_SUBTYPES)[number]; + +export const ROLE_SUBTYPE_SERVICE = "service"; +export const ROLE_SUBTYPE_USER = "user"; +export const ROLE_SUBTYPE_GROUP = "group"; +export const ROLE_SUBTYPE_TOKEN = "token"; +export const ROLE_SUBTYPES = [ROLE_SUBTYPE_SERVICE, ROLE_SUBTYPE_USER, ROLE_SUBTYPE_GROUP, ROLE_SUBTYPE_TOKEN] as const; +export type RoleSubType = (typeof ROLE_SUBTYPES)[number]; + +// --------------------------------------------------------------------------- +// Attributes +// --------------------------------------------------------------------------- + +/** `system @owner` — an organization, by name. */ +export const SYSTEM_ATTR_OWNER = "owner"; +/** `app @runsAs` — a `role.service`, by name. */ +export const APP_ATTR_RUNS_AS = "runsAs"; +/** `app.service @public`. */ +export const APP_ATTR_PUBLIC = "public"; +/** `app.client @shell`. */ +export const APP_ATTR_SHELL = "shell"; +/** `app.job @schedule` — a five-field cron expression in UTC. */ +export const APP_ATTR_SCHEDULE = "schedule"; +/** `build.image @repository`. */ +export const BUILD_ATTR_REPOSITORY = "repository"; +/** `resource @residency` — `free` (default) or `confined`. */ +export const RESOURCE_ATTR_RESIDENCY = "residency"; +export const RESIDENCY_FREE = "free"; +export const RESIDENCY_CONFINED = "confined"; +export const RESIDENCY_VALUES = [RESIDENCY_FREE, RESIDENCY_CONFINED] as const; +export type Residency = (typeof RESIDENCY_VALUES)[number]; +/** `resource.rdb @schemas`. */ +export const RESOURCE_ATTR_SCHEMAS = "schemas"; +/** `resource.keyValue @volatile`. */ +export const RESOURCE_ATTR_VOLATILE = "volatile"; +/** `resource.objectStore @publicRead`. */ +export const RESOURCE_ATTR_PUBLIC_READ = "publicRead"; +/** `resource.queue @ordered`. */ +export const RESOURCE_ATTR_ORDERED = "ordered"; +/** `resource.queue @deadLetter`. */ +export const RESOURCE_ATTR_DEAD_LETTER = "deadLetter"; +/** `role @memberOf` — `role.group` nodes, by name. */ +export const ROLE_ATTR_MEMBER_OF = "memberOf"; +/** `role @credential` — the name of an adopted key, never a value. */ +export const ROLE_ATTR_CREDENTIAL = "credential"; +/** `role.token @heldBy` — an organization, by name. */ +export const ROLE_ATTR_HELD_BY = "heldBy"; diff --git a/server/typescript/packages/metadata/src/core/systems/systems-definition.embedded.ts b/server/typescript/packages/metadata/src/core/systems/systems-definition.embedded.ts new file mode 100644 index 0000000000..9e67d038a0 --- /dev/null +++ b/server/typescript/packages/metadata/src/core/systems/systems-definition.embedded.ts @@ -0,0 +1,427 @@ +// AUTO-GENERATED by scripts/generate-embedded-metamodel.ts — DO NOT EDIT. +// Canonical source: repo-root spec/metamodel/systems.json +// Regenerate: bun run scripts/generate-embedded-metamodel.ts +// +// Embeds the canonical FR-033 ProviderDefinition so the provider can register +// itself wherever the on-disk spec/ tree is unavailable (bundled builds). +import type { ProviderDefinition } from "../../provider-data.js"; + +export const SYSTEMS_DEFINITION: ProviderDefinition = { + "provider": "metaobjects-systems-core", + "types": [ + { + "type": "organization", + "subType": "base", + "description": "Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "organization", + "subType": "company", + "extendsBase": true, + "description": "A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company.", + "whenToUse": "Every party that owns a system or holds a token. A party that publishes no metadata is written down by whoever depends on it, under the party's own package name.", + "rules": "Lives at the document root. Its units are its children, addressed `Company.unit` (`pkg::Company.unit` from another package).", + "children": [ + { + "type": "organization", + "subType": "unit", + "name": "*", + "min": 0, + "max": null, + "description": "The teams or divisions inside the company." + } + ] + }, + { + "type": "organization", + "subType": "unit", + "extendsBase": true, + "description": "A team or division inside a company. Units nest: a unit is a child of a company or of another unit.", + "whenToUse": "When a system's owner is a team rather than the whole company.", + "children": [ + { + "type": "organization", + "subType": "unit", + "name": "*", + "min": 0, + "max": null, + "description": "The units inside this one." + } + ] + }, + { + "type": "system", + "subType": "base", + "description": "Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "owner", + "min": 0, + "max": 1, + "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources.", + "ref": { + "targetType": "organization" + } + } + ] + }, + { + "type": "system", + "subType": "software", + "extendsBase": true, + "description": "A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package.", + "whenToUse": "Every product or service, including one somebody else runs that an app calls: write it down under its owner's package name.", + "rules": "Lives at the document root. Names are unique per type within the system, so an app and a role may share a name: every reference names the type it wants.", + "children": [ + { + "type": "app", + "subType": "*", + "name": "*", + "min": 0, + "max": null, + "description": "The system's apps." + }, + { + "type": "resource", + "subType": "*", + "name": "*", + "min": 0, + "max": null, + "description": "The system's resources." + }, + { + "type": "role", + "subType": "*", + "name": "*", + "min": 0, + "max": null, + "description": "The identities that act in the system." + } + ] + }, + { + "type": "app", + "subType": "base", + "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "runsAs", + "min": 0, + "max": 1, + "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND.", + "ref": { + "targetType": "role", + "targetSubTypes": [ + "service" + ] + } + }, + { + "type": "build", + "subType": "*", + "name": "*", + "min": 0, + "max": 1, + "description": "How the app's deployable is made. At most one, of any kind." + } + ] + }, + { + "type": "app", + "subType": "service", + "extendsBase": true, + "description": "A long-running process that answers requests: a web server, an API, a socket server.", + "whenToUse": "Anything that listens on a port and stays up.", + "children": [ + { + "type": "attr", + "subType": "boolean", + "name": "public", + "min": 0, + "max": 1, + "description": "The service is meant to be reached from outside every system: from browsers or from parties holding no role in the model. Absent means it is reached only by the apps and roles the model names." + } + ] + }, + { + "type": "app", + "subType": "client", + "extendsBase": true, + "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", + "whenToUse": "A front end built and shipped as files, whatever serves them.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "shell", + "min": 0, + "max": 1, + "description": "The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here." + } + ] + }, + { + "type": "app", + "subType": "job", + "extendsBase": true, + "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", + "whenToUse": "A cron job, a nightly import, a queue drain that is not a long-running service.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "schedule", + "min": 0, + "max": 1, + "description": "When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered." + } + ] + }, + { + "type": "build", + "subType": "base", + "description": "Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "build", + "subType": "image", + "extendsBase": true, + "description": "The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here.", + "whenToUse": "An app whose image someone else builds: a product sold as images that the buyer deploys.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "repository", + "min": 1, + "max": 1, + "description": "Where the publisher keeps the image, without a tag (`registry.example.com/team/app`)." + } + ] + }, + { + "type": "resource", + "subType": "base", + "description": "Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "residency", + "min": 0, + "max": 1, + "allowedValues": [ + "free", + "confined" + ], + "default": "free", + "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." + } + ] + }, + { + "type": "resource", + "subType": "rdb", + "extendsBase": true, + "description": "A relational database: tables queried with SQL, the store of record.", + "whenToUse": "Any store an app queries with SQL, whatever the product.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "schemas", + "isArray": true, + "min": 0, + "max": 1, + "description": "The schema names the database holds. Optional and usually absent: the set can be computed from the entities' source.rdb @schema. Declaring it closes the list." + } + ] + }, + { + "type": "resource", + "subType": "keyValue", + "extendsBase": true, + "description": "A store of values fetched by key.", + "whenToUse": "A key-value store that is the source of its data, or a cache (@volatile).", + "children": [ + { + "type": "attr", + "subType": "boolean", + "name": "volatile", + "min": 0, + "max": 1, + "description": "The contents may be lost at any moment without losing data: a cache. Absent means the store is durable." + } + ] + }, + { + "type": "resource", + "subType": "objectStore", + "extendsBase": true, + "description": "Files and blobs addressed by key.", + "whenToUse": "Uploaded images, exports, static assets kept outside the app.", + "children": [ + { + "type": "attr", + "subType": "boolean", + "name": "publicRead", + "min": 0, + "max": 1, + "description": "Anyone may read the objects without a credential. Absent means every read needs a grant." + } + ] + }, + { + "type": "resource", + "subType": "document", + "extendsBase": true, + "description": "A document store: records kept and fetched as whole documents.", + "whenToUse": "Records whose shape is a document rather than a row." + }, + { + "type": "resource", + "subType": "search", + "extendsBase": true, + "description": "A search index: documents found by text and filters.", + "whenToUse": "Full-text search over records kept elsewhere." + }, + { + "type": "resource", + "subType": "queue", + "extendsBase": true, + "description": "A message queue: each message is handed to one consumer and gone once it is handled.", + "whenToUse": "Work handed from one app to another to run later.", + "children": [ + { + "type": "attr", + "subType": "boolean", + "name": "ordered", + "min": 0, + "max": 1, + "description": "Messages with the same key are delivered in the order they were sent. Absent means no order is promised." + }, + { + "type": "attr", + "subType": "boolean", + "name": "deadLetter", + "min": 0, + "max": 1, + "description": "A message that keeps failing is set aside rather than dropped. How many attempts come first is a setting." + } + ] + }, + { + "type": "resource", + "subType": "stream", + "extendsBase": true, + "description": "A retained, ordered log that many consumers read, each at its own position. A message can be read again.", + "whenToUse": "Events several consumers read independently, or read again." + }, + { + "type": "resource", + "subType": "volume", + "extendsBase": true, + "description": "A disk attached to an app that survives a restart.", + "whenToUse": "A file system path an app writes to and must keep." + }, + { + "type": "role", + "subType": "base", + "description": "Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "memberOf", + "isArray": true, + "min": 0, + "max": 1, + "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.", + "ref": { + "targetType": "role", + "targetSubTypes": [ + "group" + ] + } + }, + { + "type": "attr", + "subType": "string", + "name": "credential", + "min": 0, + "max": 1, + "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." + } + ] + }, + { + "type": "role", + "subType": "service", + "extendsBase": true, + "description": "A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs).", + "whenToUse": "Every identity an app or job of the system acts as." + }, + { + "type": "role", + "subType": "user", + "extendsBase": true, + "description": "A named person, or an agent acting for one. No shared secret is generated or stored for it.", + "whenToUse": "A person who signs in to a resource directly." + }, + { + "type": "role", + "subType": "group", + "extendsBase": true, + "description": "Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in.", + "whenToUse": "Several roles that share the same access." + }, + { + "type": "role", + "subType": "token", + "extendsBase": true, + "description": "Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer.", + "whenToUse": "Access handed to something that is not one of the system's apps.", + "children": [ + { + "type": "attr", + "subType": "string", + "name": "heldBy", + "min": 0, + "max": 1, + "description": "Who was handed the token: an organization node, by name (`tidewell::Tidewell`). Optional. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node is ERR_REF_WRONG_KIND. ADR-0070 call 9 also admits a system here; that waits on the reference facet accepting more than one target type.", + "ref": { + "targetType": "organization" + } + } + ] + } + ], + "extends": [ + { + "type": "metadata", + "subType": "root", + "children": [ + { + "type": "organization", + "subType": "company", + "name": "*", + "min": 0, + "max": null, + "description": "An organization: a top-level, packaged node." + }, + { + "type": "system", + "subType": "software", + "name": "*", + "min": 0, + "max": null, + "description": "A system: a top-level, packaged node." + } + ] + } + ] +}; diff --git a/server/typescript/packages/metadata/src/core/systems/systems-provider.ts b/server/typescript/packages/metadata/src/core/systems/systems-provider.ts new file mode 100644 index 0000000000..77e674df7e --- /dev/null +++ b/server/typescript/packages/metadata/src/core/systems/systems-provider.ts @@ -0,0 +1,31 @@ +// systemsCoreProvider — the systems vocabulary (ADR-0070, new in 1.4.0): organizations, +// systems, apps, builds, resources and roles, from spec/metamodel/systems.json. +// +// It is its OWN provider rather than part of metaobjects-core-types (GOVERNANCE.md, +// "Extension packs and the core metamodel"), and it is in the default bundle +// (`coreProviders`), so every port loads it. Its references (`system @owner`, +// `app @runsAs`, `role @memberOf`, `role.token @heldBy`) are reference facets in the +// definition file, enforced by the generic resolver; the provider adds no code checks. + +import type { MetaDataTypeProvider } from "../../provider.js"; +import type { TypeRegistry, TypeId } from "../../registry.js"; +import { applyProviderDefinition, type FactoryMap } from "../../provider-data.js"; +import { MetaSystemsNode } from "./meta-system-node.js"; +import { SYSTEMS_DEFINITION } from "./systems-definition.embedded.js"; + +/** The systems provider's id (a logical id, shared by every port). */ +export const SYSTEMS_CORE_PROVIDER_ID = "metaobjects-systems-core"; + +export const systemsCoreProvider: MetaDataTypeProvider = { + id: SYSTEMS_CORE_PROVIDER_ID, + dependencies: ["metaobjects-core-types"], + description: + "Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role.", + registerTypes(registry: TypeRegistry): void { + const factories: FactoryMap = {}; + for (const def of SYSTEMS_DEFINITION.types ?? []) { + factories[`${def.type}.${def.subType}`] = (typeId: TypeId, name: string) => new MetaSystemsNode(typeId, name); + } + applyProviderDefinition(registry, SYSTEMS_DEFINITION, factories); + }, +}; diff --git a/server/typescript/packages/metadata/src/index.ts b/server/typescript/packages/metadata/src/index.ts index e49ecf96f1..0419b292b4 100644 --- a/server/typescript/packages/metadata/src/index.ts +++ b/server/typescript/packages/metadata/src/index.ts @@ -286,6 +286,9 @@ export { VIEW_EXPRESSIONS_PROVIDER_ID, } from "./persistence/view-expressions/view-expressions-provider.js"; export { reportingProvider, REPORTING_PROVIDER_ID } from "./core/reporting/reporting-provider.js"; +export { systemsCoreProvider, SYSTEMS_CORE_PROVIDER_ID } from "./core/systems/systems-provider.js"; +export { MetaSystemsNode } from "./core/systems/meta-system-node.js"; +export * from "./core/systems/systems-constants.js"; export { requirementsProvider, REQUIREMENTS_PROVIDER_ID } from "./core/requirement/requirements-provider.js"; // FR-033 — the constraint engine: additive merge + the contradiction validator. diff --git a/server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts b/server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts index 85b156fd7c..91bfac8cc8 100644 --- a/server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts +++ b/server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts @@ -32,6 +32,7 @@ import { TRANSITION_DEFINITION } from "../core/transition/transition-definition. import { VIEW_EXPRESSIONS_DEFINITION } from "../persistence/view-expressions/view-expressions-definition.embedded.js"; import { REPORTING_DEFINITION } from "../core/reporting/reporting-definition.embedded.js"; import { REQUIREMENT_DEFINITION } from "../core/requirement/requirement-definition.embedded.js"; +import { SYSTEMS_DEFINITION } from "../core/systems/systems-definition.embedded.js"; /** * Every embedded provider definition the core metamodel composes from. The @@ -59,10 +60,11 @@ export const ALL_PROVIDER_DEFINITIONS: readonly ProviderDefinition[] = [ TEMPLATE_DEFINITION, PROMPT_DEFINITION, // The business-rules pack (metaobjects-rules), the view-expressions pack, the - // reporting pack and the requirements pack. + // reporting pack, the requirements pack and the systems vocabulary (ADR-0070). API_DEFINITION, TRANSITION_DEFINITION, VIEW_EXPRESSIONS_DEFINITION, REPORTING_DEFINITION, REQUIREMENT_DEFINITION, + SYSTEMS_DEFINITION, ]; diff --git a/server/typescript/packages/metadata/src/registry-manifest.ts b/server/typescript/packages/metadata/src/registry-manifest.ts index 51eab8d304..0175bc3f75 100644 --- a/server/typescript/packages/metadata/src/registry-manifest.ts +++ b/server/typescript/packages/metadata/src/registry-manifest.ts @@ -141,7 +141,7 @@ export interface ManifestType { * constant read `"0.10"`). Bump with that script — never by hand — so the manifest and * all four port constants move together. */ -export const METAMODEL_VERSION = "1.3"; +export const METAMODEL_VERSION = "1.4"; /** The full canonical manifest. All collections are sorted for byte-stability. */ export interface RegistryManifest { diff --git a/server/typescript/packages/metadata/src/shared/base-types.ts b/server/typescript/packages/metadata/src/shared/base-types.ts index 94d2be295b..2dcd3027d7 100644 --- a/server/typescript/packages/metadata/src/shared/base-types.ts +++ b/server/typescript/packages/metadata/src/shared/base-types.ts @@ -36,11 +36,17 @@ export const TYPE_BINDING = "binding"; /** ADR-0066 — an allowed move between two members of a `field.enum` (`transition.action`). */ export const TYPE_TRANSITION = "transition"; /** - * ADR-0070 — the `system` type. Not a registered base type yet (core registers it in - * 1.4.0, so it is not in BASE_TYPES): the reference facet's `sameSystem` check reads it - * to find a node's system, its nearest ancestor of this type. + * ADR-0070 — the systems vocabulary (provider `metaobjects-systems-core`, 1.4.0): + * `organization.*`, `system.software`, `app.*`, `build.image`, `resource.*` and + * `role.*`. The reference facet's `sameSystem` check reads `system` to find a node's + * system, its nearest ancestor of that type. */ +export const TYPE_ORGANIZATION = "organization"; export const TYPE_SYSTEM = "system"; +export const TYPE_APP = "app"; +export const TYPE_BUILD = "build"; +export const TYPE_RESOURCE = "resource"; +export const TYPE_ROLE = "role"; export const BASE_TYPES = [ TYPE_METADATA, @@ -64,6 +70,12 @@ export const BASE_TYPES = [ TYPE_OPERATION, TYPE_BINDING, TYPE_TRANSITION, + TYPE_ORGANIZATION, + TYPE_SYSTEM, + TYPE_APP, + TYPE_BUILD, + TYPE_RESOURCE, + TYPE_ROLE, ] as const; export type BaseType = (typeof BASE_TYPES)[number]; diff --git a/server/typescript/packages/metadata/src/validate-max-occurs.ts b/server/typescript/packages/metadata/src/validate-max-occurs.ts index 6ce8521be1..7329bfabcc 100644 --- a/server/typescript/packages/metadata/src/validate-max-occurs.ts +++ b/server/typescript/packages/metadata/src/validate-max-occurs.ts @@ -4,8 +4,14 @@ // complement to config-driven `defaultName`: a singleton's static default name is // only collision-free if the singleton constraint is actually enforced (two // nameless identity.primary nodes would otherwise both default to "primary"). +// +// It also enforces a child rule's `max` (an app has at most one `build.*`, of any +// kind). That bound is on the parent's EFFECTIVE children, so a child inherited +// through `extends` counts: inherited children are taken first, and each declared +// child past the bound is reported. import type { MetaData } from "./shared/meta-data.js"; -import type { TypeRegistry } from "./registry.js"; +import { childRuleMatches, type TypeRegistry } from "./registry.js"; +import { TYPE_ATTR } from "./shared/base-types.js"; import { ParseError } from "./errors.js"; export function validateMaxOccurs(root: MetaData, registry: TypeRegistry): ParseError[] { @@ -38,7 +44,31 @@ function walk(node: MetaData, registry: TypeRegistry, errors: ParseError[]): voi ); } } + checkChildRuleMax(node, registry, errors); // ADR-0039: own — structural walk over the physical declaration tree (each // declared node is visited once at its declaration site). for (const child of node.ownChildren()) walk(child, registry, errors); } + +function checkChildRuleMax(node: MetaData, registry: TypeRegistry, errors: ParseError[]): void { + for (const rule of registry.find(node.type, node.subType)?.childRules ?? []) { + const max = rule.max; + if (max === undefined || max === null || rule.childType === TYPE_ATTR) continue; + // ADR-0039: resolving, so a child inherited through `extends` counts against the bound. + const matching = node.children().filter((c) => childRuleMatches(rule, c)); + if (matching.length <= max) continue; + // ADR-0039: own — the declared children are the ones this node can be blamed for. + const own = new Set(node.ownChildren()); + const ordered = [...matching.filter((c) => !own.has(c)), ...matching.filter((c) => own.has(c))]; + const owner = node.name !== "" ? ` '${node.name}'` : ""; + for (const extra of ordered.slice(max)) { + if (!own.has(extra)) continue; + errors.push( + new ParseError( + `${extra.type}.${extra.subType} '${extra.name}' is one too many under ${node.type}.${node.subType}${owner}: at most ${max} ${rule.childType}.${String(rule.childSubType)} is allowed`, + { code: "ERR_TOO_MANY_OCCURRENCES", source: extra.source }, + ), + ); + } + } +} diff --git a/server/typescript/packages/metadata/test/conformance/adapter.ts b/server/typescript/packages/metadata/test/conformance/adapter.ts index 1627ed310c..c96fa3aaac 100644 --- a/server/typescript/packages/metadata/test/conformance/adapter.ts +++ b/server/typescript/packages/metadata/test/conformance/adapter.ts @@ -3,6 +3,7 @@ // Binds the metadata package's typed-tree API to the neutral // ConformanceAdapter interface from @metaobjectsdev/conformance. +import { systemsCoreProvider } from "../../src/core/systems/systems-provider.js"; import type { ConformanceAdapter, ErrorEnvelopeRecord, @@ -167,6 +168,7 @@ export const PROVIDERS: Readonly> = { [viewExpressionsProvider.id]: viewExpressionsProvider, // "metaobjects-view-expressions" (origin.function, @union/@grain) [reportingProvider.id]: reportingProvider, // "metaobjects-reporting" (object.report, dimension/measure/segment) [requirementsProvider.id]: requirementsProvider, // "metaobjects-requirements" (requirement.*) + [systemsCoreProvider.id]: systemsCoreProvider, // "metaobjects-systems-core" (organization/system/app/build/resource/role) // Test-only — provider-extension-* fixtures. "example-template-briefing": exampleTemplateBriefingProvider, "example-custom-vocabulary": exampleCustomVocabularyProvider, diff --git a/server/typescript/packages/metadata/test/definition-schema.test.ts b/server/typescript/packages/metadata/test/definition-schema.test.ts index b9b8358c1d..9ab2c64d70 100644 --- a/server/typescript/packages/metadata/test/definition-schema.test.ts +++ b/server/typescript/packages/metadata/test/definition-schema.test.ts @@ -51,8 +51,8 @@ function withAttr(attr: Record): unknown { } describe("definition schema — the existing definition files", () => { - test("spec/metamodel holds the 22 core definition files", () => { - expect(definitionFiles.length).toBe(22); + test("spec/metamodel holds the 23 core definition files", () => { + expect(definitionFiles.length).toBe(23); }); for (const file of definitionFiles) { @@ -62,10 +62,10 @@ describe("definition schema — the existing definition files", () => { }); } - test("the core definition files declare exactly the four core references, each with its existing code", () => { + test("the core definition files declare exactly the four core references with their existing codes, and the systems vocabulary's four", () => { // spec/metamodel-definitions.md, "Existing references keep their codes": the four - // references core once declared in code live in the definition files, and no other - // core attribute is a reference yet. + // references core once declared in code live in the definition files. The systems + // vocabulary (ADR-0070) adds four new references, which take the default codes. const found: string[] = []; for (const file of definitionFiles) { const doc = JSON.parse(readFileSync(join(specDir, file), "utf-8")) as { @@ -89,6 +89,10 @@ describe("definition schema — the existing definition files", () => { `relationship.association @objectRef ${relationship}`, `relationship.base @objectRef ${relationship}`, `relationship.composition @objectRef ${relationship}`, + `app.base @runsAs ${JSON.stringify({ targetType: "role", targetSubTypes: ["service"] })}`, + `role.base @memberOf ${JSON.stringify({ targetType: "role", targetSubTypes: ["group"] })}`, + `role.token @heldBy ${JSON.stringify({ targetType: "organization" })}`, + `system.base @owner ${JSON.stringify({ targetType: "organization" })}`, ].sort(), ); }); diff --git a/server/typescript/packages/metadata/test/index.test.ts b/server/typescript/packages/metadata/test/index.test.ts index abfd54a117..b9bdefa3ee 100644 --- a/server/typescript/packages/metadata/test/index.test.ts +++ b/server/typescript/packages/metadata/test/index.test.ts @@ -143,6 +143,8 @@ describe("Public API surface — @metaobjectsdev/metadata index", () => { if (t === "api" || t === "operation" || t === "binding" || t === "transition") continue; // The reporting and requirements packs own these; core alone has none. if (t === "dimension" || t === "measure" || t === "segment" || t === "requirement") continue; + // The systems provider (metaobjects-systems-core) owns these; core alone has none. + if (t === "organization" || t === "system" || t === "app" || t === "build" || t === "resource" || t === "role") continue; const subs = registry.allSubTypesOf(t); expect(subs.length).toBeGreaterThan(0); } @@ -317,7 +319,7 @@ describe("Public API surface — @metaobjectsdev/metadata index", () => { }); test("BASE_TYPES array is exported and correct length", () => { - expect(BASE_TYPES).toHaveLength(21); + expect(BASE_TYPES).toHaveLength(27); expect(BASE_TYPES).toContain(TYPE_OBJECT); expect(BASE_TYPES).toContain(TYPE_FIELD); expect(BASE_TYPES).toContain(TYPE_LAYOUT); diff --git a/server/typescript/packages/metadata/test/provider-vocabulary.test.ts b/server/typescript/packages/metadata/test/provider-vocabulary.test.ts index 24b785bfb6..a328e7d005 100644 --- a/server/typescript/packages/metadata/test/provider-vocabulary.test.ts +++ b/server/typescript/packages/metadata/test/provider-vocabulary.test.ts @@ -74,19 +74,20 @@ describe("logical provider vocabulary", () => { for (const p of coreProviders) expect(Object.keys(canonical.providers)).toContain(p.id); }); - test("only core and the four named packs declare types; the rest are pure projections", () => { + test("only core and the five named packs declare types; the rest are pure projections", () => { // The shape ADR-0050 describes, asserted rather than assumed. A type-declaring - // provider beyond these five appearing fails this loudly, which is the moment to + // provider beyond these six appearing fails this loudly, which is the moment to // decide whether the OWN/PROJECTED split still holds. The packs // (metaobjects-reporting, metaobjects-requirements, metaobjects-rules, - // metaobjects-view-expressions) own their types and project onto core's; see - // GOVERNANCE.md, "Extension packs and the core metamodel". + // metaobjects-systems-core, metaobjects-view-expressions) own their types and + // project onto core's; see GOVERNANCE.md, "Extension packs and the core metamodel". const declaring = Object.entries(canonical.providers).filter(([, v]) => v.declaresTypes); expect(declaring.map(([k]) => k)).toEqual([ "metaobjects-core-types", "metaobjects-reporting", "metaobjects-requirements", "metaobjects-rules", + "metaobjects-systems-core", "metaobjects-view-expressions", ]); for (const [, v] of Object.entries(canonical.providers)) { diff --git a/server/typescript/packages/metadata/test/provider.test.ts b/server/typescript/packages/metadata/test/provider.test.ts index 8c9d6e6543..8aacb3554b 100644 --- a/server/typescript/packages/metadata/test/provider.test.ts +++ b/server/typescript/packages/metadata/test/provider.test.ts @@ -10,6 +10,7 @@ import { rulesProvider } from "../src/core/rules/rules-provider.js"; import { viewExpressionsProvider } from "../src/persistence/view-expressions/view-expressions-provider.js"; import { reportingProvider } from "../src/core/reporting/reporting-provider.js"; import { requirementsProvider } from "../src/core/requirement/requirements-provider.js"; +import { systemsCoreProvider } from "../src/core/systems/systems-provider.js"; import { TypeRegistry, TypeId } from "../src/registry.js"; import { MetaField } from "../src/core/field/meta-field.js"; import { @@ -101,7 +102,7 @@ describe("coreTypesProvider", () => { expect(registry.defaultSubTypeOf(TYPE_METADATA)).toBe(SUBTYPE_ROOT); }); - it("coreProviders is a ten-provider bundle: coreTypesProvider + dbProvider + docProvider + promptProvider + uiProvider + uiWebProvider + rulesProvider + viewExpressionsProvider + reportingProvider + requirementsProvider", () => { + it("coreProviders is an eleven-provider bundle: coreTypesProvider + dbProvider + docProvider + promptProvider + uiProvider + uiWebProvider + rulesProvider + viewExpressionsProvider + reportingProvider + requirementsProvider + systemsCoreProvider", () => { // FR-033 S1-field-A re-homed the field's filter/sort/teaching/extract/storage // attrs out of core into the concern providers. promptProvider (renamed from // templateProvider; id metaobjects-prompt) carries @xmlText/@example/@instruction @@ -116,8 +117,9 @@ describe("coreTypesProvider", () => { // (metaobjects-view-expressions) are packs split out of core in 1.3.0; they are in // the default bundle so no model changes, and each can be composed out. So are // reportingProvider (metaobjects-reporting) and requirementsProvider - // (metaobjects-requirements), split out the same way. - expect(coreProviders).toHaveLength(10); + // (metaobjects-requirements), split out the same way. systemsCoreProvider + // (metaobjects-systems-core, ADR-0070) is new in 1.4.0, its own provider from the start. + expect(coreProviders).toHaveLength(11); expect(coreProviders[0]).toBe(coreTypesProvider); expect(coreProviders[1]).toBe(dbProvider); expect(coreProviders[2]).toBe(docProvider); @@ -128,6 +130,7 @@ describe("coreTypesProvider", () => { expect(coreProviders[7]).toBe(viewExpressionsProvider); expect(coreProviders[8]).toBe(reportingProvider); expect(coreProviders[9]).toBe(requirementsProvider); + expect(coreProviders[10]).toBe(systemsCoreProvider); }); it("registerCoreTypes registers the structural types but not the DB-domain attrs", () => { @@ -140,8 +143,11 @@ describe("coreTypesProvider", () => { // dbProvider only extends and adds no types, so the only types composeRegistry adds // over core alone are the packs' (business rules, origin.function, reporting, - // requirements). - const packTypes = ["api", "operation", "binding", "transition", "dimension", "measure", "segment", "requirement"]; + // requirements, systems). + const packTypes = [ + "api", "operation", "binding", "transition", "dimension", "measure", "segment", "requirement", + "organization", "system", "app", "build", "resource", "role", + ]; const coreOnly = viaProviders.allTypes().filter( (t) => !packTypes.includes(t.type) && diff --git a/server/typescript/packages/metadata/test/reference-facet.test.ts b/server/typescript/packages/metadata/test/reference-facet.test.ts index cc79f20ab6..90fd8e858d 100644 --- a/server/typescript/packages/metadata/test/reference-facet.test.ts +++ b/server/typescript/packages/metadata/test/reference-facet.test.ts @@ -3,14 +3,20 @@ // `System.child` and `pkg::System.child`, the lookup is kind-typed, and the registry // manifest writes the facet only when an attr has one. // -// No shipped definition file uses the facet yet, so these tests compose a test provider -// with a small system vocabulary of their own. +// These tests compose a test provider with a small system vocabulary of their own, on +// core without the systems provider (which registers the same type names), so each case +// can use exactly the facet it needs. The shipped systems vocabulary is held by the +// conformance corpus. import { describe, it, expect } from "bun:test"; import { MetaDataLoader } from "../src/loader/meta-data-loader.js"; import { InMemoryStringSource } from "../src/loader/meta-data-source.js"; import { composeRegistry, type MetaDataTypeProvider } from "../src/provider.js"; import { coreProviders } from "../src/core-types.js"; +import { SYSTEMS_CORE_PROVIDER_ID } from "../src/core/systems/systems-provider.js"; + +/** Core without the systems provider, whose type names the test vocabulary reuses. */ +const baseProviders = coreProviders.filter((p) => p.id !== SYSTEMS_CORE_PROVIDER_ID); import { applyProviderDefinition, defineProviderFromData, @@ -119,7 +125,7 @@ const testProvider: MetaDataTypeProvider = { }; async function load(text: string, format: "yaml" | "json" = "yaml") { - const registry = composeRegistry([...coreProviders, testProvider]); + const registry = composeRegistry([...baseProviders, testProvider]); const loader = new MetaDataLoader({ registry, strict: true }); const { root, errors } = await loader.load([ new InMemoryStringSource(text, { id: `systems.${format}`, format }), @@ -532,7 +538,7 @@ metadata.root: describe("reference facet — the registry manifest", () => { it("writes `ref` only on an attribute that has one, in the fixed key order", () => { - const registry = composeRegistry([...coreProviders, testProvider]); + const registry = composeRegistry([...baseProviders, testProvider]); const manifest = buildRegistryManifest(registry); const grant = manifest.types.find((t) => t.type === "grant" && t.subType === "rdb")!; const resource = grant.attrs.find((a) => a.name === "resource")!; @@ -557,8 +563,13 @@ describe("reference facet — the registry manifest", () => { const withRef = manifest.types.flatMap((t) => t.attrs.filter((a) => a.ref !== undefined).map((a) => `${t.type}.${t.subType} @${a.name}`), ); - // Only the four core references (spec/metamodel-definitions.md) carry a facet. + // The four core references (spec/metamodel-definitions.md) and the systems + // vocabulary's four (ADR-0070), each written on every subtype that inherits it. expect(withRef.sort()).toEqual([ + "app.base @runsAs", + "app.client @runsAs", + "app.job @runsAs", + "app.service @runsAs", "field.map @objectRef", "field.object @objectRef", "identity.reference @references", @@ -566,6 +577,14 @@ describe("reference facet — the registry manifest", () => { "relationship.association @objectRef", "relationship.base @objectRef", "relationship.composition @objectRef", + "role.base @memberOf", + "role.group @memberOf", + "role.service @memberOf", + "role.token @heldBy", + "role.token @memberOf", + "role.user @memberOf", + "system.base @owner", + "system.software @owner", ]); const plain = manifest.types.find((t) => t.type === "relationship" && t.subType === "association")!; expect(Object.keys(plain.attrs.find((a) => a.name === "cardinality")!)).not.toContain("ref"); diff --git a/site-reference/index.html b/site-reference/index.html index cbc9c2e409..3e709675bb 100644 --- a/site-reference/index.html +++ b/site-reference/index.html @@ -71,6 +71,26 @@ types/api.md#apioperational +app.base +Abstract app base: the attributes every app.* shares. Not authored directly: an app.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). +types/app.md#appbase + + +app.client +Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself. +types/app.md#appclient + + +app.job +Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it. +types/app.md#appjob + + +app.service +A long-running process that answers requests: a web server, an API, a socket server. +types/app.md#appservice + + attr.base Abstract base attribute — the polymorphic/unconstrained value-type marker. Stores its value type-preserved (never stringified), accepting any type; used for an untyped attr (e.g. a field's @default, whose value-type follows the owning field's subtype). Not authored directly: a attr.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED) — this subtype is a registry anchor concrete subtypes inherit from, never a node in a document. types/attr.md#attrbase @@ -136,6 +156,16 @@ types/binding.md#bindingrest +build.base +Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a build.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). +types/build.md#buildbase + + +build.image +The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here. +types/build.md#buildimage + + dimension.attribute A named group-by attribute of the entity that declares it (FR-044). Groups report rows by a column value as-is. @of names Entity.field: the owning entity, or the @via terminal. @via may follow only to-one hops, so grouping by a related row's column can never multiply the measured rows. types/dimension.md#dimensionattribute @@ -331,6 +361,21 @@ types/operation.md#operationquery +organization.base +Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an organization.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). +types/organization.md#organizationbase + + +organization.company +A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company. +types/organization.md#organizationcompany + + +organization.unit +A team or division inside a company. Units nest: a unit is a child of a company or of another unit. +types/organization.md#organizationunit + + origin.aggregate A value reduced from the related row-set reached along a relationship path (@via) from the base entity: count/sum/avg/min/max over a column (@of); any/all predicate quantifiers over a @filter; or collect (an array rollup — of the @of column, or of the carrying field.object's declared @objectRef value object when @of is omitted). types/origin.md#originaggregate @@ -391,6 +436,76 @@ types/requirement.md#requirementfunctional +resource.base +Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a resource.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). +types/resource.md#resourcebase + + +resource.document +A document store: records kept and fetched as whole documents. +types/resource.md#resourcedocument + + +resource.keyValue +A store of values fetched by key. +types/resource.md#resourcekeyvalue + + +resource.objectStore +Files and blobs addressed by key. +types/resource.md#resourceobjectstore + + +resource.queue +A message queue: each message is handed to one consumer and gone once it is handled. +types/resource.md#resourcequeue + + +resource.rdb +A relational database: tables queried with SQL, the store of record. +types/resource.md#resourcerdb + + +resource.search +A search index: documents found by text and filters. +types/resource.md#resourcesearch + + +resource.stream +A retained, ordered log that many consumers read, each at its own position. A message can be read again. +types/resource.md#resourcestream + + +resource.volume +A disk attached to an app that survives a restart. +types/resource.md#resourcevolume + + +role.base +Abstract role base: an identity that can act in its system. Not authored directly: a role.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). +types/role.md#rolebase + + +role.group +Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in. +types/role.md#rolegroup + + +role.service +A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs). +types/role.md#roleservice + + +role.token +Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer. +types/role.md#roletoken + + +role.user +A named person, or an agent acting for one. No shared secret is generated or stored for it. +types/role.md#roleuser + + segment.filter A named, reusable row filter on the declaring entity (FR-044). Measures and reports reference it by name; exporters emit it as a named segment. types/segment.md#segmentfilter @@ -406,6 +521,16 @@ types/source.md#sourcerdb +system.base +Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a system.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED). +types/system.md#systembase + + +system.software +A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as System.child (Parcels.db), or pkg::System.child from another package. +types/system.md#systemsoftware + + template.base Abstract base template — the shared root subtype for the fourth pillar (FR-004, ADR-0011). A template is a typed payload bound to either a rendered text artifact (prompt/output) or a tool-call envelope. The base carries no attrs of its own; concrete subtypes add their reference + governance attrs. Not authored directly: a template.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED) — this subtype is a registry anchor concrete subtypes inherit from, never a node in a document. types/template.md#templatebase diff --git a/site-reference/providers.html b/site-reference/providers.html index f2cb2d5635..18ad263179 100644 --- a/site-reference/providers.html +++ b/site-reference/providers.html @@ -192,6 +192,25 @@

metaobjects-rules

  • transition.action: @condition, @from, @to
  • transition.base: @permission, @public
  • +

    metaobjects-systems-core

    +

    Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role.

    +

    Owns (registers): app.base, app.client, app.job, app.service, build.base, build.image, organization.base, organization.company, organization.unit, resource.base, resource.document, resource.keyValue, resource.objectStore, resource.queue, resource.rdb, resource.search, resource.stream, resource.volume, role.base, role.group, role.service, role.token, role.user, system.base, system.software

    +

    Contributes attributes:

    +
      +
    • app.base: @runsAs
    • +
    • app.client: @shell
    • +
    • app.job: @schedule
    • +
    • app.service: @public
    • +
    • build.image: @repository
    • +
    • resource.base: @residency
    • +
    • resource.keyValue: @volatile
    • +
    • resource.objectStore: @publicRead
    • +
    • resource.queue: @deadLetter, @ordered
    • +
    • resource.rdb: @schemas
    • +
    • role.base: @credential, @memberOf
    • +
    • role.token: @heldBy
    • +
    • system.base: @owner
    • +

    metaobjects-ui

    UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D).

    Contributes attributes:

    diff --git a/site-reference/types/app.html b/site-reference/types/app.html new file mode 100644 index 0000000000..1a40bce8d9 --- /dev/null +++ b/site-reference/types/app.html @@ -0,0 +1,216 @@ + + + + + + Metamodel — `app` types | MetaObjects + + + + + + + + + + +
    +

    Metamodel reference

    +

    Metamodel — app types

    +

    Each section below is one app.<subType>. The Attributes table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see providers.md). +Allowed children lists the structural child rules with their cardinality +(min..max, * = unbounded).

    +

    app.base

    +

    Abstract app base: the attributes every app.* shares. Not authored directly: an app.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).

    +

    Owning provider: metaobjects-systems-core

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @runsAsstringnometaobjects-systems-coreThe service role this app acts as: a role.service, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND.
    +

    Allowed children

    +
      +
    • build.* — 0..1
    • +
    +

    app.client

    +

    Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: A front end built and shipped as files, whatever serves them.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @runsAsstringnometaobjects-systems-coreThe service role this app acts as: a role.service, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND.
    @shellstringnometaobjects-systems-coreThe UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here.
    +

    Allowed children

    +
      +
    • build.* — 0..1
    • +
    +

    app.job

    +

    Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: A cron job, a nightly import, a queue drain that is not a long-running service.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @runsAsstringnometaobjects-systems-coreThe service role this app acts as: a role.service, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND.
    @schedulestringnometaobjects-systems-coreWhen the job runs, as a five-field cron expression in UTC (0 3 * * *). Absent means it runs only when triggered.
    +

    Allowed children

    +
      +
    • build.* — 0..1
    • +
    +

    app.service

    +

    A long-running process that answers requests: a web server, an API, a socket server.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Anything that listens on a port and stays up.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @publicbooleannometaobjects-systems-coreThe service is meant to be reached from outside every system: from browsers or from parties holding no role in the model. Absent means it is reached only by the apps and roles the model names.
    @runsAsstringnometaobjects-systems-coreThe service role this app acts as: a role.service, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND.
    +

    Allowed children

    +
      +
    • build.* — 0..1
    • +
    + +
    +
    + +
    + + diff --git a/site-reference/types/build.html b/site-reference/types/build.html new file mode 100644 index 0000000000..65e509ffec --- /dev/null +++ b/site-reference/types/build.html @@ -0,0 +1,102 @@ + + + + + + Metamodel — `build` types | MetaObjects + + + + + + + + + + +
    +

    Metamodel reference

    +

    Metamodel — build types

    +

    Each section below is one build.<subType>. The Attributes table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see providers.md). +Allowed children lists the structural child rules with their cardinality +(min..max, * = unbounded).

    +

    build.base

    +

    Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a build.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).

    +

    Owning provider: metaobjects-systems-core

    +

    Attributes

    +

    No subtype-specific attributes.

    +

    Allowed children

    +

    No structural children.

    +

    build.image

    +

    The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: An app whose image someone else builds: a product sold as images that the buyer deploys.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @repositorystringyesmetaobjects-systems-coreWhere the publisher keeps the image, without a tag (registry.example.com/team/app).
    +

    Allowed children

    +

    No structural children.

    + +
    +
    + +
    + + diff --git a/site-reference/types/metadata.html b/site-reference/types/metadata.html index 50aeb8ceb6..6aa7804d3d 100644 --- a/site-reference/types/metadata.html +++ b/site-reference/types/metadata.html @@ -59,7 +59,9 @@

    metadata.root

  • api.* — 0..*
  • field.* — 0..*
  • object.* — 0..*
  • +
  • organization.company — 0..*
  • requirement.* — 0..*
  • +
  • system.software — 0..*
  • template.* — 0..*
  • validator.* — 0..*
  • diff --git a/site-reference/types/organization.html b/site-reference/types/organization.html new file mode 100644 index 0000000000..15002faa8b --- /dev/null +++ b/site-reference/types/organization.html @@ -0,0 +1,94 @@ + + + + + + Metamodel — `organization` types | MetaObjects + + + + + + + + + + +
    +

    Metamodel reference

    +

    Metamodel — organization types

    +

    Each section below is one organization.<subType>. The Attributes table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see providers.md). +Allowed children lists the structural child rules with their cardinality +(min..max, * = unbounded).

    +

    organization.base

    +

    Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an organization.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).

    +

    Owning provider: metaobjects-systems-core

    +

    Attributes

    +

    No subtype-specific attributes.

    +

    Allowed children

    +

    No structural children.

    +

    organization.company

    +

    A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company.

    +

    Owning provider: metaobjects-systems-core

    +

    Rules: Lives at the document root. Its units are its children, addressed Company.unit (pkg::Company.unit from another package).

    +

    When to use: Every party that owns a system or holds a token. A party that publishes no metadata is written down by whoever depends on it, under the party's own package name.

    +

    Attributes

    +

    No subtype-specific attributes.

    +

    Allowed children

    +
      +
    • organization.unit — 0..*
    • +
    +

    organization.unit

    +

    A team or division inside a company. Units nest: a unit is a child of a company or of another unit.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: When a system's owner is a team rather than the whole company.

    +

    Attributes

    +

    No subtype-specific attributes.

    +

    Allowed children

    +
      +
    • organization.unit — 0..*
    • +
    + +
    +
    + +
    + + diff --git a/site-reference/types/resource.html b/site-reference/types/resource.html new file mode 100644 index 0000000000..374d559118 --- /dev/null +++ b/site-reference/types/resource.html @@ -0,0 +1,371 @@ + + + + + + Metamodel — `resource` types | MetaObjects + + + + + + + + + + +
    +

    Metamodel reference

    +

    Metamodel — resource types

    +

    Each section below is one resource.<subType>. The Attributes table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see providers.md). +Allowed children lists the structural child rules with their cardinality +(min..max, * = unbounded).

    +

    resource.base

    +

    Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a resource.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).

    +

    Owning provider: metaobjects-systems-core

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @residencystringnofreefree, confinedmetaobjects-systems-coreWhere the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit.
    +

    Allowed children

    +

    No structural children.

    +

    resource.document

    +

    A document store: records kept and fetched as whole documents.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Records whose shape is a document rather than a row.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @residencystringnofreefree, confinedmetaobjects-systems-coreWhere the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit.
    +

    Allowed children

    +

    No structural children.

    +

    resource.keyValue

    +

    A store of values fetched by key.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: A key-value store that is the source of its data, or a cache (@volatile).

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @residencystringnofreefree, confinedmetaobjects-systems-coreWhere the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit.
    @volatilebooleannometaobjects-systems-coreThe contents may be lost at any moment without losing data: a cache. Absent means the store is durable.
    +

    Allowed children

    +

    No structural children.

    +

    resource.objectStore

    +

    Files and blobs addressed by key.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Uploaded images, exports, static assets kept outside the app.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @publicReadbooleannometaobjects-systems-coreAnyone may read the objects without a credential. Absent means every read needs a grant.
    @residencystringnofreefree, confinedmetaobjects-systems-coreWhere the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit.
    +

    Allowed children

    +

    No structural children.

    +

    resource.queue

    +

    A message queue: each message is handed to one consumer and gone once it is handled.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Work handed from one app to another to run later.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @deadLetterbooleannometaobjects-systems-coreA message that keeps failing is set aside rather than dropped. How many attempts come first is a setting.
    @orderedbooleannometaobjects-systems-coreMessages with the same key are delivered in the order they were sent. Absent means no order is promised.
    @residencystringnofreefree, confinedmetaobjects-systems-coreWhere the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit.
    +

    Allowed children

    +

    No structural children.

    +

    resource.rdb

    +

    A relational database: tables queried with SQL, the store of record.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Any store an app queries with SQL, whatever the product.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @residencystringnofreefree, confinedmetaobjects-systems-coreWhere the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit.
    @schemasstring[]nometaobjects-systems-coreThe schema names the database holds. Optional and usually absent: the set can be computed from the entities' source.rdb @schema. Declaring it closes the list.
    +

    Allowed children

    +

    No structural children.

    +

    resource.search

    +

    A search index: documents found by text and filters.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Full-text search over records kept elsewhere.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @residencystringnofreefree, confinedmetaobjects-systems-coreWhere the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit.
    +

    Allowed children

    +

    No structural children.

    +

    resource.stream

    +

    A retained, ordered log that many consumers read, each at its own position. A message can be read again.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Events several consumers read independently, or read again.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @residencystringnofreefree, confinedmetaobjects-systems-coreWhere the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit.
    +

    Allowed children

    +

    No structural children.

    +

    resource.volume

    +

    A disk attached to an app that survives a restart.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: A file system path an app writes to and must keep.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @residencystringnofreefree, confinedmetaobjects-systems-coreWhere the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit.
    +

    Allowed children

    +

    No structural children.

    + +
    +
    + +
    + + diff --git a/site-reference/types/role.html b/site-reference/types/role.html new file mode 100644 index 0000000000..632ac8ee8f --- /dev/null +++ b/site-reference/types/role.html @@ -0,0 +1,264 @@ + + + + + + Metamodel — `role` types | MetaObjects + + + + + + + + + + +
    +

    Metamodel reference

    +

    Metamodel — role types

    +

    Each section below is one role.<subType>. The Attributes table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see providers.md). +Allowed children lists the structural child rules with their cardinality +(min..max, * = unbounded).

    +

    role.base

    +

    Abstract role base: an identity that can act in its system. Not authored directly: a role.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).

    +

    Owning provider: metaobjects-systems-core

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @credentialstringnometaobjects-systems-coreThe name of an existing key this role adopts (keys/ANTHROPIC_API_KEY). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name.
    @memberOfstring[]nometaobjects-systems-coreThe groups this role belongs to: role.group nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.
    +

    Allowed children

    +

    No structural children.

    +

    role.group

    +

    Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Several roles that share the same access.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @credentialstringnometaobjects-systems-coreThe name of an existing key this role adopts (keys/ANTHROPIC_API_KEY). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name.
    @memberOfstring[]nometaobjects-systems-coreThe groups this role belongs to: role.group nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.
    +

    Allowed children

    +

    No structural children.

    +

    role.service

    +

    A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs).

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Every identity an app or job of the system acts as.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @credentialstringnometaobjects-systems-coreThe name of an existing key this role adopts (keys/ANTHROPIC_API_KEY). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name.
    @memberOfstring[]nometaobjects-systems-coreThe groups this role belongs to: role.group nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.
    +

    Allowed children

    +

    No structural children.

    +

    role.token

    +

    Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: Access handed to something that is not one of the system's apps.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @credentialstringnometaobjects-systems-coreThe name of an existing key this role adopts (keys/ANTHROPIC_API_KEY). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name.
    @heldBystringnometaobjects-systems-coreWho was handed the token: an organization node, by name (tidewell::Tidewell). Optional. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node is ERR_REF_WRONG_KIND. ADR-0070 call 9 also admits a system here; that waits on the reference facet accepting more than one target type.
    @memberOfstring[]nometaobjects-systems-coreThe groups this role belongs to: role.group nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.
    +

    Allowed children

    +

    No structural children.

    +

    role.user

    +

    A named person, or an agent acting for one. No shared secret is generated or stored for it.

    +

    Owning provider: metaobjects-systems-core

    +

    When to use: A person who signs in to a resource directly.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @credentialstringnometaobjects-systems-coreThe name of an existing key this role adopts (keys/ANTHROPIC_API_KEY). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name.
    @memberOfstring[]nometaobjects-systems-coreThe groups this role belongs to: role.group nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.
    +

    Allowed children

    +

    No structural children.

    + +
    +
    + +
    + + diff --git a/site-reference/types/system.html b/site-reference/types/system.html new file mode 100644 index 0000000000..09f680ad87 --- /dev/null +++ b/site-reference/types/system.html @@ -0,0 +1,128 @@ + + + + + + Metamodel — `system` types | MetaObjects + + + + + + + + + + +
    +

    Metamodel reference

    +

    Metamodel — system types

    +

    Each section below is one system.<subType>. The Attributes table lists +the subtype's own + concern-contributed attributes (provider-tagged); universal +documentation attributes are omitted here (see providers.md). +Allowed children lists the structural child rules with their cardinality +(min..max, * = unbounded).

    +

    system.base

    +

    Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a system.base node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).

    +

    Owning provider: metaobjects-systems-core

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @ownerstringnometaobjects-systems-coreThe organization, or a unit of one, that owns the system: an organization node, by name (Quillhaven, quillhaven::Quillhaven.ParcelOps). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources.
    +

    Allowed children

    +

    No structural children.

    +

    system.software

    +

    A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as System.child (Parcels.db), or pkg::System.child from another package.

    +

    Owning provider: metaobjects-systems-core

    +

    Rules: Lives at the document root. Names are unique per type within the system, so an app and a role may share a name: every reference names the type it wants.

    +

    When to use: Every product or service, including one somebody else runs that an app calls: write it down under its owner's package name.

    +

    Attributes

    + + + + + + + + + + + + + + + + + + + + + +
    AttributeTypeRequiredDefaultAllowed valuesProviderDescription
    @ownerstringnometaobjects-systems-coreThe organization, or a unit of one, that owns the system: an organization node, by name (Quillhaven, quillhaven::Quillhaven.ParcelOps). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources.
    +

    Allowed children

    +
      +
    • app.* — 0..*
    • +
    • resource.* — 0..*
    • +
    • role.* — 0..*
    • +
    + +
    + + + diff --git a/spec/metamodel-definitions.md b/spec/metamodel-definitions.md index 483590eef8..ea2275d099 100644 --- a/spec/metamodel-definitions.md +++ b/spec/metamodel-definitions.md @@ -164,9 +164,8 @@ Two worked cases. They are normative: | a | `runsAs: db` on an app under `system.software Parcels`. `Parcels` has a `resource.rdb db` and no `role db`. | `ERR_REF_WRONG_KIND` | | b | `runsAs: nobody`. No node named `nobody` exists in the referrer's containers or at the top level. | `ERR_REF_UNRESOLVED` | -These two cases become conformance fixtures in the change that first registers vocabulary using -the facet. No fixture exists before then, because the `system` and `role` vocabulary is not -registered. +These two cases are the conformance fixtures `error-ref-wrong-kind-runsas` (a) and +`error-ref-unresolved-runsas` (b). A value raises at most one error, the first that fails. Each step's message names the attribute, the value as written and, for steps 2 and 3, what was found (its type, subtype and system). @@ -178,8 +177,8 @@ lookup path names: `Ledger.clerk`, where `Ledger` inherits `clerk` from `Parcels `Ledger`, not in `Parcels`. For `sameSystem`, the declaring node's system and the target's system must be the same node. A declaring node with no system fails step 3, because a reference that must stay inside a system -cannot be declared outside one. The `system` type is registered by core in 1.4.0 (ADR-0070); a -facet that sets `sameSystem` before then can never pass and no definition file sets it. +cannot be declared outside one. Core registers the `system` type from 1.4.0 (ADR-0070). No +shipped definition file sets `sameSystem` yet. ## What the facet does not do @@ -193,8 +192,12 @@ facet that sets `sameSystem` before then can never pass and no definition file s ## Status -The format and the schema are specified here. The four core references above use `ref`; no -other definition file does yet. +The format and the schema are specified here. The four core references above use `ref`, and so +does the systems vocabulary (`spec/metamodel/systems.json`, provider `metaobjects-systems-core`, +ADR-0070): `system.* @owner` and `role.token @heldBy` name an `organization`, `app.* @runsAs` a +`role.service`, and `role.* @memberOf` a `role.group`, all with the default codes. `@heldBy` takes +one target type today, so a token held by a system raises `ERR_REF_WRONG_KIND` until the facet +accepts a list of target types. Ports whose spec reader reads and enforces `ref`: TypeScript, C#, Java, Kotlin, Python, Rust. Each reads the four core references from the definition files (in Rust, from its vendored copy in @@ -203,5 +206,6 @@ Each reads the four core references from the definition files (in Rust, from its The two default codes are in `fixtures/conformance/ERROR-CODES.json` and its vendored Rust copy, and in the TypeScript, Python, Java (Kotlin shares it) and C# error-code catalogs. Rust lists only the codes it raises, so its reader change adds them there. The two -worked cases become conformance fixtures in the change that first registers new vocabulary using -the facet (the four core references above are not new vocabulary). +worked cases are the conformance fixtures `error-ref-wrong-kind-runsas` and +`error-ref-unresolved-runsas`, added with the systems vocabulary, the first new vocabulary to use +the facet. diff --git a/spec/metamodel.md b/spec/metamodel.md index 639774f3a4..54c4cca724 100644 --- a/spec/metamodel.md +++ b/spec/metamodel.md @@ -51,5 +51,12 @@ complete, loadable node — the name is optional. This is a generic registry rul per-type loader special-case, and is gated cross-port by the `identity-primary-default-name` / `error-too-many-primary` conformance fixtures. +**A child rule's `max`.** A child rule may bound how many children it admits (`app.*` +admits at most one `build.*`, of any kind). The bound is on the parent's effective +children, so a child inherited through `extends` counts: inherited children are taken +first, and each declared child past the bound is an `ERR_TOO_MANY_OCCURRENCES` error. +Gated cross-port by the `error-app-two-builds` / `error-app-three-builds` / +`error-app-build-beside-inherited` conformance fixtures. + See `typescript/packages/metadata/src/constants.ts` for the canonical vocabulary (type names, subtype names, structural keys, separators). diff --git a/spec/metamodel/systems.json b/spec/metamodel/systems.json new file mode 100644 index 0000000000..8ff1f9e598 --- /dev/null +++ b/spec/metamodel/systems.json @@ -0,0 +1,233 @@ +{ + "provider": "metaobjects-systems-core", + "types": [ + { + "type": "organization", + "subType": "base", + "description": "Abstract organization base: the shared root of organization.company and organization.unit (ADR-0070, call 2). Not authored directly: an `organization.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "organization", + "subType": "company", + "extendsBase": true, + "description": "A legal entity: it can own systems, operate environments and be handed credentials. Declared once, by the company itself, under its own package, and imported by everyone else. There is no vendor or customer kind: whether a company is one is a fact about the reader, not the company.", + "whenToUse": "Every party that owns a system or holds a token. A party that publishes no metadata is written down by whoever depends on it, under the party's own package name.", + "rules": "Lives at the document root. Its units are its children, addressed `Company.unit` (`pkg::Company.unit` from another package).", + "children": [ + { "type": "organization", "subType": "unit", "name": "*", "min": 0, "max": null, "description": "The teams or divisions inside the company." } + ] + }, + { + "type": "organization", + "subType": "unit", + "extendsBase": true, + "description": "A team or division inside a company. Units nest: a unit is a child of a company or of another unit.", + "whenToUse": "When a system's owner is a team rather than the whole company.", + "children": [ + { "type": "organization", "subType": "unit", "name": "*", "min": 0, "max": null, "description": "The units inside this one." } + ] + }, + { + "type": "system", + "subType": "base", + "description": "Abstract system base: the attributes every system.* shares (ADR-0070, call 1). Not authored directly: a `system.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "owner", "min": 0, "max": 1, "description": "The organization, or a unit of one, that owns the system: an organization node, by name (`Quillhaven`, `quillhaven::Quillhaven.ParcelOps`). Optional. Whether this model deploys the system is never declared: it is derived from the deployment nodes in the model's own sources.", "ref": { "targetType": "organization" } } + ] + }, + { + "type": "system", + "subType": "software", + "extendsBase": true, + "description": "A system: the apps it is made of, the resources they keep their state in and the roles that act in it. The one kind of system. A file that declares one reads the same in every repository that loads it, so nothing here says whether the reader builds, runs or only calls it. Its children are addressed from outside it as `System.child` (`Parcels.db`), or `pkg::System.child` from another package.", + "whenToUse": "Every product or service, including one somebody else runs that an app calls: write it down under its owner's package name.", + "rules": "Lives at the document root. Names are unique per type within the system, so an app and a role may share a name: every reference names the type it wants.", + "children": [ + { "type": "app", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The system's apps." }, + { "type": "resource", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The system's resources." }, + { "type": "role", "subType": "*", "name": "*", "min": 0, "max": null, "description": "The identities that act in the system." } + ] + }, + { + "type": "app", + "subType": "base", + "description": "Abstract app base: the attributes every app.* shares. Not authored directly: an `app.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "runsAs", "min": 0, "max": 1, "description": "The service role this app acts as: a `role.service`, by name. A bare name is a role of the app's own system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a service role, is ERR_REF_WRONG_KIND.", "ref": { "targetType": "role", "targetSubTypes": ["service"] } }, + { "type": "build", "subType": "*", "name": "*", "min": 0, "max": 1, "description": "How the app's deployable is made. At most one, of any kind." } + ] + }, + { + "type": "app", + "subType": "service", + "extendsBase": true, + "description": "A long-running process that answers requests: a web server, an API, a socket server.", + "whenToUse": "Anything that listens on a port and stays up.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "public", "min": 0, "max": 1, "description": "The service is meant to be reached from outside every system: from browsers or from parties holding no role in the model. Absent means it is reached only by the apps and roles the model names." } + ] + }, + { + "type": "app", + "subType": "client", + "extendsBase": true, + "description": "Code that runs on the user's device: a single-page web app, a static site, a mobile app. It calls services; it serves nothing itself.", + "whenToUse": "A front end built and shipped as files, whatever serves them.", + "children": [ + { "type": "attr", "subType": "string", "name": "shell", "min": 0, "max": 1, "description": "The UI frame (a nav.shell of a UI pack) this client presents, by name. Recorded by name only: no UI pack is required, so the name is not resolved here." } + ] + }, + { + "type": "app", + "subType": "job", + "extendsBase": true, + "description": "Work that runs to completion and exits: a scheduled task, a migration, a one-off batch. It may run on a schedule (@schedule) or when something triggers it.", + "whenToUse": "A cron job, a nightly import, a queue drain that is not a long-running service.", + "children": [ + { "type": "attr", "subType": "string", "name": "schedule", "min": 0, "max": 1, "description": "When the job runs, as a five-field cron expression in UTC (`0 3 * * *`). Absent means it runs only when triggered." } + ] + }, + { + "type": "build", + "subType": "base", + "description": "Abstract build base: how an app's deployable is made, the same in every environment. A build is a child of an app. Not authored directly: a `build.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED)." + }, + { + "type": "build", + "subType": "image", + "extendsBase": true, + "description": "The app is shipped as a prebuilt container image that its publisher keeps in a registry. The tag deployed is a setting, never an attribute here.", + "whenToUse": "An app whose image someone else builds: a product sold as images that the buyer deploys.", + "children": [ + { "type": "attr", "subType": "string", "name": "repository", "min": 1, "max": 1, "description": "Where the publisher keeps the image, without a tag (`registry.example.com/team/app`)." } + ] + }, + { + "type": "resource", + "subType": "base", + "description": "Abstract resource base: the attributes every resource.* shares. A resource holds state or carries messages for the system's apps, and somebody has to run it. Its kind says what it is for an app, never which product supplies it: the product is a setting. Not authored directly: a `resource.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "residency", "min": 0, "max": 1, "allowedValues": ["free", "confined"], "default": "free", "description": "Where the data may be kept. confined: every copy of this data, in any one provision, stays inside one jurisdiction, and only apps running inside it may reach it directly. free (the default): no such limit." } + ] + }, + { + "type": "resource", + "subType": "rdb", + "extendsBase": true, + "description": "A relational database: tables queried with SQL, the store of record.", + "whenToUse": "Any store an app queries with SQL, whatever the product.", + "children": [ + { "type": "attr", "subType": "string", "name": "schemas", "isArray": true, "min": 0, "max": 1, "description": "The schema names the database holds. Optional and usually absent: the set can be computed from the entities' source.rdb @schema. Declaring it closes the list." } + ] + }, + { + "type": "resource", + "subType": "keyValue", + "extendsBase": true, + "description": "A store of values fetched by key.", + "whenToUse": "A key-value store that is the source of its data, or a cache (@volatile).", + "children": [ + { "type": "attr", "subType": "boolean", "name": "volatile", "min": 0, "max": 1, "description": "The contents may be lost at any moment without losing data: a cache. Absent means the store is durable." } + ] + }, + { + "type": "resource", + "subType": "objectStore", + "extendsBase": true, + "description": "Files and blobs addressed by key.", + "whenToUse": "Uploaded images, exports, static assets kept outside the app.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "publicRead", "min": 0, "max": 1, "description": "Anyone may read the objects without a credential. Absent means every read needs a grant." } + ] + }, + { + "type": "resource", + "subType": "document", + "extendsBase": true, + "description": "A document store: records kept and fetched as whole documents.", + "whenToUse": "Records whose shape is a document rather than a row." + }, + { + "type": "resource", + "subType": "search", + "extendsBase": true, + "description": "A search index: documents found by text and filters.", + "whenToUse": "Full-text search over records kept elsewhere." + }, + { + "type": "resource", + "subType": "queue", + "extendsBase": true, + "description": "A message queue: each message is handed to one consumer and gone once it is handled.", + "whenToUse": "Work handed from one app to another to run later.", + "children": [ + { "type": "attr", "subType": "boolean", "name": "ordered", "min": 0, "max": 1, "description": "Messages with the same key are delivered in the order they were sent. Absent means no order is promised." }, + { "type": "attr", "subType": "boolean", "name": "deadLetter", "min": 0, "max": 1, "description": "A message that keeps failing is set aside rather than dropped. How many attempts come first is a setting." } + ] + }, + { + "type": "resource", + "subType": "stream", + "extendsBase": true, + "description": "A retained, ordered log that many consumers read, each at its own position. A message can be read again.", + "whenToUse": "Events several consumers read independently, or read again." + }, + { + "type": "resource", + "subType": "volume", + "extendsBase": true, + "description": "A disk attached to an app that survives a restart.", + "whenToUse": "A file system path an app writes to and must keep." + }, + { + "type": "role", + "subType": "base", + "description": "Abstract role base: an identity that can act in its system. Not authored directly: a `role.base` node fails to load (ERR_ABSTRACT_SUBTYPE_AUTHORED).", + "children": [ + { "type": "attr", "subType": "string", "name": "memberOf", "isArray": true, "min": 0, "max": 1, "description": "The groups this role belongs to: `role.group` nodes, by name. A bare name is a role of the same system. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node, or a role that is not a group, is ERR_REF_WRONG_KIND.", "ref": { "targetType": "role", "targetSubTypes": ["group"] } }, + { "type": "attr", "subType": "string", "name": "credential", "min": 0, "max": 1, "description": "The name of an existing key this role adopts (`keys/ANTHROPIC_API_KEY`). Never a value. Written only for a key the model cannot create: a role's credential is otherwise implied, with a derived name." } + ] + }, + { + "type": "role", + "subType": "service", + "extendsBase": true, + "description": "A running app or job. A generator creates a login for it and delivers the credential to the app that runs as it (@runsAs).", + "whenToUse": "Every identity an app or job of the system acts as." + }, + { + "type": "role", + "subType": "user", + "extendsBase": true, + "description": "A named person, or an agent acting for one. No shared secret is generated or stored for it.", + "whenToUse": "A person who signs in to a resource directly." + }, + { + "type": "role", + "subType": "group", + "extendsBase": true, + "description": "Nobody directly: a group exists to carry what its members share (@memberOf), and cannot sign in.", + "whenToUse": "Several roles that share the same access." + }, + { + "type": "role", + "subType": "token", + "extendsBase": true, + "description": "Automation outside the system's own apps, given a scoped token: a deploy pipeline, CI, an outside consumer.", + "whenToUse": "Access handed to something that is not one of the system's apps.", + "children": [ + { "type": "attr", "subType": "string", "name": "heldBy", "min": 0, "max": 1, "description": "Who was handed the token: an organization node, by name (`tidewell::Tidewell`). Optional. A name that resolves to nothing is ERR_REF_UNRESOLVED; one that names another kind of node is ERR_REF_WRONG_KIND. ADR-0070 call 9 also admits a system here; that waits on the reference facet accepting more than one target type.", "ref": { "targetType": "organization" } } + ] + } + ], + "extends": [ + { + "type": "metadata", + "subType": "root", + "children": [ + { "type": "organization", "subType": "company", "name": "*", "min": 0, "max": null, "description": "An organization: a top-level, packaged node." }, + { "type": "system", "subType": "software", "name": "*", "min": 0, "max": null, "description": "A system: a top-level, packaged node." } + ] + } + ] +} diff --git a/templates/metamodel/provider-descriptions.json b/templates/metamodel/provider-descriptions.json index 4cbe8f7f5c..a4241a7a6a 100644 --- a/templates/metamodel/provider-descriptions.json +++ b/templates/metamodel/provider-descriptions.json @@ -6,6 +6,7 @@ "metaobjects-reporting": "Reporting (FR-044): object.report, dimension / measure / segment on an entity, and @segment on origin.aggregate and origin.first.", "metaobjects-requirements": "Requirements: requirement.functional and requirement.architectural, declared at the document root and checked by meta verify.", "metaobjects-rules": "Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).", + "metaobjects-systems-core": "Systems (ADR-0070): organization, system.software, app (service, client, job), build.image, resource and role.", "metaobjects-ui": "UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D).", "metaobjects-ui-web": "Web presentation view attrs — @rows (view.textarea) and the view.image control attrs. Every port applies this provider and loads them strictly; only TypeScript acts on them so far.", "metaobjects-view-expressions": "View expressions (rc.21): origin.function plus the projection @union / @unionAll / @grain / @grainOrdinal attributes."