Skip to content

feat(packs): add systems, delivery and railway vocabulary packs - #649

Merged
dmealing merged 6 commits into
mainfrom
fm/mo-pack-a2-systems-delivery
Nov 25, 2026
Merged

dmealing merged 6 commits into
mainfrom
fm/mo-pack-a2-systems-delivery

Conversation

@dmealing

@dmealing dmealing commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Adds three independent packs under packs/ (each 0.1.0, preview, unpublished, TypeScript only): systems (system.internal/external, app.service/client/job, resource.*), delivery (environment.*, build.*, runtime.process, deployment.base, value.literal/value.ref, with reference and uniqueness checks in pack validators), and railway (registers deployment.railway, vocabulary only). Each ships a vocabulary pin, conformance fixtures (including a genericized Railway worked example), and a README. The systems pack also ships refs.test.ts.
  • Adds an additive core export in @metaobjectsdev/metadata: applyProviderDefinition and its definition types, an optional ValidatorMap fourth argument, the NodeValidator/ValidationContext types, and referrerPackageFor. No vocabulary, expected-registry.json, metamodelVersion or core version change.
  • railway is vocabulary only by decision: the delivery pack's deployment.base is abstract and a platform pack registers the concrete subtype, so without deployment.railway no deployment (and not the worked example) could load. Lane A3 adds the Railway emitter on top of it.
  • Renames the design report's value.ref @from to @producedBy (with @output kept). Core's loader treats any attribute named from as an object reference (REF_BEARING_ATTR_NAMES) and would bind and rewrite the value as one, so the pack uses its own name rather than asking core for an opt-out. The literal value attribute is @literal because value is a reserved structural key.
  • References to nested nodes use the ADR-0059 dotted form, System.child / pkg::System.child (the report sketched a bare @app: game), and are resolved by kind in the packs' own validators.
  • Ports: TypeScript only. In every other port a model that uses this vocabulary fails by name (ADR-0069's port rule).
  • scripts/pack-conformance.ts accepts error codes from every pack a pack requires. Changelog fragments and docs/features/extending-with-providers.md describe the new export and the packs.
Validation

Risk Assessment

✅ Low: The change is additive, confined to the new packs plus an additive core export, and the round-2 fixes check out under independent tracing; the fixture, doc and manifest files I did not read are listed as unreviewed.

Testing

Baseline scripts/ci-local.sh --affected --strict-toolchains passed at the target commit and was not re-run; no source or test files changed here, so no re-run was needed. I drove three scenarios live. A disposable driver in scratch loaded synthetic user models through the real MetaDataLoader with core plus the systems, delivery and railway providers composed. Scenario 1: the acme::game worked example with the acme::estate overlay loads clean, @app resolves to Game.server, and the overlay merges @replicas to 2. Scenario 2: kind-aware binding. A mixed valid model and a dotted Shop.worker reference (resource and app share the name) both load. A wrong-kind-only bare name is rejected with ERR_SYSTEMS_UNRESOLVED_REF naming resource.cache, which is the round-2 review fix. Scenario 3, adversarial: an entity sharing the system's name does not shadow Game.server; Game.missing fails with ERR_DELIVERY_UNRESOLVED_REF; a duplicate (@app, @Environment) deployment fails with ERR_DELIVERY_DUPLICATE_DEPLOYMENT. The pack conformance runner also passed (systems 4, delivery 5, railway 7), and the focused refs.test.ts passed 11 of 11. Evidence transcript: packs-a2-live-transcript.txt. Scratch driver removed; worktree clean. Overall: all three scenarios pass live.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Worked Railway example (acme::game app-on-Railway plus acme::estate overlay) loads clean through the real loader; deployment @app resolves to Game.server; overlay merges @replicas to 2 (synthetic inpu… ✅ pass live packs-a2-live-transcript.txt (S1 section)
Kind-aware reference binding: valid mixed-kind bare name loads; wrong-kind-only bare name is rejected with a clear ERR_SYSTEMS_UNRESOLVED_REF; dotted Shop.worker resolves to the app when a resource sh… ✅ pass live packs-a2-live-transcript.txt (S2 section)
Adversarial deployment references: an entity sharing the system name does not shadow Game.server; Game.missing and a duplicate (@app, @Environment) deployment are rejected with their pack error codes… ✅ pass live packs-a2-live-transcript.txt (S3 section)
Evidence: Live driver transcript for the three scenarios and pack conformance runs
# S1 worked example (acme::game app-on-Railway + acme::estate overlay) through real loader
LOAD OK
deployment railway server-production app=Game.server replicas=2 env=production
  top: system.internal Game
  top: environment.standing production
  top: deployment.railway server-production
  top: environment.standing staging
  top: deployment.railway server-staging
# S2 kind-aware bare-name binding
== mixed-ok
LOAD OK
== wrongkind-only
LOAD FAILED
  ERR_SYSTEMS_UNRESOLVED_REF: app.service "api" @calls "Mail" resolves to resource.cache, not an app or a system.external.
== dotted-ok
LOAD OK
# S3 deployment refs adversarial
== entity-shadow
  warn: {"code":"WARN_LEGACY","message":"entity object 'Game' has no primary identity (add an identity child or mark @isAbstract: true)","source":{"format":"code","caller":"MetaDataLoader"}}
LOAD OK
== entity-shadow-missing
  warn: {"code":"WARN_LEGACY","message":"entity object 'Game' has no primary identity (add an identity child or mark @isAbstract: true)","source":{"format":"code","caller":"MetaDataLoader"}}
LOAD FAILED
  ERR_DELIVERY_UNRESOLVED_REF: deployment.railway "server-production" @app "Game.missing" does not resolve to an app.
== dup-deploy
LOAD FAILED
  ERR_DELIVERY_DUPLICATE_DEPLOYMENT: deployment.railway "b" deploys the same app in the same environment as "a": a model has at most one deployment per (@app, @environment).
# pack conformance
pack systems: conformance 4 pass
pack delivery: conformance 5 pass
pack railway: conformance 7 pass

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 5 issues found → auto-fixed (2) ✅
  • ⚠️ packs/systems/typescript/src/refs.ts:53 - FINDING CATEGORY NOTE: this is an ordinary source finding, not an intent contradiction (omit category). resolveSystemRef binds references by name without constraining kind. (a) The dotted form's owner is bound with resolveRef(root, ref, pkg) and no ownerType; core's bindOwner returns the FIRST top-level node of ANY type with that resolution key (server/typescript/packages/metadata/src/naming-refs.ts:213-220, first match in child order). Sequence: one collection holds entities and the systems model (the default metaobjects/ layout for a TypeScript-only project); package acme::game declares object.entity Game (in a file loaded first) and system.internal Game with resource.database db; a deployment.railway with @app: "Game.server" binds the entity, finds no child server, and fails ERR_DELIVERY_UNRESOLVED_REF ... does not resolve to a app. Declare the system first and the identical model loads. (b) The bare-name fallback takes the same untyped lookup (refs.ts:51 to 53): @calls: ["Mail"] binds a same-named top-level object declared before the system.external. (c) For the dotted form the last segment is children().find(name), first match of any kind (naming-refs.ts:279-281; no lastType is passed): with resource.queue worker declared before app.job worker in Shop, @calls: ["Shop.worker"] resolves to the queue and fails, while the bare worker inside Shop is kind-aware (refs.ts:50; refs.test.ts 'given the kinds wanted, a bare name prefers the sibling of that kind'). Core's reference-attribute resolver is type-keyed for exactly this reason (loader/validation-registry.ts:22-25). Reachable through every checkRefs caller: packs/systems/typescript/src/index.ts:38-39 (@needs, @calls), packs/delivery/typescript/src/index.ts:38-39 and :77 (@app, @environment, @from).
  • ⚠️ packs/delivery/metamodel/delivery.json:106 - value.ref @from reuses an attribute name in core's REF_BEARING_ATTR_NAMES (metadata/src/naming-refs.ts:57-78 excludes only transition.*), so the core pass resolveReferences (metadata/src/loader/resolve-references.ts:137) treats it as an OBJECT reference. Sequence: package acme::game holds system.internal Game (with resource.database db), an object.entity Game, and a deployment whose value.ref has @from: "Game.db". The pack validator passes (resource). resolveAttr then binds the owner as an object, i.e. the entity, sets attr.resolvedTarget to that entity (what refTarget() returns) and rewrites @from to "acme::game::Game.db". The model loads with a wrong recorded target and a canonical value that differs from the authored one only because an unrelated entity shares the system's name; meta fmt and the canonical serializer then emit the rewritten spelling. Checked by packs/delivery/typescript/src/index.ts:77. The defect is in the pack's new vocabulary, the remedy is not: core keys on attribute name plus node type and gives a pack no opt-out, so it needs authorization rather than a fix. Options: exclude a node whose registered type declares no reference descriptor for the attribute (needs the registry in resolveReferences), add a per-type opt-out, or accept and document. Renaming is not open: the intent fixes @from.
  • ℹ️ packs/systems/typescript/src/refs.ts:87 - checkRefs derives its miss hint from the reference's shape alone (refs.ts:86-88), so a bare @environment: "prod" that misses reports A node inside a system is named System.prod. Environments are top-level nodes; the real fix is a typo or pkg::name. The same template yields does not resolve to a app / a environment and not a app or system.external (refs.ts:88, 90). Suggest emitting the hint only when the wanted kinds include app or resource (or letting the caller pass it) and choosing the article from the first kind.
  • ℹ️ packs/delivery/typescript/src/index.ts:76 - Value bindings and deployments carry no uniqueness check, so an ambiguous model loads clean. (1) Two value.* children of one deployment with the same @setting: the app's model declares value.literal profile, an estate overlay adds a value.ref under another name with @setting: Spring.profile; children accumulate, validateValue (index.ts:76) checks only @from. (2) Two deployment.railway for the same @app and @environment, though packs/railway/metamodel/railway.json:9 names that pair as the unit; validateDeployment (index.ts:37) checks only that each reference resolves. A later generator would have to pick by child order, which depends on load order across files. Decide whether this slice states these invariants (a pack validator like validateBuild) or leaves them to the emitter lane; adding either is new behavior, so this is a question, not a fix.
  • ℹ️ packs/README.md:11 - changelog.d/independent-packs-skeleton.md:3, folded into the same unreleased release, still says No pack exists yet, and nothing published changes. With this change three packs exist (packs/README.md:9-11). Reword that sentence to point at packs/README.md. ADR-0069 line 40 (none exists yet) is a dated record; leave it unless the ADR is amended.

🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:

  • ⚠️ packs/systems/typescript/src/refs.ts:53 - FINDING CATEGORY NOTE: this is an ordinary source finding, not an intent contradiction (omit category). resolveSystemRef binds references by name without constraining kind. (a) The dotted form's owner is bound with resolveRef(root, ref, pkg) and no ownerType; core's bindOwner returns the FIRST top-level node of ANY type with that resolution key (server/typescript/packages/metadata/src/naming-refs.ts:213-220, first match in child order). Sequence: one collection holds entities and the systems model (the default metaobjects/ layout for a TypeScript-only project); package acme::game declares object.entity Game (in a file loaded first) and system.internal Game with resource.database db; a deployment.railway with @app: "Game.server" binds the entity, finds no child server, and fails ERR_DELIVERY_UNRESOLVED_REF ... does not resolve to a app. Declare the system first and the identical model loads. (b) The bare-name fallback takes the same untyped lookup (refs.ts:51 to 53): @calls: ["Mail"] binds a same-named top-level object declared before the system.external. (c) For the dotted form the last segment is children().find(name), first match of any kind (naming-refs.ts:279-281; no lastType is passed): with resource.queue worker declared before app.job worker in Shop, @calls: ["Shop.worker"] resolves to the queue and fails, while the bare worker inside Shop is kind-aware (refs.ts:50; refs.test.ts 'given the kinds wanted, a bare name prefers the sibling of that kind'). Core's reference-attribute resolver is type-keyed for exactly this reason (loader/validation-registry.ts:22-25). Reachable through every checkRefs caller: packs/systems/typescript/src/index.ts:38-39 (@needs, @calls), packs/delivery/typescript/src/index.ts:38-39 and :77 (@app, @environment, @from).
  • ℹ️ packs/systems/typescript/src/refs.ts:87 - checkRefs derives its miss hint from the reference's shape alone (refs.ts:86-88), so a bare @environment: "prod" that misses reports A node inside a system is named System.prod. Environments are top-level nodes; the real fix is a typo or pkg::name. The same template yields does not resolve to a app / a environment and not a app or system.external (refs.ts:88, 90). Suggest emitting the hint only when the wanted kinds include app or resource (or letting the caller pass it) and choosing the article from the first kind.
  • ⚠️ packs/systems/typescript/src/refs.ts:51 - A wrong-kind sibling shadows a right-kind top-level node for bare names. In resolveSystemRef the sibling lookup does (kinds ? named.find(isKind) : undefined) ?? named[0] and returns named[0] even when kinds is given and no sibling has the wanted kind. Concrete case: system Shop holds resource.cache named Mail and app.service api with @calls: ["Mail"], and a top-level system.external named Mail exists in the same package. The bare ref returns the resource, never reaches the top-level fallback, and checkRefs reports 'resolves to resource.cache, not an app or a system.external'. A valid model fails to load. The user intent says a bare name means 'a sibling in the referrer's own system (of the wanted kind), then a top-level node'. The same wrong-kind-first shadowing is what the prior round (resolver-untyped-binding) fixed for the dotted and top-level paths. This sibling path was left behind. Fix: when kinds is given, return a sibling only if it is of a wanted kind. Otherwise continue to the top-level lookup, and keep named[0] only as the last-resort return so the caller can name the wrong kind. Add a refs.test.ts case for it.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Worked Railway example (acme::game app-on-Railway plus acme::estate overlay) loads clean through the real loader; deployment @app resolves to Game.server; overlay merges @replicas to 2 (synthetic inpu… ✅ pass live packs-a2-live-transcript.txt (S1 section)
Kind-aware reference binding: valid mixed-kind bare name loads; wrong-kind-only bare name is rejected with a clear ERR_SYSTEMS_UNRESOLVED_REF; dotted Shop.worker resolves to the app when a resource sh… ✅ pass live packs-a2-live-transcript.txt (S2 section)
Adversarial deployment references: an entity sharing the system name does not shadow Game.server; Game.missing and a duplicate (@app, @Environment) deployment are rejected with their pack error codes… ✅ pass live packs-a2-live-transcript.txt (S3 section)
  • scripts/ci-local.sh --affected --strict-toolchains
  • scripts/ci-local.sh --affected --strict-toolchains (baseline, passed at target commit; not re-run)
  • bun scripts/pack-conformance.ts systems|delivery|railway (4, 5, 7 scenarios pass)
  • scratch driver (outside worktree) loading packs/railway/fixtures/conformance/railway-worked-example/input with systems/delivery/railway providers: LOAD OK, deployment app=Game.server, replicas=2
  • scratch driver: mixed-kind bare ref model LOAD OK
  • scratch driver: wrong-kind-only bare ref LOAD FAILED with ERR_SYSTEMS_UNRESOLVED_REF
  • scratch driver: dotted Shop.worker with resource and app sharing name LOAD OK
  • scratch driver: entity-shadowed Game.server LOAD OK
  • scratch driver: Game.missing LOAD FAILED with ERR_DELIVERY_UNRESOLVED_REF
  • scratch driver: duplicate deployment LOAD FAILED with ERR_DELIVERY_DUPLICATE_DEPLOYMENT
  • bun test test/refs.test.ts in packs/systems/typescript (11 pass, 0 fail)
⚠️ **Document** - 3 infos
  • ℹ️ README.md:327 - Doc-only: README.md packs tree said "none shipped yet" (stale). Fixed to point at packs/README.md. This was the only stale fact found.
  • ℹ️ packs/delivery/metamodel/delivery.json:106 - Intent text says value.ref uses @from, but the recorded round-2 decision renamed it to @producedBy. Code (delivery.json, constants.ts), packs/delivery/README.md and CHANGELOG follow @producedBy, so docs are consistent. The PR body must state the rename from @from to @producedBy, and the rename should be confirmed as intended.
  • ℹ️ spec/decisions/ADR-0069-independent-packs.md:40 - spec/decisions/ADR-0069-independent-packs.md:40 says "none exists yet". It is a dated ADR record, so it is left unchanged per the placement policy. An ADR amendment would be needed to change it.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…ailway (ADR-0069)

Three independent packs, TypeScript port only, each 0.1.0 preview and
unpublished:

- systems: system.internal / system.external, app.service / app.client /
  app.job, resource.database / cache / bucket / keyvalue / queue / volume.
  An app's @needs and @Calls resolve at load (ERR_SYSTEMS_UNRESOLVED_REF),
  addressed as System.child or pkg::System.child; @settings and @shell are
  names only.
- delivery (requires systems): environment.standing / ephemeral / local,
  build.dockerfile / command / static (one per app), runtime.process, the
  abstract deployment.base a platform pack specialises, value.literal and
  value.ref. A deployment's @app / @Environment and a value.ref's @from
  resolve at load (ERR_DELIVERY_UNRESOLVED_REF); @Secrets and @setting are
  names only, since the config pack is not required.
- railway (requires delivery): deployment.railway, vocabulary only, so the
  worked Railway example can load. Its fixture holds the app side and an
  estate repository's added deployment and overlay, with placeholder names.

Core: applyProviderDefinition and its definition types are exported from
@metaobjectsdev/metadata, with an optional validator map, so a pack registers
its JSON vocabulary the way the bundled packs do. pack-conformance accepts
the error codes of the packs a pack requires. No vocabulary,
expected-registry.json, metamodelVersion or core version change.
…olve in the declaring package

checkRefs takes the ValidationContext instead of a bound error callback, and
resolves through referrerPackageFor (now exported from core, ADR-0059 R3), so an
inherited reference means what it meant where it was written. pack-conformance
throws on a required pack with no directory instead of falling back.
, a hint for a bare name that misses

- A bare reference prefers the sibling of the wanted kind when an app and a
  resource of the system share the name.
- An app's build bound counts its effective builds, so one declared beside an
  inherited build is a second build.
- value.ref @output is the closed set its description lists.
- An unresolved bare name says a node inside a system is named System.child
  (a deployment sits in no system, so its @from always is).

New fixtures: delivery error-build-beside-inherited, railway
error-value-ref-bare-from-and-bad-output; a unit test for the same-name case.
@dmealing
dmealing merged commit ff89719 into main Nov 25, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-pack-a2-systems-delivery branch November 25, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant