From d8136005f461b3c87f3ce7993167259b6886131d Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sat, 21 Nov 2026 15:32:54 +0900 Subject: [PATCH 01/12] =?UTF-8?q?docs(operations):=20=EC=9B=90=EC=9E=A5=20?= =?UTF-8?q?N-06~N-08=EC=97=90=EC=84=9C=20=EC=A7=80=EC=9A=B4=20V2=20?= =?UTF-8?q?=EC=8B=9C=ED=97=98=20=EA=B2=BD=EB=A1=9C=EB=A5=BC=20=EB=BA=80?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit adapter 처리 원장 N-06~N-08의 「실패 테스트 명령」 칸이 2026-11-03에 V2 client와 함께 지운 시험 파일 셋을 백틱 없는 맨 글자로 적는다. 문서 머리는 「테스트 경로는 지금 위치로 적는다」고 하고, 백틱을 붙이면 verify:documentation이 실패하므로 맨 글자로 검사를 비켜 간 모양이다. .claude/rules/docs.md는 검사를 피하려고 백틱을 빼지 말라고 한다. 세 칸을 「없음 — <무슨 시험>이었고 2026-11-03에 V2 client와 함께 지웠다(`048f490a`)」로 바꾸고 경로를 지운다. 버린 안: 원장 전체를 docs/history/로 옮기기 — 지금 위치를 가리키는 링크와 문서 지도가 같이 바뀌어 이 항목 범위를 넘는다. HISTORY_HOLDERS에 넣기 — 검사 규칙을 바꾸는 소유자 결정이다. 위험·한계: 지운 파일 이름이 이 문서에서 사라진다. 어떤 시험이었는지는 칸에 말로 남기고, 파일 이름은 지운 커밋과 기록 문서(docs/history/, docs/reviews/)에 그대로 있다. 검증: 살아 있는 문서(docs/history·docs/reviews 밖)에서 세 경로의 git grep이 main 3줄 → 0줄. verify:documentation은 PR의 desktop 묶음에서 돈다. Refs: REV-FE-0008, REV-FE-0022 --- docs/operations/adapter-remediation-ledger.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/operations/adapter-remediation-ledger.md b/docs/operations/adapter-remediation-ledger.md index 401a16ea..0d4a883e 100644 --- a/docs/operations/adapter-remediation-ledger.md +++ b/docs/operations/adapter-remediation-ledger.md @@ -75,9 +75,9 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | N-03 | 실행 중인 V3 경로 | `corepack pnpm exec vitest run tests/unit/http-execution-v3.test.ts -t "retry-time fence"` | `fix: preserve command effect certainty across retries` | `FIXED_NOT_RELEASED` | command effect 판정 회귀 | 실패: 시도 한 번을 보낸 뒤 `NOT_STARTED`와 함께 `SCOPE_FENCED`가 재현됨 → 통과 `MAYBE_APPLIED`. lattice 표 9/9. `check:types` PASS. `lint` PASS | | N-04 | 실행 중인 조립의 정리(teardown) | `corepack pnpm exec vitest run tests/unit/telemetry.test.ts tests/unit/runtime-adapters.test.ts` | `fix: terminate telemetry work on disposal` | `FIXED_NOT_RELEASED` | teardown 변경 뒤 telemetry 전달 유실 | 실패 10개(lifecycle 5 + capacity 5) → 통과 34/34. `check:diagnostics` PASS. `check:types` PASS. `check:architecture` PASS. `lint` PASS | | N-05 | Rollout 차단 요인(sidecar 조립 안 됨) | `corepack pnpm exec vitest run tests/unit/conditional-validator-store.test.ts` | `fix: harden bounded state sidecars` | `FIXED_NOT_RELEASED` | 저장된 validator 키 비호환 | 실패: 충돌 사례(올바른 binding 두 개가 구분자로 이은 키 하나를 공유) → 통과. 키는 이제 크기가 제한되고 검증된 tuple이며 `JSON.stringify`로 인코딩한다 | -| N-06 | 구 V2 rollback 경계(seam) | V2 client 테스트 tests/integration/http-client.test.ts(2026-11-03에 V2 client와 함께 지웠다) | `fix: harden the legacy HTTP rollback path` | `FIXED_NOT_RELEASED` | 구 keyed command 거부 급증 | 실패: 잘못된 키 사례 4개 → 통과. credential과 fetch 전에 거부한다(credential 호출 0회, fetch 0회) | -| N-07 | 구 V2 rollback 경계(seam) | V2 client 테스트 tests/integration/http-client.test.ts와 tests/integration/auth-recovery.test.ts(2026-11-03에 V2 client와 함께 지웠다) | `fix: harden the legacy HTTP rollback path` | `FIXED_NOT_RELEASED` | 구 credential timeout 회귀 | 실패: 끝나지 않는 owner → 통과. credential 대기가 기존 attempt controller와 경주(race)하므로 타이머를 더 만들지 않는다. 소유권은 fetch 0회로 REQUEST_TIMEOUT / REQUEST_ABORTED / AUTH_INTEGRATION_FAILURE에 대응한다 | -| N-08 | 구 V2 rollback 경계(seam) | V2 bounded JSON 테스트 tests/unit/bounded-json-compatibility.test.ts(2026-11-03에 V2 client와 함께 지웠다) | `fix: harden the legacy HTTP rollback path` | `FIXED_NOT_RELEASED` | 구 JSON 실패 코드 drift | 통과 7/7(예외를 던지는 cancel/releaseLock 포함). `readBoundedJson`은 이제 구 코드를 그대로 두고 `bounded-body-reader`에 맡긴다 | +| N-06 | 구 V2 rollback 경계(seam) | 없음 — V2 client 시험이었고 2026-11-03에 V2 client와 함께 지웠다(`048f490a`) | `fix: harden the legacy HTTP rollback path` | `FIXED_NOT_RELEASED` | 구 keyed command 거부 급증 | 실패: 잘못된 키 사례 4개 → 통과. credential과 fetch 전에 거부한다(credential 호출 0회, fetch 0회) | +| N-07 | 구 V2 rollback 경계(seam) | 없음 — V2 client와 그 인증 복구 시험이었고 2026-11-03에 V2 client와 함께 지웠다(`048f490a`) | `fix: harden the legacy HTTP rollback path` | `FIXED_NOT_RELEASED` | 구 credential timeout 회귀 | 실패: 끝나지 않는 owner → 통과. credential 대기가 기존 attempt controller와 경주(race)하므로 타이머를 더 만들지 않는다. 소유권은 fetch 0회로 REQUEST_TIMEOUT / REQUEST_ABORTED / AUTH_INTEGRATION_FAILURE에 대응한다 | +| N-08 | 구 V2 rollback 경계(seam) | 없음 — V2 bounded JSON 시험이었고 2026-11-03에 V2 client와 함께 지웠다(`048f490a`) | `fix: harden the legacy HTTP rollback path` | `FIXED_NOT_RELEASED` | 구 JSON 실패 코드 drift | 통과 7/7(예외를 던지는 cancel/releaseLock 포함). `readBoundedJson`은 이제 구 코드를 그대로 두고 `bounded-body-reader`에 맡긴다 | | N-09 | 실행 중인 cross-context host | `corepack pnpm exec vitest run tests/unit/cross-tab-invalidation.test.ts` | `fix: harden bounded state sidecars` | `FIXED_NOT_RELEASED` | cross-tab 무효화 유실 | 실패: 다른 영역의 pulse를 받아들임 → 통과 13/13. localStorage를 한 번만 잡고 `StorageEvent.storageArea`를 객체 동일성으로 비교한다. pulse 키는 `CACHE_INVALIDATION_PULSE`로 등록했다. `check:registries` PASS | | N-10 | Cursor runtime `AVAILABLE_NOT_COMPOSED` | `corepack pnpm exec vitest run tests/unit/cursor-pagination-runtime.test.ts` | `fix: harden bounded state sidecars` | `FIXED_NOT_RELEASED` | pagination abort 의미 변경 | 실패: 끝나지 않는 loader → 통과 `PAGINATION_ABORTED`, 늦게 온 page는 무시 | | N-11 | 실행 중인 조립 | `corepack pnpm exec vitest run tests/unit/telemetry.test.ts -t capacity` | `fix: terminate telemetry work on disposal` | `FIXED_NOT_RELEASED` | 올바른 조립에서 capacity 거부 | 실패: capacity 사례 5/5 → 통과. 상한은 VD-07 §7-4에 적었다 | -- 2.54.0 From d460a5f8a47f2cb599da7ae44381e52287a118d6 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sat, 21 Nov 2026 15:37:36 +0900 Subject: [PATCH 02/12] =?UTF-8?q?fix(docs):=20=EC=88=AB=EC=9E=90=20?= =?UTF-8?q?=EB=B3=B5=EC=82=AC=20=EA=B2=80=EC=82=AC=EA=B0=80=20=EC=98=88?= =?UTF-8?q?=EC=82=B0=20=EA=B0=92=EA=B3=BC=20=EC=8B=9C=ED=97=98=20=EC=88=98?= =?UTF-8?q?=EB=8F=84=20=EB=B3=B8=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .claude/rules/docs.md는 예산·기준선·테스트 수를 옮겨 적지 말라고 하고 그 검사를 verify:documentation이 한다고 쓴다. 그런데 docs-system.ts의 COPIED_COUNTS는 게이트·recipe·adapter 개수만 본다. 「예산은 initial JS 206848 bytes다」나 「시험 1600개」를 써도 통과하고, 「게이트가 29개」처럼 조사가 끼면 게이트 개수도 놓친다. 살아 있는 문서에 실제 복사가 있다 (performance-evidence.md의 「206,848 B」, 원장의 시험 수). - 예산 값: config/performance/budgets.json의 숫자 값을 facts (budgetValues)로 읽어, 1000 이상인 값을 숫자로 찾는다(천 단위 쉼표 있어도 없어도). 「A에서 B로」 안의 값은 지난 변경의 기록(결정 행, 그 예시)이라 다음 변경 뒤에도 참이므로 읽지 않는다. - 시험 수: 「시험·테스트 N개」「N개 시험」「N tests」 꼴. 세 자리 이상만 본다. 그보다 작은 수는 문장이 말하는 정해진 묶음(생성기가 만드는 시험 3개, 한 사례의 시험 10개)이다. - 게이트 개수 꼴에 조사(가·이·은·는·을·를)를 허용한다. 걸린 복사 줄은 정본을 가리키게 고쳤다: performance-evidence.md(예산 값 문장·유도 계산의 결론·D9), decisions.md(D9 행의 값, FE-6 행의 「시험 33개」), 원장(실행 결과의 전체 시험 수 넷). ci-script-assessment.md는 판정 시점 표이므로 스크립트 수·줄 수도 판정 시점 값이라고 머리에 적었다. 버린 안: 규칙 문장에서 예산·시험 수를 지우기 — 규칙이 막으려던 drift를 풀어 준다. 예외 목록(scripts/docs-system-exceptions.txt)에 줄 더하기 — 목록은 줄기만 하고 FROZEN이 비어 어떤 줄도 실패한다. 결정 색인을 HISTORY_HOLDERS에 넣기 — 검사 규칙을 바꾸는 소유자 결정이다. 1000 미만 예산 값·100 미만 시험 수도 보기 — manual·testing.md·performance.md의 보통 문장(「테스트 3개」, 「204,800 B에서 206,848 B로 올린 결정」)이 걸리고, 그 문서는 이 항목 범위 밖이다. 위험·한계: 1000 미만 예산 값(LCP 밖의 ms 상한, 0.1 CLS, 파일 수 32)과 100 미만 시험 수, KiB로 바꿔 쓴 예산은 여전히 검사 밖이다. 「A에서 B로」 꼴로 쓴 현재 값도 읽지 않는다. 검증: 노트북 node 탐침으로 이 repo 문서에 checkDocsSystem 실패 0건, 새 시험 사례 11개가 기대대로(거절 6·통과 5). 단위 시험·RED· verify:documentation은 PR의 desktop 묶음에서 돈다. Refs: REV-FE-0009, REV-FE-0022 --- docs/operations/adapter-remediation-ledger.md | 8 +-- docs/operations/ci-script-assessment.md | 2 +- docs/operations/performance-evidence.md | 9 +-- docs/work/reference/decisions.md | 4 +- scripts/lib/docs-system.ts | 64 ++++++++++++++++++- tests/unit/docs-system.test.ts | 20 ++++++ 6 files changed, 95 insertions(+), 12 deletions(-) diff --git a/docs/operations/adapter-remediation-ledger.md b/docs/operations/adapter-remediation-ledger.md index 0d4a883e..c32efe0a 100644 --- a/docs/operations/adapter-remediation-ledger.md +++ b/docs/operations/adapter-remediation-ledger.md @@ -44,7 +44,7 @@ rg -n "AVAILABLE_NOT_COMPOSED|DESIGNED_NOT_IMPLEMENTED|NOT_SELECTED" docs/archit | `corepack pnpm check:types` | 0 | app, node, test, recipes, web-worker, service-worker 프로젝트가 모두 통과한다. | | `corepack pnpm lint` | 0 | `--max-warnings=0`로 경고 없음. | | `corepack pnpm check:architecture` | 0 | 모듈 286개, 의존 854개, import 해석 실패 없음. graph fixture 12개 PASS. TS-only 정책 PASS. 허용 PASS / 금지 9개 거부. | -| `corepack pnpm test:unit` | 1 | 테스트 파일 110개 통과 / 1개 실패. 테스트 1496개 통과 / 19개 실패(전체 1515개), 150.92s. | +| `corepack pnpm test:unit` | 1 | 테스트 파일 1개 실패, 테스트 19개 실패(나머지는 통과), 150.92s. | ### `test:unit` 실패 원인 @@ -183,7 +183,7 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | `corepack pnpm test:integration` | 0 | 52개 통과 | | 참조 샘플 기능 시험(그 script는 2026-11-07 샘플과 함께 지웠다) | 0 | 26개 통과 | | `corepack pnpm test:recipes` | 0 | 17개 통과 | -| `corepack pnpm test:unit` | 1 | 테스트 1585개 통과 / 19개 실패. 19개는 원래 있던 그대로인 `ci-artifact-contract` sandbox 실패다 | +| `corepack pnpm test:unit` | 1 | 테스트 19개 실패(나머지는 통과). 19개는 원래 있던 그대로인 `ci-artifact-contract` sandbox 실패다 | | `corepack pnpm check:registries` | 0 | registry 11개 PASS | | `corepack pnpm verify:documentation` | 0 | PASS_SCOPED | | 음성 fixture `invalid-image-cdn-resolve-signal.ts` 단독 tsc(그 script는 2026-11-08 `check:types:fixtures`로 합쳤다) | 1 | **0이 아닌 것이 정상이다.** `resolve()`가 이제 lifetime signal 없는 호출을 거부함을 보이는 음성 fixture다(BT-IMG-01). | @@ -350,7 +350,7 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | `tests/unit/security-followup.test.ts` | 2 | 따로 돌리면 통과한다. | | `tests/integration/provider-guardian-transaction.test.ts` | 1 | 과거 기준: 따로 돌리면 통과했다. 지금은 프로세스 integration 테스트로 분류한다. | -전체 1723개 중 1619개 통과다. 전에는 빼야 했던 세 파일 `tests/unit/`의 `removal-fixture.test.ts`, +위 표의 실패 말고는 모두 통과했다. 전에는 빼야 했던 세 파일 `tests/unit/`의 `removal-fixture.test.ts`, `tests/unit/supply-chain.test.ts`, `tests/integration/security-followup-archive.test.ts`도 이제 전체 실행에서 통과한다. @@ -460,7 +460,7 @@ $ sysctl kernel.apparmor_restrict_unprivileged_userns kernel.apparmor_restrict_unprivileged_userns = 1 ``` -이 재현에는 이 저장소의 코드가 하나도 없다. 같은 세션 앞부분에서는 똑같은 sandbox가 끝까지 돌았다. 그러니 제약은 도중에 켜졌다. 제약이 있는 동안 provider 테스트 108개 중 16개는 여기서 돌 수 없다. kernel이 허락하지 않는 sandbox가 필요하기 때문이다. 이 테스트는 통과로도, 제품 결함으로도 세지 않는다. namespace를 허락하는 host에서는 같은 파일이 107/108이었다. +이 재현에는 이 저장소의 코드가 하나도 없다. 같은 세션 앞부분에서는 똑같은 sandbox가 끝까지 돌았다. 그러니 제약은 도중에 켜졌다. 제약이 있는 동안 provider 테스트 중 16개는 여기서 돌 수 없다. kernel이 허락하지 않는 sandbox가 필요하기 때문이다. 이 테스트는 통과로도, 제품 결함으로도 세지 않는다. namespace를 허락하는 host에서는 같은 파일이 107/108이었다. ### 이 작업 뒤에도 실패하는 것 diff --git a/docs/operations/ci-script-assessment.md b/docs/operations/ci-script-assessment.md index 83751dbc..d3efc27f 100644 --- a/docs/operations/ci-script-assessment.md +++ b/docs/operations/ci-script-assessment.md @@ -3,7 +3,7 @@ - 작성일: 2026-11-08, 기준 커밋 `ad3a071f`(정리 2단계 끝) - 정본 설계: design-docs `repo-structure/03-ci.md` 7.3절 F3. 이 문서는 판정만 남긴다. 코드는 바꾸지 않았다. - 상태: 판정 표. 옮기는 작업은 이 표를 근거로 따로 한다. -- 판정 뒤 바뀐 것(2026-11-08): check-optional-recipe-types.ts는 정리 3단계에서 지웠다. `*:fixture` 자기 시험 명령은 merge 게이트에서 main 단계 FE-GATE-029로 옮겼고, CI 계약 기준선 파일은 지웠다. 아래 표의 게이트 칸은 판정 시점(`ad3a071f`) 값이다. +- 판정 뒤 바뀐 것(2026-11-08): check-optional-recipe-types.ts는 정리 3단계에서 지웠다. `*:fixture` 자기 시험 명령은 merge 게이트에서 main 단계 FE-GATE-029로 옮겼고, CI 계약 기준선 파일은 지웠다. 아래 표의 게이트 칸과 이 문서의 스크립트 수·줄 수는 판정 시점(`ad3a071f`) 값이다. 대상: `scripts/check-*.ts` 30개, 6,351줄. 코드를 읽고 판정했다. pnpm·tsc·테스트는 돌리지 않았다. 줄 번호는 모두 `git show ad3a071f:<파일>` 기준이다. diff --git a/docs/operations/performance-evidence.md b/docs/operations/performance-evidence.md index b3e0c527..bd6c5ac4 100644 --- a/docs/operations/performance-evidence.md +++ b/docs/operations/performance-evidence.md @@ -41,8 +41,8 @@ 돌리고 같은 변경에 넣는다. - 여유는 예산에서 `gzipBytes`를 뺀 값이다. 그것을 `perFeatureGzipBytes`로 나누면 더 넣을 수 있는 기능 수다. 새 context마다 `perContextGzipBytes`가 더 든다. -- 예산 값 `initialJsGzipBytes`는 206,848 B(202 KiB)다. 1105 수정 라운드에서 - 204,800 B를 올렸다(2026-11-06). 그 라운드의 검사·진단 코드(조립 때 code 검사 +- 예산 값 `initialJsGzipBytes`의 정본은 `config/performance/budgets.json`이다. 1105 수정 라운드에서 + 204,800 B에서 206,848 B로 올렸다(2026-11-06). 그 라운드의 검사·진단 코드(조립 때 code 검사 1105/03-01, 홈 시작 링크 08-03, scope closer 진단 02-01 등)가 초기 JS를 1,184 B 늘려, 생성 기능 둘을 더하는 FE-GATE-020 드릴이 예산을 663 B 넘었다(그 라운드를 합친 빌드에서 잼, 기록 커밋 `0fee3fe`). 버린 대안은 런타임 @@ -54,13 +54,14 @@ - 폭의 근거(1106/15-01, 결정 D9): 예산은 드릴 측정값에 기능 하나의 상한 (`perFeatureGzipBytes` 상한 1 KiB)을 더해 KiB 단위로 올림한 값이다. 드릴은 CI env에서 205,465 B였다(2026-11-06, `bbde570`, FE-GATE-020). 205,465 + - 1,024 = 206,489 B를 올림하면 202 KiB = 206,848 B다. 그래서 드릴 위의 여유 + 1,024 = 206,489 B를 KiB 단위로 올리면 202 KiB이고, 이것이 예산 값이다 + (`config/performance/budgets.json`). 그래서 드릴 위의 여유 1,383 B는 기능 하나(1,024 B)와 올림(359 B)이다. 이 규칙에 템플릿 자신이 더 쓸 몫은 없다. 템플릿 변경이 이 여유를 쓰면 그만큼 기능 몫이 준다. - 되돌림 규칙: 위 "다시 볼 때"마다 드릴을 다시 잰다. 드릴 측정값이 204,800 B 이하이면 같은 규칙(드릴 + 1 KiB를 KiB 단위로 올림)으로 예산을 내린다. 그때 규칙의 값은 201 KiB 이하다. - - D9(206,848 B를 그대로 둔다)는 메인 세션이 2026-11-06에 정했다. 사용자가 뒤집을 + - D9(초기 JS 예산을 그대로 둔다)는 메인 세션이 2026-11-06에 정했다. 사용자가 뒤집을 수 있다. 결정 기록은 `docs/reviews/2026-11-06-maturity-review/README.md`다. - 기능 실행부(`feature-runtime.ts`)는 라우트에 들어갈 때 받는 lazy chunk다. lazy chunk 예산은 파일마다 120 KiB(`lazyChunkGzipBytes`)다. diff --git a/docs/work/reference/decisions.md b/docs/work/reference/decisions.md index 406cffc2..11eab1d1 100644 --- a/docs/work/reference/decisions.md +++ b/docs/work/reference/decisions.md @@ -55,7 +55,7 @@ | 1103 결정 D1~D6 | 2026-11-04 | 짝 업로드는 Fileserver multipart client(D1), 업무 거절은 operation 단위 `refusedBeforeWrite` code 목록(D2), 시각 테스트는 기능 영역을 가리고 찍음(D3), 접근성 e2e 응답 모양(D4), CHANGELOG는 순 변경 요약(D5), 짝 계약은 pin 파일 + 답 표 대조 + drift 검사(D6) | 1103 README 「조치」 | | WebKit preload 경고(1103/11-09) | 2026-11-05 | 경고 문구 하나만 무시하고 preload 사용을 세 엔진에서 직접 검사한다 | 1103 README 14.7절 | | 1105 결정 D7 | 2026-11-05 | 초기 JS 예산을 204,800 B에서 206,848 B로 올린다 | 1105 README 16.2절 | -| 1106 결정 D9·D10 | 2026-11-06 | 초기 JS 예산 206,848 B를 그대로 두고 근거·되돌림 규칙을 `docs/operations/performance-evidence.md`에 둔다(D9). 결과 불명 KEYED 재전송이 쓰기 전 거절로 끝나도 훅이 결과 불명과 키를 지킨다. 재전송의 거절이 결과 불명을 푸는 것은 짝 백엔드 표의 code뿐이다(D10과 보완 둘, 판정 `src/contracts/errors.ts` `isRefusedOnEveryAttempt`) | 1106 README 16.2절 | +| 1106 결정 D9·D10 | 2026-11-06 | 초기 JS 예산을 1105 D7에서 올린 값 그대로 두고 근거·되돌림 규칙을 `docs/operations/performance-evidence.md`에 둔다(D9). 결과 불명 KEYED 재전송이 쓰기 전 거절로 끝나도 훅이 결과 불명과 키를 지킨다. 재전송의 거절이 결과 불명을 푸는 것은 짝 백엔드 표의 code뿐이다(D10과 보완 둘, 판정 `src/contracts/errors.ts` `isRefusedOnEveryAttempt`) | 1106 README 16.2절 | | 결정 D8 FE-GATE-013 판정 | 2026-11-12 | desktop에서 FE-GATE-013의 실패가 사전 점검의 user namespace 제한(bwrap) 하나뿐이고 `scripts/verify.sh parts FE-GATE-013`의 뒤 명령이 모두 rc=0이면, merge 판정에서 그 실패를 호스트 원인으로 빼고 센다. 게이트 「충족」은 조건을 갖춘 runner에서 FE-GATE-013이 통과한 것으로만 센다. 버린 안: runner에서 통과할 때까지 merge 판정을 미충족으로 두기(그 runner가 아직 없어 모든 PR의 merge 판정이 막힌다). 재검토: 조건을 갖춘 runner가 merge 단계를 돌게 되면 desktop 예외가 아직 필요한지 다시 본다. 판정 방법은 `gates.md` 3절 | 소유자 결정 e(2026-11-11, 「그 조건이 되는 실행 환경을 찾아 초록으로」)에 따라 총괄이 권하는 안으로 정함(2026-11-12, repo 밖). 관련 발견 1105/12-01 | | 검사기 자기 시험의 단계 | 2026-11-07 | 검사기 자기 시험(`*:fixture` 15개)과 `check:ci:gating`을 merge에서 main 단계 FE-GATE-029로 옮기고, CI 계약 기준선 파일을 지운다. 버린 안: merge에 두기(PR마다 같은 자기 시험을 돈다). 위험: 검사기를 깨는 PR이 main에서야 빨개진다. 그래서 검사 script를 고치면 merge에 더해 FE-GATE-029를 돌린다(`.claude/rules/gates-and-budgets.md`) | 소유자 승인, 커밋 `f6b2b96c` 본문, `docs/operations/ci-quality-gates.md` 머리, round9 1112/08-14 | | round9 R9-D1 결과 불명 상태의 소유 | 2026-11-12 | 권하는 안으로 정함(2026-11-12, 총괄). `useAppForm`이 코디네이터의 결과 불명 상태를 받는 선택 옵션을 갖고(추가만), 생성 작성 페이지가 그것을 쓴다. 이미 생성한 기능은 CHANGELOG 이행 안내. 버린 안: 문서로만 | round9 README 7절, 1112/01-01 | @@ -73,7 +73,7 @@ | 결정 p 선택 runtime 제거 드릴을 main 단계로 | 2026-11-12 | FE-GATE-020의 선택 runtime 제거 드릴 셋(optional recipe, browser file/storage, realtime)을 새 게이트 FE-GATE-030으로 떼어 main 단계(`main_gate`)에서 돌린다. 기능 드릴(샘플 제거, scaffold)은 merge에 남는다. 이유: runner PR 1회 약 30분 가운데 7분쯤이고, worker를 늘리지 않고 merge 25분 목표에 닿는 길이 이것뿐이었다. 대가: 그 셋의 회귀를 병합 뒤 main run에서 본다. main이 빨강이면 다음 PR이 고친다. 짝 백엔드가 무거운 lane을 nightly로 옮긴 것과 같은 모양이다. 재검토: runner가 늘거나 드릴이 빨라져 merge에 다시 넣어도 25분 안이면 되돌린다 | 권하는 안으로 정함(2026-11-12, 총괄): 백엔드 nightly lane과 같은 모양(design-docs `template-program/README.md` 5절 p, w2-fe-2가 올린 O1) | | 의존성 캐시는 merge job만 | 2026-11-13 | merge job 셋(`merge_static`·`merge_test`·`merge_browser`)만 Node toolcache·corepack·pnpm store와 메타데이터 캐시를 `.nvmrc`·`pnpm-lock.yaml` 해시 키로 복원하고, 저장은 main run만 한다. release·promotion·provider job은 공급망 증거를 만들므로 매번 새로 설치한다. 이유: worker를 늘리지 않고 job마다 되풀이하던 내려받기와 공급망 검증 요청을 없앤다. 캐시가 없거나 깨져도 frozen install이 같은 node_modules를 만든다. 짝 백엔드의 JDK·Gradle·Trivy 캐시와 같은 저장 규칙이다. 버린 안: CI 이미지에 의존성을 굽기(레지스트리 쓰기 토큰이 든다). 규칙의 정본은 `scripts/contracts/ci-gates.ts`의 `DEPENDENCY_CACHE`. (2026-11-20 FE-7 행이 바꿈) | 권하는 안으로 정함(2026-11-13, 총괄): 의존성 캐시는 merge job만, 공급망 증거 job은 매번 새로 설치 | | PR은 바뀐 범위의 merge 게이트만 | 2026-11-13 | PR run의 merge job은 `config/ci/pr-gate-selection.json` 경로표로 바뀐 파일이 닿는 게이트만 돌고, 안 도는 게이트는 `건너뜀: <게이트 ID> — <이유>` 한 줄을 남긴다. 전역 파일·표에 없는 파일·빈 diff·diff를 못 읽음이면 전부 돈다. main·release run은 늘 전부 돈다. 판정은 `scripts/lib/pr-gate-selection.ts`, 계약 시험은 `tests/unit/pr-gate-selection.test.ts`다 | 소유자 결정(2026-11-13 18:3x, design-docs `ci/manual.md` 4절). PR 경로표가 놓친 것은 main이 잡는다. main push에서 선택 때문에 놓친 실패가 나오면 경로표를 고친다 | -| FE-6 `@a11y` 시험은 FE-GATE-009에서만 | 2026-11-20 | round9 R9-D11을 바꾼다. FE-GATE-008의 `test:e2e`는 이름에 `@a11y`가 붙은 시험을 빼고(`--grep-invert @a11y`) 돈다. 그 시험은 FE-GATE-009의 `test:a11y`가 자기 실행으로 돈다. `test:a11y`의 설정(`playwright.a11y.config.ts`)은 e2e 설정을 펼치고 결과 경로만 바꾼다(2026-11-20, 008의 e2e 결과를 덮던 것을 고침). 그래서 그 시험이 도는 project(chromium·firefox·webkit)도 같고, 결과 경로 시험(`tests/unit/playwright-result-paths.test.ts`)이 결과 경로 밖 설정이 같은지 본다. 전제(게이트마다 증거를 새로 만든다)는 그대로다. 버린 안(FE-GATE-009가 FE-GATE-008 결과를 읽기)도 계속 버린다. 이유: merge browser job이 같은 `@a11y` 시험 33개를 두 번 돌았다. 대가: FE-GATE-008만 돌리면 `@a11y` 시험(axe 스캔, 생성 기능 목록의 빈·오류 상태 화면)은 돌지 않는다. 재검토: CI run에서 FE-GATE-008이 돌고 FE-GATE-009가 돌지 않는 경우(단계에서 009를 빼기, 두 게이트를 다른 조건의 job으로 나누기, PR 경로표)가 생기면 그 run에서 `@a11y` 시험이 돌지 않으므로 되돌린다. a11y 설정이 결과 경로 밖에서 e2e 설정과 달라지면 그 시험이 도는 브라우저를 다시 대조한다 | 총괄(2026-11-20): 소유자 2026-11-19 CI 속도 지시, design-docs `ci/06-frontend-ci-speed-handoff.md` 4.1절 | +| FE-6 `@a11y` 시험은 FE-GATE-009에서만 | 2026-11-20 | round9 R9-D11을 바꾼다. FE-GATE-008의 `test:e2e`는 이름에 `@a11y`가 붙은 시험을 빼고(`--grep-invert @a11y`) 돈다. 그 시험은 FE-GATE-009의 `test:a11y`가 자기 실행으로 돈다. `test:a11y`의 설정(`playwright.a11y.config.ts`)은 e2e 설정을 펼치고 결과 경로만 바꾼다(2026-11-20, 008의 e2e 결과를 덮던 것을 고침). 그래서 그 시험이 도는 project(chromium·firefox·webkit)도 같고, 결과 경로 시험(`tests/unit/playwright-result-paths.test.ts`)이 결과 경로 밖 설정이 같은지 본다. 전제(게이트마다 증거를 새로 만든다)는 그대로다. 버린 안(FE-GATE-009가 FE-GATE-008 결과를 읽기)도 계속 버린다. 이유: merge browser job이 같은 `@a11y` 시험을 모두 두 번 돌았다. 대가: FE-GATE-008만 돌리면 `@a11y` 시험(axe 스캔, 생성 기능 목록의 빈·오류 상태 화면)은 돌지 않는다. 재검토: CI run에서 FE-GATE-008이 돌고 FE-GATE-009가 돌지 않는 경우(단계에서 009를 빼기, 두 게이트를 다른 조건의 job으로 나누기, PR 경로표)가 생기면 그 run에서 `@a11y` 시험이 돌지 않으므로 되돌린다. a11y 설정이 결과 경로 밖에서 e2e 설정과 달라지면 그 시험이 도는 브라우저를 다시 대조한다 | 총괄(2026-11-20): 소유자 2026-11-19 CI 속도 지시, design-docs `ci/06-frontend-ci-speed-handoff.md` 4.1절 | | FE-7 main job도 의존성 캐시 | 2026-11-20 | 2026-11-13 「의존성 캐시는 merge job만」을 바꾼다. main job(`main_gate`, FE-GATE-029·030)도 merge job 셋과 같은 키·경로로 캐시를 복원한다. 저장은 그대로 main run만 하고, 설치는 그대로 `--frozen-lockfile`이다. release·promotion·provider job은 그대로 매번 새로 설치한다. 이유: main job만 install이 15~24초였다(merge job은 1~2초). main job은 공급망 증거를 만들지 않는다. 재검토: main job이 공급망 증거를 만들게 되면 release·promotion job처럼 매번 새로 설치하게 되돌린다. main run 로그의 install step이 캐시를 복원해도 줄지 않으면 캐시 step을 뺀다 | 총괄(2026-11-20): design-docs `ci/06-frontend-ci-speed-handoff.md` 4.2절 | | FE-4 005 안 일반 실행 빼기 | 2026-11-20 | FE-GATE-005는 `tests/unit`·`tests/contract`를 `test:coverage`에서 한 번만 돈다. `test:unit`·`test:contract` 명령을 게이트에서 빼고, 같은 coverage 실행에서 `scripts/lib/coverage-bundle-junit-reporter.ts`가 `artifacts/tests/unit.xml`·`contract.xml`을 쓴다. 증거 이름과 게이트 ID는 그대로이고, 두 증거는 FE-GATE-005의 명령이 그 실행 중에 새로 만든다. 전제(게이트마다 증거를 새로 만든다)는 그대로다. 버린 안: coverage 실행 한 번이 FE-GATE-004·006·007의 증거까지 내기(design-docs `ci/04-…` R-3 (가), 약 −1:30). 그 세 게이트가 FE-GATE-005의 결과를 읽게 되어 FE-6에서 버린 꼴과 같다: coverage 실행이 죽으면 세 게이트도 판정을 못 내고, 혼자 돌릴 수 없다. 004는 005보다 앞이라 차례도 바꿔야 했다. 이유: FE-GATE-005 안에서 같은 시험 파일을 두 번 돌았다(약 0:57). 대가: unit·contract 시험은 이제 coverage 계측 아래에서만 돈다. 시간에 기대는 시험이 가려질 수 있다. 004·006·007의 묶음은 coverage에서 한 번 더 돈다(약 0:33). 재검토: coverage 실행에서 안 보이고 일반 실행에서만 보이는 unit·contract 실패가 나오면 일반 실행을 되돌린다. Vitest를 올릴 때는 reporter가 그 JUnit reporter에 기대므로 분할한 보고서를 일반 실행과 다시 대조한다 | 총괄(2026-11-20): 소유자 2026-11-19 CI 속도 지시, design-docs `ci/06-frontend-ci-speed-handoff.md` 4.3·6.2절 | | 구조·기술 결정 기록 | 2026-07-26~ | `VD-01`~(빈 번호 있음) | `docs/adr/` | diff --git a/scripts/lib/docs-system.ts b/scripts/lib/docs-system.ts index 2828930e..743c5c1f 100644 --- a/scripts/lib/docs-system.ts +++ b/scripts/lib/docs-system.ts @@ -54,6 +54,7 @@ export type DocsProblem = Readonly<{ export type DocsDocument = Readonly<{ path: string; text: string }>; export const EXCEPTIONS_FILE = "scripts/docs-system-exceptions.txt"; +const BUDGETS_FILE = "config/performance/budgets.json"; /** * Fingerprints (sha256, first 16 hex) of the exception list lines: the * 2026-11-08 baseline, which only shrinks. When it is empty no document is @@ -165,14 +166,41 @@ const FRAMEWORKS = Object.freeze([ ] as const); const NAMED_VERSION = /\b(?:React(?: DOM| Router)?|Vite|TypeScript|Vitest|Playwright|TanStack Query|Zod|Storybook|Node(?:\.js)?)\s+v?\d+\.\d+(?:\.\d+)?\b/gu; +// A count after its noun may take a particle (「게이트가 29개」, 「시험은 33개」). +const COUNT_PARTICLE = "(?:가|이|은|는|을|를)?"; +const SUITE_COUNT = "(?:\\d{1,3}(?:,\\d{3})+|\\d{3,})"; const COPIED_COUNTS = Object.freeze([ [ "gate count (config/ci/gates.json)", - /\b\d+\s*개의?\s*(?:merge\s*)?(?:게이트|gate)|(?:게이트|gate)\s*\d+\s*개|\b\d+\s+(?:merge\s+)?gates\b/giu, + new RegExp( + `\\b\\d+\\s*개의?\\s*(?:merge\\s*)?(?:게이트|gate)|(?:게이트|gate)${COUNT_PARTICLE}\\s*\\d+\\s*개|\\b\\d+\\s+(?:merge\\s+)?gates\\b`, + "giu", + ), ], ["recipe count (config/recipes/frontend-capability-recipes.json)", /\b\d+\s*개의?\s*recipe|recipe\s*\d+\s*개|\b\d+\s+recipes\b/giu], ["adapter count (docs/reviews/adapters/INVENTORY.md)", /\b\d+\s*개의?\s*adapter|adapter\s*\d+\s*개|\b\d+\s+adapters\b/giu], + // A suite's test count is a run's output; the runner reports it, and a copy + // is stale after the next added test (.claude/rules/docs.md 「숫자(예산, + // 기준선, 테스트 수)」). Counts under a hundred name a fixed set a sentence is + // about (the generator's three tests, the ten tests of one case), so only + // three digits or more are read. + [ + "test count (the test runner reports it)", + new RegExp( + `\\b${SUITE_COUNT}\\s*개의?\\s*(?:시험|테스트)|(?:시험|테스트)${COUNT_PARTICLE}\\s*${SUITE_COUNT}\\s*개|\\b${SUITE_COUNT}\\s+tests\\b`, + "giu", + ), + ], ] as const); +// Budget values of four digits or more are looked for as numbers, with or +// without thousands separators (「206848」, 「206,848 B」). Smaller ones (0.1, +// 32, 200) are ordinary numbers in prose and would fail unrelated lines. A +// value in 「A에서 B로」 records a change (a decision row, the example of one), +// which stays true after the next change, so it is not read as a copy. +const BUDGET_VALUE_MINIMUM = 1000; +const BUDGET_UNIT = "(?:\\s*(?:B|bytes|KiB|ms))?"; +const CHANGE_FROM_BEFORE = new RegExp(`\\d[\\d,]*${BUDGET_UNIT}\\s*에서\\s*$`, "u"); +const CHANGE_TO_AFTER = new RegExp(`^${BUDGET_UNIT}\\s*에서\\s*\\d`, "u"); const sha16 = (line: string) => createHash("sha256").update(line, "utf8").digest("hex").slice(0, 16); @@ -274,6 +302,8 @@ export type DocsFacts = Readonly<{ docsFiles: readonly string[]; /** Framework name → exact version, from package.json and .nvmrc. */ frameworkVersions: ReadonlyMap; + /** Budget key (`bundle.initialJsGzipBytes`) → value, from config/performance/budgets.json. */ + budgetValues: ReadonlyMap; /** Paths a copy may delete (README 「복사한 뒤 지워도 되는 것」), without a trailing slash. */ deletable: readonly string[]; }>; @@ -380,6 +410,14 @@ function checkNumber(documents: readonly DocsDocument[], facts: DocsFacts): Docs ([name, version]) => [name, new RegExp(`(?(); + for (const [key, value] of facts.budgetValues) { + if (Number.isInteger(value) && value >= BUDGET_VALUE_MINIMUM) budgetKeys.set(value, [...(budgetKeys.get(value) ?? []), key]); + } + const budgets = [...budgetKeys].map(([value, keys]) => { + const digits = String(value).replace(/\B(?=(?:\d{3})+$)/gu, ",?"); + return [`budget value (config/performance/budgets.json ${keys.join(", ")})`, new RegExp(`(? [start, start + value.length] as const); for (const [name, pattern] of exact) { for (const match of line.matchAll(pattern)) { @@ -702,6 +748,21 @@ export function frameworkVersions(repositoryRoot: string): Map { return versions; } +/** Numeric budget values by dotted key, from config/performance/budgets.json (none when it is absent). */ +export function budgetValues(repositoryRoot: string): Map { + const values = new Map(); + const file = join(repositoryRoot, BUDGETS_FILE); + if (!existsSync(file)) return values; + const visit = (node: unknown, key: string) => { + if (typeof node === "number" && key !== "schemaVersion") values.set(key, node); + else if (node !== null && typeof node === "object") { + for (const [name, child] of Object.entries(node)) visit(child, key === "" ? name : `${key}.${name}`); + } + }; + visit(JSON.parse(readFileSync(file, "utf8")), ""); + return values; +} + /** * Runs the checks on the documents under `documentsRoot`, naming paths in * `repositoryRoot`. verify:documentation passes its working directory (a copy @@ -716,6 +777,7 @@ export function checkDocsSystem(documentsRoot: string, repositoryRoot: string): knownPaths: knownPaths(treeFiles(repositoryRoot)), docsFiles: documentFiles.filter((path) => path.startsWith(DOCS_ROOT)), frameworkVersions: frameworkVersions(repositoryRoot), + budgetValues: budgetValues(repositoryRoot), deletable: deletableHistory( existsSync(join(documentsRoot, README_FILE)) ? readFileSync(join(documentsRoot, README_FILE), "utf8") : "", ), diff --git a/tests/unit/docs-system.test.ts b/tests/unit/docs-system.test.ts index d2692d4f..717f8230 100644 --- a/tests/unit/docs-system.test.ts +++ b/tests/unit/docs-system.test.ts @@ -28,6 +28,10 @@ const facts: DocsFacts = { ["React", "19.2.8"], ["Node.js", "24.14.0"], ]), + budgetValues: new Map([ + ["bundle.initialJsGzipBytes", 206_848], + ["lab.namedInteractionMs", 200], + ]), deletable: ["docs/history", "docs/reviews"], }; @@ -214,10 +218,26 @@ describe("copied numbers", () => { ["a gate count", "merge 단계 게이트 14개가 돈다.", "gate count"], ["a recipe count", "12개 recipe가 있다.", "recipe count"], ["an adapter count", "adapter 119개를 센다.", "adapter count"], + ["a gate count after a particle", "merge 단계 게이트가 14개다.", "gate count"], + ["a budget value", "예산은 initial JS 206848 bytes다.", "budget value"], + ["a budget value with thousands separators", "| 초기 JS | 206,848 B |", "budget value"], + ["a suite's test count", "시험 1600개가 돈다.", "test count"], + ["a suite's test count after a particle", "테스트가 1,515개다.", "test count"], + ["a suite's test count in English", "It ran 1600 tests.", "test count"], ])("fails %s", (_, line, label) => { expect(run("number", living(line))).toEqual([expect.stringContaining(label)]); }); + it.each([ + ["a budget value in a change it records", "1105에서 예산을 204,800 B에서 206,848 B로 올렸다."], + ["a budget value a change starts from", "예산을 206,848 B에서 210,000 B로 올린다."], + ["a budget value under four digits, an ordinary number in prose", "200 ms 안에 반응한다."], + ["a test count under a hundred, a fixed set the sentence is about", "생성기는 테스트 3개와 시험 33개를 만든다."], + ["a number that only contains a budget value", "id 1206848과 2068480은 다른 값이다."], + ])("passes %s", (_, line) => { + expect(run("number", living(line))).toEqual([]); + }); + it("counts a version next to its name once", () => { expect(run("number", living("React 19.2.8을 쓴다."))).toHaveLength(1); }); -- 2.54.0 From f04ea3b30a5768081b63556dfd1452f3538a6b4e Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sat, 21 Nov 2026 15:45:23 +0900 Subject: [PATCH 03/12] =?UTF-8?q?refactor(docs):=20=EB=AC=B8=EC=84=9C=20?= =?UTF-8?q?=EA=B2=80=EC=82=AC=EC=9D=98=20src=20=EA=B5=AC=EC=A1=B0=C2=B7?= =?UTF-8?q?=EC=B0=B8=EC=A1=B0=C2=B7R6=C2=B7R7=EC=9D=84=20=EC=88=9C?= =?UTF-8?q?=EC=88=98=20=ED=95=A8=EC=88=98=EB=A1=9C=20=EB=82=98=EB=88=88?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit verify-documentation-readiness.ts는 export 없는 621줄 최상위 script라 검사 하나를 고칠 때마다 시험이 script를 자식 프로세스로 통째로 띄운다 (한 번에 최대 15.8 s). R7(문서 안 인프라 설정) 거절을 기대하는 시험이 없어, R7 줄을 지워도 실패하는 시험이 없다. src 구조(checkSourceStructure), 문서 참조(checkDocumentReferences, namedPath·명령 경로·verify.sh script·생성물 판정 포함), R6·R7 (checkLayoutRules)을 scripts/lib/documentation-readiness-checks.ts로 옮긴다. docs-system.ts의 runDocsSystemChecks처럼 문서와 사실(facts)을 받아 문제 목록을 돌려준다. script는 저장소에서 사실을 읽고(파일 존재, package.json script, gates.json ID, .gitignore, 짝 저장소 pin과 git tree) 출력만 한다. 검사 규칙과 출력 문구는 그대로다. 새 시험 tests/unit/documentation-readiness-checks.test.ts는 메모리 입력으로 검사마다 통과·거절을 본다. 문서를 읽지 않으므로 제거 드릴의 문서 시험 목록(REMOVAL_FIXTURE_DOCUMENT_TESTS)에 넣지 않는다. documentation-readiness.test.ts에서는 그 시험이 덮는 자식 프로세스 사례 11개(경로·명령·생성물·src 구조)를 빼고, 옮긴 검사 셋을 진짜 문서에서 한 번에 깨뜨려 stderr 줄과 실패 검사 이름을 보는 사례 하나로 배선을 본다. 색인 링크, README 삭제 표, script·게이트 ID 사실, 짝 저장소(git), 출력 사례는 그대로 자식 프로세스로 남는다. 버린 안: R7 거절 시험만 자식 프로세스로 더하기 — 15 s짜리 실행이 하나 더 는다. 자식 프로세스 사례를 「이 repo 그대로 통과」 하나만 남기기 — 짝 저장소 pin 조회와 README 삭제 표처럼 script가 사실을 읽는 배선은 메모리 시험이 보지 못한다. 위험·한계: 옮기며 동작이 바뀌면 출력이 달라진다. 옛 script와 새 script를 같은 문서(통과·여러 검사를 깨뜨린 상태)에 돌려 rc·stdout· stderr·보고서가 같은지 PR의 desktop RED 묶음에서 본다. 검증: 노트북 node 탐침으로 새 시험의 문서 참조·R7 사례 9개가 기대값과 같다. 단위 시험·변이·옛/새 출력 비교는 PR의 desktop 묶음에서 돈다. Refs: REV-FE-0011, REV-FE-0022 --- scripts/lib/documentation-readiness-checks.ts | 295 ++++++++++++++++++ scripts/verify-documentation-readiness.ts | 257 +++------------ .../documentation-readiness-checks.test.ts | 229 ++++++++++++++ tests/unit/documentation-readiness.test.ts | 99 ++---- 4 files changed, 589 insertions(+), 291 deletions(-) create mode 100644 scripts/lib/documentation-readiness-checks.ts create mode 100644 tests/unit/documentation-readiness-checks.test.ts diff --git a/scripts/lib/documentation-readiness-checks.ts b/scripts/lib/documentation-readiness-checks.ts new file mode 100644 index 00000000..795cd165 --- /dev/null +++ b/scripts/lib/documentation-readiness-checks.ts @@ -0,0 +1,295 @@ +import { dirname, join, matchesGlob, normalize } from "node:path/posix"; + +/** + * The checks of scripts/verify-documentation-readiness.ts that read documents + * and facts and return what is wrong, as runDocsSystemChecks in + * scripts/lib/docs-system.ts does. The script reads the repository (files, + * package.json, gates.json, the paired checkouts) and reports; the tests give + * these functions inputs in memory (tests/unit/documentation-readiness-checks.test.ts). + */ + +// ---------------------------------------------------------------- src structure + +// 1101/14-03. The entry documents drew a `src/domain` layer that does not +// exist and left out `src/platform`, `src/apps` and `src/contexts`; layers.md +// said its table "cannot drift" from the rules while most rule names were +// missing. The folder and rule lists come from the code. layers.md describes +// each folder in one table row, and the other entry documents repeat that +// description verbatim as "`src/` — ", so a new folder or +// rule must be documented, the descriptions cannot diverge, and no document +// may name a top-level folder that is gone. +export const RULES_DOCUMENT = "docs/architecture/layers.md"; +export const STRUCTURE_DOCUMENTS = Object.freeze([ + RULES_DOCUMENT, + "README.md", + "docs/architecture/overview.md", + "docs/architecture/frontend-application-foundation.md", +]); + +export type SourceStructureEntry = Readonly<{ + path: string; + missingFolders: string[]; + unknownFolders: string[]; + missingRules: string[]; +}>; + +/** One entry per STRUCTURE_DOCUMENTS; a document missing from `texts` reads as empty. */ +export function checkSourceStructure( + input: Readonly<{ + texts: ReadonlyMap; + sourceFolders: readonly string[]; + architectureRules: readonly string[]; + }>, +): SourceStructureEntry[] { + const rulesText = input.texts.get(RULES_DOCUMENT) ?? ""; + const folderDescriptions = new Map( + [...rulesText.matchAll(/^\| `src\/([\w-]+)` \| (.+) \|$/gmu)].map((match) => [match[1], match[2]]), + ); + return STRUCTURE_DOCUMENTS.map((path) => { + const text = path === RULES_DOCUMENT ? rulesText : (input.texts.get(path) ?? ""); + const namedFolders = new Set([...text.matchAll(/\bsrc\/([\w-]+)/gu)].map((match) => match[1] ?? "")); + return { + path, + missingFolders: input.sourceFolders.filter((folder) => { + const description = folderDescriptions.get(folder); + if (description === undefined) return true; + return path !== RULES_DOCUMENT && !text.includes(`\`src/${folder}\` — ${description}`); + }), + unknownFolders: [...namedFolders].filter((folder) => !input.sourceFolders.includes(folder)).sort(), + missingRules: + path === RULES_DOCUMENT ? input.architectureRules.filter((rule) => !text.includes(`\`${rule}\``)) : [], + }; + }); +} + +// ---------------------------------------------------------------- document references + +export const NOT_CREATED: ReadonlySet = new Set([ + // Reserved by generic-worker-has-no-network-or-credentials. The generic CPU + // worker is NOT_SELECTED; docs/manual/03-outside-feature-folder.md says how + // to add it with its own tsconfig. + "src/adapters/web-worker", +]); +// pnpm's own commands, which are not package scripts. +const PNPM_COMMANDS = new Set(["add", "dlx", "exec", "install", "list", "why"]); + +/** What the reference check looks a document's names up in; the script reads it from this repository. */ +export type ReferenceFacts = Readonly<{ + /** Whether a path relative to the repository root exists (file or folder). */ + exists: (path: string) => boolean; + /** The names in the repository root. */ + topLevelEntries: ReadonlySet; + /** Package scripts (package.json). */ + scripts: ReadonlySet; + /** Gate IDs config/ci/gates.json defines, and the retired ones. */ + gateIds: ReadonlySet; + /** The paired repositories config/contracts/backend-contract-pin.json pins. */ + pairedRepositories: ReadonlySet; + /** Whether `reference` (`..//`) is in the pinned tree, or null when it cannot be checked here. */ + pairedReferenceExists: (reference: string) => boolean | null; + /** The pattern lines of .gitignore. */ + ignorePatterns: readonly string[]; + /** History a copy deleted (README 「복사한 뒤 지워도 되는 것」); a path under one is not drift. */ + deletedHistory: readonly string[]; + /** Paths of the removable sample features that are not installed. */ + removedFeaturePaths: readonly string[]; + /** Scripts of the removable sample features that are not installed. */ + removedFeatureScripts: ReadonlySet; +}>; + +export type DocumentReferences = Readonly<{ + path: string; + missingPaths: string[]; + unverifiedLinks: string[]; + missingScripts: string[]; + unknownGateIds: string[]; +}>; + +// Generated output is what git ignores, so a document may name it before a +// run has written it. +export function ignoredByGit(file: string, ignorePatterns: readonly string[]): boolean { + let ignored = false; + for (const line of ignorePatterns) { + const pattern = line.replace(/^!/u, "").replace(/^\/|\/$/gu, ""); + const glob = pattern.includes("/") ? pattern : `**/${pattern}`; + if (matchesGlob(file, glob) || matchesGlob(file, `${glob}/**`)) ignored = !line.startsWith("!"); + } + return ignored; +} + +// A backtick span is a path when it starts at a top-level entry, at an entry +// beside the document or at a paired repository; line numbers and anchors are +// dropped. A path into a paired repository is returned relative to this one +// (`..//…`). +export function namedPath(token: string, document: string, facts: ReferenceFacts): string | null { + const candidate = token.replace(/#.*$/u, "").replace(/:\d[\d,:-]*$/u, ""); + // An ellipsis, `...` or `…`, stands for any name, as in scripts/lib/docs-system.ts. + if (!candidate.includes("/") || candidate.startsWith("/") || /[\s*<>{}$()|…]|\.\.\./u.test(candidate)) return null; + const first = candidate.split("/")[0] ?? ""; + if (facts.topLevelEntries.has(first)) return candidate; + if (facts.pairedRepositories.has(first)) return `../${candidate}`; + return first !== "." && first !== ".." && facts.exists(join(dirname(document), first)) + ? join(dirname(document), candidate) + : null; +} +// A link that leaves the repository is kept (`../…`); the caller looks it up +// in the paired repositories. +function linkedPath(target: string, document: string): string | null { + if (/^(?:[a-z][a-z+.-]*:|#)/iu.test(target)) return null; + return normalize(join(dirname(document), target.replace(/#.*$/u, ""))); +} +// 1103/12-05. A command span is not a path, so the paths it takes as +// arguments (`corepack pnpm exec vitest run tests/…`, `node scripts/…`) were +// never looked up. Leading `NAME=value` assignments are skipped, a +// `--flag=value` argument is read as its value, and placeholders (``, +// globs, `$VAR`) are left alone by namedPath. +const COMMAND_HEADS = new Set([ + "corepack", "pnpm", "npx", "node", "vitest", "playwright", "tsc", "eslint", "bash", "sh", "python3", +]); +// 1112/08-06. `scripts/verify.sh` is this repository's main entry and most +// documented commands go through it: the entry is itself a path, `exec --` +// runs a command whose paths are looked up like any other, and `script` +// names package scripts (verifyScripts). +const VERIFY_ENTRY = /^(?:\.\/)?scripts\/verify\.sh$/u; +function commandWords(command: string): Readonly<{ words: string[]; head: number }> { + const words = command.trim().replace(/^\$\s+/u, "").split(/\s+/u); + let head = 0; + while (/^[A-Z_][A-Z0-9_]*=/u.test(words[head] ?? "")) head += 1; + return { words, head }; +} +function commandPaths(command: string, document: string, facts: ReferenceFacts): (string | null)[] { + const { words, head } = commandWords(command); + const first = words[head] ?? ""; + if (VERIFY_ENTRY.test(first)) { + const separator = words.indexOf("--", head + 1); + const executed = words[head + 1] === "exec" && separator > head ? words.slice(separator + 1).join(" ") : ""; + return [namedPath(first, document, facts), ...(executed === "" ? [] : commandPaths(executed, document, facts))]; + } + if (!COMMAND_HEADS.has(first)) return []; + return words + .slice(head + 1) + .map((word) => namedPath(word.replace(/^--?[\w.-]+=/u, "").replace(/^["']|["']$/gu, ""), document, facts)); +} +/** The package scripts `scripts/verify.sh script … [-- args]` runs; placeholders are left alone. */ +function verifyScripts(command: string): string[] { + const { words, head } = commandWords(command); + if (!VERIFY_ENTRY.test(words[head] ?? "") || words[head + 1] !== "script") return []; + const names: string[] = []; + for (const word of words.slice(head + 2)) { + if (word.startsWith("-")) break; + names.push(word); + } + return names.filter((name) => /^[a-z](?:[\w:-]*\w)?$/u.test(name)); +} +// Lines of fenced shell blocks (```bash, ```sh, ```shell, ```console or no +// language), which is where most documented commands are. +function fencedCommands(text: string): string[] { + const commands: string[] = []; + let fence: string | null = null; + for (const line of text.split("\n")) { + const marker = /^\s*```(\w*)/u.exec(line); + if (marker) { + fence = fence === null ? (marker[1] ?? "") : null; + continue; + } + if (fence !== null && /^(?:bash|sh|shell|console|zsh)?$/u.test(fence)) commands.push(line); + } + return commands; +} + +/** The paths, links, package scripts and gate IDs `document` names that do not exist. */ +export function checkDocumentReferences(document: string, text: string, facts: ReferenceFacts): DocumentReferences { + const scriptPrefixes = new Set([...facts.scripts].map((name) => name.split(":")[0])); + const missingScript = (name: string) => !facts.scripts.has(name) && !facts.removedFeatureScripts.has(name); + const named = [ + ...[...text.matchAll(/`([^`\n]+)`/gu)].flatMap(([, token = ""]) => [ + namedPath(token, document, facts), + ...commandPaths(token, document, facts), + ]), + ...fencedCommands(text).flatMap((command) => commandPaths(command, document, facts)), + ...[...text.matchAll(/\]\(([^)\s]+)\)/gu)].map(([, target = ""]) => linkedPath(target, document)), + ]; + const missingPaths = new Set(); + const unverifiedLinks = new Set(); + for (const file of named) { + if (file === null) continue; + const trimmed = file.replace(/\/$/u, ""); + if (trimmed.startsWith("../")) { + // Outside this repository: `..//`. + const found = facts.pairedReferenceExists(trimmed); + if (found === null) unverifiedLinks.add(trimmed); + else if (!found) missingPaths.add(trimmed); + continue; + } + if ( + !facts.exists(trimmed) && + !NOT_CREATED.has(trimmed) && + !ignoredByGit(trimmed, facts.ignorePatterns) && + !facts.deletedHistory.some((entry) => trimmed === entry || trimmed.startsWith(`${entry}/`)) && + !facts.removedFeaturePaths.some((entry) => trimmed === entry || trimmed.startsWith(`${entry}/`)) + ) { + missingPaths.add(trimmed); + } + } + const missingScripts = new Set(); + for (const [, name = ""] of text.matchAll(/(?:corepack pnpm|`pnpm) (?:run )?([a-z](?:[\w:-]*\w)?)/gu)) { + if (!PNPM_COMMANDS.has(name) && missingScript(name)) missingScripts.add(name); + } + for (const [, name = ""] of text.matchAll(/`([a-z][\w-]*:[\w:-]*\w)(?=[` ])/gu)) { + if (scriptPrefixes.has(name.split(":")[0]) && missingScript(name)) missingScripts.add(name); + } + const commands = [...[...text.matchAll(/`([^`\n]+)`/gu)].map(([, token = ""]) => token), ...fencedCommands(text)]; + for (const name of commands.flatMap(verifyScripts)) { + if (missingScript(name)) missingScripts.add(name); + } + return { + path: document, + missingPaths: [...missingPaths].sort(), + unverifiedLinks: [...unverifiedLinks].sort(), + missingScripts: [...missingScripts].sort(), + unknownGateIds: [...new Set([...text.matchAll(/\bFE-GATE-\d+\b/gu)].map(([id]) => id))] + .filter((id) => !facts.gateIds.has(id)) + .sort(), + }; +} + +// ---------------------------------------------------------------- repository layout rules + +// Repository layout rules of docs/manual/03-outside-feature-folder.md. +// R6: the manual's examples point at generator output or at code blocks in +// the manual, never at a sample feature a copy is meant to delete (the +// template's own sample took the manual's examples with it on 2026-11-07). +// R7: host, cluster and infrastructure configuration (nginx, Kubernetes, +// Helm, Terraform) lives in the infrastructure repository; a current document +// links to it and states the host contract (config/hosting/, FE-GATE-019) +// instead of carrying a copy. The history folders are records and keep what +// they recorded: the current documents are the living documents +// scripts/lib/docs-system.ts reads for drift (records and decision records out). +const INFRASTRUCTURE_FENCE = /^\s*```\s*(nginx|hcl|terraform|helm)\b/iu; +const INFRASTRUCTURE_MANIFEST = + /^\s*kind:\s*(Deployment|StatefulSet|DaemonSet|Ingress|Service|ConfigMap|CronJob|HelmRelease|Kustomization)\s*$/u; + +export type LayoutRuleViolation = Readonly<{ path: string; rule: "R6" | "R7"; detail: string }>; + +/** R6 and R7 in one current document; `sampleFeaturePaths` are the removable sample features' paths. */ +export function checkLayoutRules( + document: string, + text: string, + sampleFeaturePaths: readonly string[], +): LayoutRuleViolation[] { + const violations: LayoutRuleViolation[] = []; + let fenced = false; + text.split("\n").forEach((line, index) => { + if (/^\s*```/u.test(line)) fenced = !fenced; + if (INFRASTRUCTURE_FENCE.test(line) || (fenced && INFRASTRUCTURE_MANIFEST.test(line))) { + violations.push({ path: document, rule: "R7", detail: `line ${index + 1}: ${line.trim()}` }); + } + if (!document.startsWith("docs/manual/")) return; + for (const samplePath of sampleFeaturePaths) { + if (line.includes(samplePath)) { + violations.push({ path: document, rule: "R6", detail: `line ${index + 1}: ${samplePath}` }); + } + } + }); + return violations; +} diff --git a/scripts/verify-documentation-readiness.ts b/scripts/verify-documentation-readiness.ts index 3abdd9fe..3901fca7 100644 --- a/scripts/verify-documentation-readiness.ts +++ b/scripts/verify-documentation-readiness.ts @@ -1,13 +1,22 @@ import { spawnSync } from "node:child_process"; import { existsSync } from "node:fs"; import { mkdir, readdir, readFile } from "node:fs/promises"; -import { dirname, join, matchesGlob, normalize, resolve } from "node:path/posix"; +import { dirname, join, normalize, resolve } from "node:path/posix"; import { fileURLToPath } from "node:url"; import { RETIRED_GATE_IDS } from "./contracts/ci-gates.ts"; import { documentationReviewArtifactSchema } from "./contracts/release-artifacts.ts"; import { RUNTIME_OVERRIDES } from "./generate-runtime-config.ts"; import { checkDocsSystem, checkedForDrift, deletableHistory, HISTORY_HOLDERS, livingDocuments } from "./lib/docs-system.ts"; +import { + checkDocumentReferences, + checkLayoutRules, + checkSourceStructure, + type DocumentReferences, + type LayoutRuleViolation, + type ReferenceFacts, + STRUCTURE_DOCUMENTS, +} from "./lib/documentation-readiness-checks.ts"; import { MANUAL_A11Y_ROUTE_IDS } from "./lib/manual-a11y-evidence.ts"; import { REMOVABLE_TEMPLATE_FEATURES, @@ -104,21 +113,9 @@ const missingRuntimeVariables = RUNTIME_VARIABLES.filter( (variable) => !readme.includes(`\`${variable}\``), ); -// 1101/14-03. The entry documents drew a `src/domain` layer that does not -// exist and left out `src/platform`, `src/apps` and `src/contexts`; layers.md -// said its table "cannot drift" from the rules while most rule names were -// missing. The folder and rule lists come from the code. layers.md describes -// each folder in one table row, and the other entry documents repeat that -// description verbatim as "`src/` — ", so a new folder or -// rule must be documented, the descriptions cannot diverge, and no document -// may name a top-level folder that is gone. -const RULES_DOCUMENT = "docs/architecture/layers.md"; -const STRUCTURE_DOCUMENTS = Object.freeze([ - RULES_DOCUMENT, - "README.md", - "docs/architecture/overview.md", - "docs/architecture/frontend-application-foundation.md", -]); +// 1101/14-03. The entry documents describe the src folders and the import +// rules as the code has them (checkSourceStructure in +// scripts/lib/documentation-readiness-checks.ts). const repositoryRoot = new URL("../", import.meta.url); const sourceFolders = (await readdir(new URL("src/", repositoryRoot), { withFileTypes: true })) .filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")) @@ -129,26 +126,15 @@ const architectureRules = ( forbidden: readonly { name: string }[]; } ).forbidden.map((rule) => rule.name); -const rulesText = await readFile(RULES_DOCUMENT, "utf8").catch(() => ""); -const folderDescriptions = new Map( - [...rulesText.matchAll(/^\| `src\/([\w-]+)` \| (.+) \|$/gmu)].map((match) => [match[1], match[2]]), -); -const sourceStructure = []; -for (const path of STRUCTURE_DOCUMENTS) { - const text = path === RULES_DOCUMENT ? rulesText : await readFile(path, "utf8").catch(() => ""); - const namedFolders = new Set([...text.matchAll(/\bsrc\/([\w-]+)/gu)].map((match) => match[1] ?? "")); - sourceStructure.push({ - path, - missingFolders: sourceFolders.filter((folder) => { - const description = folderDescriptions.get(folder); - if (description === undefined) return true; - return path !== RULES_DOCUMENT && !text.includes(`\`src/${folder}\` — ${description}`); - }), - unknownFolders: [...namedFolders].filter((folder) => !sourceFolders.includes(folder)).sort(), - missingRules: - path === RULES_DOCUMENT ? architectureRules.filter((rule) => !text.includes(`\`${rule}\``)) : [], - }); -} +const sourceStructure = checkSourceStructure({ + texts: new Map( + await Promise.all( + STRUCTURE_DOCUMENTS.map(async (path) => [path, await readFile(path, "utf8").catch(() => "")] as const), + ), + ), + sourceFolders, + architectureRules, +}); const sourceStructureDocumented = sourceStructure.every( (entry) => entry.missingFolders.length === 0 && @@ -165,14 +151,6 @@ const DOCUMENT_INDEX = "docs/README.md"; // Past states are their subject: they name removed scripts and paths on purpose // (HISTORY_HOLDERS in scripts/lib/docs-system.ts says which and why). const UNCHECKED_DOCUMENTS = HISTORY_HOLDERS; -const NOT_CREATED = new Set([ - // Reserved by generic-worker-has-no-network-or-credentials. The generic CPU - // worker is NOT_SELECTED; docs/manual/03-outside-feature-folder.md says how - // to add it with its own tsconfig. - "src/adapters/web-worker", -]); -// pnpm's own commands, which are not package scripts. -const PNPM_COMMANDS = new Set(["add", "dlx", "exec", "install", "list", "why"]); const rootDirectory = fileURLToPath(repositoryRoot); const exists = (file: string) => existsSync(join(rootDirectory, file)); @@ -183,7 +161,6 @@ const scripts = new Set( .scripts, ), ); -const scriptPrefixes = new Set([...scripts].map((name) => name.split(":")[0])); const gateIds = new Set([ ...( JSON.parse(await readFile(join(rootDirectory, "config/ci/gates.json"), "utf8")) as { gates: { id: string }[] } @@ -203,24 +180,11 @@ const removedTemplateFeaturePaths = removedTemplateFeatures.flatMap((feature) => removableTemplateFeaturePaths(feature), ); const removedTemplateFeatureScripts = new Set(removedTemplateFeatures.flatMap((feature) => feature.scripts)); -function missingScript(name: string): boolean { - return !scripts.has(name) && !removedTemplateFeatureScripts.has(name); -} -// Generated output is what git ignores, so a document may name it before a -// run has written it. +// Generated output is what git ignores (ignoredByGit). const ignorePatterns = (await readFile(join(rootDirectory, ".gitignore"), "utf8").catch(() => "")) .split("\n") .map((line) => line.trim()) .filter((line) => line !== "" && !line.startsWith("#")); -function generated(file: string): boolean { - let ignored = false; - for (const line of ignorePatterns) { - const pattern = line.replace(/^!/u, "").replace(/^\/|\/$/gu, ""); - const glob = pattern.includes("/") ? pattern : `**/${pattern}`; - if (matchesGlob(file, glob) || matchesGlob(file, `${glob}/**`)) ignored = !line.startsWith("!"); - } - return ignored; -} // A copy may delete the history README lists under 「복사한 뒤 지워도 되는 // 것」. A path under an entry that is gone is not drift. const deletedHistory = deletableHistory(readme).filter((entry) => !exists(entry)); @@ -278,85 +242,18 @@ function pairedReferenceExists(reference: string): boolean | null { return inside.length === 0 || tree.paths.has(inside.join("/")); } -// A backtick span is a path when it starts at a top-level entry, at an entry -// beside the document or at a paired repository; line numbers and anchors are -// dropped. A path into a paired repository is returned relative to this one -// (`..//…`). -function namedPath(token: string, document: string): string | null { - const candidate = token.replace(/#.*$/u, "").replace(/:\d[\d,:-]*$/u, ""); - // An ellipsis, `...` or `…`, stands for any name, as in scripts/lib/docs-system.ts. - if (!candidate.includes("/") || candidate.startsWith("/") || /[\s*<>{}$()|…]|\.\.\./u.test(candidate)) return null; - const first = candidate.split("/")[0] ?? ""; - if (topLevelEntries.has(first)) return candidate; - if (pairedPins.has(first)) return `../${candidate}`; - return first !== "." && first !== ".." && exists(join(dirname(document), first)) - ? join(dirname(document), candidate) - : null; -} -// A link that leaves the repository is kept (`../…`); the caller looks it up -// in the paired repositories. -function linkedPath(target: string, document: string): string | null { - if (/^(?:[a-z][a-z+.-]*:|#)/iu.test(target)) return null; - return normalize(join(dirname(document), target.replace(/#.*$/u, ""))); -} -// 1103/12-05. A command span is not a path, so the paths it takes as -// arguments (`corepack pnpm exec vitest run tests/…`, `node scripts/…`) were -// never looked up. Leading `NAME=value` assignments are skipped, a -// `--flag=value` argument is read as its value, and placeholders (``, -// globs, `$VAR`) are left alone by namedPath. -const COMMAND_HEADS = new Set([ - "corepack", "pnpm", "npx", "node", "vitest", "playwright", "tsc", "eslint", "bash", "sh", "python3", -]); -// 1112/08-06. `scripts/verify.sh` is this repository's main entry and most -// documented commands go through it: the entry is itself a path, `exec --` -// runs a command whose paths are looked up like any other, and `script` -// names package scripts (verifyScripts). -const VERIFY_ENTRY = /^(?:\.\/)?scripts\/verify\.sh$/u; -function commandWords(command: string): Readonly<{ words: string[]; head: number }> { - const words = command.trim().replace(/^\$\s+/u, "").split(/\s+/u); - let head = 0; - while (/^[A-Z_][A-Z0-9_]*=/u.test(words[head] ?? "")) head += 1; - return { words, head }; -} -function commandPaths(command: string, document: string): (string | null)[] { - const { words, head } = commandWords(command); - const first = words[head] ?? ""; - if (VERIFY_ENTRY.test(first)) { - const separator = words.indexOf("--", head + 1); - const executed = words[head + 1] === "exec" && separator > head ? words.slice(separator + 1).join(" ") : ""; - return [namedPath(first, document), ...(executed === "" ? [] : commandPaths(executed, document))]; - } - if (!COMMAND_HEADS.has(first)) return []; - return words - .slice(head + 1) - .map((word) => namedPath(word.replace(/^--?[\w.-]+=/u, "").replace(/^["']|["']$/gu, ""), document)); -} -/** The package scripts `scripts/verify.sh script … [-- args]` runs; placeholders are left alone. */ -function verifyScripts(command: string): string[] { - const { words, head } = commandWords(command); - if (!VERIFY_ENTRY.test(words[head] ?? "") || words[head + 1] !== "script") return []; - const names: string[] = []; - for (const word of words.slice(head + 2)) { - if (word.startsWith("-")) break; - names.push(word); - } - return names.filter((name) => /^[a-z](?:[\w:-]*\w)?$/u.test(name)); -} -// Lines of fenced shell blocks (```bash, ```sh, ```shell, ```console or no -// language), which is where most documented commands are. -function fencedCommands(text: string): string[] { - const commands: string[] = []; - let fence: string | null = null; - for (const line of text.split("\n")) { - const marker = /^\s*```(\w*)/u.exec(line); - if (marker) { - fence = fence === null ? (marker[1] ?? "") : null; - continue; - } - if (fence !== null && /^(?:bash|sh|shell|console|zsh)?$/u.test(fence)) commands.push(line); - } - return commands; -} +const referenceFacts: ReferenceFacts = { + exists, + topLevelEntries, + scripts, + gateIds, + pairedRepositories: new Set(pairedPins.keys()), + pairedReferenceExists, + ignorePatterns, + deletedHistory, + removedFeaturePaths: removedTemplateFeaturePaths, + removedFeatureScripts: removedTemplateFeatureScripts, +}; const index = await readFile(DOCUMENT_INDEX, "utf8").catch(() => ""); const contractDocuments = new Set([DOCUMENT_INDEX]); @@ -373,7 +270,7 @@ for (const [, target = ""] of (index.match(/^## 1\.[\s\S]*?(?=^## )/mu)?.[0] ?? for (const document of livingDocuments(process.cwd())) { if (!UNCHECKED_DOCUMENTS.has(document)) contractDocuments.add(document); } -const documentReferences = []; +const documentReferences: DocumentReferences[] = []; for (const document of contractDocuments) { const text = await readFile(document, "utf8").catch(() => null); if (text === null) { @@ -389,74 +286,14 @@ for (const document of contractDocuments) { } continue; } - const named = [ - ...[...text.matchAll(/`([^`\n]+)`/gu)].flatMap(([, token = ""]) => [ - namedPath(token, document), - ...commandPaths(token, document), - ]), - ...fencedCommands(text).flatMap((command) => commandPaths(command, document)), - ...[...text.matchAll(/\]\(([^)\s]+)\)/gu)].map(([, target = ""]) => linkedPath(target, document)), - ]; - const missingPaths = new Set(); - const unverifiedLinks = new Set(); - for (const file of named) { - if (file === null) continue; - const trimmed = file.replace(/\/$/u, ""); - if (trimmed.startsWith("../")) { - // Outside this repository: `..//`. - const found = pairedReferenceExists(trimmed); - if (found === null) unverifiedLinks.add(trimmed); - else if (!found) missingPaths.add(trimmed); - continue; - } - if ( - !exists(trimmed) && - !NOT_CREATED.has(trimmed) && - !generated(trimmed) && - !deletedHistory.some((entry) => trimmed === entry || trimmed.startsWith(`${entry}/`)) && - !removedTemplateFeaturePaths.some((entry) => trimmed === entry || trimmed.startsWith(`${entry}/`)) - ) { - missingPaths.add(trimmed); - } - } - const missingScripts = new Set(); - for (const [, name = ""] of text.matchAll(/(?:corepack pnpm|`pnpm) (?:run )?([a-z](?:[\w:-]*\w)?)/gu)) { - if (!PNPM_COMMANDS.has(name) && missingScript(name)) missingScripts.add(name); - } - for (const [, name = ""] of text.matchAll(/`([a-z][\w-]*:[\w:-]*\w)(?=[` ])/gu)) { - if (scriptPrefixes.has(name.split(":")[0]) && missingScript(name)) missingScripts.add(name); - } - const commands = [...[...text.matchAll(/`([^`\n]+)`/gu)].map(([, token = ""]) => token), ...fencedCommands(text)]; - for (const name of commands.flatMap(verifyScripts)) { - if (missingScript(name)) missingScripts.add(name); - } - documentReferences.push({ - path: document, - missingPaths: [...missingPaths].sort(), - unverifiedLinks: [...unverifiedLinks].sort(), - missingScripts: [...missingScripts].sort(), - unknownGateIds: [...new Set([...text.matchAll(/\bFE-GATE-\d+\b/gu)].map(([id]) => id))] - .filter((id) => !gateIds.has(id)) - .sort(), - }); + documentReferences.push(checkDocumentReferences(document, text, referenceFacts)); } const documentReferencesValid = documentReferences.every( (entry) => entry.missingPaths.length === 0 && entry.missingScripts.length === 0 && entry.unknownGateIds.length === 0, ); -// Repository layout rules of docs/manual/03-outside-feature-folder.md. -// R6: the manual's examples point at generator output or at code blocks in -// the manual, never at a sample feature a copy is meant to delete (the -// template's own sample took the manual's examples with it on 2026-11-07). -// R7: host, cluster and infrastructure configuration (nginx, Kubernetes, -// Helm, Terraform) lives in the infrastructure repository; a current document -// links to it and states the host contract (config/hosting/, FE-GATE-019) -// instead of carrying a copy. The history folders are records and keep what -// they recorded: the current documents are the living documents -// scripts/lib/docs-system.ts reads for drift (records and decision records out). -const INFRASTRUCTURE_FENCE = /^\s*```\s*(nginx|hcl|terraform|helm)\b/iu; -const INFRASTRUCTURE_MANIFEST = - /^\s*kind:\s*(Deployment|StatefulSet|DaemonSet|Ingress|Service|ConfigMap|CronJob|HelmRelease|Kustomization)\s*$/u; +// Repository layout rules R6 and R7 of docs/manual/03-outside-feature-folder.md +// in the current documents (checkLayoutRules). const sampleFeaturePaths = REMOVABLE_TEMPLATE_FEATURES.flatMap((feature) => removableTemplateFeaturePaths(feature)); const currentDocuments = [ "README.md", @@ -465,23 +302,11 @@ const currentDocuments = [ .map((name) => `docs/${name}`) .filter(checkedForDrift), ].sort(); -const layoutRuleViolations: { path: string; rule: "R6" | "R7"; detail: string }[] = []; +const layoutRuleViolations: LayoutRuleViolation[] = []; for (const document of currentDocuments) { const text = await readFile(document, "utf8").catch(() => null); if (text === null) continue; - let fenced = false; - text.split("\n").forEach((line, index) => { - if (/^\s*```/u.test(line)) fenced = !fenced; - if (INFRASTRUCTURE_FENCE.test(line) || (fenced && INFRASTRUCTURE_MANIFEST.test(line))) { - layoutRuleViolations.push({ path: document, rule: "R7", detail: `line ${index + 1}: ${line.trim()}` }); - } - if (!document.startsWith("docs/manual/")) return; - for (const samplePath of sampleFeaturePaths) { - if (line.includes(samplePath)) { - layoutRuleViolations.push({ path: document, rule: "R6", detail: `line ${index + 1}: ${samplePath}` }); - } - } - }); + layoutRuleViolations.push(...checkLayoutRules(document, text, sampleFeaturePaths)); } // docs-system.md K1, K2, K4-K6 and the polite-form rule: language, record diff --git a/tests/unit/documentation-readiness-checks.test.ts b/tests/unit/documentation-readiness-checks.test.ts new file mode 100644 index 00000000..f0c2afe0 --- /dev/null +++ b/tests/unit/documentation-readiness-checks.test.ts @@ -0,0 +1,229 @@ +import { describe, expect, it } from "vitest"; + +import { + checkDocumentReferences, + checkLayoutRules, + checkSourceStructure, + type ReferenceFacts, + RULES_DOCUMENT, +} from "../../scripts/lib/documentation-readiness-checks.ts"; + +/** + * The checks verify:documentation runs, on inputs in memory. Each check has a + * passing input and an input that only it rejects (docs-system.md 7). The + * script's wiring (which documents it reads, the facts it builds from this + * repository, the paired checkouts, the stderr) is tested by spawning it in + * tests/unit/documentation-readiness.test.ts. This file reads no document, so + * the removal drills run it too (REMOVAL_FIXTURE_DOCUMENT_TESTS in + * scripts/lib/removal-fixture.ts). + */ + +describe("repository layout rules R6 and R7", () => { + const SAMPLE = ["src/features/sample-notes"]; + + it("passes a document with shell blocks and no infrastructure configuration", () => { + const text = "# 배포\n\n```bash\ncorepack pnpm build\n```\n\n호스트 계약은 `config/hosting/`이다.\n"; + expect(checkLayoutRules("docs/operations/deploy.md", text, SAMPLE)).toEqual([]); + }); + + it.each(["nginx", "hcl", "terraform", "Helm"])("R7 fails a ```%s block", (language) => { + const text = `# 배포\n\n\`\`\`${language}\nserver {}\n\`\`\`\n`; + expect(checkLayoutRules("docs/operations/deploy.md", text, SAMPLE)).toEqual([ + { path: "docs/operations/deploy.md", rule: "R7", detail: `line 3: \`\`\`${language}` }, + ]); + }); + + it("R7 fails a cluster manifest inside a block, and not the same words in prose", () => { + const text = "kind: Deployment\n\n```yaml\napiVersion: apps/v1\nkind: Deployment\n```\n"; + expect(checkLayoutRules("docs/operations/deploy.md", text, SAMPLE)).toEqual([ + { path: "docs/operations/deploy.md", rule: "R7", detail: "line 5: kind: Deployment" }, + ]); + }); + + it("R6 fails a manual line naming a sample feature, and only in docs/manual/", () => { + const text = "예시는 `src/features/sample-notes/feature-module.ts`를 본다.\n"; + expect(checkLayoutRules("docs/manual/01-add-a-feature.md", text, SAMPLE)).toEqual([ + { path: "docs/manual/01-add-a-feature.md", rule: "R6", detail: "line 1: src/features/sample-notes" }, + ]); + expect(checkLayoutRules("docs/architecture/overview.md", text, SAMPLE)).toEqual([]); + expect(checkLayoutRules("docs/manual/01-add-a-feature.md", text, [])).toEqual([]); + }); +}); + +describe("source structure (1101/14-03)", () => { + const RULES = [ + "# 계층", + "", + "| 폴더 | 역할 |", + "| --- | --- |", + "| `src/platform` | 제품 중립 커널 |", + "| `src/features` | 기능 폴더 |", + "", + "규칙: `platform-is-neutral`, `features-use-barrels`.", + ].join("\n"); + const ENTRY = "`src/platform` — 제품 중립 커널\n`src/features` — 기능 폴더\n"; + const texts = (changes: Readonly> = {}) => + new Map( + Object.entries({ + [RULES_DOCUMENT]: RULES, + "README.md": ENTRY, + "docs/architecture/overview.md": ENTRY, + "docs/architecture/frontend-application-foundation.md": ENTRY, + ...changes, + }), + ); + const check = (changes?: Readonly>, sourceFolders = ["features", "platform"]) => + checkSourceStructure({ + texts: texts(changes), + sourceFolders, + architectureRules: ["platform-is-neutral", "features-use-barrels"], + }).filter( + (entry) => entry.missingFolders.length + entry.unknownFolders.length + entry.missingRules.length > 0, + ); + + it("passes when every folder has its row and every entry document repeats it", () => { + expect(check()).toEqual([]); + }); + + it("fails when layers.md loses a rule name, as renaming a rule does", () => { + expect(check({ [RULES_DOCUMENT]: RULES.replace("`features-use-barrels`", "`features-barrels`") })).toEqual([ + { path: RULES_DOCUMENT, missingFolders: [], unknownFolders: [], missingRules: ["features-use-barrels"] }, + ]); + }); + + it("fails when a document names a top-level src folder that does not exist", () => { + expect(check({ "README.md": `${ENTRY}\`src/domain\`은 없다.\n` })).toEqual([ + { path: "README.md", missingFolders: [], unknownFolders: ["domain"], missingRules: [] }, + ]); + }); + + it("fails when a document describes a folder differently from layers.md", () => { + expect(check({ "docs/architecture/overview.md": ENTRY.replace("기능 폴더", "기능 묶음") })).toEqual([ + { path: "docs/architecture/overview.md", missingFolders: ["features"], unknownFolders: [], missingRules: [] }, + ]); + }); + + it("fails every document for a folder layers.md has no row for", () => { + expect(check({}, ["apps", "features", "platform"]).map((entry) => [entry.path, entry.missingFolders])).toEqual([ + [RULES_DOCUMENT, ["apps"]], + ["README.md", ["apps"]], + ["docs/architecture/overview.md", ["apps"]], + ["docs/architecture/frontend-application-foundation.md", ["apps"]], + ]); + }); +}); + +describe("document references", () => { + const FILES = new Set([ + "docs", + "docs/operations", + "docs/operations/ci.md", + "docs/operations/runbooks", + "docs/README.md", + "scripts", + "scripts/check-docs.ts", + "scripts/verify.sh", + "tests", + "tests/unit", + "tests/unit/docs.test.ts", + "README.md", + ]); + const facts = (overrides: Partial = {}): ReferenceFacts => ({ + exists: (path) => FILES.has(path), + topLevelEntries: new Set(["docs", "scripts", "src", "tests", "README.md", "artifacts"]), + scripts: new Set(["verify:documentation", "lint", "drill:runbook"]), + gateIds: new Set(["FE-GATE-017"]), + pairedRepositories: new Set(["backend"]), + pairedReferenceExists: () => true, + ignorePatterns: ["artifacts/quality/"], + deletedHistory: [], + removedFeaturePaths: [], + removedFeatureScripts: new Set(), + ...overrides, + }); + const DOCUMENT = "docs/operations/ci.md"; + const check = (text: string, overrides?: Partial) => { + const { path, ...found } = checkDocumentReferences(DOCUMENT, text, facts(overrides)); + expect(path).toBe(DOCUMENT); + return found; + }; + const NONE = { missingPaths: [], unverifiedLinks: [], missingScripts: [], unknownGateIds: [] }; + + it("passes a document whose paths, links, scripts and gate IDs exist", () => { + const text = [ + "`scripts/check-docs.ts:12`, [색인](../README.md#1), `corepack pnpm verify:documentation`, `lint`", + "FE-GATE-017이 돈다. `node scripts/…`, `scripts/verify.sh script <이름>…`, `src/adapters/web-worker`", + "```bash", + "VERIFY_SNAPSHOT=1 scripts/verify.sh exec -- node tests/unit/docs.test.ts --flag=tests/unit/docs.test.ts", + "corepack pnpm drill:runbook -- FE-RB-005 --release-root ", + "```", + ].join("\n"); + expect(check(text)).toEqual(NONE); + }); + + it("fails a path, a link target and a path beside the document that do not exist", () => { + expect(check("`scripts/check-dosc.ts` [지도](../READNE.md) `runbooks/gone.md`").missingPaths).toEqual([ + "docs/READNE.md", + "docs/operations/runbooks/gone.md", + "scripts/check-dosc.ts", + ]); + }); + + it("fails the paths an inline command, a shell block and a verify.sh exec take", () => { + const text = [ + "`corepack pnpm exec vitest run tests/unit/no-such.test.ts`", + "`python3 scripts/no-such.py --history docs`", + "```bash", + "scripts/verify.sh exec -- node scripts/no-such.ts", + "```", + ].join("\n"); + expect(check(text).missingPaths).toEqual(["scripts/no-such.py", "scripts/no-such.ts", "tests/unit/no-such.test.ts"]); + }); + + it("fails package scripts and gate IDs that do not exist", () => { + const text = "`corepack pnpm verify:documentaton`, `lint:fixx `, `scripts/verify.sh script no:such -- --x`, FE-GATE-099"; + expect(check(text)).toEqual({ + ...NONE, + missingScripts: ["lint:fixx", "no:such", "verify:documentaton"], + unknownGateIds: ["FE-GATE-099"], + }); + }); + + it("does not ask generated output to exist", () => { + expect(check("See `artifacts/quality/not-generated-yet.json`.")).toEqual(NONE); + }); + + it("accepts a path under history a copy deleted or a removed sample, and only that", () => { + const text = "`docs/retired-notes/plan.md` `src/features/sample-notes/x.ts` `corepack pnpm sample:seed`"; + expect( + check(text, { + topLevelEntries: new Set(["docs", "src"]), + deletedHistory: ["docs/retired-notes"], + removedFeaturePaths: ["src/features/sample-notes"], + removedFeatureScripts: new Set(["sample:seed"]), + }), + ).toEqual(NONE); + expect(check(text, { topLevelEntries: new Set(["docs", "src"]) })).toEqual({ + ...NONE, + missingPaths: ["docs/retired-notes/plan.md", "src/features/sample-notes/x.ts"], + missingScripts: ["sample:seed"], + }); + }); + + it("looks a paired reference up in the pinned tree, and reports one it cannot check as unverified", () => { + const text = "`backend/docs/web/http-contract.md` [계약](../../../backend/docs/gone.md)"; + const lookedUp: string[] = []; + const found = check(text, { + pairedReferenceExists: (reference) => { + lookedUp.push(reference); + return reference.endsWith("http-contract.md"); + }, + }); + expect(lookedUp.sort()).toEqual(["../backend/docs/gone.md", "../backend/docs/web/http-contract.md"]); + expect(found).toEqual({ ...NONE, missingPaths: ["../backend/docs/gone.md"] }); + expect(check(text, { pairedReferenceExists: () => null })).toEqual({ + ...NONE, + unverifiedLinks: ["../backend/docs/gone.md", "../backend/docs/web/http-contract.md"], + }); + }); +}); diff --git a/tests/unit/documentation-readiness.test.ts b/tests/unit/documentation-readiness.test.ts index 9374e83e..13a9ab77 100644 --- a/tests/unit/documentation-readiness.test.ts +++ b/tests/unit/documentation-readiness.test.ts @@ -181,18 +181,6 @@ describe("verify:documentation current contract documents (1101/14-05)", () => { expect(result.status, result.stderr).toBe(0); }, VERIFY_TIMEOUT); - it.each([ - ["README.md", "scripts/verify-documentation-readiness.ts", "scripts/verify-documentation-readyness.ts"], - ["docs/contracts/compatibility.md", "scripts/check-compatibility.ts", "scripts/check-compatibilty.ts"], - // reached through the `operations/` directory link - ["docs/operations/release-cache-rollback.md", "scripts/lib/hosting-probe.ts", "scripts/lib/hosting-prob.ts"], - ])("fails when %s names a path that does not exist", async (document, before, after) => { - const result = await verifyWithReadme((text) => text.replace(`\`${before}\``, `\`${after}\``), document); - expect(result.status).toBe(1); - expect(result.stderr).toContain(`${document} names paths that do not exist: ${after}`); - expect(result.stderr).toMatch(/\(failed: document references\)/u); - }, VERIFY_TIMEOUT); - it("fails when docs/README.md links a document that does not exist", async () => { const result = await verifyWithReadme( (index) => index.replace("(architecture/layers.md)", "(architecture/layer.md)"), @@ -212,11 +200,6 @@ describe("verify:documentation current contract documents (1101/14-05)", () => { expect(result.stderr).toContain("docs/README.md names gate IDs that config/ci/gates.json does not define: FE-GATE-099"); }, VERIFY_TIMEOUT); - it("does not ask generated output to exist", async () => { - const result = await verifyWithReadme((readme) => `${readme}\nSee \`artifacts/quality/not-generated-yet.json\`.\n`); - expect(result.status, result.stderr).toBe(0); - }, VERIFY_TIMEOUT); - it("accepts a path under history a copy deleted, and only that", async () => { const naming = (readme: string) => `${readme}\nSee \`docs/retired-notes/plan.md\`.\n`; const deleted = await verifyWithReadme((readme) => @@ -237,42 +220,6 @@ describe("verify:documentation commands and sibling links (1103/12-05)", () => { const CI_DOC = "docs/operations/ci-quality-gates.md"; const BACKEND = "clean-architecture-backend-template/docs/web/http-contract.md"; - it.each([ - ["an inline command", "`corepack pnpm exec vitest run tests/integration/no-such-client.test.ts`"], - ["a shell block", "```bash\nnode tests/integration/no-such-client.test.ts --flag\n```"], - ])("fails when %s names a path that does not exist", async (_shape, line) => { - const result = await verify({ [CI_DOC]: (text) => `${text}\n${line}\n` }); - expect(result.status).toBe(1); - expect(result.stderr).toContain(`${CI_DOC} names paths that do not exist: tests/integration/no-such-client.test.ts`); - }, VERIFY_TIMEOUT); - - it("looks up a command's existing arguments and leaves placeholders alone", async () => { - const result = await verify({ - [CI_DOC]: (text) => `${text}\n\`corepack pnpm exec vitest run tests/unit/documentation-readiness.test.ts -t "x"\`\n` + - "```bash\ncorepack pnpm drill:runbook -- FE-RB-005 --release-root \n```\n" + - "Any script is run as `node scripts/…`.\n" + - "`scripts/verify.sh exec -- node scripts/run-vitest.ts run tests/unit/documentation-readiness.test.ts`, " + - "`scripts/verify.sh script verify:documentation lint -- --x`, `scripts/verify.sh script <이름>…`, " + - "`python3 scripts/check-work-docs.py --history <경로>`\n", - }); - expect(result.status, result.stderr).toBe(0); - }, VERIFY_TIMEOUT); - - // 1112/08-06. Commands through this repository's entry point, and python3 - // commands, were not read, so a stale path or script name in them passed. - it("reads commands run through scripts/verify.sh and python3", async () => { - const result = await verify({ - [CI_DOC]: (text) => `${text}\n\`scripts/verify.sh exec -- node scripts/no-such.ts\`\n` + - "```bash\nVERIFY_SNAPSHOT=1 scripts/verify.sh exec -- node tests/unit/no-such-shell.test.ts\n```\n" + - "`python3 scripts/no-such.py --history docs`\n`scripts/verify.sh script no:such-script -- --flag`\n", - }); - expect(result.status).toBe(1); - expect(result.stderr).toContain( - `${CI_DOC} names paths that do not exist: scripts/no-such.py, scripts/no-such.ts, tests/unit/no-such-shell.test.ts`, - ); - expect(result.stderr).toContain(`${CI_DOC} names package scripts that do not exist: no:such-script`); - }, VERIFY_TIMEOUT); - it("checks a link or a path into a paired repository checked out beside this one", async () => { const naming = (target: string) => (text: string) => `${text}\n[contract](../../../${target}) and \`${target}\`\n`; @@ -378,35 +325,37 @@ describe("verify:documentation paired references at the pinned commit (1105/12-0 // 1101/14-03. The entry documents drew a top-level domain layer that does not // exist, left out three of the nine src folders, and layers.md named a // minority of the architecture rules while claiming it could not drift. -describe("verify:documentation source structure (1101/14-03)", () => { - it("fails when layers.md loses a rule name, as renaming a rule does", async () => { - const result = await verifyWithReadme( - (layers) => layers.replaceAll("`platform-kernel-is-product-neutral`", "`platform-kernel`"), - "docs/architecture/layers.md", - ); +// The checks in scripts/lib/documentation-readiness-checks.ts have their +// passing and failing inputs in tests/unit/documentation-readiness-checks.test.ts. +// This case breaks each of them once in the real documents, so the script's +// wiring (the documents it reads, the facts it builds from src/ and +// .dependency-cruiser.json, the stderr line and the failed-check name) is +// tested by one run instead of one run per input. +describe("verify:documentation runs the moved checks (1101/14-03, 1103/12-05, R7)", () => { + const CI_DOC = "docs/operations/ci-quality-gates.md"; + + it("names what source structure, document references and the layout rules find", async () => { + const result = await verify({ + "docs/architecture/layers.md": (layers) => + layers.replaceAll("`platform-kernel-is-product-neutral`", "`platform-kernel`"), + "docs/architecture/overview.md": (overview) => + overview.replace("- `src/platform` — 어느 폴더든", "- `src/platform` — 공용"), + "README.md": (readme) => + readme.replace("presentation -> application -> contracts", "presentation -> application -> `src/domain`"), + [CI_DOC]: (text) => `${text}\n\`scripts/verify.sh exec -- node scripts/no-such.ts\`\n\n\`\`\`nginx\nserver {}\n\`\`\`\n`, + }); expect(result.status).toBe(1); expect(result.stderr).toContain( "docs/architecture/layers.md does not name .dependency-cruiser.json rules: platform-kernel-is-product-neutral", ); - expect(result.stderr).toMatch(/\(failed: source structure\)/u); - }, VERIFY_TIMEOUT); - - it("fails when a document names a top-level src folder that does not exist", async () => { - const result = await verifyWithReadme((readme) => - readme.replace("presentation -> application -> contracts", "presentation -> application -> `src/domain`"), - ); - expect(result.status).toBe(1); expect(result.stderr).toContain("README.md names src folders that do not exist: domain"); - }, VERIFY_TIMEOUT); - - it("fails when a document describes a folder differently from layers.md", async () => { - const result = await verifyWithReadme( - (overview) => overview.replace("- `src/platform` — 어느 폴더든", "- `src/platform` — 공용"), - "docs/architecture/overview.md", - ); - expect(result.status).toBe(1); expect(result.stderr).toContain( "docs/architecture/overview.md does not describe src folders as the layers.md table does: platform", ); + expect(result.stderr).toContain(`${CI_DOC} names paths that do not exist: scripts/no-such.ts`); + expect(result.stderr).toMatch( + new RegExp(`${CI_DOC} breaks R7 of docs/manual/03-outside-feature-folder\\.md: line \\d+: \`\`\`nginx`, "u"), + ); + expect(result.stderr).toMatch(/\(failed: source structure, document references, repository layout rules\)/u); }, VERIFY_TIMEOUT); }); -- 2.54.0 From ec8c04c2ff12c11d4ed6f80387178831c9e4f904 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sat, 21 Nov 2026 15:59:52 +0900 Subject: [PATCH 04/12] =?UTF-8?q?docs(changelog):=20=EC=88=AB=EC=9E=90=20?= =?UTF-8?q?=EB=B3=B5=EC=82=AC=20=EA=B2=80=EC=82=AC=EA=B0=80=20=EC=98=88?= =?UTF-8?q?=EC=82=B0=20=EA=B0=92=EA=B3=BC=20=EC=8B=9C=ED=97=98=20=EC=88=98?= =?UTF-8?q?=EB=8F=84=20=EB=B3=B4=EB=8A=94=20=EA=B2=83=EC=9D=84=20=EC=A0=81?= =?UTF-8?q?=EB=8A=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit verify:documentation(FE-GATE-017)이 예산 값·세 자리 이상 시험 수·조사 붙은 게이트 개수를 옮겨 적은 다운스트림 문서를 실패시키므로 미출시 절 「보안·계약 변경」에 [계약] 줄로 적는다. 원장 세 행(REV-FE-0008)과 검사 함수 분리(REV-FE-0011)는 다운스트림 동작을 바꾸지 않아 적지 않는다. Refs: REV-FE-0009, REV-FE-0022 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ff909d5..70db6eee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,6 +127,7 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지 | [계약] | `check:ci:gating`(FE-GATE-029)이 Playwright 실행의 `--grep`·`--grep-invert`·파일 필터를 읽는다. testDir은 필터 없는 gated 실행이 있거나, `--grep-invert P` 실행마다 같은 testDir을 `--grep P`(같은 글자)로 도는 gated 실행이 있을 때만 게이트 안으로 센다. 파일 필터가 있는 실행, `--grep`·`--grep-invert`를 합쳐 둘 이상 쓴 실행, 설정(또는 그 설정이 import한 설정)에 `grep`·`grepInvert`가 있는 실행은 부분 실행으로 센다. 그 testDir의 게이트 밖 파일은 testDir·실행·빠진 짝을 대는 한 줄로 실패한다. 전에는 009의 Playwright 실행을 빼도 통과해, 시험이 모두 `@a11y`인 `tests/e2e/accessibility.spec.ts`가 어느 게이트에서도 돌지 않았다. `-c X`·`-cX`·`--config=X`로 고른 설정도 이제 읽는다(전에는 e2e 설정의 testDir로 셌다). 위 "먼저 할 일" | `scripts/lib/playwright-test-args.ts`, `scripts/lib/ungated-tests.ts`, `scripts/check-ci-gating.ts`, `playwright.a11y.config.ts`, `tests/unit/playwright-test-args.test.ts`, `tests/unit/ungated-tests.test.ts`, `tests/unit/playwright-result-paths.test.ts`, `docs/operations/ci-quality-gates.md` | `32982e55` | | [보안] | telemetry payload 정제가 복사하는 값의 총수를 `maxNodes`(기본 512)로 막는다. 같은 객체를 여러 key가 가리키는 payload(정규화된 엔티티 graph 등)를 경로마다 따로 복사해, `emit` 한 번이 호출 스택을 수 초 막거나 heap OOM으로 탭을 죽였다. 여러 경로가 가리키는 객체의 key는 한 번만 읽는다. 순회가 너비 우선이 되어 상한이 차면 얕은 필드가 남고 깊은 값이 `[truncated]`가 된다. 복사본 객체의 key 순서가 원본 순서가 된다(전에는 거꾸로, fingerprint는 그대로). 깊이 제한 시험이 잘린 모양과 순환 payload를 단언한다 | `src/platform/telemetry/redact-telemetry.ts`, `src/platform/telemetry/telemetry-pipeline.ts`, `tests/platform/telemetry/redact-telemetry.test.ts`, `config/scale/feature-shape-ceilings.json` | `d406c10b`, `0190b631` | | [계약] | `mapTransportFailure`가 `JsonBudgetExceededError`의 own data `violation`이 `"invalid-json"`이면 `response.invalid`로 분류한다. 전에는 `parseBoundedJson`이 JSON이 아닌 응답에 던진 오류가 `response.too-large`가 되어 날 `SyntaxError`(`response.invalid`)와 갈렸다. 두 kind의 category(`contract`)·retryability(`never`)는 같다. `violation`이 accessor면 부르지 않고 `response.too-large`로 둔다. 시험 표에 fan-out 초과·`TimeoutError`·invalid-json 줄을 더한다 | `src/platform/errors/platform-errors.ts`, `tests/platform/errors/platform-errors.test.ts` | `a934554d` | +| [계약] | `verify:documentation`(FE-GATE-017)의 숫자 복사 검사가 `config/performance/budgets.json`의 예산 값(1000 이상, 천 단위 쉼표가 있든 없든), 세 자리 이상 시험 수(「시험·테스트 N개」「N개 시험」「N tests」), 조사가 붙은 게이트 개수(「게이트가 29개」)도 본다. 전에는 게이트·recipe·adapter 개수만 봤다. 자기 문서가 이 값을 옮겨 적었으면 실패하니 정본(`budgets.json`, 시험 보고서)을 가리키게 고친다. 「A에서 B로」 안의 값은 지난 변경의 기록이라 읽지 않는다. 1000 미만 예산 값과 100 미만 시험 수는 여전히 검사 밖이다 | `scripts/lib/docs-system.ts` | `d460a5f8` | ### 그 밖의 변경 -- 2.54.0 From 9aab9c0f2842750d5108168c030471ef4f5a7b8d Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sat, 21 Nov 2026 16:26:53 +0900 Subject: [PATCH 05/12] =?UTF-8?q?fix(docs):=20=EC=88=AB=EC=9E=90=20?= =?UTF-8?q?=EB=B3=B5=EC=82=AC=20=EA=B2=80=EC=82=AC=EA=B0=80=20=EC=8B=A4?= =?UTF-8?q?=ED=96=89=EA=B8=B0=20=EB=AC=B8=EA=B5=AC=EC=99=80=20=EB=B6=99?= =?UTF-8?q?=EC=97=AC=20=EC=93=B4=20=EB=8B=A8=EC=9C=84=EB=8F=84=20=EB=B3=B8?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d460a5f8의 숫자 복사 검사에 빈틈이 있다(리뷰 1회). - 시험 수: 「1,619개 통과」「104개 실패」「Tests 1619 passed」처럼 실행기가 쓰는 꼴을 못 본다. 원장에 이 꼴의 실행 결과가 남아 있다. - 예산 값: 「206848B」「2500ms」처럼 단위를 붙여 쓰면 값 뒤 lookahead가 막아 안 걸린다. - 「A에서 B로」 면제: 앞이 「숫자 에서」이기만 하면 빠져서 「FE-GATE-011에서 206,848 B 상한으로」「206,848 B에서 1 B만」 같은 현재 값 복사도 통과한다. - 게이트 개수: 앞 단어 경계가 없어 「aggregate가 2개」도 걸린다. - budgetValues 읽기와 checkDocsSystem 배선을 보는 시험이 없다. budgets.json을 못 읽으면 검사가 소리 없이 꺼진다. 고친 것: - 시험 수 꼴에 「N개 통과·실패」「N passed·failed」(세 자리 이상)를 더한다. - 값 뒤에 B·bytes·KiB·ms가 바로 붙어도 값으로 읽는다. - 면제는 양쪽이 숫자(+단위)인 「A에서 B로·으로」의 A와 B에만 준다. A 숫자 앞에 글자·점·쉼표·하이픈이 오면(FE-GATE-011) 숫자로 보지 않는다. - `gate` 앞에 영문자가 오면 게이트 개수로 읽지 않는다. - 이 repo의 budgets.json에서 값을 읽는지, checkDocsSystem이 그 값으로 임시 문서를 실패시키는지 보는 시험을 더한다. 새 꼴에 걸린 원장 실행 결과(통과 수 15줄, 같은 값 한 줄 더)는 통과 수를 빼고 「모두 통과」「N개 실패(나머지는 통과)」로 고쳤다. 원장의 「107/108」도 개수 없이 적었다. performance-evidence.md의 「202 KiB이고, 이것이 예산 값이다」는 정본만 가리키게 고쳤다. 바로잡음(d460a5f8 본문): 1000 미만 예산 값을 빼는 근거로 든 「204,800 B에서 206,848 B로 올린 결정」은 1000 이상 값이라 근거가 못 된다(면제로 통과한다). 바른 근거는 문턱을 1로 낮추면 문서 21개에서 27건(200·500·32 같은 보통 수)이 걸린다는 것이다. 100 미만 시험 수를 빼는 근거 「정해진 묶음」도 다 맞지는 않다. 문턱을 없애면 문서 4개에서 19건이 걸리는데, 매뉴얼의 「테스트 3개」 말고는 대부분 원장의 작은 실행 결과(「80개 통과」「테스트 19개 실패」)다. 이 작은 실행 결과 수는 검사 밖에 남는다 (코드 주석에 적었다). 버린 안: 「A에서 B로」 면제를 없애기 — 결정 행(D9)과 그 예시가 지난 변경을 적는 꼴이라 걸린다. 시험 수를 모든 자릿수로 보기 — 위 19건이 걸리고, 원장 전체를 다시 써야 해 이 항목 범위 밖이다. 위험·한계: KiB로 쓴 예산(「202 KiB」), 1000 미만 예산 값, 100 미만 시험 수는 여전히 검사 밖이다. 면제의 B 뒤에 다른 말이 끼면(「206,848 B(상한)로」) 면제되지 않아 실패한다. 검증: 노트북 node 탐침으로 이 repo 문서 checkDocsSystem 실패 0건, 새 꼴 사례 20개가 기대대로(거절 12·통과 8), 배선 시험 탐침 통과, 변이 둘(배선을 빈 Map으로, 읽기 끊기)이 각각 실패. scripts/verify.sh docs rc=0. 단위 시험과 RED는 PR의 desktop 묶음에서 돈다. Refs: REV-FE-0009, REV-FE-0022 --- docs/operations/adapter-remediation-ledger.md | 34 +++++++++---------- docs/operations/performance-evidence.md | 4 +-- scripts/lib/docs-system.ts | 34 ++++++++++++------- tests/unit/docs-system.test.ts | 29 ++++++++++++++++ 4 files changed, 70 insertions(+), 31 deletions(-) diff --git a/docs/operations/adapter-remediation-ledger.md b/docs/operations/adapter-remediation-ledger.md index c32efe0a..3d31f138 100644 --- a/docs/operations/adapter-remediation-ledger.md +++ b/docs/operations/adapter-remediation-ledger.md @@ -71,7 +71,7 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | ID | Activation | 실패 테스트(red test) 명령 | 수정 커밋/PR | Rollout 상태 | Rollback 기준 | 증거 | | --- | --- | --- | --- | --- | --- | --- | | N-01 | 실행 중인 V3 경로 | `corepack pnpm exec vitest run tests/integration/http-execution-v3-observability.test.ts` | `fix: restore V3 HTTP observability` | `FIXED_NOT_RELEASED` | diagnostics/telemetry producer 게이트 회귀 | 실패 5/5 → 통과 5/5. `check:diagnostics` PASS(diagnostic 8개, telemetry producer 5개). `check:types` PASS. `check:architecture` PASS | -| N-02 | 실행 중인 V3 경로 | `corepack pnpm exec vitest run tests/integration/http-execution-v3-auth-profile.test.ts` | `fix: enforce installed HTTP auth profiles` | `FIXED_NOT_RELEASED` | profile 강제 뒤 인증 요청 4xx 급증 | 실패: 테스트 파일이 로드되지 않음(`installRestAuthProfileRegistry` 없음) → 통과 7/7. `check:types` PASS. `check:architecture` PASS. `lint` PASS. unit+integration+features 1560개 통과, 실패는 원래 있던 환경 탓 `ci-artifact-contract` 실패뿐 | +| N-02 | 실행 중인 V3 경로 | `corepack pnpm exec vitest run tests/integration/http-execution-v3-auth-profile.test.ts` | `fix: enforce installed HTTP auth profiles` | `FIXED_NOT_RELEASED` | profile 강제 뒤 인증 요청 4xx 급증 | 실패: 테스트 파일이 로드되지 않음(`installRestAuthProfileRegistry` 없음) → 통과 7/7. `check:types` PASS. `check:architecture` PASS. `lint` PASS. unit+integration+features는 원래 있던 환경 탓 `ci-artifact-contract` 실패 말고 모두 통과 | | N-03 | 실행 중인 V3 경로 | `corepack pnpm exec vitest run tests/unit/http-execution-v3.test.ts -t "retry-time fence"` | `fix: preserve command effect certainty across retries` | `FIXED_NOT_RELEASED` | command effect 판정 회귀 | 실패: 시도 한 번을 보낸 뒤 `NOT_STARTED`와 함께 `SCOPE_FENCED`가 재현됨 → 통과 `MAYBE_APPLIED`. lattice 표 9/9. `check:types` PASS. `lint` PASS | | N-04 | 실행 중인 조립의 정리(teardown) | `corepack pnpm exec vitest run tests/unit/telemetry.test.ts tests/unit/runtime-adapters.test.ts` | `fix: terminate telemetry work on disposal` | `FIXED_NOT_RELEASED` | teardown 변경 뒤 telemetry 전달 유실 | 실패 10개(lifecycle 5 + capacity 5) → 통과 34/34. `check:diagnostics` PASS. `check:types` PASS. `check:architecture` PASS. `lint` PASS | | N-05 | Rollout 차단 요인(sidecar 조립 안 됨) | `corepack pnpm exec vitest run tests/unit/conditional-validator-store.test.ts` | `fix: harden bounded state sidecars` | `FIXED_NOT_RELEASED` | 저장된 validator 키 비호환 | 실패: 충돌 사례(올바른 binding 두 개가 구분자로 이은 키 하나를 공유) → 통과. 키는 이제 크기가 제한되고 검증된 tuple이며 `JSON.stringify`로 인코딩한다 | @@ -86,7 +86,7 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | ID | Activation | 실패 테스트 명령 | 수정 커밋/PR | Rollout 상태 | Rollback 기준 | 증거 | | --- | --- | --- | --- | --- | --- | --- | -| STO-01 | 템플릿에서 OPFS 조립 안 됨. 제품 writer가 있으면 **Critical** | `corepack pnpm exec vitest run tests/unit/opfs-byte-store.test.ts tests/unit/opfs-worker-runtime.test.ts tests/unit/indexeddb-opfs-journal.test.ts` | `fix: preserve OPFS recovery authority during cleanup` | `FIXED_NOT_RELEASED` | OPFS reconcile 적체 또는 journal 증가 | 실패: 새 saga 사례 4개 → OPFS 테스트 파일 3개에서 통과 25/25. `check:types` PASS(web-worker 포함). `check:browser-file-storage-boundaries` PASS. `lint` PASS. `test:unit` 1511개 통과, 실패는 원래 있던 환경 탓 `ci-artifact-contract` 실패뿐 | +| STO-01 | 템플릿에서 OPFS 조립 안 됨. 제품 writer가 있으면 **Critical** | `corepack pnpm exec vitest run tests/unit/opfs-byte-store.test.ts tests/unit/opfs-worker-runtime.test.ts tests/unit/indexeddb-opfs-journal.test.ts` | `fix: preserve OPFS recovery authority during cleanup` | `FIXED_NOT_RELEASED` | OPFS reconcile 적체 또는 journal 증가 | 실패: 새 saga 사례 4개 → OPFS 테스트 파일 3개에서 통과 25/25. `check:types` PASS(web-worker 포함). `check:browser-file-storage-boundaries` PASS. `lint` PASS. `test:unit`은 원래 있던 환경 탓 `ci-artifact-contract` 실패 말고 모두 통과 | | STO-02 | 브라우저 파일 runtime 조립 안 됨 | `corepack pnpm exec vitest run tests/unit/browser-file-download.test.ts` | `fix: execute canonical browser download targets` | `FIXED_NOT_RELEASED` | canonical target 때문에 다운로드 이동이 막힘 | 실패 2개(가공하지 않은 상대 href를 host에 넘김) → 통과 17/17 | | STO-03 | 공개 캐시 조립 안 됨 | `corepack pnpm exec vitest run tests/unit/public-response-cache.test.ts` | `fix: make public cache staging repairable` | `FIXED_NOT_RELEASED` | 기존 정책을 조립 단계에서 거부 | 실패: STO-03..05에 걸친 사례 4개 → 통과 21/21. `check:types` PASS. `check:browser-file-storage-boundaries` PASS. `lint` PASS | | STO-04 | 공개 캐시 조립 안 됨 | `corepack pnpm exec vitest run tests/unit/public-response-cache.test.ts` | `fix: make public cache staging repairable` | `FIXED_NOT_RELEASED` | restage 반복 또는 대역폭 급증 | — | @@ -163,9 +163,9 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | 테스트 | 종료 | 결과 | | --- | ---: | --- | -| `tests/unit/browser-rpc` + `tests/unit/realtime` | 0 | 192개 통과 | +| `tests/unit/browser-rpc` + `tests/unit/realtime` | 0 | 모두 통과 | | OPFS, IndexedDB, 공개 캐시, 다운로드 | 0 | 80개 통과 | -| abortable-operation, presigned, 재개 가능 업로드, image CDN | 0 | 104개 통과 | +| abortable-operation, presigned, 재개 가능 업로드, image CDN | 0 | 모두 통과 | | Service Worker + Web Push | 0 | 66개 통과 | ### 저장소 게이트 @@ -179,7 +179,7 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | `corepack pnpm check:browser-file-storage-boundaries` | 0 | PASS, 거부 34건 | | `corepack pnpm check:realtime-boundaries` | 0 | PASS | | `git diff --check` | 0 | 문제 없음 | -| `corepack pnpm test:component` | 0 | 126개 통과 | +| `corepack pnpm test:component` | 0 | 모두 통과 | | `corepack pnpm test:integration` | 0 | 52개 통과 | | 참조 샘플 기능 시험(그 script는 2026-11-07 샘플과 함께 지웠다) | 0 | 26개 통과 | | `corepack pnpm test:recipes` | 0 | 17개 통과 | @@ -309,8 +309,8 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | `corepack pnpm check:realtime-boundaries` | 0 | PASS | | `corepack pnpm verify:documentation` | 0 | PASS_SCOPED | | `git diff --check` | 0 | 문제 없음 | -| `tests/unit` + `tests/integration`, 제외 없음 | — | 1643개 통과 / 1747개. 실패 104개는 아래 환경 탓 파일 네 개에서 나온다 | -| `corepack pnpm test:component` | 0 | 126개 통과 | +| `tests/unit` + `tests/integration`, 제외 없음 | — | 아래 환경 탓 파일 네 개의 실패 말고는 모두 통과 | +| `corepack pnpm test:component` | 0 | 모두 통과 | | `corepack pnpm test:recipes` | 0 | 17개 통과 | | 참조 샘플 기능 시험(그 script는 2026-11-07 샘플과 함께 지웠다) | 0 | 26개 통과 | @@ -318,7 +318,7 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | 게이트 | 상태 | 원인 | | --- | --- | --- | -| `tests/unit/`의 `ci-workflow-generation.test.ts` | 82개 실패 / 325개 통과 | 변경 전 기준에서도 같다(`git stash` 비교). 이 파일이 띄우는 하위 프로세스 게이트는 이 sandbox에서 돌 수 없다. | +| `tests/unit/`의 `ci-workflow-generation.test.ts` | 82개 실패(나머지는 통과) | 변경 전 기준에서도 같다(`git stash` 비교). 이 파일이 띄우는 하위 프로세스 게이트는 이 sandbox에서 돌 수 없다. | | `tests/system/ci-runner/ci-artifact-contract.test.ts` | 실패 | 원래 있던 그대로의 sandbox, cgroup, `/tmp` 권한 동작이다. | | `tests/unit/security-followup.test.ts`, `tests/integration/provider-guardian-transaction.test.ts`, `tests/unit/risk-coverage.test.ts` | 전체 실행 부하에서 불안정(flaky) | 과거 기준 결과다. 셋 다 새 프로세스에서 통과했다(함께 돌려 78개 통과). | @@ -404,13 +404,13 @@ AssertionError: expected [] to deeply equal ArrayContaining{…} | `corepack pnpm check:architecture` | 0 | 모듈 290개, 의존 879개. fixture 12개 PASS. 허용 PASS / 금지 9개 거부 | | `corepack pnpm check:adapter-inventory` | 0 | 파일 119개. 공유 확장자 7개. shared-abort importer 5개 나열 | | `corepack pnpm check:optional-recipes:source` | 0 | file-transfer 53,810 / 54,600 gzip 바이트 | -| `corepack pnpm exec vitest run tests/unit/browser-rpc tests/unit/realtime` | 0 | 파일 17개 / 234개 통과 | -| abortable-operation, presigned, 재개 가능 업로드, image CDN | 0 | 파일 7개 / 176개 통과 | -| OPFS, journal, 공개 캐시, cursor | 0 | 파일 5개 / 100개 통과 | +| `corepack pnpm exec vitest run tests/unit/browser-rpc tests/unit/realtime` | 0 | 파일 17개 모두 통과 | +| abortable-operation, presigned, 재개 가능 업로드, image CDN | 0 | 파일 7개 모두 통과 | +| OPFS, journal, 공개 캐시, cursor | 0 | 파일 5개 모두 통과 | | Service Worker + Web Push | 0 | 파일 6개 / 79개 통과 | | `corepack pnpm exec vitest run tests/integration` | 0 | 파일 11개 / 82개 통과 | -전체 `tests/unit` + `tests/integration` 실행은 **1,845개 통과 / 1,864개**이고, 파일 129개 중 128개가 통과했다. 실패 19건은 전부 `tests/system/ci-runner/ci-artifact-contract.test.ts`에서 나온다. 위에 이미 적은, 원래 있던 sandbox, cgroup, RLIMIT, `/tmp` 권한 동작이다. 이 작업 전에도 같은 파일이 똑같이 실패했다. 실패하는 adapter 테스트는 없다. +전체 `tests/unit` + `tests/integration` 실행은 파일 129개 중 128개가 통과했다. 실패 19건은 전부 `tests/system/ci-runner/ci-artifact-contract.test.ts`에서 나온다. 위에 이미 적은, 원래 있던 sandbox, cgroup, RLIMIT, `/tmp` 권한 동작이다. 이 작업 전에도 같은 파일이 똑같이 실패했다. 실패하는 adapter 테스트는 없다. ## 운영 계약 리뷰 (2026-08-15) @@ -460,7 +460,7 @@ $ sysctl kernel.apparmor_restrict_unprivileged_userns kernel.apparmor_restrict_unprivileged_userns = 1 ``` -이 재현에는 이 저장소의 코드가 하나도 없다. 같은 세션 앞부분에서는 똑같은 sandbox가 끝까지 돌았다. 그러니 제약은 도중에 켜졌다. 제약이 있는 동안 provider 테스트 중 16개는 여기서 돌 수 없다. kernel이 허락하지 않는 sandbox가 필요하기 때문이다. 이 테스트는 통과로도, 제품 결함으로도 세지 않는다. namespace를 허락하는 host에서는 같은 파일이 107/108이었다. +이 재현에는 이 저장소의 코드가 하나도 없다. 같은 세션 앞부분에서는 똑같은 sandbox가 끝까지 돌았다. 그러니 제약은 도중에 켜졌다. 제약이 있는 동안 provider 테스트 중 16개는 여기서 돌 수 없다. kernel이 허락하지 않는 sandbox가 필요하기 때문이다. 이 테스트는 통과로도, 제품 결함으로도 세지 않는다. namespace를 허락하는 host에서는 같은 파일이 한 개 말고 모두 통과했다. ### 이 작업 뒤에도 실패하는 것 @@ -472,10 +472,10 @@ kernel.apparmor_restrict_unprivileged_userns = 1 | fixture | 전 | 후 | | --- | ---: | ---: | -| 참조 feature | 첫 단언 전에 실패 | 1,612개 통과 / 1개 실패 | -| 선택 recipe | 실패 39개 | 1,386개 통과 / 2개 실패 | -| 브라우저 파일 + 스토리지 | 실패 40개 | 1,006개 통과 / 3개 실패 | -| realtime | 도달 못 함 | 1,159개 통과 / 1개 실패 | +| 참조 feature | 첫 단언 전에 실패 | 1개 실패(나머지는 통과) | +| 선택 recipe | 실패 39개 | 2개 실패(나머지는 통과) | +| 브라우저 파일 + 스토리지 | 실패 40개 | 3개 실패(나머지는 통과) | +| realtime | 도달 못 함 | 1개 실패(나머지는 통과) | 남은 실패는 하나하나가 위에서 말한 환경 제약 테스트 세 개 중 하나다. diff --git a/docs/operations/performance-evidence.md b/docs/operations/performance-evidence.md index bd6c5ac4..a4ac43b9 100644 --- a/docs/operations/performance-evidence.md +++ b/docs/operations/performance-evidence.md @@ -54,8 +54,8 @@ - 폭의 근거(1106/15-01, 결정 D9): 예산은 드릴 측정값에 기능 하나의 상한 (`perFeatureGzipBytes` 상한 1 KiB)을 더해 KiB 단위로 올림한 값이다. 드릴은 CI env에서 205,465 B였다(2026-11-06, `bbde570`, FE-GATE-020). 205,465 + - 1,024 = 206,489 B를 KiB 단위로 올리면 202 KiB이고, 이것이 예산 값이다 - (`config/performance/budgets.json`). 그래서 드릴 위의 여유 + 1,024 = 206,489 B를 KiB 단위로 올린 값을 그때 예산으로 정했다(지금 값의 + 정본은 `config/performance/budgets.json`). 그래서 드릴 위의 여유 1,383 B는 기능 하나(1,024 B)와 올림(359 B)이다. 이 규칙에 템플릿 자신이 더 쓸 몫은 없다. 템플릿 변경이 이 여유를 쓰면 그만큼 기능 몫이 준다. - 되돌림 규칙: 위 "다시 볼 때"마다 드릴을 다시 잰다. 드릴 측정값이 204,800 B diff --git a/scripts/lib/docs-system.ts b/scripts/lib/docs-system.ts index 743c5c1f..eda8ba7c 100644 --- a/scripts/lib/docs-system.ts +++ b/scripts/lib/docs-system.ts @@ -167,13 +167,14 @@ const FRAMEWORKS = Object.freeze([ const NAMED_VERSION = /\b(?:React(?: DOM| Router)?|Vite|TypeScript|Vitest|Playwright|TanStack Query|Zod|Storybook|Node(?:\.js)?)\s+v?\d+\.\d+(?:\.\d+)?\b/gu; // A count after its noun may take a particle (「게이트가 29개」, 「시험은 33개」). +// `gate` is read only as a word of its own, not inside 「aggregate」. const COUNT_PARTICLE = "(?:가|이|은|는|을|를)?"; const SUITE_COUNT = "(?:\\d{1,3}(?:,\\d{3})+|\\d{3,})"; const COPIED_COUNTS = Object.freeze([ [ "gate count (config/ci/gates.json)", new RegExp( - `\\b\\d+\\s*개의?\\s*(?:merge\\s*)?(?:게이트|gate)|(?:게이트|gate)${COUNT_PARTICLE}\\s*\\d+\\s*개|\\b\\d+\\s+(?:merge\\s+)?gates\\b`, + `\\b\\d+\\s*개의?\\s*(?:merge\\s*)?(?:게이트|gate)|(?:게이트|(? createHash("sha256").update(line, "utf8").digest("hex").slice(0, 16); @@ -416,7 +426,7 @@ function checkNumber(documents: readonly DocsDocument[], facts: DocsFacts): Docs } const budgets = [...budgetKeys].map(([value, keys]) => { const digits = String(value).replace(/\B(?=(?:\d{3})+$)/gu, ",?"); - return [`budget value (config/performance/budgets.json ${keys.join(", ")})`, new RegExp(`(? { ["a suite's test count", "시험 1600개가 돈다.", "test count"], ["a suite's test count after a particle", "테스트가 1,515개다.", "test count"], ["a suite's test count in English", "It ran 1600 tests.", "test count"], + ["a suite's test count in the runner's words", "전체 1723개 중 1,619개 통과.", "test count"], + ["a suite's failure count in the runner's words", "104개 실패했다.", "test count"], + ["a suite's test count in the runner's English words", "Tests 1619 passed (1723)", "test count"], + ["a budget value with its unit attached", "206848B를 넘으면 실패한다.", "budget value"], + ["a budget value after a gate ID, not a change", "FE-GATE-011에서 206,848 B 상한으로 본다.", "budget value"], + ["a budget value a sentence measures from, not a change", "206,848 B에서 1 B만 넘어도 실패한다.", "budget value"], ])("fails %s", (_, line, label) => { expect(run("number", living(line))).toEqual([expect.stringContaining(label)]); }); @@ -234,10 +245,28 @@ describe("copied numbers", () => { ["a budget value under four digits, an ordinary number in prose", "200 ms 안에 반응한다."], ["a test count under a hundred, a fixed set the sentence is about", "생성기는 테스트 3개와 시험 33개를 만든다."], ["a number that only contains a budget value", "id 1206848과 2068480은 다른 값이다."], + ["a count after a word that only ends in gate", "aggregate가 2개 있다."], ])("passes %s", (_, line) => { expect(run("number", living(line))).toEqual([]); }); + it("reads this repository's budget values, and checkDocsSystem looks for them", () => { + const budgets = JSON.parse(readFileSync("config/performance/budgets.json", "utf8")) as { + bundle: { initialJsGzipBytes: number }; + }; + const value = budgets.bundle.initialJsGzipBytes; + expect(budgetValues(process.cwd()).get("bundle.initialJsGzipBytes")).toBe(value); + const root = mkdtempSync(join(tmpdir(), "docs-system-budget-")); + try { + mkdirSync(join(root, "docs/operations"), { recursive: true }); + writeFileSync(join(root, "docs/operations/budget-copy.md"), `# 예산\n\n${KOREAN}예산은 ${value} B다.\n`); + const failures = checkDocsSystem(root, process.cwd()).failures.filter((failure) => failure.includes("budget value")); + expect(failures).toEqual([expect.stringContaining("docs/operations/budget-copy.md:4")]); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }); + it("counts a version next to its name once", () => { expect(run("number", living("React 19.2.8을 쓴다."))).toHaveLength(1); }); -- 2.54.0 From 1b2b546d43e47fde97e1b0aff36213fcb1e1c824 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sat, 21 Nov 2026 16:26:53 +0900 Subject: [PATCH 06/12] =?UTF-8?q?fix(docs):=20=EB=AC=B8=EC=84=9C=20?= =?UTF-8?q?=EA=B2=80=EC=82=AC=20=EB=B6=84=EB=A6=AC=EA=B0=80=20=EB=82=A1?= =?UTF-8?q?=EA=B2=8C=20=EB=A7=8C=EB=93=A0=20hooks=20=EC=8B=9C=ED=97=98?= =?UTF-8?q?=EA=B3=BC=20=EB=AC=B8=EC=84=9C=EB=A5=BC=20=EA=B3=A0=EC=B9=9C?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit f04ea3b3이 경로·명령 판정 함수를 scripts/lib/documentation-readiness- checks.ts로 옮기고 facts 인자를 붙였다. 그런데 scripts/tests/ test_check_work_docs.py의 TypeScriptRulesTest는 그 코드 조각과 COMMAND_HEADS를 여전히 verify-documentation-readiness.ts에서 찾아 `scripts/verify.sh hooks`의 시험 둘(조각 21개)이 실패한다. CI는 이 단계를 돌리지 않아 merge 게이트로는 안 잡힌다. 문서 넷도 옛 위치를 가리킨다: 매뉴얼 03 7단계의 NOT_CREATED, docs/README.md· docs/work/reference/gates.md·docs/operations/ci-quality-gates.md의 문서 검사 코드 정본. - TypeScriptRulesTest: 옮긴 조각과 COMMAND_HEADS를 새 모듈에서 찾고, facts 인자가 붙은 꼴(`facts.topLevelEntries`, `facts.exists`, `namedPath(…, document, facts)`)로 고친다. 그대로 남은 조각(색인 절, livingDocuments, checkDocsSystem 호출)은 script에서 찾는다. - 문서 넷이 새 모듈을 가리키게 한다. - documentation-readiness-checks.test.ts에 거절 사례를 더한다: 앞붙임(`CI=true VERIFY_SNAPSHOT=1 node …`) 뒤의 없는 경로와 `--out=<없는 경로>`. 앞붙임 사례가 통과 쪽에만 있어 `while (…) head += 1;`을 지워도, `--flag=` 벗기기를 지워도 시험이 다 통과했다. 지운 자식 프로세스 시험이 잡던 앞의 변이를 다시 잡는다. 버린 안: TypeScriptRulesTest에서 조각 대조를 빼기 — Python 쪽 검사 (check-work-docs.py)가 TypeScript 규칙과 같은지 보는 유일한 시험이다. 위험·한계: scripts/check-work-docs.py:167 주석도 옛 script만 적지만 이 항목 범위 밖 파일이라 두었다(PR memo). 검증: python3 -m unittest scripts.tests.test_check_work_docs OK, scripts/verify.sh hooks rc=0(91개), scripts/verify.sh docs rc=0. 노트북 node 탐침으로 새 거절 사례가 통과하고, 변이 둘(`while` 줄 삭제, `--flag=` 벗기기 삭제)이 각각 실패. vitest와 RED는 PR의 desktop 묶음에서 돈다. Refs: REV-FE-0011, REV-FE-0022 --- docs/README.md | 2 +- docs/manual/03-outside-feature-folder.md | 2 +- docs/operations/ci-quality-gates.md | 2 +- docs/work/reference/gates.md | 2 +- scripts/tests/test_check_work_docs.py | 62 ++++++++++--------- .../documentation-readiness-checks.test.ts | 8 +++ 6 files changed, 44 insertions(+), 34 deletions(-) diff --git a/docs/README.md b/docs/README.md index ce57a2be..a65efb90 100644 --- a/docs/README.md +++ b/docs/README.md @@ -178,7 +178,7 @@ | `style` | 살아 있는 문서와 결정 기록의 문장 끝이 높임(「~합니다」「~하세요」)이 아닌가. 코드, 따옴표·낫표 안 인용, `> 이력` 블록은 보지 않는다 | - 그 밖에 같은 명령이 루트 README의 런타임 변수 표, 입구 문서의 `src/` 폴더 설명(`architecture/layers.md` 표와 글자가 같아야 한다), 수동 접근성 기록의 범위, 2026-07-18 도식 리뷰 사본 둘의 일치를 본다. -- 규칙과 판정의 정본은 `scripts/lib/docs-system.ts`(검사 여섯)와 `scripts/verify-documentation-readiness.ts`(참조와 그 밖의 검사)다. 백엔드 템플릿의 문서 검사기(그 repo의 `check-docs.py`)를 같은 이름·문턱으로 옮긴 것이다. +- 규칙과 판정의 정본은 `scripts/lib/docs-system.ts`(검사 여섯)와 `scripts/verify-documentation-readiness.ts`(참조와 그 밖의 검사, 판정 함수는 `scripts/lib/documentation-readiness-checks.ts`)다. 백엔드 템플릿의 문서 검사기(그 repo의 `check-docs.py`)를 같은 이름·문턱으로 옮긴 것이다. - 검사 자신의 시험: `tests/unit/docs-system.test.ts`, `tests/unit/documentation-readiness.test.ts`. - 예외 목록 `scripts/docs-system-exceptions.txt`는 비어 있고 줄기만 한다. 목록에 새 줄을 더하면 실패한다(줄마다 `scripts/lib/docs-system.ts`의 `FROZEN`에 지문이 있어야 하는데, `FROZEN`이 비어 있다). 기준선을 늘리는 것은 규칙을 바꾸는 일이라 소유자 결정이 필요하다. - 복사한 프로젝트가 지운 기록(`history/`, `reviews/`)과 지운 샘플 기능의 경로는 없어도 된다. git이 무시하는 생성 산출물도 없어도 된다. diff --git a/docs/manual/03-outside-feature-folder.md b/docs/manual/03-outside-feature-folder.md index 1d926905..bcec3dcd 100644 --- a/docs/manual/03-outside-feature-folder.md +++ b/docs/manual/03-outside-feature-folder.md @@ -207,7 +207,7 @@ src/features/product-capabilities.ts (SERVICE_WORKER = ACTIVE) 4. `tsconfig.json`의 `references`에 `{ "path": "./tsconfig.web-worker.json" }`을 더한다. 편집기가 Worker 파일에 이 설정을 쓴다. 5. `package.json`에 `"check:types:web-worker": "tsc --project tsconfig.web-worker.json"`을 더하고 `check:types` 사슬에 잇는다. 사슬 끝의 `node scripts/check-typecheck-inputs.ts`가 이 tsconfig의 입력이 0개면 실패시킨다. 6. `config/repository-layout.json`에 `tsconfig.web-worker.json` 항목을 더한다(E절 R1). `sets`는 `tsconfig.service-worker.json`과 같게 `fixture-copy`·`secret-scan`이다. `config/security/secret-scan-policy.json`의 `trackedRoots`에도 같은 이름을 더한다(R2). -7. `scripts/verify-documentation-readiness.ts`의 `NOT_CREATED`에서 `src/adapters/web-worker`를 뺀다. +7. `scripts/lib/documentation-readiness-checks.ts`의 `NOT_CREATED`에서 `src/adapters/web-worker`를 뺀다. --- diff --git a/docs/operations/ci-quality-gates.md b/docs/operations/ci-quality-gates.md index ef3fd3cc..89cd1b6b 100644 --- a/docs/operations/ci-quality-gates.md +++ b/docs/operations/ci-quality-gates.md @@ -147,7 +147,7 @@ DOCUMENTATION_READY (off-chain) `DOCUMENTATION_READY`(`verify:documentation`)가 검사하는 범위와 방법은 `docs/README.md` 5절과 `docs/work/reference/gates.md` 「문서 검사」가 정본이다(코드는 `scripts/verify-documentation-readiness.ts`, -`scripts/lib/docs-system.ts`). 여기에 목록을 다시 적지 않는다(1112/08-07). +`scripts/lib/documentation-readiness-checks.ts`, `scripts/lib/docs-system.ts`). 여기에 목록을 다시 적지 않는다(1112/08-07). `check:architecture`는 Babel parser/Node resolver 기반 `staticImportGraph`를 `artifacts/quality/dependency-report.json`에 기록한다. 규칙은 diff --git a/docs/work/reference/gates.md b/docs/work/reference/gates.md index 9bb98c81..3e83c006 100644 --- a/docs/work/reference/gates.md +++ b/docs/work/reference/gates.md @@ -106,7 +106,7 @@ release 단계 게이트는 merge 단계에 없다. 그래서 lab 게이트 회 ## 7. 문서 검사 -`verify:documentation`(FE-GATE-017, documentation 단계)이 문서를 검사하는 범위와 방법의 정본은 `scripts/verify-documentation-readiness.ts`, `scripts/lib/docs-system.ts`와 `docs/README.md` 5절이다. +`verify:documentation`(FE-GATE-017, documentation 단계)이 문서를 검사하는 범위와 방법의 정본은 `scripts/verify-documentation-readiness.ts`, `scripts/lib/documentation-readiness-checks.ts`, `scripts/lib/docs-system.ts`와 `docs/README.md` 5절이다. - **범위:** 살아 있는 문서 전부(루트 `AGENTS.md`·`README.md`, `docs/` 아래 기록 밖 문서, `src/`의 `AGENTS.md`·모듈 README, `.claude/` 아래 문서). 기록(`docs/design/`, `docs/history/`)은 머리 블록만 보고, 결정 기록(`docs/adr/`)은 본문의 언어·문체도 본다. - **보는 것:** 언어(한국어인가), 문체(「~한다」), 숫자 복사, 기록의 머리 블록, 문서 지도와 루트 README 필수 절. 그리고 백틱 안의 repo 경로(`:줄` 꼬리는 떼고 본다), 셸 코드 블록과 백틱 안 명령의 경로 인자, 마크다운 링크, `corepack pnpm