fix(features): withhold feature inputs switched off by FEATURE_OVERRIDES (Q-6.9-5)
createRuntimeAdapters computed activeFeatureIds and then composed feature inputs for every installed feature, so a feature disabled by the kill switch still got its API from application.features.get(); only the router honoured the switch. createInstalledFeatureInputs now takes the active ids (optional; the default stays "every installed feature" for callers without runtime config) and the runtime passes them. Verified: tests/unit/runtime-adapters.test.ts — disabled feature has no features.has/get (RED before: has() was true); every installed feature still resolves when nothing is switched off. All gates pass except the known tests/unit/removal-fixture.test.ts (artifacts/ absent). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a328776bf2
commit
76de74a0fa
@@ -561,7 +561,9 @@ export async function createRuntimeAdapters(
|
||||
http: contractOperations,
|
||||
telemetry: featureTelemetry,
|
||||
});
|
||||
const featureInputs = createInstalledFeatureInputs(featureCapabilities);
|
||||
const featureInputs = createInstalledFeatureInputs(featureCapabilities, [
|
||||
...activeFeatureIds,
|
||||
]);
|
||||
|
||||
return Object.freeze({
|
||||
outputPorts: Object.freeze({
|
||||
|
||||
@@ -16,13 +16,22 @@ type InstalledFeatureCapabilityContext = ContributionsCapabilityContext<
|
||||
/**
|
||||
* Adapter installation is a projection of feature-owned descriptors. Adding a
|
||||
* feature changes its descriptor and the generated index, not this composer.
|
||||
*
|
||||
* Q-6.9-5. The runtime composer passes `activeFeatureIds` (installed minus
|
||||
* `FEATURE_OVERRIDES`). A feature switched off there gets no input, so
|
||||
* `application.features.get()` cannot hand out its API; the router was the
|
||||
* only place that honoured the switch before. The default (every installed
|
||||
* feature) is for callers that have no runtime configuration.
|
||||
*/
|
||||
export function createInstalledFeatureInputs(
|
||||
context: InstalledFeatureCapabilityContext,
|
||||
activeFeatureIds: readonly string[] = INSTALLED_PRODUCT_FEATURE_MODULES.map(
|
||||
(module) => module.id,
|
||||
),
|
||||
): InstalledFeatureInputs {
|
||||
return composeFeatureAdapterInputs(
|
||||
INSTALLED_FEATURE_ADAPTER_CONTRIBUTIONS,
|
||||
INSTALLED_PRODUCT_FEATURE_MODULES.map((module) => module.id),
|
||||
activeFeatureIds,
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import {
|
||||
createRuntimeHttpClient,
|
||||
} from "../../src/bootstrap/runtime-adapters.ts";
|
||||
import { createBrowserMutationIntentFactory } from "../../src/adapters/platform/browser-mutation-intent-factory.ts";
|
||||
import { createApplication } from "../../src/application/create-application.ts";
|
||||
import type { ApplicationFeatureId } from "../../src/application/ports/in/application-api.ts";
|
||||
import { INSTALLED_PRODUCT_FEATURE_IDS } from "../../src/features/installed-product-manifest.ts";
|
||||
import { TEST_HTTP_CONTRACT } from "../helpers/http-contract-fixture.ts";
|
||||
|
||||
type Runtime = Parameters<typeof createRuntimeAdapters>[0]["runtime"];
|
||||
@@ -278,6 +281,51 @@ describe("runtime adapter composition", () => {
|
||||
expect(serviceWorker?.active).toBe(0);
|
||||
});
|
||||
|
||||
it("gives a feature switched off by FEATURE_OVERRIDES no application API (Q-6.9-5)", async () => {
|
||||
const [disabledId, ...activeIds] = INSTALLED_PRODUCT_FEATURE_IDS;
|
||||
const adapters = await createRuntimeAdapters({
|
||||
runtime: {
|
||||
...runtime,
|
||||
config: {
|
||||
...runtime.config,
|
||||
FEATURE_OVERRIDES: { [disabledId!]: "DISABLED" },
|
||||
},
|
||||
},
|
||||
release,
|
||||
host: {},
|
||||
});
|
||||
const application = createApplication(
|
||||
adapters.outputPorts,
|
||||
adapters.featureInputs,
|
||||
);
|
||||
|
||||
expect(adapters.outputPorts.productFeatures.isActive(disabledId!)).toBe(false);
|
||||
expect(application.features.has(disabledId!)).toBe(false);
|
||||
expect(() =>
|
||||
application.features.get(disabledId as ApplicationFeatureId),
|
||||
).toThrow(/not installed/u);
|
||||
for (const featureId of activeIds) {
|
||||
expect(application.features.has(featureId)).toBe(true);
|
||||
}
|
||||
adapters.infrastructure.dispose();
|
||||
});
|
||||
|
||||
it("still resolves every installed feature API when nothing is switched off", async () => {
|
||||
const adapters = await createRuntimeAdapters({ runtime, release, host: {} });
|
||||
const application = createApplication(
|
||||
adapters.outputPorts,
|
||||
adapters.featureInputs,
|
||||
);
|
||||
|
||||
for (const featureId of INSTALLED_PRODUCT_FEATURE_IDS) {
|
||||
expect(application.features.has(featureId)).toBe(true);
|
||||
expect(
|
||||
application.features.get(featureId as ApplicationFeatureId),
|
||||
).toBeDefined();
|
||||
}
|
||||
adapters.infrastructure.dispose();
|
||||
});
|
||||
|
||||
it("states contract identity as a digest for a V2 release manifest", async () => {
|
||||
const adapters = await createRuntimeAdapters({ runtime, release, host: {} });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user