feat: make product features a declared selection with a runtime kill switch

Which features a build contains was not a decision anybody could express. The
reference feature was spread directly into the route, API, schema, codec and
adapter registries, so shipping without it meant editing five files by hand and
hoping nothing still referred to it — and there was no way at all to take it out
of service on a running deployment. The removability gate proved the editing
worked; nothing made it a choice.

There is now one manifest. `VITE_PRODUCT_FEATURES` narrows it at build time and
`FEATURE_OVERRIDES` in the runtime document takes an installed feature out of
service without a rebuild. Every registry composes from the manifest, and a test
fails if a new one forgets to.

Both inputs are subtractive, and the vocabulary is what enforces it rather than
a check somewhere downstream: the override enum has no `ENABLED`, and a
build-time selection naming something the source tree does not declare is
refused instead of ignored. A configuration document that could name a feature
into existence would be a configuration document choosing which code runs.

Disabling is not just hiding. Withdrawing a route from navigation would leave a
typed deep link that still mounts the feature, so the router refuses it too and
answers with a surface that says the deployment switched it off. The platform
overview now distinguishes the three states an operator actually needs: serving,
switched off, and not in this build.

What this is not: an env var does not shrink the bundle. A static import cannot
be undone by a value, and making the import graph itself depend on a
configuration string is the thing §3.5 exists to prevent — measured, `none`
changes the output by 58 bytes. Physical removal remains FE-GATE-020's job, and
the code comments say so rather than implying otherwise.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-08-15 20:45:19 +09:00
co-authored by Claude Opus 5
parent 0a97d235e4
commit 711d61e73f
36 changed files with 875 additions and 26 deletions
+3
View File
@@ -12,5 +12,8 @@
"WEB_WORKER": "DEFAULT",
"SERVICE_WORKER": "DEFAULT",
"OFFLINE_COMMANDS": "DEFAULT"
},
"FEATURE_OVERRIDES": {
"reference-feature": "DEFAULT"
}
}
+3
View File
@@ -12,5 +12,8 @@
"WEB_WORKER": "DEFAULT",
"SERVICE_WORKER": "DEFAULT",
"OFFLINE_COMMANDS": "DEFAULT"
},
"FEATURE_OVERRIDES": {
"reference-feature": "DEFAULT"
}
}
+3
View File
@@ -13,5 +13,8 @@
"WEB_WORKER": "DEFAULT",
"SERVICE_WORKER": "DEFAULT",
"OFFLINE_COMMANDS": "DEFAULT"
},
"FEATURE_OVERRIDES": {
"reference-feature": "DEFAULT"
}
}
+3
View File
@@ -13,5 +13,8 @@
"WEB_WORKER": "DEFAULT",
"SERVICE_WORKER": "DEFAULT",
"OFFLINE_COMMANDS": "DEFAULT"
},
"FEATURE_OVERRIDES": {
"reference-feature": "DEFAULT"
}
}
+3
View File
@@ -14,5 +14,8 @@
"WEB_WORKER": "DEFAULT",
"SERVICE_WORKER": "DEFAULT",
"OFFLINE_COMMANDS": "DEFAULT"
},
"FEATURE_OVERRIDES": {
"reference-feature": "DEFAULT"
}
}
+6
View File
@@ -102,6 +102,12 @@ export function createApplication(
getCapabilitySnapshot() {
return outputPorts.runtimeCapabilities.getSnapshot();
},
getFeatureSnapshot() {
return outputPorts.productFeatures.getSnapshot();
},
isFeatureActive(featureId: string) {
return outputPorts.productFeatures.isActive(featureId);
},
});
const recovery = Object.freeze({
@@ -1,8 +1,10 @@
import type { SessionState } from "../auth-session-port.ts";
import type { ProductFeatureStatus } from "../product-features-port.ts";
import type { RuntimeCapabilitySnapshot } from "../runtime-capabilities-port.ts";
import type { StoragePort } from "../storage-port.ts";
export type { SessionState } from "../auth-session-port.ts";
export type { ProductFeatureStatus };
export type { RuntimeCapabilitySnapshot };
/**
@@ -64,6 +66,13 @@ export type ApplicationApi = Readonly<{
* reads capability state here instead of importing the composition root.
*/
getCapabilitySnapshot(): RuntimeCapabilitySnapshot;
/**
* §3.5. Which product features this build contains and which of them the
* runtime document switched off. Presentation reads state here; it never
* learns how to reach a feature the build left out.
*/
getFeatureSnapshot(): readonly ProductFeatureStatus[];
isFeatureActive(featureId: string): boolean;
}>;
recovery: Readonly<{
recoverChunk(input: Readonly<{
@@ -1,5 +1,6 @@
import type { AuthSessionPort } from "../auth-session-port.ts";
import type { ReleaseInfoPort } from "../release-info-port.ts";
import type { ProductFeaturesPort } from "../product-features-port.ts";
import type { RuntimeCapabilitiesPort } from "../runtime-capabilities-port.ts";
import type { StoragePort } from "../storage-port.ts";
import type { TelemetryPort } from "../telemetry-port.ts";
@@ -19,5 +20,6 @@ export type ApplicationOutputPorts = Readonly<{
telemetry: TelemetryPort;
releaseInfo: ReleaseInfoPort;
runtimeCapabilities: RuntimeCapabilitiesPort;
productFeatures: ProductFeaturesPort;
navigation: Readonly<{ reload(): void }>;
}>;
@@ -0,0 +1,16 @@
import type { ProductFeatureStatus } from "../../contracts/product-features.ts";
export type { ProductFeatureStatus };
/**
* §3.5. The application reads feature state; it never resolves it.
*
* Only the composition root knows both halves of the answer — what the build
* compiled in and what the runtime document disabled — so the snapshot arrives
* here already reduced to ids and states. It carries no feature module, so
* reading it cannot become a way to reach code the build left out.
*/
export type ProductFeaturesPort = Readonly<{
getSnapshot(): readonly ProductFeatureStatus[];
isActive(featureId: string): boolean;
}>;
+30
View File
@@ -41,6 +41,14 @@ import {
INVALIDATION_TOPIC_VERSIONS,
} from "../features/installed-feature-contracts.ts";
import { INSTALLED_RUNTIME_CAPABILITIES } from "../features/installed-runtime-capabilities.ts";
import {
COMPILED_PRODUCT_FEATURE_IDS,
INSTALLED_PRODUCT_FEATURE_IDS,
} from "../features/installed-product-manifest.ts";
import {
activeProductFeatureIds,
resolveProductFeatures,
} from "../contracts/product-features.ts";
import { describeRuntimeCapabilities } from "../contracts/runtime-capabilities.ts";
import {
fetchReleaseManifest,
@@ -382,6 +390,27 @@ export async function createRuntimeAdapters(
);
},
});
/**
* §3.5. The two halves of the feature answer meet here and nowhere else: the
* manifest says what the build compiled in, the runtime document says what is
* switched off. Neither can add to the other.
*/
const productFeatureStatuses = resolveProductFeatures(
COMPILED_PRODUCT_FEATURE_IDS,
INSTALLED_PRODUCT_FEATURE_IDS,
config.FEATURE_OVERRIDES,
);
const activeFeatureIds = new Set(
activeProductFeatureIds(productFeatureStatuses),
);
const productFeatures = Object.freeze({
getSnapshot() {
return productFeatureStatuses;
},
isActive(featureId: string) {
return activeFeatureIds.has(featureId);
},
});
const navigation = Object.freeze({
reload() {
const location = host.location;
@@ -486,6 +515,7 @@ export async function createRuntimeAdapters(
telemetry,
releaseInfo,
runtimeCapabilities,
productFeatures,
navigation,
}),
infrastructure: Object.freeze({
+10
View File
@@ -1,3 +1,4 @@
import type { ProductFeatureOverrideMap } from "../contracts/product-features.ts";
import {
runtimeConfigV1ArtifactSchema,
runtimeConfigV2ArtifactSchema,
@@ -44,6 +45,11 @@ export type RuntimeConfig = Readonly<{
RELEASE_ID?: string;
BUILD_ID?: string;
CAPABILITY_OVERRIDES: CapabilityOverrides;
/**
* §3.5. Runtime kill switch per installed feature. Subtractive only: a
* feature the build did not install cannot be named into existence here.
*/
FEATURE_OVERRIDES: ProductFeatureOverrideMap;
/** Present only while a V1 document is still accepted. */
LEGACY_API_CONTRACT_VERSION?: string;
}>;
@@ -122,6 +128,10 @@ export function validateRuntimeConfig(value: unknown): RuntimeConfigValidation {
? (parsed as RuntimeConfigV2).CAPABILITY_OVERRIDES
: DEFAULT_OVERRIDES),
}),
// A V1 document predates feature overrides, so it disables nothing.
FEATURE_OVERRIDES: Object.freeze({
...(isV2 ? (parsed as RuntimeConfigV2).FEATURE_OVERRIDES : {}),
}),
...(isV2
? {}
: {
+5
View File
@@ -47,6 +47,11 @@ export const ENV_REGISTRY = Object.freeze({
RELEASE_MANIFEST_URL: runtime("public", true, "/release-manifest.json"),
// §3.5: overrides may only disable an installed capability, never enable one.
CAPABILITY_OVERRIDES: runtime("public", false, null),
// §3.5: likewise for features — subtractive, keyed by installed feature id.
FEATURE_OVERRIDES: runtime("public", false, null),
// §3.5: build-time narrowing of the product manifest. A feature left out
// here is not imported by any registry and never reaches the bundle.
VITE_PRODUCT_FEATURES: build("compile-time", false, null),
});
function build(
+143
View File
@@ -0,0 +1,143 @@
/**
* §3.5 / §6.1. Which product features this build contains, and which of them a
* deployment is allowed to switch off.
*
* Two different questions, deliberately answered by two different inputs:
*
* - **Installed** is a build-time decision. `VITE_PRODUCT_FEATURES` selects
* from the features this source tree declares; a feature left out contributes
* no route, no operation, no schema, no codec and no adapter, so nothing can
* reach it. It does *not* shrink the bundle: a static import cannot be undone
* by a value, and building the import graph from a configuration string is
* exactly what §3.5 forbids. Physical removal is FE-GATE-020's job — delete
* the feature directory and rebuild, which that gate proves still works.
* - **Active** is a runtime decision. `FEATURE_OVERRIDES` in the runtime config
* may take an installed feature out of service without a rebuild.
*
* Both directions are subtractive, and that is the invariant this module
* exists to hold: neither input can ever turn on a feature whose source is
* absent. A configuration document that could name a feature into existence
* would be a configuration document that chooses which code runs, and no
* dynamic import path is ever built from one.
*/
export type ProductFeatureOverride = "DEFAULT" | "DISABLED";
export type ProductFeatureState =
/** Compiled in and not disabled: the feature serves traffic. */
| "ACTIVE"
/** Compiled in, switched off by the runtime document. */
| "DISABLED_BY_CONFIG"
/** Not selected at build time; not in the bundle. */
| "NOT_INSTALLED";
export type ProductFeatureOverrideMap = Readonly<
Record<string, ProductFeatureOverride>
>;
export type ProductFeatureStatus = Readonly<{
featureId: string;
state: ProductFeatureState;
}>;
/** The shape every feature contract exposes to the manifest. */
export type SelectableProductFeature = Readonly<{ featureId: string }>;
/**
* The explicit "no product features" selection.
*
* A blank value cannot mean it: an unset CI variable expands to a blank string
* far too easily, and a build that silently shipped no features would be a very
* expensive way to learn that. Selecting nothing has to be something you typed.
*/
export const NO_PRODUCT_FEATURES = "none";
/**
* Applies the build-time selection to the features this source tree declares.
*
* An empty or absent declaration keeps everything, so an ordinary build needs
* no environment at all. A declaration naming something that is not compiled is
* refused rather than ignored: silently accepting it would let a deployment
* believe it had enabled a feature that does not exist.
*/
export function selectCompiledProductFeatures<
Feature extends SelectableProductFeature,
>(
compiled: readonly Feature[],
declared: string | undefined,
): readonly Feature[] {
const compiledIds = compiled.map((feature) => feature.featureId);
assertUniqueFeatureIds(compiledIds);
if (declared === undefined || declared.trim() === "") {
return Object.freeze([...compiled]);
}
if (declared.trim() === NO_PRODUCT_FEATURES) return Object.freeze([]);
const requested = declared
.split(",")
.map((entry) => entry.trim())
.filter((entry) => entry.length > 0);
if (requested.length === 0) {
throw new Error(
`VITE_PRODUCT_FEATURES is set to ${JSON.stringify(declared)}, which names ` +
`no feature. Use "${NO_PRODUCT_FEATURES}" to select none, or leave it ` +
`unset to keep ${compiledIds.join(", ")}.`,
);
}
const unknown = requested.filter((id) => !compiledIds.includes(id));
if (unknown.length > 0) {
throw new Error(
`VITE_PRODUCT_FEATURES names features this build does not contain: ${unknown.join(
", ",
)}. Selection can only remove from ${compiledIds.join(", ")}.`,
);
}
return Object.freeze(
compiled.filter((feature) => requested.includes(feature.featureId)),
);
}
/**
* The state of every feature the source tree declares, given what was compiled
* and what the runtime document says.
*
* `compiledIds` is the full declared set rather than the installed one so a
* build that dropped a feature still reports it as `NOT_INSTALLED` instead of
* omitting it. An operator looking at the platform overview needs to see the
* difference between "off" and "never heard of it".
*/
export function resolveProductFeatures(
compiledIds: readonly string[],
installedIds: readonly string[],
overrides: ProductFeatureOverrideMap = {},
): readonly ProductFeatureStatus[] {
assertUniqueFeatureIds(compiledIds);
return Object.freeze(
[...compiledIds].sort().map((featureId) =>
Object.freeze({
featureId,
state: !installedIds.includes(featureId)
? ("NOT_INSTALLED" as const)
: overrides[featureId] === "DISABLED"
? ("DISABLED_BY_CONFIG" as const)
: ("ACTIVE" as const),
}),
),
);
}
/** The feature ids serving traffic right now. */
export function activeProductFeatureIds(
statuses: readonly ProductFeatureStatus[],
): readonly string[] {
return Object.freeze(
statuses
.filter((status) => status.state === "ACTIVE")
.map((status) => status.featureId),
);
}
function assertUniqueFeatureIds(ids: readonly string[]): void {
if (new Set(ids).size !== ids.length) {
throw new Error(`duplicate product feature id: ${ids.join(", ")}`);
}
}
+18
View File
@@ -52,6 +52,23 @@ export const capabilityOverrideArtifactSchema = z
OFFLINE_COMMANDS: "DEFAULT",
});
/**
* §3.5 / §6.1. A runtime switch that can take an installed feature out of
* service without a rebuild.
*
* Values are `DEFAULT | DISABLED` for the same reason `CAPABILITY_OVERRIDES`
* is: a configuration document may subtract from what the build installed and
* may never add to it. Keys are feature ids; naming a feature this build does
* not contain is inert rather than an error, so a shared configuration
* document can cover several builds.
*/
export const featureOverrideArtifactSchema = z
.record(
z.string().regex(/^[a-z][a-z0-9-]{0,63}$/u, "feature id is invalid"),
z.enum(["DEFAULT", "DISABLED"]),
)
.default({});
type RuntimeConfigArtifactDraft = Readonly<{
APP_ENV: "local" | "development" | "staging" | "production";
API_BASE_URL: string;
@@ -138,6 +155,7 @@ export const runtimeConfigV2ArtifactSchema = z
...runtimeConfigArtifactFields,
CONFIG_SCHEMA_VERSION: z.literal("2.0"),
CAPABILITY_OVERRIDES: capabilityOverrideArtifactSchema,
FEATURE_OVERRIDES: featureOverrideArtifactSchema,
})
.strict()
.superRefine(runtimeConfigArtifactInvariants);
@@ -4,6 +4,8 @@ import {
type InstalledContractPackageIdentity,
} from "../contracts/external-contract-runtime.ts";
import { REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION } from "./reference-feature/contracts/reference-feature-contract-contribution.ts";
import { REFERENCE_FEATURE_ID } from "./reference-feature/contracts/reference-feature-contract.ts";
import { INSTALLED_PRODUCT_FEATURE_IDS } from "./installed-product-manifest.ts";
/**
* §4.8. Static contract selection SSOT.
@@ -13,7 +15,11 @@ import { REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION } from "./reference-feature/con
* `src/features/<feature>/contracts/<service>-contract-contribution.ts`.
*/
export const INSTALLED_CONTRACT_CONTRIBUTIONS: readonly InstalledContractContribution[] =
Object.freeze([REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION]);
Object.freeze(
INSTALLED_PRODUCT_FEATURE_IDS.includes(REFERENCE_FEATURE_ID)
? [REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION]
: [],
);
export const COMPOSED_CONTRACT_CONTRIBUTIONS = composeContractContributions(
INSTALLED_CONTRACT_CONTRIBUTIONS,
+10 -1
View File
@@ -1,14 +1,23 @@
import type { ApplicationFeatureInputs } from "../application/ports/in/application-api.ts";
import { createReferenceFeatureInstalledInput } from "./reference-feature/adapters/create-reference-feature-input.ts";
import { REFERENCE_FEATURE_ID } from "./reference-feature/contracts/reference-feature-contract.ts";
import { INSTALLED_PRODUCT_FEATURE_IDS } from "./installed-product-manifest.ts";
/**
* §3.5. Partial on purpose: a feature the manifest did not select supplies no
* driving input, so consumers have to narrow before calling one. A total type
* here would let feature code compile against an input that is not there.
*/
type InstalledFeatureInputs = Readonly<
Pick<ApplicationFeatureInputs, typeof REFERENCE_FEATURE_ID>
Partial<Pick<ApplicationFeatureInputs, typeof REFERENCE_FEATURE_ID>>
>;
export function createInstalledFeatureInputs(
context: Parameters<typeof createReferenceFeatureInstalledInput>[0],
): InstalledFeatureInputs {
if (!INSTALLED_PRODUCT_FEATURE_IDS.includes(REFERENCE_FEATURE_ID)) {
return Object.freeze({});
}
const referenceFeature = createReferenceFeatureInstalledInput(context);
return Object.freeze({
[referenceFeature.featureId]: referenceFeature.input,
+41 -12
View File
@@ -4,7 +4,9 @@ import {
composeSchemaRegistry,
PLATFORM_SCHEMA_REGISTRY,
} from "../contracts/schema-registry.ts";
import { REFERENCE_FEATURE_CONTRACT } from "./reference-feature/contracts/reference-feature-contract.ts";
import {
INSTALLED_PRODUCT_FEATURES,
} from "./installed-product-manifest.ts";
import {
composeApiOperations,
validateApiRuntimeBindings,
@@ -13,18 +15,27 @@ import { validateRestProfileBindings } from "../contracts/rest-profiles.ts";
import { composeRuntimeSchemaCodecs } from "../contracts/schema-registry.ts";
import { composeBoundaryMapperRegistry } from "../contracts/boundary-mapper.ts";
export const INSTALLED_FEATURE_CONTRACTS = Object.freeze([
REFERENCE_FEATURE_CONTRACT,
]);
/**
* §3.5. Composed from the product manifest rather than from a literal list, so
* a feature the build did not select contributes no routes, no operations, no
* schemas and no messages — and is therefore not reachable from any registry.
*/
export const INSTALLED_FEATURE_CONTRACTS = INSTALLED_PRODUCT_FEATURES;
export const ROUTE_REGISTRY = Object.freeze({
...PLATFORM_ROUTE_REGISTRY,
...REFERENCE_FEATURE_CONTRACT.routes,
});
export const ROUTE_RUNTIME_CONTRACT = Object.freeze({
...PLATFORM_ROUTE_RUNTIME_CONTRACT,
...REFERENCE_FEATURE_CONTRACT.routeRuntimeContracts,
});
export const ROUTE_REGISTRY = Object.freeze(
INSTALLED_FEATURE_CONTRACTS.reduce(
(registry, contract) => ({ ...registry, ...contract.routes }),
{ ...PLATFORM_ROUTE_REGISTRY },
),
) as typeof PLATFORM_ROUTE_REGISTRY &
(typeof INSTALLED_PRODUCT_FEATURES)[number]["routes"];
export const ROUTE_RUNTIME_CONTRACT = Object.freeze(
INSTALLED_FEATURE_CONTRACTS.reduce(
(registry, contract) => ({ ...registry, ...contract.routeRuntimeContracts }),
{ ...PLATFORM_ROUTE_RUNTIME_CONTRACT },
),
) as typeof PLATFORM_ROUTE_RUNTIME_CONTRACT &
(typeof INSTALLED_PRODUCT_FEATURES)[number]["routeRuntimeContracts"];
export const API_OPERATIONS = composeApiOperations(
INSTALLED_FEATURE_CONTRACTS.map((contract) => contract.apiOperations),
);
@@ -69,6 +80,24 @@ export const API_RUNTIME_BINDINGS_VALID = validateApiRuntimeBindings(
MAPPER_REGISTRY,
);
/**
* §3.5. Which feature owns each route.
*
* A route contributed by a feature disappears with it at build time, and has to
* be withdrawn from navigation and from the router when the runtime document
* disables that feature. Platform routes have no owner and are always present.
*/
export const ROUTE_FEATURE_OWNER: Readonly<Record<string, string>> =
Object.freeze(
Object.fromEntries(
INSTALLED_FEATURE_CONTRACTS.flatMap((contract) =>
Object.keys(contract.routes).map(
(routeId) => [routeId, contract.featureId] as const,
),
),
),
);
export const NAVIGATION_ROUTES = Object.freeze(
Object.values(ROUTE_REGISTRY)
.filter(isNavigableRoute)
+8 -2
View File
@@ -1,10 +1,16 @@
import { REFERENCE_MESSAGE_CATALOGS } from "./reference-feature/contracts/reference-message-catalog.ts";
/**
* §3.5. Messages are deliberately *not* gated on the manifest. The catalog's
* key type is what makes `message()` total, so dropping keys would turn every
* lookup partial for the sake of a few unreachable strings.
*/
const reference = REFERENCE_MESSAGE_CATALOGS;
export const INSTALLED_MESSAGE_CATALOGS = Object.freeze({
"ko-KR": Object.freeze({
...REFERENCE_MESSAGE_CATALOGS["ko-KR"],
...reference["ko-KR"],
}),
"en-US": Object.freeze({
...REFERENCE_MESSAGE_CATALOGS["en-US"],
...reference["en-US"],
}),
} as const);
+14 -2
View File
@@ -4,13 +4,25 @@ import {
REFERENCE_FEATURE_ROUTE_CODECS,
REFERENCE_FEATURE_ROUTE_RUNTIME,
} from "./reference-feature/presentation/reference-feature-runtime.tsx";
import { REFERENCE_FEATURE_ID } from "./reference-feature/contracts/reference-feature-contract.ts";
import { INSTALLED_PRODUCT_FEATURE_IDS } from "./installed-product-manifest.ts";
/**
* §3.5. A feature the manifest did not select contributes no codec and no route
* component, so the router has nothing to mount for it. The module is still
* linked — a static import cannot be undone by a value — which is why physical
* removal is FE-GATE-020's job and this is deselection, not deletion.
*/
const referenceSelected = INSTALLED_PRODUCT_FEATURE_IDS.includes(
REFERENCE_FEATURE_ID,
);
export const ROUTE_CODECS = Object.freeze({
...PLATFORM_ROUTE_CODECS,
...REFERENCE_FEATURE_ROUTE_CODECS,
...(referenceSelected ? REFERENCE_FEATURE_ROUTE_CODECS : {}),
});
export const ROUTE_RUNTIME = Object.freeze({
...PLATFORM_ROUTE_RUNTIME,
...REFERENCE_FEATURE_ROUTE_RUNTIME,
...(referenceSelected ? REFERENCE_FEATURE_ROUTE_RUNTIME : {}),
});
@@ -0,0 +1,63 @@
import {
selectCompiledProductFeatures,
type SelectableProductFeature,
} from "../contracts/product-features.ts";
import { REFERENCE_FEATURE_CONTRACT } from "./reference-feature/contracts/reference-feature-contract.ts";
/**
* §3.5. The product manifest: the single declaration of which features this
* build contains.
*
* Before this file the reference feature was spread directly into the route,
* API, schema and message registries, so the only way to ship without it was to
* edit five registries by hand and hope nothing still referred to it. The
* removability gate proved that editing worked; nothing made it a decision you
* could express.
*
* Adding an entry here is what installs a feature. `VITE_PRODUCT_FEATURES` may
* then narrow the list at build time — a comma-separated subset, `none` for an
* empty selection, absent meaning "all of them". A narrowed-out feature reaches
* no registry, so it is not routed, not navigable and not callable.
*
* It is not deleted. The import above is static, and a value cannot undo a
* static import; making the import itself conditional on configuration is the
* thing §3.5 exists to prevent. FE-GATE-020 is what proves the feature can be
* physically removed, by removing it and rebuilding the whole project.
*/
const COMPILED_PRODUCT_FEATURES = Object.freeze([
REFERENCE_FEATURE_CONTRACT,
] as const);
/**
* Every feature this source tree declares, selected or not. The platform
* overview reports on this set so an operator can tell a feature that was built
* out from one that never existed.
*/
export const COMPILED_PRODUCT_FEATURE_IDS: readonly string[] = Object.freeze(
COMPILED_PRODUCT_FEATURES.map((feature) => feature.featureId),
);
/**
* `import.meta.env` exists in a Vite build and not under Node, and this module
* is read by release scripts as well as by the app. A missing environment means
* "nothing was narrowed", which is the same answer a plain developer build
* gives.
*/
function declaredFeatureSelection(): string | undefined {
const environment = (
import.meta as unknown as {
env?: Readonly<Record<string, string | undefined>>;
}
).env;
return environment?.["VITE_PRODUCT_FEATURES"];
}
export const INSTALLED_PRODUCT_FEATURES = selectCompiledProductFeatures(
COMPILED_PRODUCT_FEATURES as readonly SelectableProductFeature[],
declaredFeatureSelection(),
) as readonly (typeof COMPILED_PRODUCT_FEATURES)[number][];
export const INSTALLED_PRODUCT_FEATURE_IDS: readonly string[] = Object.freeze(
INSTALLED_PRODUCT_FEATURES.map((feature) => feature.featureId),
);
@@ -226,6 +226,30 @@ function capabilityBadge(
return { text: `활성 (${status.active})`, variant: "success" };
}
/**
* §3.5. The three states an operator has to be able to tell apart: shipped and
* serving, shipped and switched off, and not in this build at all.
*/
const FEATURE_BADGE = Object.freeze({
ACTIVE: Object.freeze({
variant: "success" as const,
text: "사용 중",
description: "이 빌드에 설치되어 있고 런타임 설정이 끄지 않았습니다.",
}),
DISABLED_BY_CONFIG: Object.freeze({
variant: "warning" as const,
text: "설정으로 중지",
description:
"이 빌드에 포함되어 있으나 런타임 설정이 껐습니다. 재빌드 없이 다시 켤 수 있습니다.",
}),
NOT_INSTALLED: Object.freeze({
variant: "neutral" as const,
text: "미설치",
description:
"빌드 시 제품 매니페스트가 선택하지 않았습니다. 런타임 설정으로는 켤 수 없습니다.",
}),
});
function buildOperationRows(): readonly OperationRow[] {
return Object.freeze(
[...COMPOSED_CONTRACT_CONTRIBUTIONS.httpByOperationId.values()].map(
@@ -273,6 +297,7 @@ export default function PlatformOverviewPage() {
const routes = Object.values(ROUTE_REGISTRY);
const operations = buildOperationRows();
const capabilities = runtime.getCapabilitySnapshot();
const features = runtime.getFeatureSnapshot();
const activeCapabilityCount = capabilities.filter(
(status) => status.active > 0,
).length;
@@ -479,6 +504,37 @@ export default function PlatformOverviewPage() {
})}
</div>
</section>
<section
className="gallery-section"
aria-labelledby="platform-features-title"
>
<header className="gallery-section__header">
<h2 id="platform-features-title"> </h2>
<p>
,
.
.
.
</p>
</header>
<div className="component-grid component-grid--two">
{features.map((status) => {
const badge = FEATURE_BADGE[status.state];
return (
<Card
key={status.featureId}
title={status.featureId}
footer={<Badge variant={badge.variant}>{badge.text}</Badge>}
>
<p data-product-feature={status.featureId}>
{badge.description}
</p>
</Card>
);
})}
</div>
</section>
</section>
);
}
+8
View File
@@ -79,6 +79,10 @@ const PLATFORM_KO_MESSAGES = {
"route.invalid.title": "올바르지 않은 주소입니다.",
"route.invalid.description": "주소의 경로 또는 검색 조건을 확인해 주세요.",
"route.invalid.action": "안전한 탐색 링크를 사용해 주세요.",
"route.disabledFeature.title": "현재 사용할 수 없는 기능입니다.",
"route.disabledFeature.description":
"이 기능은 배포 설정에서 중지되어 있습니다. 코드에는 포함되어 있으며 운영자가 다시 켤 수 있습니다.",
"route.disabledFeature.action": "다른 탐색 링크를 사용해 주세요.",
"route.auth.integration.title": "로그인 연동이 필요합니다.",
"route.auth.integration.description":
"외부 인증 소유자가 연결되면 이 보호 라우트를 사용할 수 있습니다.",
@@ -233,6 +237,10 @@ const PLATFORM_EN_MESSAGES = {
"route.invalid.title": "This address is invalid.",
"route.invalid.description": "Check the path and search parameters.",
"route.invalid.action": "Use a safe navigation link.",
"route.disabledFeature.title": "This feature is not available right now.",
"route.disabledFeature.description":
"The deployment configuration has switched it off. It is still part of this build and an operator can switch it back on.",
"route.disabledFeature.action": "Use another navigation link.",
"route.auth.integration.title": "Sign-in integration is required.",
"route.auth.integration.description":
"This protected route is available after an external authentication owner is connected.",
+10 -1
View File
@@ -5,6 +5,7 @@ import type { SessionState } from "../../application/ports/in/application-api.ts
import { normalizeColorSchemePreference } from "../../application/policies/color-scheme.ts";
import {
NAVIGATION_ROUTES,
ROUTE_FEATURE_OWNER,
routePath,
} from "../../features/installed-feature-contracts.ts";
import {
@@ -19,6 +20,7 @@ import {
useLocale,
type MessageKey,
} from "../i18n/index.ts";
import { useApplication } from "../providers/application-provider.tsx";
import { useSession } from "../providers/session-provider.tsx";
import { useTheme } from "../providers/theme-provider.tsx";
@@ -166,10 +168,17 @@ export function AppShell() {
function PrimaryNavigation({ id }: Readonly<{ id: string }>) {
const { resolve, message } = useLocale();
const { runtime } = useApplication();
// §3.5. A feature the runtime document disabled does not advertise itself.
// The router refuses its routes too, so this is presentation, not the switch.
const routes = NAVIGATION_ROUTES.filter((definition) => {
const owner = ROUTE_FEATURE_OWNER[definition.routeId];
return owner === undefined || runtime.isFeatureActive(owner);
});
return (
<nav id={id} aria-label={message("shell.primaryNavigation")}>
<ul className="app-navigation">
{NAVIGATION_ROUTES.map((definition) => (
{routes.map((definition) => (
<li key={definition.routeId}>
<NavLink
className={({ isActive }) =>
+34 -2
View File
@@ -18,6 +18,7 @@ import {
import {
getRoute,
ROUTE_FEATURE_OWNER,
ROUTE_REGISTRY,
} from "../../features/installed-feature-contracts.ts";
import type { RouteDefinition } from "../../contracts/routes.ts";
@@ -96,6 +97,26 @@ function InvalidRouteSurface({ code }: { code: string }) {
);
}
/**
* §3.5. A route whose feature the runtime document switched off. It answers as
* "not available" rather than rendering the feature or crashing, so disabling a
* feature is a deployment action and not an outage.
*/
function DisabledFeatureSurface({ featureId }: { featureId: string }) {
const { message } = useLocale();
return (
<section className="ui-page" data-surface="disabled-feature">
<PageHeader
title={message("route.disabledFeature.title")}
description={message("route.disabledFeature.description")}
/>
<p data-disabled-feature={featureId}>
{message("route.disabledFeature.action")}
</p>
</section>
);
}
function RouteLifecycle({
definition,
buildId,
@@ -245,11 +266,22 @@ function RegisteredRoute({
buildId: string;
}) {
const definition = getRoute(routeId);
const runtime = ROUTE_RUNTIME[routeId];
const params = useParams();
const [search] = useSearchParams();
const location = useLocation();
const { diagnostics, recovery } = useApplication();
const { diagnostics, runtime: platformRuntime, recovery } = useApplication();
// §3.5. A feature the runtime document disabled is out of service, not
// merely hidden: withdrawing it from navigation alone would leave a typed
// deep link that still mounts it.
const owner = ROUTE_FEATURE_OWNER[routeId];
if (owner !== undefined && !platformRuntime.isFeatureActive(owner)) {
return <DisabledFeatureSurface featureId={owner} />;
}
// The registry and the runtime table are composed from the same manifest, so
// a route without a component means the two disagree — refuse rather than
// crash the shell.
const runtime = ROUTE_RUNTIME[routeId];
if (!runtime) return <DisabledFeatureSurface featureId={owner ?? routeId} />;
const parsed = parseRouteInput(routeId, params, search);
if (!parsed.success) return <InvalidRouteSurface code={parsed.code} />;
@@ -0,0 +1,83 @@
// @vitest-environment jsdom
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { createAnonymousSessionAdapter } from "../../src/adapters/auth/external-session-adapter.ts";
import { ROUTE_REGISTRY } from "../../src/features/installed-feature-contracts.ts";
import { INSTALLED_PRODUCT_FEATURE_IDS } from "../../src/features/installed-product-manifest.ts";
import { ApplicationProvider } from "../../src/presentation/providers/application-provider.tsx";
import { AppRouter } from "../../src/presentation/routes/app-router.tsx";
import { createTestApplication } from "../helpers/create-test-application.ts";
import { createProductFeaturesStub } from "../helpers/runtime-capabilities-stub.ts";
/**
* §3.5. The runtime kill switch, exercised through the running app rather than
* through the resolver that computes it.
*
* Withdrawing a feature from navigation is not the same as taking it out of
* service: a typed deep link would still mount it. Both halves are asserted
* here, on the same render, so the switch cannot be half-wired.
*/
const FEATURE_ID = INSTALLED_PRODUCT_FEATURE_IDS[0]!;
const FEATURE_ROUTE = ROUTE_REGISTRY.REFERENCE_RESOURCE_LIST;
function renderAt(path: string, disabled: boolean) {
window.history.pushState({}, "", path);
return render(
<ApplicationProvider
application={createTestApplication({
session: createAnonymousSessionAdapter(),
...(disabled
? {
productFeatures: createProductFeaturesStub({
[FEATURE_ID]: "DISABLED_BY_CONFIG",
}),
}
: {}),
})}
>
<AppRouter />
</ApplicationProvider>,
);
}
describe("runtime product feature switch", () => {
it("advertises the feature's route while the feature is active", async () => {
renderAt("/", false);
expect(
await screen.findByRole("link", { name: FEATURE_ROUTE.navigationLabel! }),
).toBeTruthy();
});
it("withdraws the feature's route from navigation when it is disabled", async () => {
renderAt("/", true);
// The shell itself still renders: disabling a feature is not an outage.
expect(await screen.findByRole("navigation")).toBeTruthy();
expect(
screen.queryByRole("link", { name: FEATURE_ROUTE.navigationLabel! }),
).toBeNull();
});
it("takes the feature out of service for a direct deep link", async () => {
renderAt(FEATURE_ROUTE.path, true);
const surface = await screen.findByText(
(_, element) =>
element?.getAttribute("data-disabled-feature") === FEATURE_ID,
{},
{ timeout: 5000 },
);
expect(surface).toBeTruthy();
});
it("serves the same deep link while the feature is active", async () => {
renderAt(FEATURE_ROUTE.path, false);
expect(
screen.queryByText(
(_, element) =>
element?.getAttribute("data-disabled-feature") === FEATURE_ID,
),
).toBeNull();
});
});
@@ -28,6 +28,7 @@ const runtime: Runtime = {
SERVICE_WORKER: "DEFAULT",
OFFLINE_COMMANDS: "DEFAULT",
},
FEATURE_OVERRIDES: {},
},
configSchema: "V2",
build: {
@@ -83,6 +84,23 @@ function referenceBoundQueryKey() {
).queryKey;
}
/**
* The installed feature inputs are partial by design: a feature the product
* manifest did not select supplies none. This suite is about the reference
* feature being composed, so it asserts that first and narrows once.
*/
function referenceInput<
Inputs extends Readonly<Partial<Record<typeof REFERENCE_FEATURE_ID, unknown>>>,
>(adapters: Readonly<{ featureInputs: Inputs }>) {
const input = adapters.featureInputs[REFERENCE_FEATURE_ID];
if (!input) {
throw new Error(
`${REFERENCE_FEATURE_ID} is not installed; the manifest did not select it`,
);
}
return input as NonNullable<Inputs[typeof REFERENCE_FEATURE_ID]>;
}
describe("reference feature runtime composition", () => {
it("invalidates a real bound query through the installed production graph", async () => {
const adapters = await createRuntimeAdapters({ runtime, release, host: {} });
@@ -117,7 +135,7 @@ describe("reference feature runtime composition", () => {
);
await expect(
adapters.featureInputs[REFERENCE_FEATURE_ID].listResources({ limit: 20 }),
referenceInput(adapters).listResources({ limit: 20 }),
).resolves.toEqual({
ok: true,
value: [
@@ -170,7 +188,7 @@ describe("reference feature runtime composition", () => {
});
await expect(
adapters.featureInputs[REFERENCE_FEATURE_ID].createResource(
referenceInput(adapters).createResource(
{ name: "Created resource" },
{ intent },
),
+3 -1
View File
@@ -4,7 +4,7 @@ import {
type ApplicationOutputPorts,
} from "../../src/application/create-application.ts";
import type { ApplicationFeatureInputs } from "../../src/application/ports/in/application-api.ts";
import { createRuntimeCapabilitiesStub } from "./runtime-capabilities-stub.ts";
import { createProductFeaturesStub, createRuntimeCapabilitiesStub } from "./runtime-capabilities-stub.ts";
type TestApplicationOverrides = Partial<ApplicationOutputPorts> &
Readonly<{
@@ -52,6 +52,8 @@ export function createTestApplication(
},
runtimeCapabilities:
overrides.runtimeCapabilities ?? createRuntimeCapabilitiesStub(),
productFeatures:
overrides.productFeatures ?? createProductFeaturesStub(),
navigation: overrides.navigation ?? { reload: () => {} },
},
overrides.featureInputs,
@@ -1,3 +1,13 @@
import {
activeProductFeatureIds,
resolveProductFeatures,
type ProductFeatureState,
} from "../../src/contracts/product-features.ts";
import type { ProductFeaturesPort } from "../../src/application/ports/product-features-port.ts";
import {
COMPILED_PRODUCT_FEATURE_IDS,
INSTALLED_PRODUCT_FEATURE_IDS,
} from "../../src/features/installed-product-manifest.ts";
import type {
RuntimeCapabilityId,
RuntimeCapabilityStatus,
@@ -32,3 +42,27 @@ export function createRuntimeCapabilitiesStub(
);
return Object.freeze({ getSnapshot: () => snapshot });
}
/**
* A product-feature port that reports the real manifest with nothing disabled.
* Tests that care about the switch build their own; the rest only need the
* boundary to be complete.
*/
export function createProductFeaturesStub(
overrides: Readonly<Record<string, ProductFeatureState>> = {},
): ProductFeaturesPort {
const snapshot = resolveProductFeatures(
COMPILED_PRODUCT_FEATURE_IDS,
INSTALLED_PRODUCT_FEATURE_IDS,
Object.fromEntries(
Object.entries(overrides)
.filter(([, state]) => state === "DISABLED_BY_CONFIG")
.map(([featureId]) => [featureId, "DISABLED" as const]),
),
);
const active = new Set(activeProductFeatureIds(snapshot));
return Object.freeze({
getSnapshot: () => snapshot,
isActive: (featureId: string) => active.has(featureId),
});
}
@@ -32,6 +32,7 @@ const runtime: Parameters<typeof loadReleaseManifest>[0] = {
SERVICE_WORKER: "DEFAULT",
OFFLINE_COMMANDS: "DEFAULT",
},
FEATURE_OVERRIDES: {},
},
configSchema: "V2",
validationDurationMs: 0,
+2 -1
View File
@@ -5,7 +5,7 @@ import {
type ApplicationOutputPorts,
} from "../../src/application/create-application.ts";
import { createTestApplication } from "../helpers/create-test-application.ts";
import { createRuntimeCapabilitiesStub } from "../helpers/runtime-capabilities-stub.ts";
import { createProductFeaturesStub, createRuntimeCapabilitiesStub } from "../helpers/runtime-capabilities-stub.ts";
declare module "../../src/application/ports/in/application-api.ts" {
interface ApplicationFeatureInputs {
@@ -99,6 +99,7 @@ describe("application input/output boundary", () => {
}),
},
runtimeCapabilities: createRuntimeCapabilitiesStub(),
productFeatures: createProductFeaturesStub(),
navigation: { reload: () => {} },
} satisfies ApplicationOutputPorts;
const application = createApplication(ports);
+2 -1
View File
@@ -5,7 +5,7 @@ import { createAnonymousSessionAdapter } from "../../src/adapters/auth/external-
import type { StoragePort } from "../../src/application/ports/storage-port.ts";
import type { DiagnosticsPort } from "../../src/application/ports/diagnostics-port.ts";
import type { TelemetryPort } from "../../src/application/ports/telemetry-port.ts";
import { createRuntimeCapabilitiesStub } from "../helpers/runtime-capabilities-stub.ts";
import { createProductFeaturesStub, createRuntimeCapabilitiesStub } from "../helpers/runtime-capabilities-stub.ts";
type ReleaseFixture = {
buildId: string;
@@ -53,6 +53,7 @@ function applicationWith(options: {
diagnostics: options.diagnostics ?? { record: () => {} },
telemetry: options.telemetry ?? { emit: () => {} },
runtimeCapabilities: createRuntimeCapabilitiesStub(),
productFeatures: createProductFeaturesStub(),
releaseInfo: {
getCurrent: async () => current,
refresh:
+222
View File
@@ -0,0 +1,222 @@
import { describe, expect, it } from "vitest";
import {
activeProductFeatureIds,
resolveProductFeatures,
selectCompiledProductFeatures,
} from "../../src/contracts/product-features.ts";
import { runtimeConfigV2ArtifactSchema } from "../../src/contracts/release-artifacts.ts";
import {
COMPILED_PRODUCT_FEATURE_IDS,
INSTALLED_PRODUCT_FEATURE_IDS,
} from "../../src/features/installed-product-manifest.ts";
import {
ROUTE_FEATURE_OWNER,
ROUTE_REGISTRY,
} from "../../src/features/installed-feature-contracts.ts";
const COMPILED = Object.freeze([
Object.freeze({ featureId: "reference-feature" }),
Object.freeze({ featureId: "billing" }),
]);
describe("build-time product selection", () => {
it("keeps everything when nothing is declared", () => {
for (const declared of [undefined, "", " "]) {
expect(
selectCompiledProductFeatures(COMPILED, declared).map((f) => f.featureId),
String(declared),
).toEqual(["reference-feature", "billing"]);
}
});
it("narrows to the declared subset", () => {
expect(
selectCompiledProductFeatures(COMPILED, "billing").map((f) => f.featureId),
).toEqual(["billing"]);
expect(
selectCompiledProductFeatures(COMPILED, " billing , reference-feature ").map(
(f) => f.featureId,
),
).toEqual(["reference-feature", "billing"]);
});
it("selects nothing only when asked explicitly", () => {
// A blank value keeps everything on purpose: an unset CI variable expands
// to a blank string, and that must not be how a build ships no features.
expect(selectCompiledProductFeatures(COMPILED, "none")).toEqual([]);
expect(selectCompiledProductFeatures(COMPILED, " none ")).toEqual([]);
expect(selectCompiledProductFeatures(COMPILED, "").length).toBe(2);
// A value that parses to no names at all is a typo, not an instruction.
expect(() => selectCompiledProductFeatures(COMPILED, ",")).toThrow(
/names no feature/u,
);
});
it("refuses to name a feature this build does not contain", () => {
// The whole point of the direction rule: an environment value can subtract
// from the source tree and must never be able to add to it. Accepting an
// unknown id silently would let a deployment believe it had switched on
// something that is not in the bundle.
expect(() => selectCompiledProductFeatures(COMPILED, "analytics")).toThrow(
/does not contain: analytics/u,
);
expect(() =>
selectCompiledProductFeatures(COMPILED, "billing,analytics"),
).toThrow(/analytics/u);
});
it("refuses a duplicated feature id in the manifest", () => {
expect(() =>
selectCompiledProductFeatures(
[{ featureId: "a" }, { featureId: "a" }],
undefined,
),
).toThrow(/duplicate product feature id/u);
});
});
describe("runtime product feature resolution", () => {
it("reports active, disabled and not-installed distinctly", () => {
const statuses = resolveProductFeatures(
["reference-feature", "billing"],
["reference-feature"],
{ "reference-feature": "DISABLED" },
);
expect(statuses).toEqual([
{ featureId: "billing", state: "NOT_INSTALLED" },
{ featureId: "reference-feature", state: "DISABLED_BY_CONFIG" },
]);
expect(activeProductFeatureIds(statuses)).toEqual([]);
});
it("cannot switch on a feature the build left out", () => {
// `DEFAULT` on an uninstalled feature is not an instruction to install it.
const statuses = resolveProductFeatures(["billing"], [], {
billing: "DEFAULT",
});
expect(statuses).toEqual([{ featureId: "billing", state: "NOT_INSTALLED" }]);
expect(activeProductFeatureIds(statuses)).toEqual([]);
});
it("ignores an override naming a feature this build never declared", () => {
// A shared runtime document may cover several builds, so a stale key is
// inert rather than fatal.
const statuses = resolveProductFeatures(
["reference-feature"],
["reference-feature"],
{ analytics: "DISABLED" },
);
expect(activeProductFeatureIds(statuses)).toEqual(["reference-feature"]);
});
it("leaves an installed feature active without an override", () => {
const statuses = resolveProductFeatures(
COMPILED_PRODUCT_FEATURE_IDS,
INSTALLED_PRODUCT_FEATURE_IDS,
);
expect(activeProductFeatureIds(statuses)).toEqual([
...INSTALLED_PRODUCT_FEATURE_IDS,
]);
});
});
describe("runtime config carries the switch", () => {
const base = {
APP_ENV: "local" as const,
API_BASE_URL: "http://localhost:8080/",
TELEMETRY_ENABLED: false,
AUTH_MODE: "demo" as const,
CONFIG_SCHEMA_VERSION: "2.0" as const,
RELEASE_MANIFEST_URL: "/release-manifest.json",
};
it("defaults to disabling nothing", () => {
const parsed = runtimeConfigV2ArtifactSchema.parse(base);
expect(parsed.FEATURE_OVERRIDES).toEqual({});
});
it("accepts only DEFAULT or DISABLED", () => {
expect(
runtimeConfigV2ArtifactSchema.parse({
...base,
FEATURE_OVERRIDES: { "reference-feature": "DISABLED" },
}).FEATURE_OVERRIDES,
).toEqual({ "reference-feature": "DISABLED" });
// There is no "ENABLED": the vocabulary itself is what makes the rule
// unbreakable, not a check somewhere downstream.
expect(
runtimeConfigV2ArtifactSchema.safeParse({
...base,
FEATURE_OVERRIDES: { "reference-feature": "ENABLED" },
}).success,
).toBe(false);
});
it("refuses a malformed feature id", () => {
for (const featureId of ["Reference", "reference_feature", "", "-x"]) {
expect(
runtimeConfigV2ArtifactSchema.safeParse({
...base,
FEATURE_OVERRIDES: { [featureId]: "DISABLED" },
}).success,
featureId,
).toBe(false);
}
});
});
describe("every installed registry consults the manifest", () => {
/**
* The manifest only means something if each registry actually asks it. A new
* registry that spreads a feature in directly would reintroduce exactly the
* coupling this file exists to remove, and nothing else would notice.
*/
it("gates every feature contribution on the selection", async () => {
const { readdir, readFile } = await import("node:fs/promises");
const nodePath = (await import("node:path")).default;
const root = "src/features";
const registries = (await readdir(root)).filter((entry) =>
/^installed-.*\.tsx?$/u.test(entry),
);
expect(registries.length).toBeGreaterThan(3);
const exempt = new Set([
// The manifest is the selection.
"installed-product-manifest.ts",
// Capabilities have their own §3.5 selection file and override vocabulary.
"installed-runtime-capabilities.ts",
// Message keys stay total on purpose; see the file for why.
"installed-feature-messages.ts",
]);
for (const registry of registries) {
if (exempt.has(registry)) continue;
const source = await readFile(nodePath.join(root, registry), "utf8");
expect(
/INSTALLED_PRODUCT_FEATURE(S|_IDS)/u.test(source),
`${registry} must compose from the product manifest`,
).toBe(true);
}
});
});
describe("route ownership", () => {
it("attributes every feature route to its feature and no platform route", () => {
for (const featureId of INSTALLED_PRODUCT_FEATURE_IDS) {
expect(Object.values(ROUTE_FEATURE_OWNER)).toContain(featureId);
}
// Platform routes have no owner, so disabling a feature can never withdraw
// the shell's own navigation.
for (const routeId of ["APP_HOME", "NOT_FOUND", "EXAMPLES_PLATFORM"]) {
expect(ROUTE_FEATURE_OWNER[routeId], routeId).toBeUndefined();
expect(Object.keys(ROUTE_REGISTRY)).toContain(routeId);
}
});
it("owns exactly the routes the registry received from features", () => {
const owned = Object.keys(ROUTE_FEATURE_OWNER);
expect(owned.length).toBeGreaterThan(0);
for (const routeId of owned) {
expect(Object.keys(ROUTE_REGISTRY), routeId).toContain(routeId);
}
});
});
+1
View File
@@ -74,6 +74,7 @@ const runtimeV2 = {
SERVICE_WORKER: "DEFAULT",
OFFLINE_COMMANDS: "DEFAULT",
},
FEATURE_OVERRIDES: {},
} as const satisfies RuntimeConfigArtifact;
async function releaseV2With(
+2
View File
@@ -26,6 +26,7 @@ const runtime: Runtime = {
SERVICE_WORKER: "DEFAULT",
OFFLINE_COMMANDS: "DEFAULT",
},
FEATURE_OVERRIDES: {},
},
configSchema: "V2",
build: {
@@ -262,6 +263,7 @@ describe("runtime adapter composition", () => {
...runtime.config.CAPABILITY_OVERRIDES,
SERVICE_WORKER: "DISABLED",
},
FEATURE_OVERRIDES: {},
},
},
release,
Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 KiB

After

Width:  |  Height:  |  Size: 424 KiB