chore(features): 참조 기능과 예제 화면을 지우고 레지스트리를 다시 승인한다
소유자 결정(2026-11-07, design-docs repo-structure/README.md 3.4절)으로 템플릿 샘플을 지운다. 샘플이 맡던 시험 대상은 앞 커밋들이 옮겼다. 참조 기능과 예제 화면, 두 context, 그 시험, e2e 3개, 수동 접근성 기록 7개, 런타임 프로필 키, test:reference-feature(명령, 산출물, 게이트 참조), 커버리지 정책 행을 지웠다. removable-template-features 목록은 비우고 장치는 남겼다: test:sample-removal은 인자가 없으면 목록을 하나씩 지우고, 비면 SKIP을 출력하고 보고서에 건너뛴 사례를 남긴다. 기능 스위치 시험과 홈 시작 링크 스위치 시험은 시험 전용 fixture 기능으로 옮겼다. browser soak은 생성 기능을 넣은 빌드에서 돈다. 문서의 샘플 경로를 고쳤다. 날짜가 붙은 설계·리뷰 기록의 본문은 그대로 두었다. 레지스트리 기준선(update:registry-baseline, OWNER DongHyeonka), CI 계약 기준선과 workflow, 초기 JS 기록(194,354B, 17파일, 첫 기능 6,327B, 기능 539B, context 4B)을 다시 받았다. 위험: 레지스트리 행 삭제는 breaking이다. 샘플을 고쳐 쓰는 다운스트림은 수정/삭제 충돌을 만난다. 성능 lab의 기능 라우트 측정은 템플릿에 공개 기능 라우트가 없어 measured:false다. TEMPLATE_FIXTURE 출처는 플랫폼 코드에 남았다. 검증(desktop): check:types, lint, check:architecture, check:registries, check:ci, verify:documentation, test:unit, test:component, test:contract, test:integration, test:recipes, test:coverage(Risk coverage PASS 378/378, 문턱 68개), test:e2e 183, test:a11y, test:visual, test:storybook, test:browser-capabilities, test:feature-scaffold PASS(76 checks), test:sample-removal SKIP, build, check:bundle.
This commit is contained in:
@@ -141,10 +141,10 @@ const misplacedAdapterResults = [
|
||||
),
|
||||
},
|
||||
{
|
||||
file: "src/features/reference-feature/adapters/boundary-fixture.ts",
|
||||
file: "src/features/fixture-feature/adapters/boundary-fixture.ts",
|
||||
result: runEslintSource(
|
||||
objectUrlBypassSource,
|
||||
"src/features/reference-feature/adapters/boundary-fixture.ts",
|
||||
"src/features/fixture-feature/adapters/boundary-fixture.ts",
|
||||
),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -59,9 +59,8 @@ if (!fixtureMode) {
|
||||
// from an ordinary `.message` read. Fixture mode runs the ESLint rule on the
|
||||
// fixture trees too, so this one gate shows the whole i18n contract rejecting
|
||||
// every forbidden file and passing the allowed one.
|
||||
// `src/presentation/examples` (the platform overview) and the example
|
||||
// screens (`src/features/platform-examples-feature/presentation`, 1103/09-04)
|
||||
// are workshop code and stay out of the ESLint rule's scope on purpose.
|
||||
// `src/presentation/examples` (the platform overview) and the stories are
|
||||
// workshop code and stay out of the ESLint rule's scope on purpose.
|
||||
const forbiddenFixtureRoot = "tests/fixtures/i18n/forbidden";
|
||||
const allowedFixtureRoot = "tests/fixtures/i18n/allowed";
|
||||
const sourceRoot = fixtureMode ? forbiddenFixtureRoot : ".";
|
||||
|
||||
@@ -113,7 +113,7 @@ type ReadFacts = Readonly<{
|
||||
* not listed.
|
||||
*
|
||||
* This finds the detail pages that take their params schema from their read
|
||||
* (the reference sample and every `create:feature --with-create` slice). A
|
||||
* (every `create:feature --with-create` slice). A
|
||||
* detail page whose params schema differs is not found, and its record alone
|
||||
* decides, as before.
|
||||
*/
|
||||
|
||||
@@ -34,8 +34,8 @@ import path from "node:path";
|
||||
* a test title), and no text rule tells that from a reference, so a spec
|
||||
* that names only a one-word ID is not found either.
|
||||
*
|
||||
* The reference sample keeps its own, wider pattern in
|
||||
* scripts/test-sample-removal.ts: the template owns all of its files.
|
||||
* The drill applies the same rule to a sample a project lists in
|
||||
* scripts/lib/removable-template-features.ts.
|
||||
*/
|
||||
function escapeRegExp(value: string): string {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { cp, mkdtemp, rename, rm } from "node:fs/promises";
|
||||
import { existsSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
import { localBuildEnvironment } from "./build-environment.ts";
|
||||
import { linkFixtureNodeModules } from "./fixture-node-modules.ts";
|
||||
import { REMOVAL_FIXTURE_COPY_TARGETS } from "./removal-fixture.ts";
|
||||
|
||||
/**
|
||||
* 2026-11-07. The template ships no feature. What needs one in a real build
|
||||
* runs on the feature `create:feature` writes, added to a copy of the
|
||||
* repository: the browser checks that one feature works end to end (route,
|
||||
* form, save, a save whose result is lost; tests/e2e/generated-feature.spec.ts
|
||||
* and the chunk recovery spec, whose fixture builds take `addGeneratedFeature`
|
||||
* as their edit) and the browser soak's failing-backend visits
|
||||
* (scripts/scale/browser-soak.ts, `buildWithGeneratedFeature`). A change of
|
||||
* the generator's output fails there. The `--keyed` write slice is the widest
|
||||
* one the command makes.
|
||||
*/
|
||||
export const GENERATED_FEATURE_ID = "order-feature";
|
||||
|
||||
export type GeneratedRoute = Readonly<{
|
||||
routeId: string;
|
||||
path: string;
|
||||
chunkId: string;
|
||||
/** The lazy page's module id (`routeRuntimeContracts`), the name of its chunk. */
|
||||
moduleId: string;
|
||||
}>;
|
||||
|
||||
export type GeneratedFeature = Readonly<{
|
||||
list: GeneratedRoute;
|
||||
detail: GeneratedRoute;
|
||||
create: GeneratedRoute;
|
||||
/** The feature's ko-KR and en-US catalogs. */
|
||||
messages: Readonly<Record<"ko-KR" | "en-US", Readonly<Record<string, string>>>>;
|
||||
/** The collection the operations call: API_BASE_URL of the build plus the path. */
|
||||
api: string;
|
||||
}>;
|
||||
|
||||
function node(root: string, args: readonly string[]): string {
|
||||
const result = spawnSync(process.execPath, args, { cwd: root, encoding: "utf8" });
|
||||
if (result.status !== 0) {
|
||||
throw new Error(`node ${args.join(" ")} failed in ${root}:\n${result.stdout}\n${result.stderr}`);
|
||||
}
|
||||
return result.stdout;
|
||||
}
|
||||
|
||||
/** The edit of a fixture build: `corepack pnpm create:feature order-feature --with-create --keyed`. */
|
||||
export async function addGeneratedFeature(root: string): Promise<void> {
|
||||
node(root, ["scripts/generate-product-feature-index.ts"]);
|
||||
node(root, ["scripts/create-feature.ts", GENERATED_FEATURE_ID, "--with-create", "--keyed"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* What the specs need to drive the feature, read from the copy the command
|
||||
* wrote it into (node runs that TypeScript as it is): the three routes, the
|
||||
* words and where its API is.
|
||||
*/
|
||||
export function generatedFeature(root: string): GeneratedFeature {
|
||||
const feature = path.join(root, "src/features", GENERATED_FEATURE_ID);
|
||||
const module = (file: string) => JSON.stringify(pathToFileURL(path.join(feature, file)).href);
|
||||
const source = `
|
||||
const { ORDER_FEATURE_CONTRACT } = await import(${module("contracts/order-feature-contract.ts")});
|
||||
const { ORDER_MESSAGE_CATALOGS } = await import(${module("contracts/order-message-catalog.ts")});
|
||||
const { ORDER_LIST_ITEMS_CONTRACT } = await import(${module("contracts/order-contract-contribution.ts")});
|
||||
const { API_BASE_URL } = JSON.parse(await (await import("node:fs/promises")).readFile("config/runtime/local.json", "utf8"));
|
||||
const route = (id) => ({
|
||||
routeId: id,
|
||||
path: ORDER_FEATURE_CONTRACT.routes[id].path,
|
||||
chunkId: ORDER_FEATURE_CONTRACT.routes[id].chunkId,
|
||||
moduleId: ORDER_FEATURE_CONTRACT.routeRuntimeContracts[id].moduleId,
|
||||
});
|
||||
process.stdout.write(JSON.stringify({
|
||||
list: route("ORDER_LIST"),
|
||||
detail: route("ORDER_DETAIL"),
|
||||
create: route("ORDER_CREATE"),
|
||||
messages: ORDER_MESSAGE_CATALOGS,
|
||||
api: new URL(ORDER_LIST_ITEMS_CONTRACT.contract.pathTemplate.slice(1), API_BASE_URL).href,
|
||||
}));
|
||||
`;
|
||||
return JSON.parse(node(root, ["--input-type=module", "-e", source])) as GeneratedFeature;
|
||||
}
|
||||
|
||||
/** A route's path with its one parameter filled in. */
|
||||
export function routePath(route: GeneratedRoute, id?: string): string {
|
||||
return id === undefined ? route.path : route.path.replace(/:[A-Za-z][A-Za-z0-9_]*/u, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* A production build of a copy of the repository with the generated feature,
|
||||
* in the local configuration. `remove` deletes the copy.
|
||||
*/
|
||||
export async function buildWithGeneratedFeature(prefix: string): Promise<
|
||||
Readonly<{ dist: string; feature: GeneratedFeature; remove(): Promise<void> }>
|
||||
> {
|
||||
const root = await mkdtemp(path.join(tmpdir(), `${prefix}-`));
|
||||
const remove = () => rm(root, { recursive: true, force: true });
|
||||
try {
|
||||
for (const entry of REMOVAL_FIXTURE_COPY_TARGETS) {
|
||||
if (!existsSync(entry)) continue;
|
||||
await cp(entry, path.join(root, entry), {
|
||||
recursive: true,
|
||||
filter: (source) => !source.includes(`${path.sep}.generated`),
|
||||
});
|
||||
}
|
||||
await linkFixtureNodeModules(root);
|
||||
await addGeneratedFeature(root);
|
||||
const build = spawnSync(process.execPath, ["scripts/build-frontend.ts"], {
|
||||
cwd: root,
|
||||
encoding: "utf8",
|
||||
env: localBuildEnvironment(),
|
||||
});
|
||||
if (build.status !== 0) {
|
||||
throw new Error(`scripts/build-frontend.ts failed in ${root}:\n${build.stdout}\n${build.stderr}`);
|
||||
}
|
||||
const dist = path.join(root, "dist-generated-feature");
|
||||
await rename(path.join(root, "dist"), dist);
|
||||
return Object.freeze({ dist, feature: generatedFeature(root), remove });
|
||||
} catch (error) {
|
||||
await remove();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
/**
|
||||
* The features this template ships that a copied project may delete: the
|
||||
* reference sample (README "Files you can delete after copying") and the
|
||||
* example screens (docs/architecture/starter-experience.md, CHANGELOG "먼저
|
||||
* 할 일" 6). Each owns its folder under `src/features/` and `tests/features/`
|
||||
* and the context it is the only feature of. The reference sample also owns
|
||||
* files outside them, which `scripts/test-sample-removal.ts` deletes with it.
|
||||
* The sample features a project ships and may delete later: each owns its
|
||||
* folder under `src/features/` and `tests/features/`, the context it is the
|
||||
* only feature of, and possibly files and package scripts outside them.
|
||||
*
|
||||
* This is the one list. The removal drill reads the reference sample's paths
|
||||
* and scripts from it, and the documentation check reads the whole of it: a
|
||||
* feature counts as deleted once its `feature-module.ts` is gone.
|
||||
* The template ships none: its reference sample and example screens were
|
||||
* deleted on 2026-11-07, when the manual and `create:feature` took over their
|
||||
* roles. A project that keeps a sample of its own lists it here. Then
|
||||
* `test:sample-removal` without `--feature` (FE-GATE-020) deletes each one
|
||||
* from a copy of the repository with these paths and scripts and runs the
|
||||
* gates, and verify:documentation lets the documents name its paths until
|
||||
* the sample is gone: a sample counts as deleted once its
|
||||
* `feature-module.ts` is.
|
||||
*/
|
||||
export type RemovableTemplateFeature = Readonly<{
|
||||
/** Its FEATURE_MODULE_ID, also its folder under src/features and tests/features. */
|
||||
@@ -21,36 +23,7 @@ export type RemovableTemplateFeature = Readonly<{
|
||||
scripts: readonly string[];
|
||||
}>;
|
||||
|
||||
export const REMOVABLE_TEMPLATE_FEATURES: readonly RemovableTemplateFeature[] = Object.freeze([
|
||||
Object.freeze({
|
||||
featureId: "reference-feature",
|
||||
contextDirectory: "src/contexts/reference-context",
|
||||
// 0929/10-02. The HTTP scenario catalog (tests/mocks) and the negative
|
||||
// type fixtures of the feature APIs run on the test contracts, so they
|
||||
// are platform checks and stay (commonTestPaths in the drill).
|
||||
extraPaths: Object.freeze([
|
||||
"tests/component/product-feature-switch.test.tsx",
|
||||
"tests/e2e/reference-form.spec.ts",
|
||||
"tests/e2e/reference-route.spec.ts",
|
||||
"tests/e2e/reference-save.spec.ts",
|
||||
// 11-04: the growth measurement copies this sample feature.
|
||||
"tests/unit/feature-shape-growth.test.ts",
|
||||
"scripts/scale/measure-feature-shape-growth.ts",
|
||||
"config/scale/feature-shape-growth.json",
|
||||
"config/scale/feature-shape-ceilings.json",
|
||||
]),
|
||||
scripts: Object.freeze(["test:reference-feature"]),
|
||||
}),
|
||||
// 1103/09-04. The example screens /examples/ui, /examples/states and
|
||||
// /examples/auth. The platform overview (/examples/platform) is a platform
|
||||
// route and is not part of it.
|
||||
Object.freeze({
|
||||
featureId: "platform-examples-feature",
|
||||
contextDirectory: "src/contexts/platform-examples-context",
|
||||
extraPaths: Object.freeze([]),
|
||||
scripts: Object.freeze([]),
|
||||
}),
|
||||
]);
|
||||
export const REMOVABLE_TEMPLATE_FEATURES: readonly RemovableTemplateFeature[] = Object.freeze([]);
|
||||
|
||||
/** Every path removing `feature` deletes: its folders, its context and its extra files. */
|
||||
export function removableTemplateFeaturePaths(feature: RemovableTemplateFeature): readonly string[] {
|
||||
|
||||
@@ -40,7 +40,7 @@ export const REMOVAL_FIXTURE_COPY_TARGETS = Object.freeze([
|
||||
|
||||
/**
|
||||
* This is the only copy-target list. Each removal script used to keep its own,
|
||||
* and they drifted: the reference-feature fixture omitted
|
||||
* and they drifted: the reference sample's fixture omitted
|
||||
* `playwright.capabilities.config.ts`, which the repository file inventory
|
||||
* requires, so supply-chain generation failed inside the fixture and took every
|
||||
* provider suite down with it — twenty-odd failures with one cause.
|
||||
|
||||
@@ -4,6 +4,7 @@ import { createServer, type Server } from "node:http";
|
||||
import type { AddressInfo } from "node:net";
|
||||
import path from "node:path";
|
||||
|
||||
import { buildWithGeneratedFeature } from "../lib/generated-feature.ts";
|
||||
import {
|
||||
classifyCounterSeries,
|
||||
classifyMemorySlope,
|
||||
@@ -13,8 +14,12 @@ import {
|
||||
/**
|
||||
* scale-architecture.md §33 / §44. Browser soak on the existing Playwright runner.
|
||||
*
|
||||
* Serves the built `dist/` on an OS-assigned 127.0.0.1 port and keeps one
|
||||
* long-lived page cycling through the app's routes by client-side navigation.
|
||||
* Serves a build on an OS-assigned 127.0.0.1 port and keeps one long-lived
|
||||
* page cycling through the app's routes by client-side navigation. One of
|
||||
* them is a feature's protected list (`featureRoute`), signed in once, whose
|
||||
* reads fail. The template has no feature: by default the soak builds a copy
|
||||
* with the one `create:feature` writes (scripts/lib/generated-feature.ts);
|
||||
* `--dist` with `--feature-route` soaks a build of a product's own.
|
||||
* The served runtime config turns telemetry on (pointed at a local collector)
|
||||
* and points the API at a stub that always answers 503, so every cycle also
|
||||
* exercises bounded retries and telemetry under a sustained backend failure.
|
||||
@@ -51,9 +56,9 @@ export type SoakSummary = Readonly<{
|
||||
storageKeyDelta: number;
|
||||
storageByteDelta: number;
|
||||
apiRequests: number;
|
||||
referenceVisits: number;
|
||||
settledReferenceVisits: number;
|
||||
apiRequestsPerReferenceVisit: number;
|
||||
featureVisits: number;
|
||||
settledFeatureVisits: number;
|
||||
apiRequestsPerFeatureVisit: number;
|
||||
telemetryPosts: number;
|
||||
telemetryEvents: number;
|
||||
maxTelemetryPostsPerMinute: number;
|
||||
@@ -83,7 +88,7 @@ export const SOAK_LIMITS = Object.freeze({
|
||||
maxTimerDelta: 10,
|
||||
maxStorageKeyDelta: 2,
|
||||
/** One logical execution: 1 attempt + at most 2 retries. */
|
||||
maxApiRequestsPerReferenceVisit: 3,
|
||||
maxApiRequestsPerFeatureVisit: 3,
|
||||
/** Two bounded pipelines (platform events + feature events) x 20/min. */
|
||||
maxTelemetryPostsPerMinute: 40,
|
||||
});
|
||||
@@ -104,8 +109,8 @@ export function summarizeSoak(
|
||||
export type SoakTotals = Readonly<{
|
||||
cycles: number;
|
||||
navigationFailures: number;
|
||||
referenceVisits: number;
|
||||
settledReferenceVisits: number;
|
||||
featureVisits: number;
|
||||
settledFeatureVisits: number;
|
||||
finalInFlightRequests: number;
|
||||
apiRequests: number;
|
||||
telemetryPosts: number;
|
||||
@@ -148,12 +153,12 @@ export function evaluateSoak(
|
||||
storageKeyDelta: delta((sample) => sample.storageKeys),
|
||||
storageByteDelta: delta((sample) => sample.storageBytes),
|
||||
apiRequests: totals.apiRequests,
|
||||
referenceVisits: totals.referenceVisits,
|
||||
settledReferenceVisits: totals.settledReferenceVisits,
|
||||
apiRequestsPerReferenceVisit:
|
||||
totals.referenceVisits === 0
|
||||
featureVisits: totals.featureVisits,
|
||||
settledFeatureVisits: totals.settledFeatureVisits,
|
||||
apiRequestsPerFeatureVisit:
|
||||
totals.featureVisits === 0
|
||||
? 0
|
||||
: Math.round((totals.apiRequests / totals.referenceVisits) * 1_000) / 1_000,
|
||||
: Math.round((totals.apiRequests / totals.featureVisits) * 1_000) / 1_000,
|
||||
telemetryPosts: totals.telemetryPosts,
|
||||
telemetryEvents: totals.telemetryEvents,
|
||||
maxTelemetryPostsPerMinute,
|
||||
@@ -192,15 +197,15 @@ export function evaluateSoak(
|
||||
{
|
||||
name: "backend failure exercised",
|
||||
passed:
|
||||
summary.settledReferenceVisits > 0 && summary.apiRequests > 0 && summary.telemetryEvents > 0,
|
||||
detail: `${summary.settledReferenceVisits} settled visits, ${summary.apiRequests} API requests, ${summary.telemetryEvents} telemetry events`,
|
||||
summary.settledFeatureVisits > 0 && summary.apiRequests > 0 && summary.telemetryEvents > 0,
|
||||
detail: `${summary.settledFeatureVisits} settled visits, ${summary.apiRequests} API requests, ${summary.telemetryEvents} telemetry events`,
|
||||
},
|
||||
{
|
||||
name: "request amplification",
|
||||
passed:
|
||||
summary.referenceVisits > 0 &&
|
||||
summary.apiRequestsPerReferenceVisit <= SOAK_LIMITS.maxApiRequestsPerReferenceVisit,
|
||||
detail: `${summary.apiRequests} requests / ${summary.referenceVisits} visits`,
|
||||
summary.featureVisits > 0 &&
|
||||
summary.apiRequestsPerFeatureVisit <= SOAK_LIMITS.maxApiRequestsPerFeatureVisit,
|
||||
detail: `${summary.apiRequests} requests / ${summary.featureVisits} visits`,
|
||||
},
|
||||
{
|
||||
name: "telemetry rate",
|
||||
@@ -348,6 +353,8 @@ export async function runBrowserSoak(
|
||||
intervalMs: number;
|
||||
warmupMs: number;
|
||||
routes: readonly string[];
|
||||
/** A feature's protected list: signed in on, then visited with the rest. */
|
||||
featureRoute: string;
|
||||
}>,
|
||||
): Promise<SoakArtifact> {
|
||||
try {
|
||||
@@ -397,13 +404,14 @@ export async function runBrowserSoak(
|
||||
await page.addInitScript(PAGE_PROBES);
|
||||
const cdp = await page.context().newCDPSession(page);
|
||||
await cdp.send("Performance.enable");
|
||||
await page.goto(`${baseUrl}/examples/reference-resources`, { waitUntil: "load" });
|
||||
await page.goto(`${baseUrl}${options.featureRoute}`, { waitUntil: "load" });
|
||||
await page.waitForSelector("#root > *", { timeout: 15_000 });
|
||||
// Protected routes need a session: start the local demo session once, so
|
||||
// the reference feature really dispatches its (failing) API requests.
|
||||
const login = page.getByRole("button", { name: /로그인 시작|Sign in|Start sign-in/u });
|
||||
if (await login.count()) {
|
||||
await login.first().click();
|
||||
// the feature really dispatches its (failing) API requests.
|
||||
// The prompt draws once the feature's context routes have loaded.
|
||||
const login = page.getByRole("button", { name: /로그인 시작|Sign in|Start sign-in/u }).first();
|
||||
if (await login.waitFor({ timeout: 10_000 }).then(() => true, () => false)) {
|
||||
await login.click();
|
||||
await page.waitForTimeout(500);
|
||||
}
|
||||
|
||||
@@ -412,8 +420,8 @@ export async function runBrowserSoak(
|
||||
let nextSample = 0;
|
||||
let cycles = 0;
|
||||
let navigationFailures = 0;
|
||||
let referenceVisits = 0;
|
||||
let settledReferenceVisits = 0;
|
||||
let featureVisits = 0;
|
||||
let settledFeatureVisits = 0;
|
||||
const probe = async () =>
|
||||
(await page.evaluate(() =>
|
||||
(window as unknown as { __soakProbe: () => Probe }).__soakProbe(),
|
||||
@@ -421,7 +429,7 @@ export async function runBrowserSoak(
|
||||
while (Date.now() - started < options.durationMs) {
|
||||
const route = options.routes[cycles % options.routes.length] ?? "/";
|
||||
cycles += 1;
|
||||
if (route === "/examples/reference-resources") referenceVisits += 1;
|
||||
if (route === options.featureRoute) featureVisits += 1;
|
||||
// Client-side navigation keeps one long-lived document, like a real session.
|
||||
await page.evaluate((target) => {
|
||||
window.history.pushState({}, "", target);
|
||||
@@ -436,10 +444,10 @@ export async function runBrowserSoak(
|
||||
);
|
||||
if (!rendered) navigationFailures += 1;
|
||||
// Most visits leave after 50ms, which cancels the query (a cancelled
|
||||
// request is intentionally not reported). Every 5th reference visit
|
||||
// request is intentionally not reported). Every 5th feature visit
|
||||
// dwells until its interaction settles, so the failing backend is really
|
||||
// observed end to end: bounded retries, then feature/platform telemetry.
|
||||
if (route === "/examples/reference-resources" && referenceVisits % 5 === 1) {
|
||||
if (route === options.featureRoute && featureVisits % 5 === 1) {
|
||||
await page.waitForTimeout(200);
|
||||
await page
|
||||
.waitForFunction(
|
||||
@@ -448,7 +456,7 @@ export async function runBrowserSoak(
|
||||
{ timeout: 5_000 },
|
||||
)
|
||||
.catch(() => undefined);
|
||||
settledReferenceVisits += 1;
|
||||
settledFeatureVisits += 1;
|
||||
}
|
||||
const elapsedMs = Date.now() - started;
|
||||
if (elapsedMs >= nextSample) {
|
||||
@@ -483,8 +491,8 @@ export async function runBrowserSoak(
|
||||
{
|
||||
cycles,
|
||||
navigationFailures,
|
||||
referenceVisits,
|
||||
settledReferenceVisits,
|
||||
featureVisits,
|
||||
settledFeatureVisits,
|
||||
finalInFlightRequests,
|
||||
apiRequests: counters.apiRequests,
|
||||
telemetryPosts: counters.telemetryPosts,
|
||||
@@ -526,16 +534,23 @@ async function main(): Promise<void> {
|
||||
const argument = (name: string, fallback: string) =>
|
||||
process.argv.find((entry) => entry.startsWith(`--${name}=`))?.slice(name.length + 3) ?? fallback;
|
||||
const artifact = path.resolve(argument("artifact", "artifacts/scale/browser-soak.json"));
|
||||
const ownBuild = argument("dist", "");
|
||||
const generated = ownBuild === "" ? await buildWithGeneratedFeature("browser-soak") : undefined;
|
||||
const featureRoute = generated ? generated.feature.list.path : argument("feature-route", "");
|
||||
if (featureRoute === "") {
|
||||
throw new Error("--dist needs --feature-route=<a feature's protected list path in that build>");
|
||||
}
|
||||
const result = await runBrowserSoak({
|
||||
distRoot: argument("dist", "dist"),
|
||||
distRoot: generated?.dist ?? ownBuild,
|
||||
durationMs: Number(argument("duration-ms", "60000")),
|
||||
intervalMs: Number(argument("interval-ms", "5000")),
|
||||
warmupMs: Number(argument("warmup-ms", "15000")),
|
||||
routes: argument(
|
||||
"routes",
|
||||
"/,/examples/reference-resources,/examples/platform,/examples/ui,/examples/states,/examples/reference-resources/status",
|
||||
["/", featureRoute, "/examples/platform", generated?.feature.create.path ?? "/not-found"].join(","),
|
||||
).split(","),
|
||||
});
|
||||
featureRoute,
|
||||
}).finally(() => generated?.remove());
|
||||
await mkdir(path.dirname(artifact), { recursive: true });
|
||||
await writeFile(artifact, `${JSON.stringify(result, null, 2)}\n`);
|
||||
process.stdout.write(
|
||||
|
||||
@@ -8,8 +8,10 @@ import {
|
||||
} from "node:fs/promises";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { ROUTE_FEATURE_OWNER } from "../src/features/installed-feature-contracts.ts";
|
||||
import { loadCiGateContract } from "./contracts/ci-gates.ts";
|
||||
import { createFileSystemDeclarationSource } from "./generate-product-feature-index.ts";
|
||||
import { productFeatureResidue } from "./lib/feature-residue.ts";
|
||||
import { isProductionModulePath } from "./lib/risk-coverage.ts";
|
||||
@@ -32,42 +34,92 @@ import {
|
||||
import { REMOVABLE_TEMPLATE_FEATURES } from "./lib/removable-template-features.ts";
|
||||
|
||||
/**
|
||||
* 09-07 (D-10). Removes one installed feature, `--feature=<id>` (default: the
|
||||
* reference sample), from a copy of the repository and proves the rest still
|
||||
* typechecks, tests, covers and builds. Every feature loses its directory, its
|
||||
* tests/features directory, its context when no other feature is left in it,
|
||||
* its runtime-profile override and its central policy rows. The sample also
|
||||
* owns the extra paths and scripts listed in SAMPLE_EXTRAS.
|
||||
* 09-07 (D-10). Removes one installed feature, `--feature=<id>`, from a copy
|
||||
* of the repository and proves the rest still typechecks, tests, covers and
|
||||
* builds. Every feature loses its directory, its tests/features directory,
|
||||
* its context when no other feature is left in it, its runtime-profile
|
||||
* override and its central policy rows. A sample that
|
||||
* scripts/lib/removable-template-features.ts lists also loses its extra paths
|
||||
* and package scripts, with the CI evidence only those scripts produce, and
|
||||
* the copy then gets a feature from create:feature and runs the gates again.
|
||||
*
|
||||
* Without `--feature` (FE-GATE-020) each listed sample is removed in turn.
|
||||
* The template lists none since its samples were deleted (2026-11-07): the
|
||||
* run then reports the drill as skipped, not passed, and test:feature-scaffold
|
||||
* removes a generated feature through `--feature`.
|
||||
*/
|
||||
const featureId =
|
||||
process.argv.find((argument) => argument.startsWith("--feature="))
|
||||
?.slice("--feature=".length) ?? "reference-feature";
|
||||
const SAMPLE_REPORT = "artifacts/tests/sample-removal.xml";
|
||||
const requestedFeature = process.argv
|
||||
.find((argument) => argument.startsWith("--feature="))
|
||||
?.slice("--feature=".length);
|
||||
|
||||
if (requestedFeature === undefined) {
|
||||
const checks: RemovalCheck[] = REMOVABLE_TEMPLATE_FEATURES.map((sample) => {
|
||||
const status = spawnSync(
|
||||
process.execPath,
|
||||
[fileURLToPath(import.meta.url), `--feature=${sample.featureId}`],
|
||||
{ stdio: "inherit" },
|
||||
).status;
|
||||
return status === 0
|
||||
? { name: sample.featureId, passed: true }
|
||||
: {
|
||||
name: sample.featureId,
|
||||
passed: false,
|
||||
failure: `test:sample-removal -- --feature=${sample.featureId} exited ${status ?? "on a signal"}`,
|
||||
};
|
||||
});
|
||||
await mkdir("artifacts/tests", { recursive: true });
|
||||
if (checks.length === 0) {
|
||||
await writeFile(
|
||||
SAMPLE_REPORT,
|
||||
`<?xml version="1.0" encoding="UTF-8"?>\n` +
|
||||
`<testsuite name="sample-removal" tests="1" failures="0" skipped="1">` +
|
||||
`<testcase name="listed-samples"><skipped message="scripts/lib/removable-template-features.ts lists no sample" /></testcase>` +
|
||||
`</testsuite>\n`,
|
||||
);
|
||||
process.stdout.write(
|
||||
"sample removal: SKIP (scripts/lib/removable-template-features.ts lists no sample; " +
|
||||
"test:feature-scaffold removes a generated feature with --feature)\n",
|
||||
);
|
||||
} else {
|
||||
await writeFile(SAMPLE_REPORT, renderRemovalJunit("sample-removal", checks));
|
||||
if (checks.some((check) => !check.passed)) process.exitCode = 1;
|
||||
}
|
||||
process.exit();
|
||||
}
|
||||
const featureId: string = requestedFeature;
|
||||
|
||||
type FeatureExtras = Readonly<{
|
||||
paths: readonly string[];
|
||||
ciScripts: readonly string[];
|
||||
evidencePathFragments: readonly string[];
|
||||
residue: RegExp;
|
||||
}>;
|
||||
|
||||
// The sample's own files and scripts outside its folders are declared with
|
||||
// the other removable template features, which verify:documentation reads too.
|
||||
const REFERENCE_SAMPLE = REMOVABLE_TEMPLATE_FEATURES.find(
|
||||
(feature) => feature.featureId === "reference-feature",
|
||||
);
|
||||
if (REFERENCE_SAMPLE === undefined) {
|
||||
throw new Error("scripts/lib/removable-template-features.ts does not declare reference-feature");
|
||||
/** The CI evidence that only `scripts` produce: it goes with them. */
|
||||
async function evidenceOnlyFrom(scripts: readonly string[]): Promise<string[]> {
|
||||
if (scripts.length === 0) return [];
|
||||
const contract = await loadCiGateContract(process.cwd());
|
||||
const commandIds = new Set(
|
||||
contract.commands.filter(({ script }) => scripts.includes(script)).map(({ id }) => id),
|
||||
);
|
||||
return contract.artifacts.flatMap((artifact) =>
|
||||
artifact.production === "command-generated" &&
|
||||
artifact.producerCommandIds.length > 0 &&
|
||||
artifact.producerCommandIds.every((commandId) => commandIds.has(commandId))
|
||||
? [artifact.path]
|
||||
: [],
|
||||
);
|
||||
}
|
||||
|
||||
const SAMPLE_EXTRAS: Readonly<Record<string, FeatureExtras>> = Object.freeze({
|
||||
"reference-feature": Object.freeze({
|
||||
paths: REFERENCE_SAMPLE.extraPaths,
|
||||
ciScripts: REFERENCE_SAMPLE.scripts,
|
||||
evidencePathFragments: [
|
||||
"reference-feature.xml",
|
||||
],
|
||||
residue: /REFERENCE_RESOURCE|reference-feature|reference-resource/i,
|
||||
}),
|
||||
// The sample's own files and scripts outside its folders, which
|
||||
// verify:documentation reads too.
|
||||
const listedSample = REMOVABLE_TEMPLATE_FEATURES.find(
|
||||
(feature) => feature.featureId === featureId,
|
||||
);
|
||||
const extras: FeatureExtras = Object.freeze({
|
||||
paths: listedSample?.extraPaths ?? [],
|
||||
ciScripts: listedSample?.scripts ?? [],
|
||||
evidencePathFragments: await evidenceOnlyFrom(listedSample?.scripts ?? []),
|
||||
});
|
||||
|
||||
function escapeRegExp(value: string): string {
|
||||
@@ -106,15 +158,6 @@ async function locateFeature(id: string) {
|
||||
}
|
||||
|
||||
const located = await locateFeature(featureId);
|
||||
const extras: FeatureExtras = SAMPLE_EXTRAS[featureId] ?? Object.freeze({
|
||||
paths: [],
|
||||
ciScripts: [],
|
||||
evidencePathFragments: [],
|
||||
residue: new RegExp(
|
||||
`${escapeRegExp(featureId)}|${escapeRegExp(located.directory)}`,
|
||||
"i",
|
||||
),
|
||||
});
|
||||
// Captured from this repository before the copy loses them.
|
||||
const featureRouteIds = Object.entries(ROUTE_FEATURE_OWNER)
|
||||
.filter(([, owner]) => owner === featureId)
|
||||
@@ -124,7 +167,7 @@ const fixtureRoot = await createRemovalFixtureRoot(`${featureId}-removal`);
|
||||
const pnpmCli = requireRemovalFixtureEnvironment("npm_execpath");
|
||||
const featureSource = `src/features/${located.directory}`;
|
||||
const featureTests = `tests/features/${located.directory}`;
|
||||
const isSample = featureId in SAMPLE_EXTRAS;
|
||||
const isSample = listedSample !== undefined;
|
||||
/**
|
||||
* Platform tests that must survive the sample feature's removal. Asserting they
|
||||
* are still present is what stops the removal fixture from "passing" by having
|
||||
@@ -281,12 +324,6 @@ try {
|
||||
const retainedCriticalModules = coveragePolicy.criticalModules.filter(
|
||||
(modulePolicy) => !modulePolicy.path?.startsWith(`${featureSource}/`),
|
||||
);
|
||||
if (
|
||||
isSample &&
|
||||
retainedCriticalModules.length === coveragePolicy.criticalModules.length
|
||||
) {
|
||||
throw new Error("Reference feature coverage policy is not registered");
|
||||
}
|
||||
coveragePolicy.criticalModules = retainedCriticalModules;
|
||||
coveragePolicy.highRiskPaths = coveragePolicy.highRiskPaths.filter(
|
||||
(modulePath) => !modulePath.startsWith(`${featureSource}/`),
|
||||
@@ -299,7 +336,7 @@ try {
|
||||
);
|
||||
coveragePolicy.repositoryBaseline -= removedProductionModuleCount;
|
||||
if (coveragePolicy.repositoryBaseline <= 0) {
|
||||
throw new Error("Reference feature removal produced an invalid coverage baseline");
|
||||
throw new Error(`${featureId} removal produced an invalid coverage baseline`);
|
||||
}
|
||||
await writeFile(
|
||||
coveragePolicyFile,
|
||||
@@ -400,7 +437,7 @@ try {
|
||||
// JavaScript of the features installed now, and test:unit compares a build
|
||||
// with it. A product re-records it when it adds a feature; removing that
|
||||
// feature changes it again, so the fixture re-records it as the product
|
||||
// would. The sample removal deletes the measurement with the sample.
|
||||
// would.
|
||||
const measurement = path.join(fixtureRoot, "scripts/scale/measure-feature-shape-growth.ts");
|
||||
if (await access(measurement).then(() => true, () => false)) {
|
||||
const measured = spawnSync(
|
||||
@@ -414,22 +451,13 @@ try {
|
||||
}
|
||||
await regenerateRemovalFixtureWorkflow(fixtureRoot);
|
||||
|
||||
const residue: string[] = [];
|
||||
if (isSample) {
|
||||
for (const root of ["src", "tests"]) {
|
||||
for (const file of await filesBelow(path.join(fixtureRoot, root))) {
|
||||
const relative = path.relative(fixtureRoot, file);
|
||||
const content = await readFile(file, "utf8");
|
||||
if (extras.residue.test(`${relative}\n${content}`)) {
|
||||
residue.push(relative);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 1105/16-04. Template tests use example feature IDs as data; only what
|
||||
// still points at the removed feature counts (scripts/lib/feature-residue.ts).
|
||||
residue.push(...(await productFeatureResidue(fixtureRoot, featureId, located.directory)));
|
||||
}
|
||||
// 1105/16-04. Template tests use example feature IDs as data; only what
|
||||
// still points at the removed feature counts (scripts/lib/feature-residue.ts).
|
||||
const residue = await productFeatureResidue(fixtureRoot, featureId, located.directory);
|
||||
const builtResiduePattern = new RegExp(
|
||||
`${escapeRegExp(featureId)}|${escapeRegExp(located.directory)}`,
|
||||
"i",
|
||||
);
|
||||
|
||||
const missingCommonTests: string[] = [];
|
||||
for (const testPath of commonTestPaths) {
|
||||
@@ -471,7 +499,7 @@ try {
|
||||
for (const file of await filesBelow(path.join(fixtureRoot, "dist"))) {
|
||||
if (!/\.(?:js|css|html|json)$/.test(file)) continue;
|
||||
const content = await readFile(file, "utf8");
|
||||
if (extras.residue.test(content)) {
|
||||
if (builtResiduePattern.test(content)) {
|
||||
builtResidue.push(path.relative(fixtureRoot, file));
|
||||
}
|
||||
}
|
||||
@@ -493,9 +521,9 @@ try {
|
||||
outcome("built-fixture-id-residue", builtResidue, "built residue"),
|
||||
);
|
||||
|
||||
// U7 (decision 4). The same copy, now without the sample, gets one feature
|
||||
// from create:feature and runs the same gates again: the command and the
|
||||
// feature it writes need nothing from the sample.
|
||||
// U7 (decision 4). The same copy, now without the listed sample, gets one
|
||||
// feature from create:feature and runs the same gates again: the command
|
||||
// and the feature it writes need nothing from the sample.
|
||||
if (isSample) {
|
||||
// 1103/09-06. With the write slice (NEVER), which needs nothing from
|
||||
// the sample either.
|
||||
@@ -513,9 +541,7 @@ try {
|
||||
const failed = checks.filter((entry) => !entry.passed);
|
||||
await mkdir("artifacts/tests", { recursive: true });
|
||||
await writeFile(
|
||||
isSample
|
||||
? "artifacts/tests/sample-removal.xml"
|
||||
: `artifacts/tests/feature-removal-${featureId}.xml`,
|
||||
`artifacts/tests/feature-removal-${featureId}.xml`,
|
||||
renderRemovalJunit(`${featureId}-removal`, checks),
|
||||
);
|
||||
if (failed.length > 0) {
|
||||
|
||||
@@ -187,15 +187,12 @@ const gateIds = new Set([
|
||||
).gates.map((gate) => gate.id),
|
||||
...RETIRED_GATE_IDS,
|
||||
]);
|
||||
// 1105/14-01. A copy may delete the template features listed in
|
||||
// scripts/lib/removable-template-features.ts, and the CHANGELOG tells
|
||||
// tech-log to delete the example screens. The documents are the template's:
|
||||
// a product that edited them to drop the feature's paths would conflict on
|
||||
// every sync. While a feature is installed (its feature-module.ts exists),
|
||||
// its paths and scripts are checked like any other; once it is not, they are
|
||||
// not drift. tech-log keeps the reference sample's folder with its contracts
|
||||
// but without its module, screens and tests (CHANGELOG "먼저 할 일" 1). A
|
||||
// misspelt feature folder is not on the list and still fails.
|
||||
// 1105/14-01. A copy may delete the sample features listed in
|
||||
// scripts/lib/removable-template-features.ts (the template lists none since
|
||||
// 2026-11-07). The documents may name a sample's paths: while it is installed
|
||||
// (its feature-module.ts exists), its paths and scripts are checked like any
|
||||
// other; once it is not, they are not drift. A misspelt feature folder is not
|
||||
// on the list and still fails.
|
||||
const removedTemplateFeatures = REMOVABLE_TEMPLATE_FEATURES.filter(
|
||||
(feature) => !exists(`src/features/${feature.featureId}/feature-module.ts`),
|
||||
);
|
||||
|
||||
@@ -35,7 +35,6 @@ export const EXTREME_SCALE_GATES = Object.freeze([
|
||||
"check:observability",
|
||||
"check:release-coherence",
|
||||
"test:platform",
|
||||
"test:reference-feature",
|
||||
"check:scale:pr",
|
||||
"check:scale:main",
|
||||
"check:scale:baseline",
|
||||
|
||||
Reference in New Issue
Block a user