Context packages and federation
Canonical persistence, exact dependency resolution, stable digests, and explicit schema migration.
The Modeller.Contexts module is the persistence and federation interface for
independently versioned bounded contexts.
It loads a canonical context package,
resolves explicit Imports against public Exports, persists deterministic JSON,
and runs only explicitly requested migrations.
It performs no application-specific database, filesystem, or network work.
Interface
ContextPackageLoadResult ContextPackageSystem.Load(ReadOnlyMemory<byte> document)
ContextPackageLoadResult ContextPackageSystem.Load(
IEnumerable<ContextPackageDocument> documents)
FederationResolutionResult ContextPackageSystem.Resolve(
IEnumerable<ReadOnlyMemory<byte>> documents,
ContextPackageIdentity root,
CancellationToken cancellationToken = default)
ContextPackagePersistenceResult ContextPackageSystem.Persist(
LoadedContextPackage package)
ContextPackageMigrationResult ContextPackageSystem.Migrate(
ReadOnlyMemory<byte> document,
string targetSchemaVersion,
IEnumerable<IContextPackageMigration> migrations,
CancellationToken cancellationToken = default)Every operation returns immutable values or structured diagnostics. Resolution never means “latest”: the requested root is exact, every Import declares a compatible version range and expected stable IDs and kinds, and exactly one supplied package must satisfy each dependency. The resulting federation snapshot locks each context ID and version to its package and semantic digests.
The plural load form combines source fragments by stable identity before model decode. Fragment order and names are packaging provenance only; duplicate definitions or mismatched package identities are rejected rather than merged by guesswork.
Digests and canonical persistence
A package digest identifies the exact UTF-8 package bytes supplied or persisted. A semantic digest identifies normalized meaning. Property order, definition order, whitespace, layout, source provenance, persistence schema, context version, and Import compatibility ranges do not affect semantic digest. Language versions, stable identities, definitions, imported stable IDs and kinds, and Exports do. Package and context versions remain exact provenance in the Federation Snapshot lock.
Persist emits one deterministic JSON document. It deliberately omits layout
and provenance companions from semantic persistence while retaining the
schema version needed by a
loader.
Resolution and failure
The resolver rejects unresolved or ambiguous versions, non-public or kind-mismatched Exports, dependency cycles, mutable published context-version/package combinations, unsupported schemas, duplicate JSON properties, invalid definitions, excessive package size, and cancellation with stable diagnostic codes. Input order does not affect the snapshot lock order.
For the Child Care reference project, the child-care@1.0.0 ACCS package
resolves to an immutable one-package snapshot with semantic digest
sha256:6d1448c32127c49571d2a7ea5982045b7aa74ed28da2d7323ac5360b94ed6728.
That result is retained as executable conformance evidence.
Explicit migration
A schema migration names one source and target schema version and transforms an immutable input document. The module follows an explicit chain, validates the final package, verifies that semantic digest and stable IDs are unchanged, and returns a report containing every step. A missing, ambiguous, cancelled, or meaning-changing chain returns diagnostics and no publishable document; the caller’s original bytes are never changed.
Changing Child Care meaning is a model migration and a new context version, not a schema-migration workaround. See the canonical persistence decision for the governing constraints.
The Readable Modelling Language and Semantic Assembly Format compiles to this canonical package form and retains source provenance without changing package authority.
The Child Care 1.1.0 package completely supersedes 1.0.0: it preserves
the application, lifecycle, Facts, Rule, Behaviour, exports, and stable IDs,
then adds Classify ACCS eligibility and its Unique decision table. A
context version is never a delta that silently removes earlier meaning.