Morph Framework Overview
Morph Framework is the plugin and manifest system that owns Morph language features, runtime behavior, backend routes, execution formats, build providers, and tooling commands. The C++ sources in src/ provide the host (pipeline spine, IR containers, diagnostic engine, CLI/LSP shells); morphs/ provides the loadable policy that tells that host which sema rules, lowers, optimizers, LLVM/GPU/shader/NN/REPL routes, runtime symbols, and morph subcommands apply.
Read this first if you wonder “where does Morph’s real power live?” → Plugin-governed pipeline.
Core Idea
Morph uses a package-first model:
- Packages own feature behavior end-to-end (surface → sema → NIR/MIR → backend → runtime/tooling), not as scattered one-offs in core.
morph.toml/feature.toml/block.tomldeclare exports, imports, providers, routes, and runtime families so discovery is data-driven.- Generated glue + stable ABI (
include/morphc/morph/MorphABI.h, packageplugin/*, build emission) registers factories into the host at build time. - The host composes packages; it does not hardcode every domain.
This means a new language or runtime capability should usually be added by extending a package or creating a new package—and only widening src/ when the framework needs a new hook shape.
Why Morph Exists
Without Morph, feature ownership drifts into compiler core files:
- parser shortcuts appear in
src/ - runtime symbols get hardcoded in shared runtime folders
- build and tooling logic become platform-specific branches
Morph prevents that by making packages the canonical ownership boundary.
The Plugin-First Rule
Feature work happens in package space first.
If an existing package can express the feature, extend that package. If no package should own the feature, create a new package. If the current framework cannot express the feature, widen the framework or SDK.
Do not edit Core as a shortcut for feature ownership.
What Counts As A Morph Feature?
Morph packages can own:
- syntax and semantic rules
- lowering behavior
- runtime families
- backend routes
- tooling commands
- execution formats
- build providers
Examples from the current repo:
| Package | Owns |
|---|---|
Core | baseline package-owned language features |
Types | type registration and type descriptors |
Ops | operator and operation ownership |
Test | test {} blocks and assertions |
Vcon | execution format and VM behavior |
Build | generic build orchestration |
Windows | Windows platform provider behavior |
The Current Canonical Model
The current Morph model is based on:
morph.tomlas the canonical package manifest- feature-first package layout
- package-owned runtime, backend, tooling, execution, and build behavior
Legacy terminology and legacy manifest layouts are not the teaching target here. Learn and use the current model.
What This Category Teaches
This category is for plugin authors.
You will learn:
- how Morph packages are structured
- how to write a plugin from zero without pushing ownership into Core
- how manifests drive discovery
- how package dependencies and imports work
- how framework SDK headers and generated glue fit into authoring
- how package scripting and implementation files should be organized
- how providers, artifacts, runtime families, and LLVM route signatures are declared
- how to add a feature to an existing package
- how to create a new package
- how runtime, backend, tooling, build, and execution ownership stay package-owned
Next Steps
- Plugin-governed pipeline - ABI, phases, backends, plus a concrete tour of root
morph.toml([include],[build], runtime/providers),blocks/*/block.toml([forms.*]), andfeatures/*/feature.toml(ops, routes, built-ins) - Plugin-First Rule - the non-negotiable ownership rule
- Package Layout - canonical folder structure
- Writing A Plugin From Scratch - full package, manifest, feature, lowering, route, emit, and test workflow
- Package Dependencies And Imports - package graph composition
- Scripting And Code Layout - where package implementation files live