# Compose features with explicit dependencies

Connect capabilities, operations and provider ports without hiding what a feature needs to execute.

Source context: Source-guided
Source: https://github.com/lssm-tech/contractspec/blob/d58fa5b7de53a947811e5cc68346be028ce18528/packages/platform/ui/surface-runtime/src/feature-hubs/effects.ts

## Treat a feature as a set of declared dependencies

A larger feature often combines operations, policy decisions, UI surfaces and external services. Feature Hubs provide a way to make those relationships inspectable rather than burying them in application startup code.

Begin with the capability you need and list its operation references and required ports. Choose only the composition your product uses; a catalogue entry is not a reason to install the entire ecosystem.

## Follow the effect gate

The inspected effect invoker first requires an active installation. It checks that the capability declares the operation and port, that a policy is bound to that operation, and that the actor has the required capability.

It then resolves the port and evaluates the policy. Where policy obligations exist, the host must fulfill them and provide evidence before the effect callback runs.

| Missing condition | Expected boundary | What to inspect |
| --- | --- | --- |
| Declared capability or operation | Invocation is rejected | Installed manifest and versioned refs |
| Provider port | Invocation cannot proceed | Host port bindings |
| Allowed policy decision | Effect remains denied | Policy input and evaluator |
| Obligation evidence | Effect remains denied | Host fulfillment and durable evidence |

## Bind providers at the host

A port is the place where your concrete implementation enters the composition. It might represent storage, a queue, a provider client or another application service. Keep its lifecycle and credentials in the host.

Provider replacement is therefore an integration task: the new implementation must satisfy the expected behavior, not merely share a method name. Test the failure and recovery paths that the feature depends on.

## Qualify the composition you actually deploy

Start with deterministic fixture ports and verify the declared dependencies and denial behavior. Then qualify the selected providers in the intended environment. Record what was fixture-backed and what was exercised against a real service.

A local all-in-one example demonstrates composition. It does not by itself establish that every provider, tenant configuration or production deployment has been verified.

## Related examples

- [Compose nine feature hubs](https://lssm.co/examples/feature-hub-composition/): Inspect one application composition with matching semantic routes for web and native.

