Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ metaobjects/
│ ├── ai/ # the LLM-call trace envelope (stable)
│ └── iam/ # users, groups, roles, grants (preview)
├── packs/ # independent packs, outside the default bundle, each with its
│ # own version (ADR-0069; none shipped yet)
│ # own version (ADR-0069; listed in packs/README.md)
├── templates/ # canonical api/docs Mustache templates (the SSOT the
│ # ports embed; byte-gated so copies cannot drift)
├── agent-context/ # the shared source the per-port AI-assistant context
Expand Down
43 changes: 43 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions changelog.d/independent-packs-skeleton.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- **Independent packs: the `packs/` directory, its gates and its lane (ADR-0069).** A capability
that is not core vocabulary can now be built in `packs/<name>/` with its own version, changelog
and port list, outside the default bundle and outside `metamodelVersion`. No pack exists yet,
and nothing published changes. `scripts/check-pack-boundary.ts` fails a change that makes core
and port list, outside the default bundle and outside `metamodelVersion`. The packs that
exist are listed in `packs/README.md`, and nothing published changes. `scripts/check-pack-boundary.ts` fails a change that makes core
depend on a pack, puts a pack in the bundle, or lets core's release tooling see `packs/`.
`scripts/check-pack-manifests.ts` holds each `pack.json` to its ports' native manifests.
`scripts/pack-vocabulary.ts` pins the rows a pack adds and fails one that changes the bundle's,
Expand Down
10 changes: 10 additions & 0 deletions changelog.d/metadata-apply-provider-definition-export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- **metadata: a provider outside core can register vocabulary from a definition file.**
`applyProviderDefinition` and its types (`ProviderDefinition`, `TypeDef`, `ChildDef`,
`ExtendDef`, `FactoryMap`, `ValidatorMap`) are exported from `@metaobjectsdev/metadata`, with
the validation hook's types (`NodeValidator`, `ValidationContext`, `SymbolTable`,
`LoaderCode`). `applyProviderDefinition` takes an optional fourth argument, a
`"<type>.<subType>"` → validator map, so a type registered from data can carry a check the data
cannot express. `referrerPackageFor` (ADR-0059 R3: the package a reference attribute resolves
in) is exported too, so a provider's own reference check resolves as the loader's does. The
bundled packs already registered this way; the independent packs under `packs/` (ADR-0069) now
can too. No vocabulary or `metamodelVersion` change.
8 changes: 8 additions & 0 deletions docs/features/extending-with-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ but is not yet core vocabulary. The contract the provider is written against (`i
`dependencies`, `registerTypes`, `register`, `extend`, `registerCommonAttrs` and the definition
file format) is covered by core's package version (`docs/compatibility-policy.md`).

**From a definition file.** A provider can keep its vocabulary as data, in the
`spec/metamodel/*.json` format, and register it with `applyProviderDefinition(registry, definition,
factories, validators?)` from `@metaobjectsdev/metadata`. `factories` maps each
`"<type>.<subType>"` to the function that constructs its node; the optional `validators` map gives
a type a `NodeValidator`, for a rule the data cannot state (a reference to a nested node, say).
The bundled packs register this way, and so do the independent packs: `packs/systems/` is a
worked example.

## Two registration modes

### `register` — declare a new `(type, subType)`
Expand Down
8 changes: 7 additions & 1 deletion packs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

A directory here is an **independent pack**: vocabulary, generators and runtime for a capability
that is not part of core, built and versioned as if it were its own repository
([ADR-0069](../spec/decisions/ADR-0069-independent-packs.md)). None exists yet.
([ADR-0069](../spec/decisions/ADR-0069-independent-packs.md)).

| Pack | What it declares | Requires | Ports |
|---|---|---|---|
| [`systems`](systems/README.md) | systems, apps (service, client, job), resources | core | TypeScript |
| [`delivery`](delivery/README.md) | environments, builds, runtime processes, deployments, value bindings | `systems` | TypeScript |
| [`railway`](railway/README.md) | `deployment.railway` (vocabulary only; the emitter is later work) | `delivery` | TypeScript |

An independent pack is not in the default bundle. A project opts in by naming its provider. It is
never in `fixtures/registry-conformance/expected-registry.json` and never moves
Expand Down
13 changes: 13 additions & 0 deletions packs/delivery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog: delivery pack

This pack's own changelog (ADR-0069). The root `CHANGELOG.md` records core only.

## [0.1.0] - unreleased

- **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
`@environment` and a `value.ref`'s `@producedBy` are resolved at load (`ERR_DELIVERY_UNRESOLVED_REF`);
`@secrets` and `@setting` are names only. A deployment holds one value per `@setting`
(`ERR_DELIVERY_DUPLICATE_SETTING`) and a model one deployment per (`@app`, `@environment`)
(`ERR_DELIVERY_DUPLICATE_DEPLOYMENT`). TypeScript port.
79 changes: 79 additions & 0 deletions packs/delivery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# delivery pack

`metaobjects-delivery`, version 0.1.0, **preview**, unpublished. An independent pack
([ADR-0069](../../spec/decisions/ADR-0069-independent-packs.md)). Requires
[`systems`](../systems/README.md).

It answers: **what runs where, and what differs per environment?** Facts true in every
environment sit under the app (how it is built, how its process runs). A deployment places one app
in one environment on one platform, and holds only what differs there.

## Vocabulary

| Node | Where | What it is | Attributes |
|---|---|---|---|
| `environment.standing`, `.ephemeral`, `.local` | document root | A named environment: production, a pull-request preview, a workstation | (documentation only) |
| `build.dockerfile` | under an `app.*`, at most one build | Built as an image from a Dockerfile | `@path`, `@context`, `@watchExclude` |
| `build.command` | under an `app.*` | Built by a command the platform's builder runs | `@command`, `@watchExclude` |
| `build.static` | under an `app.*` | A directory of files served as they are | `@directory`, `@command`, `@watchExclude` |
| `runtime.process` | under an `app.*` | How one of its processes runs | `@command`, `@port`, `@healthPath`, `@healthTimeoutSeconds`, `@drainSeconds`, `@restart` (`always`, `onFailure`, `never`) |
| `deployment.<platform>` | document root | An app in an environment on a platform. A **platform pack** registers the subtype (the [`railway`](../railway/README.md) pack registers `deployment.railway`) | `@app`, `@environment`, `@domains`, `@replicas`, `@region`, `@branch`, `@secrets`, plus the platform's own |
| `value.literal` | under a deployment | A setting's fixed value there | `@setting`, `@literal` |
| `value.ref` | under a deployment | A setting's value produced by another node at deploy time | `@setting`, `@producedBy`, `@output` |

`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
[`metamodel/delivery.json`](metamodel/delivery.json).

## References

- `@app` names an app as `System.app`, or `pkg::System.app` from another package.
- `@environment` names an `environment.*` node.
- `value.ref`'s `@producedBy` names a `resource.*` or `app.*` the same way. A deployment sits at the
document root, in no system, so these are always written `System.child`: a bare name finds
only a top-level node. `@output` says which of its
values (`url`, `host`, `port`, `user`, `password`, `privateUrl`, `publicUrl`), for a platform
generator to map. This is how an address
stays out of a repository: it is named, never written.

## Uniqueness

- A deployment holds at most one `value.*` per `@setting` (`ERR_DELIVERY_DUPLICATE_SETTING`). An estate
overlay that overrides a value has to reuse the value node's name so the overlay merges it; a
second, differently named value for the same setting is an error.
- A model holds at most one deployment per (`@app`, `@environment`), compared as resolved nodes, so
`Game.server` and `acme::game::Game.server` collide (`ERR_DELIVERY_DUPLICATE_DEPLOYMENT`).

Each fails the load with `ERR_DELIVERY_UNRESOLVED_REF` when it resolves to nothing or to the wrong
kind of node. A platform pack holds its deployments to the same rule by passing
`validateDeployment` as its subtype's validator. `@secrets` (a config pack `vault.*`) and
`@setting` (`Group.field` of an `object.settings`) are names only: this pack does not require the
config pack.

## The estate pattern

The app's repository declares its own deployments. A separate estate repository loads that model,
adds deployments the app never declared (a staging environment), and overrides the ones it did by
overlay, using the loader's existing merge:

```json
{ "metadata.root": { "package": "acme::game", "children": [
{ "deployment.railway": { "name": "server-production", "overlay": true, "@replicas": 2 } }
] } }
```

The `railway` pack's `railway-worked-example` fixture is the whole example, both sides.

## Ports

TypeScript only (ADR-0069's port rule: elsewhere a model that uses it fails by name).

## Checks

```
bun scripts/pack-vocabulary.ts delivery
bun scripts/pack-conformance.ts delivery
scripts/ci-local.sh --only packs
```
8 changes: 8 additions & 0 deletions packs/delivery/fixtures/conformance/ERROR-CODES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 1,
"codes": {
"ERR_DELIVERY_UNRESOLVED_REF": "A deployment's @app or @environment, or a value.ref's @producedBy, names no node, or names a node of the wrong kind (@app takes an app.*, @environment an environment.*, @producedBy a resource.* or an app.*).",
"ERR_DELIVERY_DUPLICATE_SETTING": "A deployment holds two value.* nodes for one @setting. An estate overlay that overrides a value must reuse the value node's name so it merges.",
"ERR_DELIVERY_DUPLICATE_DEPLOYMENT": "Two deployments target the same (@app, @environment), compared as resolved nodes."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"metadata.root": {
"package": "acme::shop",
"children": [
{
"system.internal": {
"name": "Shop",
"children": [
{
"app.client": {
"name": "storefront",
"children": [
{
"build.static": {
"name": "site",
"@command": "npm run build",
"@directory": "dist",
"@watchExclude": [
"docs/**"
]
}
}
]
}
},
{
"app.service": {
"name": "api",
"children": [
{
"build.command": {
"name": "jar",
"@command": "./gradlew bootJar"
}
},
{
"runtime.process": {
"name": "web",
"@command": "java -jar app.jar",
"@drainSeconds": 30,
"@healthPath": "/health",
"@healthTimeoutSeconds": 120,
"@port": 8080,
"@restart": "always"
}
},
{
"runtime.process": {
"name": "worker",
"@command": "java -jar app.jar --worker",
"@restart": "onFailure"
}
}
]
}
},
{
"app.job": {
"name": "nightlyExport",
"@schedule": "0 3 * * *",
"children": [
{
"build.dockerfile": {
"name": "image",
"@context": "jobs",
"@path": "jobs/Dockerfile"
}
},
{
"runtime.process": {
"name": "run",
"@restart": "never"
}
}
]
}
}
]
}
},
{
"environment.standing": {
"name": "production"
}
},
{
"environment.standing": {
"name": "staging"
}
},
{
"environment.ephemeral": {
"name": "preview"
}
},
{
"environment.local": {
"name": "workstation"
}
}
]
}
}
Loading
Loading