fix(features): check declared needs and show the IndexedDB capability assembly (09-05)

A missing capability reached the feature factory as an anonymous TypeError.
The composer now names the feature and the capability, and the IndexedDB
provider example moves from a browser spec into an opt-in recipe with a test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-25 22:14:11 +09:00
co-authored by Claude Opus 5.5
parent 30cf71b249
commit bc7c46b2d5
7 changed files with 246 additions and 0 deletions
@@ -174,6 +174,20 @@ export function composeFeatureAdapterInputs<
}
seen.add(contribution.featureId);
if (!enabled.has(contribution.featureId)) continue;
// 09-05. The context type already asks for every declared need, but a
// host that widens it (or JavaScript) used to reach the feature's factory
// and fail there as an anonymous TypeError.
const provided = context as Readonly<
Partial<Record<FeaturePlatformCapabilityId, unknown>>
>;
const missing = contribution.needs.find(
(need) => provided[need] === undefined,
);
if (missing !== undefined) {
throw new TypeError(
`feature ${contribution.featureId} needs ${missing}, which the host did not provide`,
);
}
const installed = invokeContribution(
contribution as unknown as FeatureAdapterContribution<