diff --git a/scripts/check-app-build-input.ts b/scripts/check-app-build-input.ts index c8c6002..8177407 100644 --- a/scripts/check-app-build-input.ts +++ b/scripts/check-app-build-input.ts @@ -27,6 +27,21 @@ export type AppBuildInputReport = Readonly<{ violations: readonly string[]; }>; +/** + * Template sync (af3d8e6). TechLog is this product's own domain, composed + * directly by the composition root rather than by the index generator + * (`src/features/tech-log/NOT_INSTALLED`). No context owns it, so the + * template's ownership rule refused every production bundle of this product; + * FE-GATE-012 stopped at the bundle budget before reaching it, which hid that. + * + * It is allowed in the bundle by name only. The generated indexes still may not + * import it, and every other directory marked NOT_INSTALLED (the reference and + * local-draft samples) is still refused if it reaches the bundle. + */ +export const DIRECTLY_COMPOSED_FEATURE_DIRECTORIES: readonly string[] = Object.freeze([ + "tech-log", +]); + const GENERATED = [ "src/.generated/product-feature-index.ts", "src/.generated/product-context-index.ts", @@ -99,8 +114,9 @@ export async function inspectAppBuildInput( }), ); bundle = { checked: true, featureDirectories }; + const composedDirectly = new Set(DIRECTLY_COMPOSED_FEATURE_DIRECTORIES); for (const directory of featureDirectories) { - if (!owned.has(directory)) { + if (!owned.has(directory) && !composedDirectly.has(directory)) { violations.push(`production bundle contains feature "${directory}" not owned by app ${appId}`); } } diff --git a/tests/architecture/app-build-input.test.ts b/tests/architecture/app-build-input.test.ts index 6c28bbe..151a5ab 100644 --- a/tests/architecture/app-build-input.test.ts +++ b/tests/architecture/app-build-input.test.ts @@ -84,6 +84,24 @@ describe("app build input isolation gate", () => { ]); }); + it("accepts this product's directly composed TechLog and still refuses an uninstalled sample", async () => { + // TechLog is composed by the composition root (src/features/tech-log/NOT_INSTALLED), + // so it is in every production bundle while no context owns it. The + // reference sample is NOT_INSTALLED too, and must not ride along. + const root = path.resolve("."); + const scratch = await mkdtemp(path.join(tmpdir(), "app-build-input-product-")); + roots.push(scratch); + const bundle = await inventory(scratch, [ + "src/features/tech-log/presentation/public/public-shell.tsx", + "src/features/reference-feature/feature-module.ts", + ]); + const report = await inspectAppBuildInput(root, { bundleInventory: bundle }); + expect(report.bundle.featureDirectories).toEqual(["reference-feature", "tech-log"]); + expect(report.violations).toEqual([ + `production bundle contains feature "reference-feature" not owned by app ${report.appId}`, + ]); + }); + it("holds for this repository's generated indexes", async () => { // The bundle side is gated after a fresh build (check:app-build-input:bundle). const report = await inspectAppBuildInput(path.resolve("."), { bundleInventory: null });