Skip to main content

Generated Glue And Factories

Morph discovery is manifest-driven, but code still needs concrete factories and registration points.

That is where generated glue comes in.


Why Generated Glue Exists

Generated glue connects:

  • package manifests
  • feature descriptors
  • factory functions
  • registry discovery

It keeps package registration consistent without forcing authors to hand-maintain large manual tables.


Where glue lives in this repo

Generated and emitted registration in this repo is centered under:

  • src/nir/morph/codegen/ — the codegen tool and emitters that turn manifest graphs into generated outputs
  • src/nir/morph/MorphManifest.* and src/nir/morph/MorphPipeline.cpp — manifest loading + plugin library load/registration logic
  • morphs/<Package>/plugin/*MorphLibrary.cpp — each package’s exported MorphlangMorphLibrary descriptor and C entry

The codegen entry binary is src/nir/morph/codegen/Main.cpp (accepts --source-root, --domain, and multiple --*-out outputs). The plugin loader expects packages to export the canonical symbol name MORPHLANG_MORPH_LIBRARY_ENTRY (see MorphPipeline.cpp).


Factory Macros And Public Surfaces

Some public framework headers expose factory macros for package authors.

Examples include macros for:

  • execution artifacts
  • execution engines
  • build pipelines

These exist so package-owned code can register concrete implementations through a stable public surface.


What Package Authors Should Expect

A feature usually needs all three layers:

  1. manifest declaration
  2. package-owned implementation
  3. generated or framework-recognized registration glue

If one layer is missing, ownership becomes fragile.


What Not To Do

Do not replace generated glue with:

  • handwritten global registration tables in core
  • random manual build wiring outside package manifests
  • one-off package export hacks that bypass the normal flow

If generated glue is too limited, widen the generator or public SDK surface.


Generated Glue Rule

Treat generated glue as part of the package system, not as a place to avoid the package system.

It exists to preserve explicit ownership, not to hide it.


Next Steps