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
Recommended Workflow
- Find the owning package.
- Find the closest existing feature folder.
- Decide whether to extend that feature or add a sibling feature folder.
- Add or update
feature.toml. - Add implementation files under the package.
- 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
Assertfeature - 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
Buildif 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
- Creating New Packages - when extension is no longer the right move
- Scripting And Code Layout - where package implementation files should live
- Runtime and Backend Ownership - keeping deeper layers package-owned