Files
clean-architecture-frontend…/tests/unit/deletable-history-documents.test.ts
T
DongHyeonka 429b8d8802 docs(history): 루트의 tasks/와 .superpowers/ 기록을 docs/history로 옮긴다
문제: 끝난 작업의 기록이 루트 폴더 둘에 따로 있다. tasks/는 2026-09-25
리뷰 수정 라운드(v0.2.0으로 끝남)의 계획·작업 목록·인계·레인 지시서와
레인 준비 스크립트 5개, .superpowers/는 2026-08-01 런타임 정합성 수정의
작업 보고 1개다. 읽는 코드는 없다(tests/unit/deletable-history-
documents.test.ts가 지킨다). 소유자가 2026-11-07 백엔드와 같이 이력
폴더로 옮기기로 정했다.

고른 방법:
- tasks/ → docs/history/plans/2026-09-25-review-fix-round/ (lanes/ 유지),
  .superpowers/sdd/2026-08-01-runtime-correctness-remediation/
  task-5-report.md → docs/history/evidence/2026-08-01-runtime-correctness-
  remediation/. 폴더 이름은 docs-system 2절과 백엔드를 따른다.
- .md 5개 맨 위에 docs-system 4.1절 머리 블록 9줄(빈 줄 포함, 백엔드와
  같은 모양)을 단다. 본문은 바꾸지 않았다: 블록 9줄을 빼면 옛 파일과
  바이트가 같다(cmp). setup-lane.sh는 실행 파일(첫 줄 shebang)이라 블록을
  달지 않고 그대로 옮긴다(R100). 같은 폴더 LANE-BRIEF.md의 블록이 그
  파일을 설명한다.
- 상태: 계획서 넷은 끝남. 기계 규칙(체크 상자가 모두 표시돼야 끝남)으로는
  plan·todo가 확인 안 함이지만, 이력이 라운드의 끝을 정한다(CHANGELOG
  0.2.0, 태그 v0.2.0 2026-09-27). 증거는 보관.
- 작성일: plan·todo는 2026-09-25. git이 처음 더한 날(ea0f01f,
  2026-09-24)은 이 파일이 앞 라운드(src 리뷰) 계획이던 때이고, 지금
  본문은 c5f379b(2026-09-25)가 통째로 다시 썼다. handoff는 본문 날짜 줄
  (2026-09-26 01:10), LANE-BRIEF는 git이 처음 더한 날(54ba358,
  2026-09-26), 보고는 git이 처음 더한 날(d9afccd, 2026-08-02).
- docs/README.md: 3절 지도에 history/ 행을 더하고 옛 경로 → 새 경로를
  적는다. 블록 첫 줄이 가리키는 「기록 문서의 머리 블록」 절(4절)을
  더한다. ../tasks/ 링크는 없앴다. README.md의 "Files you can delete
  after copying" 행도 docs/history/로 바꾼다.
- deletable-history-documents.test.ts: docs/history 패턴을 더하고
  tasks/ 패턴은 뺀다. 루트 tasks/가 없어져 그 패턴이 지킬 문서가 없고,
  남기면 제품의 "tasks/..." 라우트·폴더 문자열을 잘못 잡는다.
버린 대안: 옮긴 파일을 가리키는 다른 기록(docs/superpowers/plans/
2026-08-02-*.md, docs/reviews/2026-09-25-maturity-review/, SPEC.md)의
옛 경로를 고치기. 기록 본문은 고치지 않는다(docs-system 1절). 대신 지도
행에 옛 경로를 적었다.

위험·한계: SPEC.md는 이번에 옮기지 않는다. 27~37줄 「공통 완료 기준」을
작업 매뉴얼(docs/work/improve.md, 뒤 단계)로 옮긴 뒤 같은 폴더로 보낸다.
secret-scan-policy.json의 trackedRoots와 루트 경로 목록 7곳에는 tasks,
.superpowers가 없어 바꿀 것이 없다.

검증:
- 옮긴 .md 5개: 첫 9줄을 빼면 옛 파일과 cmp가 같다. git diff -M이
  R091~R100 rename으로 잡고 지운 줄은 0이다.
- desktop(네 커밋의 끝 30a379f, 로그 ~/l1-layout-cleanup-logs/):
  deletable-history-documents.test.ts는 지금 트리에서 통과하고, 테스트
  폴더에 "docs/history/plans"를 담은 파일 하나를 두면 그 줄을 내며
  실패한다. verify:documentation: PASS_SCOPED. test:unit 3091 tests 통과.

Refs: design-docs repo-structure/04-frontend-layout.md 2.1절, 9.2절;
design-docs conventions/docs-system.md 2·4절
2026-11-07 19:02:47 +09:00

88 lines
3.1 KiB
TypeScript

import { readdir, readFile } from "node:fs/promises";
import path from "node:path";
import { describe, expect, it } from "vitest";
/**
* README.md, "Files you can delete after copying", tells a new project that
* the build and the gates read none of the history documents except
* `docs/reviews/adapters/INVENTORY.md`. The removal fixtures rely on the same
* promise: they do not copy `docs/`. A test that opens a review document broke
* all three removal checks (fix of 11-04), so the promise is checked here.
*/
const CODE_ROOTS = ["src", "tests", "scripts", "config", "recipes", "schemas", ".gitea"];
const ROOT_FILES = [
"package.json",
"vite.config.ts",
"vitest.config.ts",
"eslint.config.ts",
"playwright.config.ts",
".dependency-cruiser.json",
];
// Built from pieces so that this file does not match itself.
const REVIEWS = ["docs", "reviews", ""].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
// for the old root folder would now only catch a product's own route or
// folder of that name.
const DELETABLE = [
new RegExp(`${REVIEWS}(?!adapters/INVENTORY\\.md)`, "u"),
new RegExp(["docs", "superpowers"].join("/"), "u"),
new RegExp(["docs", "history"].join("/"), "u"),
new RegExp(`\\b${"SPEC"}\\.md\\b`, "u"),
new RegExp(`\\b${"CLAUDE"}\\.md\\b`, "u"),
];
/**
* 1101/14-01. A section number without a document name cannot be followed,
* and the scale design it meant used to live only in the history bundle a
* copy deletes. Cite it as `scale-architecture.md §N`
* (docs/architecture/scale-architecture.md, a current contract).
*/
const UNNAMED_SECTION = new RegExp(`\\b${"spec"} ?§`, "iu");
async function codeFiles(directory: string): Promise<string[]> {
const entries = await readdir(directory, { withFileTypes: true }).catch(
() => [],
);
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 files.flat();
}
async function linesMatching(patterns: readonly RegExp[]): Promise<string[]> {
const files = [
...(await Promise.all(CODE_ROOTS.map(codeFiles))).flat(),
...ROOT_FILES,
];
const matches: string[] = [];
for (const file of files) {
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}`);
});
}
return matches;
}
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([]);
});
it("are not cited as an unnamed design section", async () => {
expect(
await linesMatching([UNNAMED_SECTION]),
"name the document: scale-architecture.md §N",
).toEqual([]);
});
});