Morphir.Mep
0.4.0-alpha.3
Prefix Reserved
See the version list below for details.
dotnet add package Morphir.Mep --version 0.4.0-alpha.3
NuGet\Install-Package Morphir.Mep -Version 0.4.0-alpha.3
<PackageReference Include="Morphir.Mep" Version="0.4.0-alpha.3" />
<PackageVersion Include="Morphir.Mep" Version="0.4.0-alpha.3" />
<PackageReference Include="Morphir.Mep" />
paket add Morphir.Mep --version 0.4.0-alpha.3
#r "nuget: Morphir.Mep, 0.4.0-alpha.3"
#:package Morphir.Mep@0.4.0-alpha.3
#addin nuget:?package=Morphir.Mep&version=0.4.0-alpha.3&prerelease
#tool nuget:?package=Morphir.Mep&version=0.4.0-alpha.3&prerelease
Morphir.Mep
One implementation of the Morphir Extension Protocol (MEP) 0.2.0-draft.1 for
morphir-dotnet hosts and guests: JSON-RPC 2.0 messages, Content-Length framing,
the session lifecycle and the model transport. Work is tracked by
#512 and
add-mep-core. The roadmap is the
Morphir extension model PRD, step 1.
Layers
| Layer | File | What it does |
|---|---|---|
| Wire types | Wire.fs |
Records and unions of the pinned contract, with parsed values (ProtocolVersion, SemanticVersion, Sha256Digest, RequestId). MepJson is generated from this file at build time by Morphir.Myriad.SystemTextJson. There is no reflection serializer. |
| Model transport | ModelTransport.fs |
Tuple selection, the host check of a selection, envelope creation and admission. Pure functions. |
| Message codec | Rpc.fs |
Classifies a JSON-RPC message by its members (JsonRpcMessage), keeps params raw, and writes messages. This is the only hand-written JSON. |
| Dispatcher | Dispatcher.fs |
DispatchAsync(bytes, ct) returns the reply bytes, or none for a notification. A method table maps method names to typed handlers; a gate refuses a method before its handler runs. |
| Framing | Framing.fs |
Content-Length frames on a Stream: header blocks up to 8192 bytes, bodies up to 64 MiB, checked before the body is read. A refused frame ends the connection. |
| Connection | Connection.fs |
Reads frames, dispatches inbound requests concurrently, matches inbound responses to the pending-request table, and sends and receives $/cancelRequest. |
| Session | Session.fs |
The pure lifecycle rules (Lifecycle.admit) and version negotiation, shared by hosts and guests. |
| Peers | Peers.fs |
Guest (lifecycle methods, gate, extension methods) and HostSession (refuses to send what the guest must refuse). |
The stream path (Connection) and the single-message path (Dispatcher.DispatchAsync)
use the same dispatcher, so they give the same bytes. Starting a guest process is not
in this project: a process host connects a HostSession to the child's streams.
A guest and a host in memory
This example is compiled by tests/Morphir.Mep.Tests/ReadmeTests.fs. Keep the two equal.
let runSession (claims: CapabilityClaimSet) (capabilities: ExtensionCapabilities) =
task {
let guest =
Guest(
{ Claims = claims
Capabilities = capabilities
Methods = readOnlyDict [] }
)
let toGuest = Pipe()
let toHost = Pipe()
let guestRun = guest.RunAsync(toGuest.Reader.AsStream(), toHost.Writer.AsStream(), CancellationToken.None)
let host =
HostSession(
toHost.Reader.AsStream(),
toGuest.Writer.AsStream(),
{ Kind = PeerKind.Cli; Name = "morphir"; Version = "0.4.0" },
null
)
let hostRun = host.RunAsync CancellationToken.None
let! session = host.InitializeAsync CancellationToken.None
let! ping = host.PingAsync CancellationToken.None
let! _ = host.ShutdownAsync CancellationToken.None
do! host.ExitAsync()
let! guestEnd = guestRun
toHost.Writer.Complete()
let! _ = hostRun
return session, ping, guestEnd
}
Add a method
- Check that the pinned contract has the method and its params and result types. Do not add a method, member or error code that the pin does not have; raise an upstream issue.
- Write a failing wire test, then add the types to
Wire.fswith the attributes that the contract's wire rules need. Add the type to the contract test (ContractTests.fs): a complete sample, and the members that the contract text lets a reader default. - Add the method to
Methodif it is new, and its capability toLifecycle.capabilityif the contract makes it depend on one (the guest replies-32013without it). - Register a handler in the guest's
MethodswithHandlers.request(params bind as one object through their codec; absent or mismatched params give-32602), and add a typed call toHostSessionif hosts send it. - Add the method to the AOT probe (
tests/Morphir.Mep.AotProbe) when it changes what C# calls.
The pin
tests/Fixtures/Mep pins the upstream
contract model (mep.ir.json), the transcripts and the model-transport corpus by commit
and digest. Do not edit the fixtures. To update the pin:
- Copy the new files from
finos/morphirat one commit, and record the commit and the SHA-256 digests inPROVENANCE.md. - Run the tests.
ContractTestsfails for each renamed or added member, and the transcript and corpus tests fail for each changed behavior. - Change the types and rules in the same pull request. A new MEP version moves every MEP part in morphir-dotnet together; drafts match only exactly.
Where a transcript and the contract text disagree, the tests follow the contract text.
The legacy transcripts initialize with 0.1; the replays use 0.2.0-draft.1 instead.
C# callers
The project is trimmable and AOT-compatible, with F# nullness metadata. Parsed values have
TryParse and Create; FrameRead has Match. tests/Morphir.Mep.AotProbe is a C#
consumer that runs the full session; InteropTests compiles C# examples and checks the
nullable-flow diagnostics.
Tests
dotnet run --project tests/Morphir.Mep.Tests -- --summary
./build.sh --target TestMepAot --configuration Release
The first command runs the wire, contract, JSON-RPC, connection, session and model-transport tests on in-memory streams. The second publishes the probe with Native AOT, refuses IL diagnostics other than the FSharp.Core summary baseline, and compares the native output with JIT byte for byte. Both run in PR CI.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- FSharp.Core (>= 10.1.403)
- Morphir.Myriad.SystemTextJson.Annotations (>= 0.4.0-alpha.3)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Morphir.Mep:
| Package | Downloads |
|---|---|
|
Morphir.Extensions
Morphir extension registry domain: parsed extension identities, capability claims and the extension catalog |
|
|
Morphir.Compilation.Mep
The MEP 0.2.0-draft.1 host side of guest processes: the guest process and session, and the frontend adapter, an IFrontend over a guest that serves morphir.frontend.compileModel. Trim-safe and AOT-safe. |
|
|
Morphir.Extensions.Installation
Local extension package installation, inventory, selection and activation for Morphir tooling. |
|
|
Morphir.Extensions.Wasm
The WASM extension runtime of morphir-dotnet: Wasmtime with the embedded Extism kernel module. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.0-alpha.5 | 94 | 11/22/2026 |
| 0.5.0-alpha.4 | 94 | 11/16/2026 |
| 0.5.0-alpha.3 | 100 | 11/14/2026 |
| 0.5.0-alpha.2 | 100 | 11/13/2026 |
| 0.5.0-alpha.1 | 96 | 11/13/2026 |
| 0.4.0-alpha.5 | 100 | 11/13/2026 |
| 0.4.0-alpha.4 | 87 | 11/10/2026 |
| 0.4.0-alpha.3 | 85 | 11/9/2026 |
### Added
- Docs: [Compile F# to Morphir IR](https://finos.github.io/morphir-dotnet/docs/getting-started/compile-fsharp/), a five-minute start, and two tutorials: car rental pricing from F# to C#, and compiling F# with the native `morphir` executable. The finished example is in `examples/car-rental-pricing` ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- Releases publish the F# frontend extension `Morphir.Frontend.FSharp.Extension` (command `morphir-fsharp-frontend`) to NuGet next to `Morphir.Tool` ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- `morphir compile`: compiles F# sources to Morphir IR with the in-process F# frontend of the dotnet tool `dotnet-morphir`. Sources come from `--input` files in order, one `--input` directory in lexical order, `--project-file`, `[frontend.<language>].project_file`, or `project.source_directory`. `--ir-version` and `ir.format_version` keep the exact format version, for example `4.0.0`. `--json` writes one report with setting origins; `--json-lines` writes the compile events and ends with the report. Human mode writes each stage's diagnostics to stderr when the stage completes. Exit codes are 0, 1, 2 and 130. The AOT executable `morphir` has no built-in F# frontend; it compiles F# through the MEP guest with `--extension` ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- `morphir compile --extension <command, path or .dll>` and `[frontend.<language>].extension`: run a frontend as a MEP `0.2.0-draft.1` guest process. The AOT `morphir` compiles F# through `morphir-fsharp-frontend` for IR versions 1 to 4; classic versions 1 and 2 are compiled at `3.0.0` and written at the requested version. Extension failures are exit code 2 with `extension.unavailable`, `extension.not_admitted`, `extension.tuple_unavailable`, `extension.protocol_error` or `extension.timeout` ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- `morphir compile --target <id> --generate-output <dir> [--option KEY=VALUE]`: continue into code generation on the compiled IR, as `generate` does ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- Compile task records: `compile` writes `compile.json` under the out root (`--out-dir`, `MORPHIR_OUT_DIR` or `workspace.out_dir`), holds `compile.lock` while it runs, leaves a tombstone when it fails, and installs a copy of the IR with `-o/--output` without changing files it did not write ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- `morphir generate` without `--input` reads the IR of the most recent compile of the project, and fails with `compile.record_missing` when there is none ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- `morphir.unrepresentable`: a classic IR version that cannot hold a value of the model (an integer outside the 64-bit range, or a character outside the Basic Multilingual Plane) fails with exit code 1 and writes no document ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- Configuration: `ir.format_version` accepts a SemVer string such as `"4.1.0-draft.1"`, and every `[frontend.<language>]` table accepts `project_file` and `extension` ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- Generation JSON reports: a diagnostic can have an optional `range`. Reports without ranges are unchanged ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- `Morphir.Mep` foundation: parsed protocol versions, generated describe params, bounded `Content-Length` framing, pinned-contract tests and a C# consumer verified under Native AOT ([#512](https://github.com/finos/morphir-dotnet/issues/512)).
- Myriad System.Text.Json record wire rules: typed scalar, empty-collection and static-provider defaults for missing members, an explicit JSON-literal fallback, empty-collection omission, flattened extension data, exact versioned-member migration and critical-path allowlists. Existing encodings remain unchanged unless annotated.
- `Morphir.FSharp.Annotations`: `[<MorphirName("...")>]` sets the Morphir name of an F# value, type, union case, record field or module, in canonical Morphir name syntax, for example to name an operator. For `netstandard2.0`, with no dependency ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- `morphir-fsharp-frontend`: the F# frontend as a MEP `0.2.0-draft.1` guest, packaged as the framework-dependent dotnet tool `Morphir.Frontend.FSharp.Extension`. It serves `morphir.frontend.compileModel` with JSON model tuples for IR `4.0.0` and `3.0.0` ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- `Morphir.Mep` frontend messages: the `compileModel` request types, the result sum, the reserved options, the request check, RFC 8785 canonical JSON and the request context digest ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- The F# generator writes more Morphir SDK operations: `Basics.integerDivide`, `negate`, `abs`, `min`, `max`, `and`, `or` and `not`; `Decimal.add`, `sub` and `mul`; `List.singleton`, `append`, `length`, `head` and `cons`; `Maybe.andThen` and `Result.andThen`; `String.append`, `length` and `join`; and the `Int.Int64` type ([#499](https://github.com/finos/morphir-dotnet/issues/499))
### Changed
- The F# generator gives each union case field the name of its constructor argument (`Large of seats: int`), so the names stay in the generated F#. A case whose argument names repeat keeps positional fields ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- The F# generator renames a parameter or local value (`__morphirLocal_` prefix) only when it hides a module value that its definition uses. It renamed every local with the name of a module value before ([#499](https://github.com/finos/morphir-dotnet/issues/499))
- The F# generator writes `List.cons` with two arguments as `head :: tail`, not as an applied lambda ([#499](https://github.com/finos/morphir-dotnet/issues/499))
### Fixed
- Custom Myriad plugin scaffolds build and load with Myriad 0.85.0, using Fantomas syntax types and copied runtime dependencies. Myriad and its coupled code generation dependencies now have their own Renovate update group, including the bundled host pins.