Skip to main content

Extending Existing Packages

Most Morph work starts by extending an existing package.


When To Extend

Extend an existing package when the new capability clearly belongs to that package's domain.

Examples:

  • a tensor operation belongs in Tensor
  • a new assertion belongs in Test
  • a new provider for shader behavior belongs in Shader

  1. Find the owning package.
  2. Find the closest existing feature folder.
  3. Decide whether to extend that feature or add a sibling feature folder.
  4. Add or update feature.toml.
  5. Add implementation files under the package.
  6. Add or update package tests.

Example: Add A New Assertion

If you want a new assertion:

  • do not patch core parser or runtime files
  • go to morphs/Test
  • update or extend the Assert feature
  • keep syntax, sema, lowering, and runtime ownership inside Test

That keeps the feature local to the package that already owns testing behavior.


Example: Add A New Build Provider

If you want a new platform-specific build target:

  • do not patch core build routing directly
  • extend Build if the generic build host needs a new capability
  • add or extend the platform package that owns the target-specific policy

Generic orchestration and concrete target ownership stay separated.


When To Stop Extending

Do not keep extending a package once the new feature stops fitting its domain.

If you feel forced to explain a feature with "this is unrelated, but we put it here anyway," that usually means a new package should exist.


Next Steps