diff --git a/CHANGELOG.md b/CHANGELOG.md index ad4bc23b..f53f81ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -177,6 +177,7 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지 | FE-GATE-013의 시스템 컨테이너 래퍼(`scripts/run-in-system-container.sh`)가 게이트 도중 TERM·INT·HUP(시간 초과, Ctrl-C, 터미널 끊김)을 받으면 그때까지 쌓인 `artifacts/`를 되가져오고 컨테이너를 지운 뒤 그 신호로 끝난다. 게이트 전에 받으면 컨테이너만 지우고 그 신호로 끝난다. 고치기 전에는 게이트 도중 TERM·HUP에 증거 없이 끝났고, 게이트 전 Ctrl-C에는 부팅·복사를 이어 가 게이트까지 돌았고, `docker run` 도중의 신호에는 컨테이너가 남았다. 컨테이너 이름은 `fe-system-container-`이고 정리는 이름으로 지운다. 게이트 로그는 끝날 때 쓰므로 신호로 끊긴 실행에서는 오지 않는다. SIGKILL 뒤 남은 컨테이너를 찾아 지우는 명령은 운영 문서 FE-GATE-013 절에 있다 | `scripts/run-in-system-container.sh`, `tests/unit/ci-gate-host-environment.test.ts`, `docs/operations/ci-quality-gates.md` | `b5f28e52` | | 노트북 `scripts/verify.sh docs`(`scripts/check-work-docs.py`)가, 기능 제거 드릴이 사본에서만 지우는 시험(`scripts/test-sample-removal.ts`의 `excludedFixtureTest` 목록)을 드릴 사본의 `verify:documentation`이 경로로 읽는 자리에 적으면 `file:line`으로 실패한다. 그 자리는 드릴이 복사하는 살아 있는 문서의 백틱 경로·명령 인자·상대 링크와 기록 문서 머리 블록의 「현재 정본」「대체」「대체됨」이다. 전에는 desktop FE-GATE-020에서야 드러났다. 그런 시험은 폴더와 파일 이름을 따로 적는다(`tests/unit/`의 `removal-fixture.test.ts`). 드릴은 `package.json`의 `test:sample-removal`로 찾는다. 그 script가 읽을 드릴 파일을 가리키지 않으면 「runs no drill file」, 목록을 못 찾으면 「was not found」, 목록에 큰따옴표 경로 말고 다른 것(펼침·작은따옴표)이 있으면 「holds more than double-quoted paths」로 실패한다. 이 규칙의 정본은 TypeScript이고, Python으로 다시 쓴 쪽과 어긋나면 `scripts/tests/test_check_work_docs.py`가 실패한다 | `scripts/check-work-docs.py`, `scripts/tests/test_check_work_docs.py`, `scripts/test-sample-removal.ts`, `docs/operations/adapter-remediation-ledger.md` | `d87f6792` | | FE-GATE-005의 기능 모양 기록 대조(`initialJavascriptRecordDrift`)가 `perContextGzipBytes` 칸만 바닥 64 B로 본다(전에는 16 B). 이 칸은 커밋 사이에서 2~28 B를 오가, 초기 청크를 바꾼 PR이 먼저 병합된 뒤 다른 PR이 낡은 base에서 잰 기록을 쓰면 main이 빨강이 됐다. 다른 칸의 16 B, 합계 256 B, context 상한 512 B는 그대로다. 소유자 결정 DES-DEC-0002(`docs/work/reference/decisions.md` 2.2절) | `scripts/scale/measure-feature-shape-growth.ts`, `tests/unit/feature-shape-growth.test.ts`, `docs/work/reference/decisions.md` | `e21a8355` | +| 이력 문서를 읽지 않는지 보는 검사(`tests/unit/deletable-history-documents.test.ts`, FE-GATE-005)가 `history-free` 목록 대신 git이 무시하지 않는 코드·설정 파일(그 시험의 `CODE_FILE` 확장자)을 본다. 복사한 프로젝트의 루트 설정이 지워도 되는 이력 문서를 읽고 있으면 새로 실패한다. 그 읽기를 없앤다. `tests/features` 바로 아래에 있던 플랫폼 시험 `feature-module`·`product-features-scale`은 `tests/unit/`로 옮기고, 지워진 참조 기능만 보던 `feature-installation-surface` 시험은 지웠다. 폴더는 `.gitkeep`으로 남는다 | `tests/unit/`, `tests/features/`, `config/repository-layout.json` | `2816a42f`, `3686f92c` | ## 미출시 — `8327e221` → 하네스와 작업 매뉴얼 diff --git a/config/repository-layout.json b/config/repository-layout.json index a8657b8a..aa6f319e 100644 --- a/config/repository-layout.json +++ b/config/repository-layout.json @@ -13,7 +13,7 @@ "fixture-copy": "제거·생성 drill과 사본 시험이 복사하는 것(scripts/lib/removal-fixture.ts)", "fixture-documents": "기능을 더하거나 지우는 drill이 문서까지 맞는지 보려고 더 복사하는 문서(scripts/lib/removal-fixture.ts)", "secret-scan": "비밀값 검사가 꼭 있어야 한다고 보는 루트. config/security/secret-scan-policy.json의 trackedRoots가 이 집합과 같아야 한다. 검사와 공급망 목록 자체는 추적되는 파일 전부와 dist, artifacts/release를 본다(scripts/lib/repository-file-inventory.ts)", - "history-free": "이력 문서를 읽으면 안 되는 코드(tests/unit/deletable-history-documents.test.ts)", + "history-free": "이력 문서를 읽지 않는지 보는 검사가 꼭 닿아야 하는 루트. 검사 자체는 git이 무시하지 않는 파일 가운데 그 시험의 확장자 목록(CODE_FILE)에 든 것에서 문서·이력·추적하지 않는 항목만 빼고 본다(tests/unit/deletable-history-documents.test.ts)", "scale-source": "규모 증거에서 '지금 코드'를 정하는 입력(scripts/verify-extreme-scale.ts)", "vite-build": "vite build가 읽는 입력(scripts/lib/vite-build-inputs.ts)", "typescript-only": "JS 파일을 두면 안 되는 곳(scripts/check-architecture.ts)", diff --git a/tests/features/.gitkeep b/tests/features/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/features/feature-installation-surface.test.ts b/tests/features/feature-installation-surface.test.ts deleted file mode 100644 index 727ef131..00000000 --- a/tests/features/feature-installation-surface.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { readFile } from "node:fs/promises"; -import { describe, expect, it } from "vitest"; -const files=["installed-product-manifest.ts","installed-feature-adapters.ts","loaded-feature-runtimes.ts","installed-feature-messages.ts","installed-contract-contributions.ts","installed-feature-contracts.ts"]; -describe("feature installation surface", () => { - it("contains no reference-specific central imports", async () => { - for(const name of files){const source=await readFile(new URL(`../../src/features/${name}`,import.meta.url),"utf8"); expect(source).not.toMatch(/REFERENCE_FEATURE_(ADAPTER|RUNTIME|CONTRACT)/); expect(source).not.toMatch(/REFERENCE_MESSAGE_CATALOGS/);} - }); -}); diff --git a/tests/unit/deletable-history-documents.test.ts b/tests/unit/deletable-history-documents.test.ts index 3ab93da6..fbf5af89 100644 --- a/tests/unit/deletable-history-documents.test.ts +++ b/tests/unit/deletable-history-documents.test.ts @@ -1,9 +1,21 @@ -import { readdir, readFile, stat } from "node:fs/promises"; +import { spawnSync } from "node:child_process"; +import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { readFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; -import { selectRepositoryPaths } from "../../scripts/lib/repository-layout.ts"; +import { + parseRepositoryLayout, + REPOSITORY_LAYOUT, + selectRepositoryEntries, + type RepositoryLayoutEntry, +} from "../../scripts/lib/repository-layout.ts"; +import { + childProcessTimeout, + DEFAULT_TEST_TIMEOUT_MS, +} from "../helpers/child-process-timeout.ts"; /** * README.md, 「복사한 뒤 지워도 되는 것」, tells a new project that @@ -14,14 +26,20 @@ import { selectRepositoryPaths } from "../../scripts/lib/repository-layout.ts"; * The root instruction files left the list on 2026-11-07: they are the * template's contract, which a copy keeps (template-contract-documents.test.ts). */ -// The history-free set of config/repository-layout.json (R2). The registry -// itself names every root item, history documents included (R1); naming a -// root item is not reading it. -const CODE_PATHS = selectRepositoryPaths("history-free"); +// The scan follows git's files. config/repository-layout.json says which root +// items hold no code, and its history-free set is what the scan has to reach +// (R2). The registry itself names every root item, history documents included +// (R1); naming a root item is not reading it. +const NOT_CODE_KINDS: ReadonlySet = new Set(["document", "history", "untracked"]); +const CODE_FILE = /(?:\.(?:[cm]?[jt]sx?|json|ya?ml|py|sh|css|html|conf)|Dockerfile)$/u; +// The longest of the tests that list the files, on desktop 2026-11-22 under +// load 12 to 16: 2145 ms in test:unit, 352 ms in test:coverage's suites. +const SCAN_TIMEOUT = childProcessTimeout(2_145); const LAYOUT_REGISTRY = "config/repository-layout.json"; // Built from pieces so that this file does not match itself. const REVIEWS = ["docs", "reviews", ""].join("/"); +const HISTORY = ["docs", "history"].join("/"); const KEPT = `${REVIEWS}adapters/INVENTORY.md`; // The 2026-09-25 round's task folder moved into the history folder on // 2026-11-07 (docs/README.md §3), so the history pattern covers it. A pattern @@ -30,7 +48,7 @@ const KEPT = `${REVIEWS}adapters/INVENTORY.md`; const DELETABLE = [ new RegExp(`${REVIEWS}(?!adapters/INVENTORY\\.md)`, "u"), new RegExp(["docs", "superpowers"].join("/"), "u"), - new RegExp(["docs", "history"].join("/"), "u"), + new RegExp(HISTORY, "u"), new RegExp(`\\b${"SPEC"}\\.md\\b`, "u"), ]; /** @@ -41,19 +59,42 @@ const DELETABLE = [ */ const UNNAMED_SECTION = new RegExp(`\\b${"spec"} ?§`, "iu"); -async function codeFiles(directory: string): Promise { - const entries = await readdir(directory, { withFileTypes: true }).catch( - () => [], +function scannedFiles( + listed: readonly string[], + layout: readonly RepositoryLayoutEntry[] = REPOSITORY_LAYOUT, +): string[] { + const skipped = new Set( + layout.filter(({ kind }) => NOT_CODE_KINDS.has(kind)).map((entry) => entry.path), ); - const files = await Promise.all( - entries.map(async (entry) => { - const target = path.join(directory, entry.name); - if (entry.isDirectory()) - return entry.name === "node_modules" ? [] : codeFiles(target); - return /\.(?:[cm]?[jt]sx?|json|ya?ml)$/u.test(entry.name) ? [target] : []; - }), + return listed.filter((file) => CODE_FILE.test(file) && !skipped.has(file.split("/")[0]!)); +} + +/** Without the GIT_* a hook sets, which would point git at another repository. */ +function ownRepositoryEnvironment(): NodeJS.ProcessEnv { + return Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith("GIT_"))); +} + +/** Tracked files, and new ones git does not ignore: a file counts before `git add`. */ +function repositoryFiles(root = "."): string[] { + const listed = spawnSync( + "git", + ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], + { + cwd: root, + encoding: "utf8", + env: ownRepositoryEnvironment(), + // Shorter than the test's own timeout, so a git that hangs fails as itself. + timeout: DEFAULT_TEST_TIMEOUT_MS, + killSignal: "SIGKILL", + // As treeFiles in scripts/lib/docs-system.ts: the list grows with files the scan skips. + maxBuffer: 64 * 1024 * 1024, + }, ); - return files.flat(); + if (listed.error || listed.status !== 0) { + throw new Error(`git ls-files failed: ${listed.error?.message ?? listed.stderr}`); + } + // A tracked file deleted in the work tree is still listed. + return listed.stdout.split("\0").filter((file) => file !== "" && existsSync(path.join(root, file))); } /** @@ -68,35 +109,160 @@ const RECORD_FOLDER_CHECKERS: ReadonlySet = new Set([ "tests/unit/docs-system.test.ts", ]); -async function linesMatching(patterns: readonly RegExp[]): Promise { - const files = ( - await Promise.all( - CODE_PATHS.map(async (entry) => - (await stat(entry).catch(() => null))?.isDirectory() ? codeFiles(entry) : [entry], - ), - ) - ).flat().filter((file) => !RECORD_FOLDER_CHECKERS.has(file)); - const matches: string[] = []; - for (const file of files) { +/** + * scripts/check-work-docs.py repeats that checker's folder lists + * (TypeScriptRulesTest in its test keeps the two equal), and its test writes + * records in a temporary repository. These lines are excused, not the files: + * another line there that names a history document may well read it. + */ +const RECORD_FOLDER_LINES: readonly Readonly<{ file: string; text: string }>[] = [ + { + file: "scripts/check-work-docs.py", + text: `RECORD_FOLDERS = ("docs/design/", "${HISTORY}/", "${REVIEWS}")`, + }, + { + file: "scripts/check-work-docs.py", + text: `RECORD_KINDS = ("docs/design/", "${HISTORY}/plans/", "${HISTORY}/evidence/", "${HISTORY}/packages/",`, + }, + { + file: "scripts/check-work-docs.py", + text: `"${HISTORY}/study/", "docs/adr/")`, + }, + { + file: "scripts/tests/test_check_work_docs.py", + text: `("${HISTORY}/old.md", f"\\n\`{deleted}\`\\n"),`, + }, + { + file: "scripts/tests/test_check_work_docs.py", + text: `("${REVIEWS}old-review.md", f"\\n\`{deleted}\`\\n"),`, + }, +]; + +type Match = Readonly<{ file: string; line: number; text: string }>; + +function matchingLines(file: string, content: string, patterns: readonly RegExp[]): Match[] { + return content + .split("\n") + .map((text, index) => ({ file, line: index + 1, text: text.trim() })) + .filter(({ text }) => patterns.some((pattern) => pattern.test(text))); +} + +function unexcused(matches: readonly Match[]): Match[] { + return matches.filter( + ({ file, text }) => + !RECORD_FOLDER_CHECKERS.has(file) && + !RECORD_FOLDER_LINES.some((line) => line.file === file && line.text === text), + ); +} + +async function linesMatching(patterns: readonly RegExp[]): Promise { + const matches: Match[] = []; + for (const file of scannedFiles(repositoryFiles())) { if (file === LAYOUT_REGISTRY) continue; - const lines = (await readFile(file, "utf8").catch(() => "")).split("\n"); - lines.forEach((line, index) => { - if (patterns.some((pattern) => pattern.test(line))) - matches.push(`${file}:${index + 1}`); - }); + matches.push(...matchingLines(file, await readFile(file, "utf8"), patterns)); } return matches; } +function locations(matches: readonly Match[]): string[] { + return matches.map(({ file, line }) => `${file}:${line}`); +} + describe("deletable history documents", () => { - it("are read by no code, test, script or configuration", async () => { - expect(await linesMatching(DELETABLE), `only ${KEPT} may be read`).toEqual([]); + // REV-FE-0019. A list kept by hand left out five Playwright configurations, + // the service worker build and .storybook/, so the scan follows the files. + it("are looked for in code and configuration that no list names", () => { + const layout = parseRepositoryLayout({ + schemaVersion: 1, + entries: [ + { path: "app", kind: "source", role: "code", readBy: "build", sets: ["history-free"] }, + { path: "notes", kind: "document", role: "text", readBy: "people" }, + { path: "old-rounds", kind: "history", role: "records", readBy: "people" }, + { path: "local-output", kind: "untracked", role: "output", readBy: "tools", optional: true }, + { path: ".gallery", kind: "tool-convention", role: "gallery", readBy: "tools" }, + { path: "gallery.config.ts", kind: "tool-convention", role: "gallery", readBy: "tools" }, + ], + }); + const read = [ + "app/main.tsx", + "app/tool.py", + "app/run.sh", + "app/runner.Dockerfile", + "app/theme.css", + "app/index.html", + "app/proxy.conf", + ".gallery/preview.tsx", + "gallery.config.ts", + "not-registered-yet.json", + ]; + const left = [ + "app/README.md", + "app/logo.png", + "notes/table.json", + "old-rounds/evidence.ts", + "local-output/report.json", + ]; + expect(scannedFiles([...read, ...left], layout)).toEqual(read); }); + it("are looked for however long git's list of files is", () => { + const root = mkdtempSync(path.join(tmpdir(), "history-scan-")); + try { + // 1300 files under an 880 byte folder: a list just over Node's 1 MiB default. + const folder = Array.from({ length: 4 }, () => "f".repeat(219)).join("/"); + const files = Array.from({ length: 1300 }, (_, index) => `${folder}/${index}.ts`).sort(); + mkdirSync(path.join(root, folder), { recursive: true }); + for (const file of files) writeFileSync(path.join(root, file), ""); + const made = spawnSync("git", ["init", "--quiet"], { + cwd: root, + env: ownRepositoryEnvironment(), + timeout: DEFAULT_TEST_TIMEOUT_MS, + killSignal: "SIGKILL", + }); + expect(made.status).toBe(0); + expect(Buffer.byteLength(files.join("\0"))).toBeGreaterThan(1024 * 1024); + expect(repositoryFiles(root).sort()).toEqual(files); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }, SCAN_TIMEOUT); + + it("are excused in a work document checker by the line, not by the file", () => { + const named = `RECORD_FOLDERS = ("docs/design/", "${HISTORY}/", "${REVIEWS}")`; + const read = `text = (root / "${REVIEWS}round9.md").read_text()`; + const file = "scripts/check-work-docs.py"; + const matches = matchingLines(file, [named, read].join("\n"), DELETABLE); + expect(locations(unexcused(matches))).toEqual([`${file}:2`]); + }); + + it("are looked for in each history-free root", () => { + const files = scannedFiles(repositoryFiles()); + expect(files.length).toBeGreaterThan(0); + // A removal drill may delete an optional root, or leave it empty. + const unreached = selectRepositoryEntries("history-free").filter( + ({ path: root, optional }) => + !optional && !files.some((file) => file === root || file.startsWith(`${root}/`)), + ); + expect(unreached, "roots the scan does not reach").toEqual([]); + }, SCAN_TIMEOUT); + + it("are read by no code, test, script or configuration", async () => { + const found = await linesMatching(DELETABLE); + expect(locations(unexcused(found)), `only ${KEPT} may be read`).toEqual([]); + // A copy may lack the checker; an excuse is stale only where its file is. + expect( + RECORD_FOLDER_LINES.filter( + ({ file, text }) => + existsSync(file) && !found.some((match) => match.file === file && match.text === text), + ), + "RECORD_FOLDER_LINES entries that match no line any more", + ).toEqual([]); + }, SCAN_TIMEOUT); + it("are not cited as an unnamed design section", async () => { expect( - await linesMatching([UNNAMED_SECTION]), + locations(unexcused(await linesMatching([UNNAMED_SECTION]))), "name the document: scale-architecture.md §N", ).toEqual([]); - }); + }, SCAN_TIMEOUT); }); diff --git a/tests/features/feature-module.test.ts b/tests/unit/feature-module.test.ts similarity index 100% rename from tests/features/feature-module.test.ts rename to tests/unit/feature-module.test.ts diff --git a/tests/features/product-features-scale.test.ts b/tests/unit/product-features-scale.test.ts similarity index 100% rename from tests/features/product-features-scale.test.ts rename to tests/unit/product-features-scale.test.ts diff --git a/tests/unit/ungated-tests.test.ts b/tests/unit/ungated-tests.test.ts index a290cdca..d59d88ca 100644 --- a/tests/unit/ungated-tests.test.ts +++ b/tests/unit/ungated-tests.test.ts @@ -43,7 +43,7 @@ describe("ungated test files", () => { }); it.each([ - "tests/features/feature-module.test.ts", + "tests/features/typecheck-probe-gated/probe.test.ts", "tests/architecture/observability-boundaries.test.ts", "tests/release/old-asset-reachability.test.ts", "tests/scripts/verify-extreme-scale.test.ts",