diff --git a/config/contracts/registry-baseline.approval.json b/config/contracts/registry-baseline.approval.json index fad51b0f..38b05eee 100644 --- a/config/contracts/registry-baseline.approval.json +++ b/config/contracts/registry-baseline.approval.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, - "snapshotDigest": "96e048bf63f739ba7acb9238e77b4b36abaf9c1fc3e40ea2f2f4a4862e0127b9", + "snapshotDigest": "8f5ae6dde9c6a293144e5bccad1765367f06ac3a6b58a6229c69426703158c9c", "owner": "DongHyeonka", - "reason": "1103/07-01 FE-REG-API rows carry descriptor wire values (statuses, limits, deadline, retry budget, traffic, command data, validation skip); problemSchema and unvalidated are breaking fields", - "approvedAt": "2026-11-04T11:23:02.382Z" + "reason": "1103/13-04 FE-REG-ENV runtime rows state required and defaultValue as runtimeConfigV2ArtifactSchema reads them (TELEMETRY_ENABLED, AUTH_MODE, RELEASE_MANIFEST_URL, CAPABILITY_OVERRIDES, FEATURE_OVERRIDES); defaultValue may be an object", + "approvedAt": "2026-11-04T11:26:00.863Z" } diff --git a/config/contracts/registry-baseline.json b/config/contracts/registry-baseline.json index 01e176d5..da86f4cd 100644 --- a/config/contracts/registry-baseline.json +++ b/config/contracts/registry-baseline.json @@ -656,7 +656,7 @@ "phase": "string", "classification": "string", "required": "boolean", - "defaultValue": "string|integer|boolean|null" + "defaultValue": "string|integer|boolean|object|null" }, "uniqueFields": [], "allowedValues": { @@ -694,7 +694,7 @@ }, "AUTH_MODE": { "classification": "public", - "defaultValue": "external", + "defaultValue": null, "phase": "runtime", "required": true }, @@ -706,7 +706,12 @@ }, "CAPABILITY_OVERRIDES": { "classification": "public", - "defaultValue": null, + "defaultValue": { + "OFFLINE_COMMANDS": "DEFAULT", + "REALTIME": "DEFAULT", + "SERVICE_WORKER": "DEFAULT", + "WEB_WORKER": "DEFAULT" + }, "phase": "runtime", "required": false }, @@ -718,7 +723,7 @@ }, "FEATURE_OVERRIDES": { "classification": "public", - "defaultValue": null, + "defaultValue": {}, "phase": "runtime", "required": false }, @@ -738,7 +743,7 @@ "classification": "public", "defaultValue": "/release-manifest.json", "phase": "runtime", - "required": true + "required": false }, "REQUEST_TIMEOUT_MS": { "classification": "public", @@ -748,7 +753,7 @@ }, "TELEMETRY_ENABLED": { "classification": "public", - "defaultValue": false, + "defaultValue": null, "phase": "runtime", "required": true }, diff --git a/config/contracts/registry-governance.json b/config/contracts/registry-governance.json index 71add621..dce422f5 100644 --- a/config/contracts/registry-governance.json +++ b/config/contracts/registry-governance.json @@ -291,7 +291,7 @@ "phase": "string", "classification": "string", "required": "boolean", - "defaultValue": "string|integer|boolean|null" + "defaultValue": "string|integer|boolean|object|null" }, "allowedValues": { "phase": ["build", "runtime"], diff --git a/src/contracts/env.ts b/src/contracts/env.ts index 48c874be..0fcf1a9e 100644 --- a/src/contracts/env.ts +++ b/src/contracts/env.ts @@ -41,6 +41,12 @@ export type EnvironmentDefinition = Readonly<{ defaultValue: unknown; }>; +/** + * FE-REG-ENV. A runtime row states its key as `runtimeConfigV2ArtifactSchema` + * (`release-artifacts.ts`) reads it: `required` when config.json must carry + * the key, and `defaultValue` the value the schema gives an absent key, or + * `null` when it gives none (1103/13-04, tests/unit/env-registry-coverage). + */ export const ENV_REGISTRY = Object.freeze(withProductRows({ // F-6. Required: a staging or production build fails without it // (scripts/generate-runtime-config.ts). Local and development builds fall @@ -53,20 +59,25 @@ export const ENV_REGISTRY = Object.freeze(withProductRows({ API_BASE_URL: runtime("public-sensitive", true, null), REQUEST_TIMEOUT_MS: runtime("public", false, 10_000), MAX_RETRY_ATTEMPTS: runtime("public", false, 2), - TELEMETRY_ENABLED: runtime("public", true, false), + TELEMETRY_ENABLED: runtime("public", true, null), TELEMETRY_ENDPOINT: runtime("public-sensitive", false, null), - AUTH_MODE: runtime("public", true, "external"), + AUTH_MODE: runtime("public", true, null), CONFIG_SCHEMA_VERSION: runtime("public", true, null), - RELEASE_MANIFEST_URL: runtime("public", true, "/release-manifest.json"), + RELEASE_MANIFEST_URL: runtime("public", false, "/release-manifest.json"), // F-6. The release identity the build writes into config.json. It must match // the deployed HTML and release manifest, or boot stops with // CONFIG_BUILD_MISMATCH (scripts/check-release-admission.ts). RELEASE_ID: runtime("public-metadata", false, null), BUILD_ID: runtime("public-metadata", false, null), // §3.5: overrides may only disable an installed capability, never enable one. - CAPABILITY_OVERRIDES: runtime("public", false, null), + CAPABILITY_OVERRIDES: runtime("public", false, Object.freeze({ + REALTIME: "DEFAULT", + WEB_WORKER: "DEFAULT", + SERVICE_WORKER: "DEFAULT", + OFFLINE_COMMANDS: "DEFAULT", + })), // §3.5: likewise for features — subtractive, keyed by installed feature id. - FEATURE_OVERRIDES: runtime("public", false, null), + FEATURE_OVERRIDES: runtime("public", false, Object.freeze({})), // §3.5: build-time narrowing of the product manifest, applied by // scripts/generate-product-feature-index.ts (09-02). A feature left out here // is not imported by any registry and never reaches the bundle. diff --git a/tests/unit/env-registry-coverage.test.ts b/tests/unit/env-registry-coverage.test.ts index f28118d0..e5efe327 100644 --- a/tests/unit/env-registry-coverage.test.ts +++ b/tests/unit/env-registry-coverage.test.ts @@ -1,19 +1,64 @@ +import { isDeepStrictEqual } from "node:util"; + import { describe, expect, it } from "vitest"; -import { ENV_REGISTRY } from "../../src/contracts/env.ts"; +import { + ENV_REGISTRY, + type EnvironmentDefinition, +} from "../../src/contracts/env.ts"; import { runtimeConfigV2ArtifactSchema } from "../../src/contracts/release-artifacts.ts"; +const rows: Readonly> = ENV_REGISTRY; +const shape = runtimeConfigV2ArtifactSchema.shape as Readonly< + Record +>; + +/** + * What the schema field says when the key is left out of config.json: a field + * that fails on `undefined` is required and has no default; one that passes + * has the parsed value as its default (`null` when it stays absent). + */ +function schemaDeclaration(key: string) { + const result = shape[key]!.safeParse(undefined); + return result.success + ? { required: false, defaultValue: result.data ?? null } + : { required: true, defaultValue: null }; +} + // 09-02. A key the deployed config.json may carry needs an FE-REG-ENV row, so // check:registries sees it. A product key added to // PRODUCT_RUNTIME_CONFIG_FIELDS without a PRODUCT_ENV_REGISTRY row fails here. describe("FE-REG-ENV coverage", () => { it("has a runtime row for every V2 runtime config key", () => { - const missing = Object.keys(runtimeConfigV2ArtifactSchema.shape).filter( - (key) => - !Object.hasOwn(ENV_REGISTRY, key) || - ENV_REGISTRY[key as keyof typeof ENV_REGISTRY].phase !== "runtime", + const missing = Object.keys(shape).filter( + (key) => !Object.hasOwn(rows, key) || rows[key]!.phase !== "runtime", ); expect(missing).toEqual([]); }); + + // 1103/13-04, 0929/P-07-05. The other direction: a runtime row names a key + // the schema reads, and states its required flag and default as the schema + // field does, so the governed snapshot does not describe another document. + it("has no runtime row the V2 schema does not read", () => { + const extra = Object.keys(rows).filter( + (key) => rows[key]!.phase === "runtime" && !Object.hasOwn(shape, key), + ); + + expect(extra).toEqual([]); + }); + + it("states each runtime row's required flag and default as its schema field does", () => { + const differences = Object.keys(shape).flatMap((key) => { + const row = rows[key]; + if (!row) return []; + const declared = { required: row.required, defaultValue: row.defaultValue }; + const expected = schemaDeclaration(key); + return isDeepStrictEqual(declared, expected) + ? [] + : [`${key}: row ${JSON.stringify(declared)}, schema ${JSON.stringify(expected)}`]; + }); + + expect(differences).toEqual([]); + }); });