Two or more projects — often in separate repositories, sometimes in separate
languages — need to share part of one metadata model: a common Customer/Address
shape, an audited-base entity, a set of enums. Copy-pasting the metadata is a fork the
moment either side edits it. dependencies in .metaobjects/config.json is the
alternative: declare a published metadata package as a dependency, meta deps sync
it into a committed snapshot, and build on it the same way you build on any other
metadata in your own tree — extends, overlay: true, and plain FQN references.
What ships today: the path, npm, python, maven and nuget transports, the
generated shared-model artifact, the lock + snapshot, default exclusion from your own
codegen/schema/ledger, and the loader errors that fire when upstream moves. See
Deferred for what is designed but not built yet — read that section
before assuming a capability exists.
metadata-sources.md already lets a sources entry point at
metadata living anywhere, including a directory copied from another project (its
"Vendoring" section).
That is enough when you just need the files. Reach for dependencies instead when
you also want:
- A recorded version and a content hash, not just "whatever is in that directory
today" —
meta deps check/verify --depstell you the moment the publisher's metadata moved out from under the hash you last accepted. - A publisher that controls what it exports.
sourcesvendoring copies whatever directory you point it at, internal shapes included. A dependency's artifact is generated by the publisher's ownsharedModelFile()(below) — the publisher decides the public surface, and it is drift-gated by the publisher's ownverify --codegen. - A refusal instead of a silent drop when your own metadata declares a brand-new
node into the publisher's package (
ERR_DEPENDENCY_PACKAGE_NOT_OWNED, below) — plain vendoring has no such concept, because it has no notion of "whose package this is."
If you just need one directory of metadata read by two build tools in a monorepo with
no separate publish/version step, plain sources vendoring is simpler and is not
going away.
A dependency spec carries a name (/^[a-z0-9][a-z0-9._-]*$/, unique across the
array — this is the LOCAL alias your config, lock, and .metaobjects/deps/<name>/
snapshot directory key on) and exactly one transport key.
Five transports locate the publisher's metaobjects.pkg.json + artifact (below).
Each answers one question, which directory holds the manifest?, and only meta deps sync and meta deps check ask it. Every other command loads the committed snapshot.
| Transport | Spec | Where it looks |
|---|---|---|
path |
{ "name": "x", "path": "../lib/metaobjects" } |
that directory, relative to the directory holding .metaobjects/: a sibling checkout, a git submodule, or any directory your build can reach |
npm |
{ "name": "x", "npm": "@acme/model", "dir": "metaobjects" } |
the installed npm package, found from the directory holding .metaobjects/ the way Node resolves it (node_modules up the tree, workspaces and hoisting included), then dir inside it |
python |
{ "name": "x", "python": "acme_model", "dir": "metaobjects" } |
the installed Python package, as importlib.util.find_spec("acme_model") reports it in your project's interpreter, then dir inside it |
maven |
{ "name": "x", "maven": "com.acme:acme-model", "version": "1.0.0" } |
that artifact's jar in your local Maven repository (~/.m2/repository, or the location below), then the jar's metaobjects/ resources (dir changes the directory) |
nuget |
{ "name": "x", "nuget": "Acme.Model", "version": "1.0.0" } |
that package in the NuGet global packages folder ($NUGET_PACKAGES, else ~/.nuget/packages), then its metaobjects/ content (dir changes the directory) |
dir is optional, must stay inside the package, and is legal beside every transport
but path. For npm and python its default is the package root; for maven and
nuget it is metaobjects. maven and nuget also require version: a local Maven
repository and the NuGet cache hold many versions side by side, so the declaration, not a
lock file elsewhere, says which one to read. maven is groupId:artifactId (the version
goes in version, not in the coordinate). python takes an importable package name (dotted
names such as acme.model work), not the distribution name you pip install. The npm
transport reads a node_modules tree; a Yarn Plug'n'Play install has none, so set
nodeLinker: node-modules for that project.
Install the package first, with your own package manager. meta deps sync does no
downloading. npm install @acme/model (or pnpm, yarn, bun) or pip install acme-model
(or uv, poetry) puts the package where the transport finds it, and the ecosystem's own
lock (package-lock.json, uv.lock, …) pins which version is installed. The
dependency lock records what that version's shared model was when you last synced.
Because the snapshot is committed, only the machine that runs sync needs the package
installed. CI, meta gen, meta migrate and every other port load the snapshot.
What a Java or .NET publisher packs (a Python publisher: see "A Python package" below). The shared-model generator writes
metaobjects.pkg.json and <name>.metaobjects.json into its output directory; the build
that packages your library puts that directory at metaobjects/ in the package. In Maven
that is a resource with a target path (<resource><directory>shared</directory> <targetPath>metaobjects</targetPath></resource>); in a .NET project it is a packed file
(<None Include="shared/**" Pack="true" PackagePath="metaobjects/" />). sync reads the
pair out of the jar (a ZIP, unpacked to a temporary directory) or out of the package
folder the NuGet cache extracted (falling back to the .nupkg when only the archive is
there), and writes the same snapshot and lock entry a path sync writes. The lock records
{"maven": "...", "version": "..."} or {"nuget": "...", "version": "..."}.
Where the local Maven repository is. The first of: $MAVEN_REPO_LOCAL;
-Dmaven.repo.local=<dir> in $MAVEN_ARGS or $MAVEN_OPTS; <localRepository> in
~/.m2/settings.xml (${user.home} and ${env.X} expanded); ~/.m2/repository. The
error names which one it used. nuget reads $NUGET_PACKAGES, else ~/.nuget/packages;
a globalPackagesFolder set only in NuGet.Config is not read, so export
$NUGET_PACKAGES for it.
Neither downloads anything. A package that is not in the local cache is
ERR_DEPENDENCY_UNRESOLVED, naming the artifact and the command that fetches it:
dependency "acme-billing": the Maven artifact com.acme:billing-model:1.4.0 is not in the local
repository <home>/.m2/repository (the default ~/.m2/repository); expected
<home>/.m2/repository/com/acme/billing-model/1.4.0/billing-model-1.4.0.jar. Fetch it with
`mvn dependency:get -Dartifact=com.acme:billing-model:1.4.0` (add -DremoteRepositories=<url>
for a repository other than Central), then re-run. meta deps sync does not download.
dependency "acme-billing": the NuGet package Acme.Billing.Model 1.4.0 is not in the global
packages folder <home>/.nuget/packages (the default ~/.nuget/packages); expected
<home>/.nuget/packages/acme.billing.model/1.4.0. Fetch it with `dotnet restore` in a
project that references Acme.Billing.Model 1.4.0 (or `dotnet add package Acme.Billing.Model
--version 1.4.0`), then re-run. meta deps sync does not download.
A jar or package that is in the cache but ships no metaobjects/ directory is also
ERR_DEPENDENCY_UNRESOLVED (check dir, or ask the publisher to pack the output); one
whose directory holds no metaobjects.pkg.json is ERR_DEPENDENCY_MANIFEST_INVALID. When
the version you declared differs from the version the manifest records, sync warns, as it
does for npm and python.
Which Python interpreter. python runs one interpreter, the first of:
$METAOBJECTS_PYTHON; the active virtualenv ($VIRTUAL_ENV); a .venv beside
.metaobjects/; python3 on PATH (python on Windows). A set $METAOBJECTS_PYTHON or $VIRTUAL_ENV
whose interpreter is missing is refused rather than skipped, because falling through
would read a different environment. sync prints the interpreter it used:
$ meta deps sync
synced acme-scheduling (new)→0.4.0 ((new)→1c9e44d0) — python: /srv/app/.venv/bin/python (from .venv)
The interpreter path never reaches the lock. find_spec imports the parent packages of
a dotted name, so this runs your own environment's code, as import would.
When a transport cannot find the package, sync and check fail with
ERR_DEPENDENCY_UNRESOLVED, naming what was tried and the fix:
dependency "acme-billing": the npm package "@acme/billing-model" is not installed where
/srv/app can resolve it. Install it (`npm install @acme/billing-model`, or your package
manager's equivalent), then re-run.
dependency "acme-scheduling": the Python package "acme_scheduling" is not installed in
/usr/bin/python3 (from PATH). Install the distribution that provides it into that
environment (for example `pip install acme-scheduling`), or point $METAOBJECTS_PYTHON at
the interpreter that has it.
dependency "acme-scheduling": no Python interpreter at /opt/py/bin/python (from
$METAOBJECTS_PYTHON). Install Python, activate the project's virtualenv, or point
$METAOBJECTS_PYTHON at the interpreter that has "acme_scheduling" installed.
If importing a dotted name's parent package raises, sync reports that error and asks
you to fix the environment; the package is not missing.
The package is installed but dir names a directory it does not ship: also
ERR_DEPENDENCY_UNRESOLVED, telling you to check dir or ask the publisher to ship the
output. The directory exists but holds no metaobjects.pkg.json:
ERR_DEPENDENCY_MANIFEST_INVALID, with the same fix.
The installed version should match the manifest. The publisher's generator stamps
the host package's version into the manifest. When the installed package's own version
(package.json, or the Python distribution's metadata) differs, sync warns (Python
versions compare in PEP 440 normalized form, so 1.0.0-rc.1 equals 1.0.0rc1): the
publisher most likely released without regenerating the shared model. The lock records
the manifest's version.
dependencies is read at every rung of the source ladder —
wherever your own sources come from (the default metaobjects/ directory, a declared
sources list, or a port's native surface), the neutral config's dependencies array
is read the same way on top of it.
meta deps sync [<name>…] [--dry-run] resolves each declared dependency through its
transport, reads its metaobjects.pkg.json, verifies the sibling artifact's bytes hash to what
the manifest records, and re-loads the artifact standalone with core providers
only (a consumer loads it with its own providers, never the publisher's, so a
Phase 1a export needing publisher-only vocabulary must fail at publish time, not
here). It then writes the committed snapshot
(.metaobjects/deps/<name>/<name>.metaobjects.json) and the lock
(.metaobjects/deps.lock.json), and finally loads the whole updated collection once
— so a sync that produces an unloadable model fails in sync itself, with the
loader's own error, rather than surfacing on the next unrelated meta gen. A failed
sync is atomic: it restores the previous lock and snapshot, prints the rollback and
the load error, and exits 1. The per-dependency synced / unchanged / pruned
lines print only after the load succeeds. Narrow to one or more names as positionals;
--dry-run reports the plan and writes nothing.
$ meta deps sync
synced acme-common 1.0.0→1.1.0 (10fbf886→a1b2c3d4)
meta deps check re-resolves each declared dependency exactly as sync's first
two steps do, and compares the artifact's currently installed hash against what the
lock recorded. Once the hashes match, it also loads the committed snapshot and exits 1
with the load error if the model does not load: matching hashes do not prove the model
loads. It never writes the lock or the snapshot. It needs the
publisher reachable right now (its path, or the package installed), which is why it is a separate command from
loading (below): CI running against a committed snapshot does not need the publisher
checked out, but a check run does.
meta deps list prints the lock's entries — name, version, hash, node count,
owned packages — with no resolution at all; it just reads
.metaobjects/deps.lock.json.
Once synced, TypeScript's, Python's, Java's, C#'s and Rust's collection resolvers (Kotlin loads
through Java's; a Spring app's runtime loader reads the same snapshot off the classpath) load dependency artifacts from the committed
snapshot first, then your own project files, offline, with no transport
involved. At load time it checks the snapshot against the lock and refuses
(ERR_DEPENDENCY_SNAPSHOT_STALE) when they disagree — a missing lock for a declared
dependency, a lock entry with no matching declaration, a missing snapshot file, or an
artifact whose bytes no longer hash to what the lock recorded (someone hand-edited
the snapshot, or synced elsewhere and forgot to commit it). Every message names the
fix: run \meta deps sync`. Two dependencies cannot export the same fully-qualified node either — that is ERR_DEPENDENCY_NODE_COLLISION, checked the moment they are both resolved — and a dependency published against a different metamodel **major** than this toolchain fails with ERR_DEPENDENCY_METAMODEL_INCOMPATIBLE(ADR-0035 Amendment 2: the metadata contract is promised on the major alone, so a dependency built against1.3loads fine at1.0; one built against 2.0` does not).
Dependency files load before your own, in the same loader.load(...) your project
already runs — so, exactly as within one project:
Reference a foreign node by FQN from any ref-bearing attribute
(@objectRef, @references, @via, …) — no different from referencing anything
else in your own tree.
extends a foreign abstract — the cross-repo form of the BaseEntity pattern
(abstracts-and-inheritance.md):
// metaobjects/meta.blog.json (consumer, package acme::blog)
{ "metadata.root": { "package": "acme::blog", "children": [
{ "object.entity": { "name": "Comment", "extends": "acme::common::Audited",
"children": [
{ "source.rdb": { "@table": "comments" } },
{ "field.string": { "name": "body", "@required": true } },
{ "identity.primary": { "@fields": ["id"] } }
]
}}
]}}Overlay a foreign node (overlay: true, same package + name) to add
presentation, validators, documentation attrs, or filter/sort flags — the local,
unshared additions a consumer is expected to make. Put overlay-only contributions in
their own file by convention (this doc uses meta.<dependency-name>.overlay.json;
the corpus itself names these files meta.ov*.json) — it is not enforced, but it
keeps "what did I add to someone else's node" visible at a glance. It is purely a
readability convention: since ADR-0055 the loader applies every overlay in a deferred
pass, so an overlay works from any file, in any position, including the same file as
its base:
// metaobjects/meta.acme-common.overlay.json (consumer)
{ "metadata.root": { "package": "acme::common", "children": [
{ "object.entity": { "name": "Customer", "overlay": true, "children": [
{ "field.string": { "name": "email", "overlay": true,
"@filterable": true, "description": "used for the support search box" } }
]}}
]}}One requirement: say overlay: true. The parser merges a same-(type, package::name) redeclaration whether or not it carries the flag — but only the
flagged form fails loudly (ERR_OVERLAY_NO_TARGET) when the target disappears
upstream. Without it, an upstream removal turns your amendment into a silent new
local object under the same name. Always flag a contribution to a node you did not
declare.
Declaring a brand-new top-level node into the dependency's package is refused. This is the one thing you may not do:
// metaobjects/meta.ext.json (consumer) — REFUSED
{ "metadata.root": { "package": "acme::common", "children": [
{ "object.value": { "name": "Note", "children": [
{ "field.string": { "name": "text" } }
]}}
]}}fails to load with:
ERR_DEPENDENCY_PACKAGE_NOT_OWNED
"acme::common::Note" is declared here, but the package "acme::common" belongs to a
metadata dependency this project imports — and "acme::common::Note" is not one of
the nodes that dependency exports. A node in an imported package would be excluded
from this project's own codegen and schema with no output and no error, so it is
refused instead.
with the fix named: declare it in a package you own and extends the dependency's
node if you need its shape, or — if you meant to amend an existing node — give it
that node's name and overlay: true. (An overlay's FQN is one of the dependency's
exported nodes, so it merges and passes; only a genuinely new declaration is
refused — this is what keeps the package-level rule from failing silently.)
A dependency's nodes are load-only by default. They load so your own model can
resolve against them, but they are excluded from every action surface — codegen,
schema, the requirements ledger — unless your own config names their package
literally. In the maintainer's words: no metadata is imported in runtime,
code-generated from, or used on the meta CLI unless explicitly imported for that
purpose.
The mechanism is one predicate, built from the lock:
imported(fqn)is true whenfqn's package is one that some resolved dependency owns (the union of every lock entry'spackages— a set lookup on packages, not on individual node names).explicitlyIncluded(pkg, patterns)is true when some pattern in the list namespkgliterally — drop the pattern's final segment; what remains must be wildcard-free and equalpkg. Soacme::common::**andacme::common::Addressboth nameacme::common;acme::**and a bare**do not — they match the package's nodes, which is a weaker statement than naming the package. This asymmetry is deliberate: a project that writesscope.include: ["**"]to mean "all of my own model" must not thereby start generating and migrating someone else's.
TypeScript's Collection.inScope — read by codegen, meta gen, verify --codegen, and the requirements ledger's denominator — composes both conjuncts:
inScope(fqn) = matchesScope(fqn, scope) && (!imported(fqn) || explicitlyIncluded(packageOf(fqn), scope.include))
Python's in_scope — read by run_gen's select and verify --codegen — is
only the second conjunct. It never applies matches_scope to the project's own
objects (the Python CLI has never scoped its own generated output); only the
import-exclusion half is new behaviour there:
inScope(fqn) = !imported(fqn) || explicitlyIncluded(packageOf(fqn), scope.include)
So scope.include narrows a Python project's own codegen output not at all — it
only ever widens which imported package is let back in. Java and Kotlin follow Python
(DependencySet.inScope, read by GeneratorUtil's selection points and RestSurfaceGate):
the import-exclusion conjunct only, because those generators have never scoped the project's
own objects either. Rust follows Python too (Collection::in_scope, read by cargo meta's
project load). Do not read the TypeScript formula above as describing every port.
migrate, verify --db, and offline generate compose the schema-side twin, which
also removes an excluded import from the expected schema before drift is computed
— so importing a table-backed entity can never turn the publisher's other tables into
DROP candidates, and never proposes creating the imported table:
inMigrateScope(fqn) = (declaredMigrateScope(fqn) ?? true) && (!imported(fqn) || explicitlyIncluded(packageOf(fqn), migrate.scope))
Naming the package in scope.include (and, if you own its tables, migrate.scope)
is how you take over a shared model — the legacy "I instantiate this metadata
myself" case, expressed with declarations that already exist rather than a separate
mode:
{
"scope": { "include": ["acme::blog::**", "acme::common::**"] },
"migrate": { "scope": ["acme::blog::**", "acme::common::**"] }
}Naming an excluded import explicitly is refused, not silently ignored. meta gen Customer (or a Python entities: ["Customer"]), where every loaded Customer is
imported and excluded, exits 2:
meta gen: 'Customer' (acme::common::Customer) is imported from dependency 'acme-common'
and is not generated here — add its package to scope.include in .metaobjects/config.json
to generate it
The requirements ledger's denominator follows the same rule. An imported entity
is excluded from the ledger's coverage count — demanding a capability claim for a
model you never declared into would report your project as failing to claim entities
it does not own. Note this also applies with zero dependencies: inScope composes
matchesScope(fqn, scope) regardless of imports, so a project that declares
scope.include for its own codegen narrows its ledger denominator to that declared
scope too, whether or not it has any dependencies at all.
A shared enum is emitted for the entities that are selected. An abstract
field.enum reaches the generated enums.ts iff a selected entity's field resolves
to it — decided by the using entity, never by the enum's own package.
A dependency published with requirements: true carries its requirements, and they load
with its model: an overlay of one resolves, and meta verify can see it. By default they
stay the publisher's ledger, not yours. The requirement gate does not check, count,
summarise or lint them, the requirement-tests generator writes no test for them, and the
requirements pages (requirementsFile()'s requirements.toon, the agent docs' agent/requirements.md, an entity page's
"Required by") do not list them. (Rust has no requirement gate or requirement-tests
generator yet, and its pages do not apply the ledger: Rust port.)
That is the same default as an imported entity's code generation, for the same reason:
you did not declare them.
To take them on, name the dependency's package in requirements.inherit:
// .metaobjects/config.json (consumer)
{
"dependencies": [{ "name": "acme-common", "npm": "@acme/common-model" }],
"requirements": { "inherit": ["acme::common::**"] }
}The inherited requirements then join your ledger: meta verify resolves their
@implementedBy against the loaded model and reports each by its status, and
requirement-tests scaffolds a test per claim. Change one's verdict for your project with
an overlay (same package, same name, overlay: true, a new @status); a NEW requirement
declared into the dependency's package is refused with ERR_DEPENDENCY_PACKAGE_NOT_OWNED,
as a new object there is.
Three rules keep it predictable:
- A pattern must NAME the package.
acme::common::**(or a node pattern such asacme::common::Customers) inheritsacme::common; a bareacme::commonnames the packageacme, and**alone names nothing, so neither inherits it. The final segment names a node, which is the explicit-include rulescope.includefollows. - It is a separate key from
scope.include. Naming a package inscope.includealso generates code for it, which is not what taking on its requirements means.scope.includealone inherits nothing. - An imported requirement never switches object coverage on, inherited or not. Only a requirement you wrote yourself does, as for a library's requirements: depending on a model must not enrol you in a gate you did not ask for.
requirements refuses any key but inherit, so a misspelling fails the load instead of
quietly leaving the ledger out. A consumer on a toolchain older than this key treats a
published requirement as its own, so pin the toolchain before you publish with
requirements: true to a consumer you do not control. The manifest's schema_version does
not change.
The loader's own validation already fails your build the moment a target you built on
is gone or incompatible — no new machinery, just the existing errors, now also firing
against a synced dependency after meta deps sync replaces the snapshot:
| Upstream change | Your construct | Error |
|---|---|---|
| a node removed or renamed (including a package rename) | overlay: true on it |
ERR_OVERLAY_NO_TARGET |
extends it |
ERR_UNRESOLVED_SUPER |
|
@objectRef / @references / @through / an origin head / a template ref to it |
ERR_UNRESOLVED_OBJECT_REF / ERR_INVALID_REFERENCE / ERR_INVALID_RELATIONSHIP / ERR_INVALID_ORIGIN / ERR_INVALID_TEMPLATE / ERR_PARAMETER_REF_UNRESOLVED |
|
| a member removed or renamed | a dotted extends: Foo.member |
ERR_UNRESOLVED_SUPER |
an identity/index @fields, a layout.dataGrid @columns, a @via path, @filter on an inherited member |
the existing validation-pass error for that construct | |
| a member's type or subtype changed | a dotted extends targeting it |
ERR_EXTENDS_TARGET_MISMATCH |
| an attr your overlay also sets is now set differently upstream | the overlay | ERR_MERGE_CONFLICT |
What load cannot see: a member's subType, isArray, @required, @values,
@objectRef, @default, or physical name changing while every name stays the
same; a base's extends retargeted; a @maxLength narrowed. Nothing in Phase 1a
classifies those as breaking automatically — see Deferred.
The check ships in TypeScript (meta deps check, meta verify --deps), Python (metaobjects deps check, metaobjects verify --deps), C# (dotnet meta verify --deps) and Rust (cargo meta verify --deps), against the same corpus and with the same three states and the same
ERR_DEPENDENCY_UPSTREAM_DRIFT. The Python, C# and Rust checks resolve the path transport only
(see Deferred). Python's deps check, like
TypeScript's, also loads the locked snapshots together once the hashes match; verify --deps is
the comparison alone in every port. Run verify --deps before verify's own load: C# runs it
first, so a dependency that is declared but not yet synced is reported as unresolved (the
check exits 1). The load that follows still refuses the missing or stale snapshot with
ERR_DEPENDENCY_SNAPSHOT_STALE and exit 2.
verify --deps runs meta deps check's comparison as one of verify's gated
subverbs (never part of the bare default — it needs the publisher reachable, its
path or its installed package, which CI checking out only your own repo may not
have). Java and Kotlin run the path case of the same comparison as
mvn metaobjects:verify -Dmeta.verify.mode=deps (Java port page). Each declared
dependency reports one of:
current— the installed artifact's hash matches the lock.drifted— the publisher's artifact has changed since you last synced. Fix: review the artifact diff, thenmeta deps sync.unresolved— the dependency could not be resolved at all right now (thepathmoved, the package is not installed, or the manifest/artifact fails validation).
Any drifted or unresolved dependency fails the command with
ERR_DEPENDENCY_UPSTREAM_DRIFT — a check that cannot check must not pass. This is
distinct from ERR_DEPENDENCY_SNAPSHOT_STALE above: that one fires at load time,
offline, when the committed snapshot disagrees with the lock; this one fires only
when you explicitly ask whether the publisher has moved since, which needs the
publisher reachable.
A publisher wires the shared-model generator (TypeScript, Java, Kotlin, C#, Python and Rust) to select a subset of its own metadata by the same include/exclude scope-pattern
grammar scope already uses, and emit it as one canonical-JSON artifact plus a
manifest:
// metaobjects.config.ts (publisher)
import { sharedModelFile } from "@metaobjectsdev/codegen-ts";
export default defineConfig({
generators: [
entityFile(), /* … */,
sharedModelFile({
name: "acme-common",
include: ["acme::common::**"],
// exclude: ["acme::common::InternalOnly"],
// requirements: true, // also publish the selected requirement.* nodes (default false)
// files: [...], // default: the run's own source files
// version: "1.2.0", // default: the nearest package.json version
target: "shared",
}),
],
targets: { shared: { outDir: "dist/shared-model" } },
});It emits <name>.metaobjects.json (a metadata.root document with no root
package — every top-level node carries its own — raw own-layer form, extends
preserved) and metaobjects.pkg.json (the manifest: version, metamodelVersion,
the artifact's sha256, and the sorted packages/nodes it exports). Along the way
it:
- Loads
filesstandalone with your project's own registry, strict. - Selects top-level nodes matching
include/exclude— always excludingtemplate.*(a publisher's prompts are not a consumer's shapes), and excludingrequirement.*unlessrequirements: true. With it, the publisher's ledger ships with the model it describes, so a consumer can inherit it (see Inheriting a dependency's requirements). Java and Kotlin take the same switch as the generator argrequirements, and C# asSharedModelGenerator.Requirements. - Checks the selection is closed — every
extendstarget and every ref-bearing attribute of a selected node (and its descendants) must resolve to another selected node, or the build fails naming the(referrer → target)pairs. This is what stops an internal shape from silently leaking through a dangling reference. A published requirement's@implementedBytargets count as references too: a requirement claiming a node you did not select is refused, so a consumer never inherits a claim that cannot resolve. - Re-loads the emitted artifact standalone with core providers only — your
provider vocabulary is not carried into the export; a Phase 1a export that needs
it fails here, at publish time, not on a consumer's
meta deps sync.
Because it is codegen output, it is drift-gated: meta verify --codegen in the
publisher's own build regenerates and diffs it, so a metadata edit that changes the
public surface cannot ship unnoticed.
shared-model can be ejected, and the artifact stays in the package.
meta eject shared-model copies a thin generator you own: which of your source files may
contribute, and where the published version comes from. The artifact is a contract whose
bytes a cross-port corpus pins and whose hash consumers verify, so everything a consumer
checks is not in the copy. It stays in two functions the copy calls, buildSharedModel
(load, select, closure check, serialize, core-vocabulary re-load) and
renderSharedModelFiles (the file names, the hash, the manifest). An unmodified copy
publishes the same bytes as the packaged generator, and a test has a consumer sync and
verify what an ejected copy published. See
own-your-codegen.
A published model travels inside the package that implements it, the way a JVM
library's jar once carried its metadata/*.json. Consumers install your package with
their package manager and declare an npm, python, maven or nuget dependency on it
(the last two are covered under Declaring a dependency). Publishing is
two steps: generate the shared model into the package, then release the package as you
already do.
An npm package.
-
Point
sharedModelFile()'s target inside the package, and list that directory infilesso it is packed:// metaobjects.config.ts sharedModelFile({ name: "acme-billing", include: ["acme::billing::**"], target: "shared" }), // … targets: { shared: { outDir: "metaobjects" } },
// package.json { "name": "@acme/billing-model", "version": "2.1.0", "files": ["dist", "metaobjects"] }
meta genwritesmetaobjects/acme-billing.metaobjects.jsonandmetaobjects/metaobjects.pkg.json, stamped withpackage.json's version. -
Bump the version, run
meta gen, thennpm publish.npm pack --dry-runlists the two files iffilesis right.
Consumers declare { "name": "acme-billing", "npm": "@acme/billing-model", "dir": "metaobjects" }.
A Python package. A Python project runs its own shared-model generator
(metaobjects gen); the Node meta writes the same bytes, so a project that still publishes
with it sees no change.
-
Point the target inside the importable package, wire the generator in
metaobjects.config.yaml, and make sure the build ships the JSON files as package data:targets: shared: outDir: src/acme_scheduling/metaobjects generators: - name: shared-model options: name: acme-scheduling include: ["acme::scheduling::**"] # exclude, requirements and files are optional; files are relative to the project # root. version defaults to the pyproject.toml [project] version below.
# pyproject.toml [project] name = "acme-scheduling" version = "0.4.0" # hatchling ships every file inside the package directory by default. With # setuptools, declare the data: [tool.setuptools.package-data] acme_scheduling = ["metaobjects/*.json"]
With no
versionoption, the Python generator stamps the nearestpyproject.toml[project]version (orpackage.jsonversion) at or above the project root. If the Python package lives elsewhere in the repository, passversionexplicitly so the manifest carries the version consumers install. With no version found, the run fails. -
Bump the version, run
metaobjects gen, then build and upload as usual (python -m build, thentwine uploadoruv publish).unzip -l dist/*.whlshows the two files if the package data is right.
Consumers declare { "name": "acme-scheduling", "python": "acme_scheduling", "dir": "metaobjects" }.
Run meta verify --codegen in your release pipeline before publishing: it fails when
the committed shared model is stale against your metadata.
A self-hosted Gitea serves an npm and a PyPI registry per owner (user or organization). The URLs have this shape; substitute your host and owner:
| Ecosystem | Registry URL |
|---|---|
| npm | https://git.example.com/api/packages/<owner>/npm/ |
| PyPI (upload) | https://git.example.com/api/packages/<owner>/pypi |
| PyPI (install index) | https://git.example.com/api/packages/<owner>/pypi/simple/ |
Publishing needs a token; installing does not when the packages are public (or the instance allows anonymous reads). Create a personal access token with package write scope, and keep it out of the repository:
# publisher's .npmrc (the token comes from the environment)
@acme:registry=https://git.example.com/api/packages/<owner>/npm/
//git.example.com/api/packages/<owner>/npm/:_authToken=${GITEA_TOKEN}npm publish # with the .npmrc above
python -m build
twine upload --repository-url https://git.example.com/api/packages/<owner>/pypi \
-u <user> -p "$GITEA_TOKEN" dist/*Consumers point their package manager at the registry with no credentials:
# consumer's .npmrc
@acme:registry=https://git.example.com/api/packages/<owner>/npm/pip install --index-url https://git.example.com/api/packages/<owner>/pypi/simple/ \
--extra-index-url https://pypi.org/simple/ acme-scheduling
# or in pyproject.toml / uv: an extra index with that URLThen meta deps sync as for any other installed package. Nothing about the registry
reaches .metaobjects/: the lock records the transport (npm/python + dir), never a
URL.
TypeScript, Python, Java, Kotlin, C# and Rust publish and consume.
TypeScript, Python, Java, Kotlin, C# and Rust can consume a dependency (load its snapshot, extend
it, overlay it). Java reads it at every rung of the Maven plugin's source ladder
(<sourceDir>/<sources>, the neutral config, the default directory), and Kotlin inherits that
through the same plugin and loader, so a Spring or Kotlin build consumes a shared model with no
extra configuration. Java, Kotlin, C#, Python and Rust can also publish: each ships a shared-model
generator (Java and Kotlin through the Maven plugin's metaobjects:generate, C# through
dotnet meta gen, Python through metaobjects gen, Rust through cargo meta gen; all five ejectable) that writes the artifact
and manifest, byte-identical to the TypeScript one and gated by fixtures/shared-model-conformance/.
The Node meta deps sync stays the only writer of the lock and the snapshot, in every port.
C#. dotnet meta reads dependencies from .metaobjects/config.json at every rung of its
source ladder — C# has no native config surface, so the explicit <metadataDir> form reads the
project's file too — verifies the committed snapshot against deps.lock.json offline, and loads
the snapshots first under dep:<name>/<artifact> source ids. It never writes either: run
meta deps sync (the Node CLI) to refresh them, and a stale snapshot fails every command with
ERR_DEPENDENCY_SNAPSHOT_STALE. An imported node is excluded from every C# generator, the
verify --codegen regeneration and the requirement gate's entity-coverage denominator unless
scope.include names its package; the one thing C# still emits from an imported package is the
POCO of a value object (and the shared enums it uses) that a generated type reaches — an entity
or local value object that holds it, or a local template whose @payloadRef / @responseRef names
it — because that generated type needs it to compile. inScope is Python's formula (no matchesScope on the
project's own objects). dotnet meta gen --entities resolves names against the in-scope
objects only, so naming an excluded import is refused the way TypeScript's "refuse an
explicitly named imported object" check refuses it (exit 2, --entities names 'X', which matches no object in the metadata. — C#'s wording, not TypeScript's imported-specific
message). Known edge: a local entity
that extends an imported concrete entity in a table-per-hierarchy mapping is not specially handled.
Plain sources vendoring |
dependencies |
|
|---|---|---|
| What you commit | a copy of a metadata directory | a generated artifact + manifest hash, pinned in a lock |
| Who decides what's exported | you, by choosing what to copy | the publisher's sharedModelFile() selection |
| Drift detection | none — the copy is whatever you last copied | meta deps check / verify --deps compare against the lock |
| Versioning | none | version + metamodelVersion recorded per sync |
| Declaring a new node into the shared package | not meaningful — there is no "owned by" concept | refused (ERR_DEPENDENCY_PACKAGE_NOT_OWNED) unless it's an overlay |
| Excluded from your own codegen/schema by default | no — everything you vendor loads exactly as your own metadata does | yes, unless scope.include / migrate.scope names the package |
Use plain vendoring for a quick, single-repo or monorepo copy with no separate
publish step. Reach for dependencies once more than one consuming project needs
the same versioned, hash-verified artifact.
If you have shipped a JVM library whose jar carried nothing but a metadata/*.json
resources directory, pulled by an ordinary dependency declaration and read off the
classpath — this generalizes that pattern rather than replacing it with something
unrecognizable. The artifact still travels inside the publisher's own ecosystem
package (an npm package's files or a Python package's package data); it is still versioned with the
package that implements it; a consumer still pulls it through its own package
manager. What's different: the artifact is one flattened, generated file rather
than a directory of hand-placed sources, its manifest is generated rather than
hand-written, and meta deps sync copies it into a committed snapshot rather
than reading it live off the classpath at build time — the classpath-at-build-time
read with no committed snapshot ("commit": false) is deferred, and the committed snapshot is the
cross-port contract every consumer gets.
Phase 2 (#482) is built. It added no new
contract: the manifest, the lock, the committed snapshot and the resolution corpus are plain files
every port reads. What it added is each port loading the snapshot, checking it, and (for Java,
Kotlin and C#) publishing one. A port that does not read the lock still fails loudly on a model
that references a node a dependency would supply (ERR_UNRESOLVED_OBJECT_REF), never silently.
| TypeScript | Python | Java | Kotlin | C# | Rust | |
|---|---|---|---|---|---|---|
| Consume (load the snapshot, scope, extend, overlay) | ✓ | ✓ | ✓ every rung of the Maven plugin's source ladder | ✓ through Java's loader and plugin | ✓ every rung of dotnet meta's source ladder |
✓ through cargo meta's project load |
| Runtime load | Node reads it | n/a (build-time) | ✓ Spring loads .metaobjects/deps.lock.json and deps/** from the classpath |
✓ same | n/a (build-time) | n/a (build-time) |
| Check | meta deps check, meta verify --deps |
metaobjects deps check, verify --deps |
mvn metaobjects:verify -Dmeta.verify.mode=deps |
same goal | dotnet meta verify --deps |
cargo meta verify --deps |
Publish (shared-model, ejectable) |
sharedModelFile() |
✓ via metaobjects gen |
✓ SharedModelGenerator via metaobjects:generate |
✓ KotlinSharedModelGenerator |
✓ SharedModelGenerator via dotnet meta gen |
✓ shared-model via cargo meta gen |
Transports sync reads |
path, npm, python, maven, nuget (Node meta deps sync is the only writer, for every port) |
|||||
Transports check resolves |
all five | path |
path |
path |
path |
path |
Publishers in every port write the same artifact and manifest bytes as sharedModelFile(),
gated by fixtures/shared-model-conformance/. See the port pages: Java,
Kotlin, C#,
Rust.
Two rulings shape it:
- Node
meta deps syncstays the only writer of the lock and the snapshot. The other ports load, check and publish; a Java or C# project needs Node to sync, as a schema-owning project already needs it formeta migrate. Because the lock is then written by one tool, its byte format never becomes a cross-port contract. - The Java Spring runtime loads the snapshot automatically when
.metaobjects/deps.lock.jsonis on the classpath, so a Spring app whose entityextendsa dependency's node does not fail at boot for want of one line of configuration.
Java and Kotlin: runtime load and verify. metaobjects:generate ships
.metaobjects/deps.lock.json and .metaobjects/deps/** on the classpath, and the application loader
reads them when the lock is there, with the build-time scoping and error codes.
mvn metaobjects:verify -Dmeta.verify.mode=deps is the Java and Kotlin meta deps check: it
resolves a path dependency, hashes its artifact against the lock and fails with
ERR_DEPENDENCY_UPSTREAM_DRIFT on drifted or unresolved. It is opt-in, and an npm, python,
maven or nuget dependency is unresolved there (run the Node meta deps check for those). See
the Java port page.
meta deps sync and check on a Maven- or C#-shaped project. Both commands read
only .metaobjects/config.json, and finish with a proof that the dependency set loads. A project
whose own metadata is in a build-tool directory (src/main/resources/metadata, a C# project's
metadata directory) declares no neutral sources, and a project may use vocabulary only its own
port registers. Neither case can be loaded by the Node toolchain, and neither is a fault in the
dependencies. In those two cases (and only those: no sources and no default directory, or
a load whose every error is an ERR_UNKNOWN_TYPE / ERR_UNKNOWN_SUBTYPE) the
proof loads the locked snapshots together instead, prints which it did, and says that the port's
own verify is the full check. A misspelt type in a project this toolchain does read takes the
same path, which is why the fallback is announced. A load that also has any other error, such as
an unresolved extends onto a removed dependency node, still fails the command and, for sync,
rolls the lock and snapshot back.
Packaged transports: Maven and NuGet. The path transport needs the
publisher's directory on disk. A JVM or .NET consumer that cannot reach it resolves a
published model from the package manager's own store instead: a Maven artifact (a JAR in the
local repository) or a NuGet package (in the global packages folder), each carrying the same
metaobjects.pkg.json and artifact pair that a publisher writes (see
the transports above). A publisher ships the pair inside its JAR (as
metaobjects/ resources) or its NuGet package (as metaobjects/ content), declared as
{ "name": "x", "maven": "com.acme:acme-model", "version": "1.0.0" } or
{ "name": "x", "nuget": "Acme.Model", "version": "1.0.0" }. Per the single-writer ruling it is Node meta deps sync that reads the pair out of the JAR or the package and writes the same snapshot and
lock entry a path sync writes, so everything downstream (check, load, scope, the corpus) is
unchanged; nothing in a port's own build resolves a dependency. This generalizes the resources-JAR
pattern described above.
Designed (see docs/superpowers/specs/2026-09-11-fr-023-metadata-dependencies-design.md)
but not built yet — do not assume any of the following exists:
- A local co-development override (
deps.local.json) that would pointsyncat an unpublished local checkout without editing the committed config. Today, switch the spec topathwhile co-developing, and back tonpm/pythonbefore committing. - A usage-aware breaking-change classifier at sync/check time. Nothing
automatically distinguishes a widening change (say,
@maxLengthgrowing) from a breaking one — the committed artifact's diff in your own history is today's review, and the load-time errors above are today's safety net. packageBindings— codegen importing a foreign named type across the dependency boundary (the FR-025 slice). A generated artifact that names a foreign type in Phase 1a does so however your own generator already resolves cross-package references.- A runtime
ObjectManagerscope predicate. Nothing at runtime refuses to serve an imported entity — "what's imported" is a load-time/codegen concept today, not a runtime one. - A JVM classpath read with
"commit": false— a Java or Kotlin build reading a dependency's artifact straight off the classpath with no committed snapshot. The committed snapshot is the only shipped path. npm,python,mavenandnugettransports in the Python, Java, C# and Rust check. Those ports' check resolvespathonly; any other dependency reportsunresolvedand names the Nodemeta deps check, because resolving it needs the consumer's installed packages or local package caches (a check that cannot check must not pass).
fixtures/dependency-conformance/— 47 cases. 36 pin resolution (includingnpm,python,mavenandnugetdependencies loading from their committed snapshot with nothing installed), the exhaustiveimported/inScope/inMigrateScopesets, overlay/extends/reference behavior against a synced snapshot, and every load- and resolution-time error above. 11 pin the upstream check (current,drifted,unresolved). Four artifacts underfixtures/dependency-conformance/artifacts/are pinned by sha256 in the README so the corpus itself can never silently drift. Seven resolution cases also pin the ledger (expectLedger,expectCoverageMeasured): which requirements are the project's own and whether coverage is measured. Which ports run which arm, and how each asserts the ledger:CONFORMANCE.md.transport-cases.jsonbeside it pins thenpm,python,mavenandnugettransports themselves (32 cases: packages laid out under a tempnode_modules, on a temp Python import path, as a jar in a temp local Maven repository and as a package in a temp NuGet cache, the directory each resolves to, the exact locksyncwrites, and each refusal), run by Nodemeta deps sync, the only writer.fixtures/shared-model-conformance/— 15 cases pinning what a publisher writes: the exact artifact and manifest bytes for a source tree andinclude/exclude/files/requirements, and the refusals (an empty selection, a requirement claiming a node outside the selection, a closure failure naming everyreferrer → targetpair, vocabulary a consumer's toolchain does not ship). TypeScript, Java (Kotlin through the same engine), C# and Python run all of it.
metadata-sources.md— where your own metadata comes from, and plain-directory vendoringabstracts-and-inheritance.md—extends:andoverlay:within one project; the cross-repository case builds on the same rulesown-your-codegen.md— generator ownership, and what an ejectedshared-modelcopy ownscli.md— themeta depscommand surface andverify --depsCONFORMANCE.md— per-port pass status fordependency-conformance