Skip to content

feat(metadata): reference facet targetType list in every port - #710

Merged
dmealing merged 4 commits into
mainfrom
fm/mo-140-ref-facet-typelist
Dec 3, 2026
Merged

dmealing merged 4 commits into
mainfrom
fm/mo-140-ref-facet-typelist

Conversation

@dmealing

@dmealing dmealing commented Dec 3, 2026

Copy link
Copy Markdown
Member

What Changed

  • The reference facet's targetType accepts a list of two or more distinct types in every port (TypeScript, C#, Java/Kotlin, Python, Rust), and referenceTargetTypes(facet) returns it as a list. A single type stays a plain string. The registry manifests write the list sorted.
  • The resolver returns an ambiguous match when nodes of two listed types share the name at the step that finds the target. That raises the facet's errorCode, otherwise ERR_REF_UNRESOLVED. A value naming another kind of node still raises ERR_REF_WRONG_KIND. spec/metamodel-definitions.md and the definition schema describe the list.
  • role.token @heldBy widens from organization to [organization, system], so a token held by a system now loads. New conformance fixtures ref-target-type-list-heldby, error-ref-wrong-kind-heldby and error-ref-ambiguous-heldby pin these cases, and the registry-conformance, metamodel-docs and role reference outputs are regenerated.
Validation

Risk Assessment

✅ Low: The type-list facet is implemented the same way in all six ports. Single-type lookup behaves as before, apart from the article in the wrong-kind message ("a organization" now reads "an organization"). New conformance fixtures and the registry manifest pin the cross-port contract, and the only gap found is one weak, misnamed test in TypeScript and Python.

Testing

Derived three scenarios: a valid org+system @heldBy load, a wrong-kind rejection, and an unresolved-target rejection. All three ran live through the real TS meta CLI against disposable projects under /mnt/scratch, and they behaved as the intent requires. Focused TS reference-facet tests also pass (35/35). The configured affected suite passed at baseline. Python, Rust, Java, Kotlin and C# ports were not driven live in this turn, so their parity relies on the baseline lanes and the committed conformance fixtures. Scratch projects removed; worktree clean.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Valid @heldBy names an organization.company and a system.software (TS meta verify, synthetic project) ✅ pass live meta verify in disposable /mnt/scratch project 'ok': loads, exit 0
@heldBy names a resource.rdb: rejected as ERR_REF_WRONG_KIND (TS meta verify, synthetic project) ✅ pass live meta verify in disposable 'bad' project: ERR_REF_WRONG_KIND, exit 1
@heldBy names no node: rejected as ERR_REF_UNRESOLVED (TS meta verify, synthetic project) ✅ pass live meta verify with unknown FQN: ERR_REF_UNRESOLVED, exit 1
  • Outcome: ⚠️ 1 info across 1 run (8m26s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ server/typescript/packages/metadata/test/reference-facet.test.ts:442 - The TypeScript test targetSubTypes narrows whichever listed type the value resolves to (and its Python twin test_target_sub_types_narrows_whichever_listed_type_the_value_resolves_to, server/python/tests/unit/test_reference_facet.py:784) uses the uses attr, whose facet is { targetType: ["role", "resource"] } with no targetSubTypes. It only checks that a role and two resources load clean, so it never exercises subtype narrowing under a type list, despite its name. Java's targetSubTypesNarrowsWhicheverListedTypeWasFound does it properly: it expects holder: Jobs (a resource.mq against subtypes web/pg) to raise ERR_REF_WRONG_KIND. Point the TypeScript and Python tests at holder (types system/app, subtypes software/service) and assert that a listed type with an unlisted subtype, such as an app.client or a system with another subtype, raises ERR_REF_WRONG_KIND. The oracle is spec/metamodel-definitions.md step 2. A wrong implementation that skips the subtype check when targetType is a list passes both tests as written.
⚠️ **Test** - 1 info
  • ℹ️ Ambiguous short-name case (org and system sharing one bare name, which the types description says is ERR_REF_UNRESOLVED) was not driven live; my attempt used FQNs in separate packages, which does not exercise it. Covered only by the TS unit suite.
  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Valid @heldBy names an organization.company and a system.software (TS meta verify, synthetic project) ✅ pass live meta verify in disposable /mnt/scratch project 'ok': loads, exit 0
@heldBy names a resource.rdb: rejected as ERR_REF_WRONG_KIND (TS meta verify, synthetic project) ✅ pass live meta verify in disposable 'bad' project: ERR_REF_WRONG_KIND, exit 1
@heldBy names no node: rejected as ERR_REF_UNRESOLVED (TS meta verify, synthetic project) ✅ pass live meta verify with unknown FQN: ERR_REF_UNRESOLVED, exit 1
  • scripts/ci-local.sh --affected --strict-toolchains
  • cd server/typescript && bun test packages/metadata/test/reference-facet.test.ts (35 pass, 0 fail)
  • bun server/typescript/packages/cli/bin/meta.ts verify in disposable project /mnt/scratch/mo140-*/ok: role.token @heldBy acme::common::Tidewell (organization.company) and acme::feeds::Feeds (system.software) loads, exit 0
  • bun ...meta.ts verify in disposable project bad: @heldBy "db" naming resource.rdb -> ERR_REF_WRONG_KIND, exit 1
  • bun ...meta.ts verify in ok project: @heldBy to unknown target -> ERR_REF_UNRESOLVED, exit 1
  • bun ...meta.ts types role.token --format json: heldBy description documents org-or-system target and error codes
  • Baseline: scripts/ci-local.sh --affected --strict-toolchains passed at target commit (not re-run; no source changed in this turn)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…le.token @heldBy names an organization or a system

TypeScript reader, resolver, manifest and tests; spec text and definition schema;
three shared conformance fixtures; registry and metamodel-docs corpora regenerated.
…ython and Rust; docs and counts

Every port's spec reader, typed lookup (ambiguity across listed types -> ERR_REF_UNRESOLVED),
wrong-kind message and registry manifest (sorted list) match the TypeScript reference.
ERROR-CODES descriptions, conformance counts 596 -> 599, Rust minPassing, site payload,
the V1 changelog note on @heldBy, and one new changelog fragment.
@dmealing
dmealing merged commit 36f3026 into main Dec 3, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-140-ref-facet-typelist branch December 3, 2026 21:46
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