Repository navigation
feat(packs): add systems, delivery and railway vocabulary packs - #649
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
packs/(each0.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), andrailway(registersdeployment.railway, vocabulary only). Each ships a vocabulary pin, conformance fixtures (including a genericized Railway worked example), and a README. Thesystemspack also shipsrefs.test.ts.@metaobjectsdev/metadata:applyProviderDefinitionand its definition types, an optionalValidatorMapfourth argument, theNodeValidator/ValidationContexttypes, andreferrerPackageFor. No vocabulary,expected-registry.json,metamodelVersionor core version change.railwayis vocabulary only by decision: the delivery pack'sdeployment.baseis abstract and a platform pack registers the concrete subtype, so withoutdeployment.railwayno deployment (and not the worked example) could load. Lane A3 adds the Railway emitter on top of it.value.ref @fromto@producedBy(with@outputkept). Core's loader treats any attribute namedfromas 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@literalbecausevalueis a reserved structural key.System.child/pkg::System.child(the report sketched a bare@app: game), and are resolved by kind in the packs' own validators.scripts/pack-conformance.tsaccepts error codes from every pack a pack requires. Changelog fragments anddocs/features/extending-with-providers.mddescribe 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-toolchainspassed 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,@appresolves to Game.server, and the overlay merges@replicasto 2. Scenario 2: kind-aware binding. A mixed valid model and a dottedShop.workerreference (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 shadowGame.server;Game.missingfails 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.Evidence: Live driver transcript for the three scenarios and pack conformance runs
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).resolveSystemRefbinds references by name without constraining kind. (a) The dotted form's owner is bound withresolveRef(root, ref, pkg)and noownerType; core'sbindOwnerreturns 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 defaultmetaobjects/layout for a TypeScript-only project); packageacme::gamedeclaresobject.entity Game(in a file loaded first) andsystem.internal Gamewithresource.database db; adeployment.railwaywith@app: "Game.server"binds the entity, finds no childserver, and failsERR_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-levelobjectdeclared before thesystem.external. (c) For the dotted form the last segment ischildren().find(name), first match of any kind (naming-refs.ts:279-281; nolastTypeis passed): withresource.queue workerdeclared beforeapp.job workerinShop,@calls: ["Shop.worker"]resolves to the queue and fails, while the bareworkerinsideShopis 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 everycheckRefscaller: 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 @fromreuses an attribute name in core'sREF_BEARING_ATTR_NAMES(metadata/src/naming-refs.ts:57-78 excludes onlytransition.*), so the core passresolveReferences(metadata/src/loader/resolve-references.ts:137) treats it as an OBJECT reference. Sequence: packageacme::gameholdssystem.internal Game(withresource.database db), anobject.entity Game, and a deployment whosevalue.refhas@from: "Game.db". The pack validator passes (resource).resolveAttrthen binds the owner as an object, i.e. the entity, setsattr.resolvedTargetto that entity (whatrefTarget()returns) and rewrites@fromto"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 fmtand 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 inresolveReferences), 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-checkRefsderives its miss hint from the reference's shape alone (refs.ts:86-88), so a bare@environment: "prod"that misses reportsA node inside a system is named System.prod.Environments are top-level nodes; the real fix is a typo orpkg::name. The same template yieldsdoes not resolve to a app/a environmentandnot 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) Twovalue.*children of one deployment with the same@setting: the app's model declaresvalue.literal profile, an estate overlay adds avalue.refunder another name with@setting: Spring.profile; children accumulate,validateValue(index.ts:76) checks only@from. (2) Twodeployment.railwayfor the same@appand@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 likevalidateBuild) 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 saysNo 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).resolveSystemRefbinds references by name without constraining kind. (a) The dotted form's owner is bound withresolveRef(root, ref, pkg)and noownerType; core'sbindOwnerreturns 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 defaultmetaobjects/layout for a TypeScript-only project); packageacme::gamedeclaresobject.entity Game(in a file loaded first) andsystem.internal Gamewithresource.database db; adeployment.railwaywith@app: "Game.server"binds the entity, finds no childserver, and failsERR_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-levelobjectdeclared before thesystem.external. (c) For the dotted form the last segment ischildren().find(name), first match of any kind (naming-refs.ts:279-281; nolastTypeis passed): withresource.queue workerdeclared beforeapp.job workerinShop,@calls: ["Shop.worker"]resolves to the queue and fails, while the bareworkerinsideShopis 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 everycheckRefscaller: 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-checkRefsderives its miss hint from the reference's shape alone (refs.ts:86-88), so a bare@environment: "prod"that misses reportsA node inside a system is named System.prod.Environments are top-level nodes; the real fix is a typo orpkg::name. The same template yieldsdoes not resolve to a app/a environmentandnot 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 returnsnamed[0]even whenkindsis given and no sibling has the wanted kind. Concrete case: system Shop holdsresource.cachenamedMailandapp.serviceapiwith@calls: ["Mail"], and a top-levelsystem.externalnamedMailexists 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: whenkindsis given, return a sibling only if it is of a wanted kind. Otherwise continue to the top-level lookup, and keepnamed[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.
scripts/ci-local.sh --affected --strict-toolchainsscripts/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=2scratch driver: mixed-kind bare ref model LOAD OKscratch driver: wrong-kind-only bare ref LOAD FAILED with ERR_SYSTEMS_UNRESOLVED_REFscratch driver: dotted Shop.worker with resource and app sharing name LOAD OKscratch driver: entity-shadowed Game.server LOAD OKscratch driver: Game.missing LOAD FAILED with ERR_DELIVERY_UNRESOLVED_REFscratch driver: duplicate deployment LOAD FAILED with ERR_DELIVERY_DUPLICATE_DEPLOYMENTbun test test/refs.test.ts in packs/systems/typescript (11 pass, 0 fail)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@fromto@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.