fix(docs): 숫자 복사 검사를 넓히고 문서 준비 판정을 순수 함수로 나눈다 #88
@@ -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」「N개(가) 통과·실패」「통과·실패 N개」「N passed·failed」), 조사가 붙은 게이트 개수(「게이트가 29개」)도 본다. 예산 값은 단위를 붙여 써도(「206848B」「2500ms」) 읽는다. 전에는 게이트·recipe·adapter 개수만 봤다. 자기 문서가 이 값을 옮겨 적었으면 실패하니 정본(`budgets.json`, 시험 보고서)을 가리키게 고친다. 양쪽이 숫자인 「A에서 B로」 안의 값은 지난 변경의 기록이라 읽지 않는다. 1000 미만 예산 값, KiB로 쓴 예산, 100 미만 시험 수는 여전히 검사 밖이다 | `scripts/lib/docs-system.ts` | `d460a5f8`, `9aab9c0f`, `a0e3644a` |
|
||||
|
||||
### 그 밖의 변경
|
||||
|
||||
|
||||
+3
-3
@@ -172,14 +172,14 @@
|
||||
| `language` | 살아 있는 문서와 결정 기록 본문이 한국어인가. 코드·명령·경로·링크·인용은 세지 않고, 영어 낱말 3개 이상이면서 한글 덩어리 비율 0.3 미만이면 영어다(보고 언어 훅 H11과 같은 판정) |
|
||||
| `head` | 기록과 결정 기록 맨 위의 머리 블록: 칸, 상태 어휘, 날짜, 한국어 요약, 현재 정본·대체됨 경로가 지금 있는지 |
|
||||
| `document references` | 살아 있는 문서의 인라인 코드·셸 코드 블록 안 repo 경로, 마크다운 링크 대상, package script 이름, FE-GATE ID가 지금 있는가. 짝 백엔드 경로는 `config/contracts/backend-contract-pin.json`이 고정한 커밋의 트리에서 찾는다 |
|
||||
| `number` | 살아 있는 문서가 프레임워크 버전이나 게이트·recipe·adapter 개수를 복사했는가. 결정 기록, 기록, `CHANGELOG.md`는 보지 않는다 |
|
||||
| `number` | 살아 있는 문서가 프레임워크 버전, 게이트·recipe·adapter 개수, `config/performance/budgets.json`의 예산 값(네 자리 이상), 시험 수(세 자리 이상)를 복사했는가. 결정 기록, 기록, `CHANGELOG.md`는 보지 않는다 |
|
||||
| `map` | 이 README의 1절 지도가 `docs/` 아래 모든 폴더를 덮는가(표 첫 칸의 `폴더/`). 파일 없이 폴더만 가진 묶음 폴더(`history/`)는 그 바로 아래 폴더가 대신한다. 지도에 있지만 없는 폴더도 실패다 |
|
||||
| `readme` | 루트 README가 첫 줄 제목, 그 아래 한 문단, 정해진 `##` 절을 정해진 순서로 가지는가 |
|
||||
| `style` | 살아 있는 문서와 결정 기록의 문장 끝이 높임(「~합니다」「~하세요」)이 아닌가. 코드, 따옴표·낫표 안 인용, `> 이력` 블록은 보지 않는다 |
|
||||
|
||||
- 그 밖에 같은 명령이 루트 README의 런타임 변수 표, 입구 문서의 `src/` 폴더 설명(`architecture/layers.md` 표와 글자가 같아야 한다), 수동 접근성 기록의 범위, 2026-07-18 도식 리뷰 사본 둘의 일치를 본다.
|
||||
- 규칙과 판정의 정본은 `scripts/lib/docs-system.ts`(검사 여섯)와 `scripts/verify-documentation-readiness.ts`(참조와 그 밖의 검사)다. 백엔드 템플릿의 문서 검사기(그 repo의 `check-docs.py`)를 같은 이름·문턱으로 옮긴 것이다.
|
||||
- 검사 자신의 시험: `tests/unit/docs-system.test.ts`, `tests/unit/documentation-readiness.test.ts`.
|
||||
- 규칙과 판정의 정본은 `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-checks.test.ts`(판정 함수), `tests/unit/documentation-readiness.test.ts`(script 배선).
|
||||
- 예외 목록 `scripts/docs-system-exceptions.txt`는 비어 있고 줄기만 한다. 목록에 새 줄을 더하면 실패한다(줄마다 `scripts/lib/docs-system.ts`의 `FROZEN`에 지문이 있어야 하는데, `FROZEN`이 비어 있다). 기준선을 늘리는 것은 규칙을 바꾸는 일이라 소유자 결정이 필요하다.
|
||||
- 복사한 프로젝트가 지운 기록(`history/`, `reviews/`)과 지운 샘플 기능의 경로는 없어도 된다. git이 무시하는 생성 산출물도 없어도 된다.
|
||||
- 설명·수치가 코드와 맞는지는 검사하지 않는다. 리뷰가 표본으로 대조한다.
|
||||
|
||||
@@ -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`를 뺀다.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -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` 실패 원인
|
||||
|
||||
@@ -71,13 +71,13 @@ 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`로 인코딩한다 |
|
||||
| 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에 적었다 |
|
||||
@@ -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,11 +179,11 @@ 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개 통과 |
|
||||
| `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). |
|
||||
@@ -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개 통과). |
|
||||
|
||||
@@ -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`도 이제 전체 실행에서 통과한다.
|
||||
|
||||
@@ -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` 실행에서 실패한 파일은 하나다. 실패 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 테스트 108개 중 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개 실패(나머지는 통과) |
|
||||
|
||||
남은 실패는 하나하나가 위에서 말한 환경 제약 테스트 세 개 중 하나다.
|
||||
|
||||
|
||||
@@ -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`에 기록한다. 규칙은
|
||||
|
||||
@@ -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:<파일>` 기준이다.
|
||||
|
||||
@@ -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 단위로 올린 값을 그때 예산으로 정했다(지금 값의
|
||||
정본은 `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`)다.
|
||||
|
||||
@@ -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절 |
|
||||
| DES-DEC-0002 perContext 기록 대조 바닥 | 2026-11-21 | FE-GATE-005의 기록 대조(`initialJavascriptRecordDrift`, `scripts/scale/measure-feature-shape-growth.ts`)에서 perContextGzipBytes 칸만 바닥을 16 B에서 64 B로 넓힌다(`PER_CONTEXT_RECORD_TOLERANCE_BYTES`). 다른 비용 칸의 16 B, 합계 256 B, context 상한 512 B·기능 상한 1 KiB, `config/scale/feature-shape-ceilings.json`은 그대로다. D-6(프론트 main 뒤처짐 막기 끔)도 그대로 둔다: 2026-11에 센 다시 볼 조건(합치면 깨지는 변경으로 한 주 두 번 넘게 빨강)이 W46 1회·W47 0회로 채워지지 않았다. 이유(확인한 사실): 이 칸은 한 커밋에서는 같은 값이고 커밋 사이에서는 2~28 B(잰 값과 기록, 최대 차 26 B)를 오간다. 초기 청크를 바꾼 PR이 먼저 병합된 뒤 다른 PR이 낡은 base에서 잰 기록을 쓰면 main이 빨강이 됐다(#56 병합 `e98d8ee9`, 기록 28·빌드 7). 64 B는 그 최대 차의 두 배 넘게, context 상한의 1/8이다. 게이트 문턱을 넓히는 일이라 소유자가 정했다(꼭 지킬 것 4). 버린 안: 둘 다 그대로(PR을 하나씩 최신 main에서 여는 관행이 깨지면 같은 빨강), 뒤처짐 막기 켬(병합마다 갱신 run 15~24분), context 여럿 평균(줄일 잡음이 있는지 모르고 측정 시간이 는다), perContext 대조 빼기(기록이 낡아도 못 잡는다). 대가: 기록이 빌드와 64 B까지 달라도 통과한다. 재검토: 64 B 바닥에서도 perContext 기록 불일치로 main이 빨강이 되거나, 합치면 깨지는 변경으로 main이 한 ISO 주에 두 번 넘게 빨강이 된다 | 소유자 결정(2026-11-21, 답 원문 「전부 권함대로」): design 허브 DES-DEC-0002(repo 밖, 항목 DES-FE-0007) |
|
||||
|
||||
@@ -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 <script>`와 백틱 안 `<prefix>:<name>` 꼴의 package script, `FE-GATE-0NN` ID가 실제로 있는가. 설명·수치가 코드와 맞는지는 보지 않는다.
|
||||
|
||||
@@ -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,52 @@ 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개」).
|
||||
// `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)",
|
||||
/\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)|(?:게이트|(?<![a-z])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 are mostly a fixed set a
|
||||
// sentence is about (the generator's three tests, the ten tests of one case)
|
||||
// and would fail those lines, so only three digits or more are read; a small
|
||||
// run's counts (「80개 통과」, 「테스트 19개 실패」) stay unchecked. The
|
||||
// runner's own words count too, in either order and with a particle
|
||||
// (「1,619개 통과」, 「1,619개가 통과했다」, 「실패 104개」, 「Tests 1619
|
||||
// passed」, 「104 failed」).
|
||||
[
|
||||
"test count (the test runner reports it)",
|
||||
new RegExp(
|
||||
`\\b${SUITE_COUNT}\\s*개의?\\s*(?:시험|테스트)|(?:시험|테스트)${COUNT_PARTICLE}\\s*${SUITE_COUNT}\\s*개|\\b${SUITE_COUNT}\\s*개${COUNT_PARTICLE}\\s*(?:통과|실패)|(?:통과|실패)${COUNT_PARTICLE}\\s*${SUITE_COUNT}\\s*개|\\b${SUITE_COUNT}\\s+(?:tests|passed|failed)\\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
|
||||
// unit may follow with or without a space (「206848B」, 「2500 ms」). A value
|
||||
// in 「A에서 B로」 with both sides numbers 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; 「FE-GATE-011에서 206,848 B 상한으로」 and 「206,848 B에서
|
||||
// 1 B만」 are not changes and are read.
|
||||
const BUDGET_VALUE_MINIMUM = 1000;
|
||||
const BUDGET_UNIT_WORD = "(?:B|bytes|KiB|ms)";
|
||||
const BUDGET_UNIT = `(?:\\s*${BUDGET_UNIT_WORD})?`;
|
||||
const CHANGE_NUMBER = `(?<![\\w.,-])\\d[\\d,]*${BUDGET_UNIT}`;
|
||||
const CHANGE_FROM_BEFORE = new RegExp(`${CHANGE_NUMBER}\\s*에서\\s*$`, "u");
|
||||
const CHANGE_TO_AFTER = new RegExp(`^${BUDGET_UNIT}\\s*(?:으로|로)`, "u");
|
||||
const CHANGE_FROM_AFTER = new RegExp(`^${BUDGET_UNIT}\\s*에서\\s*${CHANGE_NUMBER}\\s*(?:으로|로)`, "u");
|
||||
|
||||
const sha16 = (line: string) => createHash("sha256").update(line, "utf8").digest("hex").slice(0, 16);
|
||||
|
||||
@@ -274,6 +313,8 @@ export type DocsFacts = Readonly<{
|
||||
docsFiles: readonly string[];
|
||||
/** Framework name → exact version, from package.json and .nvmrc. */
|
||||
frameworkVersions: ReadonlyMap<string, string>;
|
||||
/** Budget key (`bundle.initialJsGzipBytes`) → value, from config/performance/budgets.json. */
|
||||
budgetValues: ReadonlyMap<string, number>;
|
||||
/** Paths a copy may delete (README 「복사한 뒤 지워도 되는 것」), without a trailing slash. */
|
||||
deletable: readonly string[];
|
||||
}>;
|
||||
@@ -380,6 +421,14 @@ function checkNumber(documents: readonly DocsDocument[], facts: DocsFacts): Docs
|
||||
([name, version]) =>
|
||||
[name, new RegExp(`(?<![\\w.§])v?${version.replaceAll(".", "\\.")}(?![\\w]|\\.\\d)`, "gu")] as const,
|
||||
);
|
||||
const budgetKeys = new Map<number, string[]>();
|
||||
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(`(?<![\\w.,])${digits}(?:(?=${BUDGET_UNIT_WORD}\\b)|(?![\\w]|[.,]\\d))`, "gu")] as const;
|
||||
});
|
||||
const problems: DocsProblem[] = [];
|
||||
for (const { path, text } of documents) {
|
||||
if (!checkedForDrift(path)) continue;
|
||||
@@ -390,6 +439,14 @@ function checkNumber(documents: readonly DocsDocument[], facts: DocsFacts): Docs
|
||||
for (const [label, pattern] of COPIED_COUNTS) {
|
||||
for (const match of line.matchAll(pattern)) found.push([label, match[0], match.index]);
|
||||
}
|
||||
for (const [label, pattern] of budgets) {
|
||||
for (const match of line.matchAll(pattern)) {
|
||||
const before = line.slice(0, match.index);
|
||||
const after = line.slice(match.index + match[0].length);
|
||||
if ((CHANGE_FROM_BEFORE.test(before) && CHANGE_TO_AFTER.test(after)) || CHANGE_FROM_AFTER.test(after)) continue;
|
||||
found.push([label, match[0], match.index]);
|
||||
}
|
||||
}
|
||||
const named = found.map(([, value, start]) => [start, start + value.length] as const);
|
||||
for (const [name, pattern] of exact) {
|
||||
for (const match of line.matchAll(pattern)) {
|
||||
@@ -702,6 +759,21 @@ export function frameworkVersions(repositoryRoot: string): Map<string, string> {
|
||||
return versions;
|
||||
}
|
||||
|
||||
/** Numeric budget values by dotted key, from config/performance/budgets.json (none when it is absent). */
|
||||
export function budgetValues(repositoryRoot: string): Map<string, number> {
|
||||
const values = new Map<string, number>();
|
||||
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 +788,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") : "",
|
||||
),
|
||||
|
||||
@@ -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/<folder>` — <description>", 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<string, string>;
|
||||
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<string> = 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<string>;
|
||||
/** Package scripts (package.json). */
|
||||
scripts: ReadonlySet<string>;
|
||||
/** Gate IDs config/ci/gates.json defines, and the retired ones. */
|
||||
gateIds: ReadonlySet<string>;
|
||||
/** The paired repositories config/contracts/backend-contract-pin.json pins. */
|
||||
pairedRepositories: ReadonlySet<string>;
|
||||
/** Whether `reference` (`../<name>/<path>`) 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<string>;
|
||||
}>;
|
||||
|
||||
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
|
||||
// (`../<name>/…`).
|
||||
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 (`<id>`,
|
||||
// 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 <name>… [-- 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<string>();
|
||||
const unverifiedLinks = new Set<string>();
|
||||
for (const file of named) {
|
||||
if (file === null) continue;
|
||||
const trimmed = file.replace(/\/$/u, "");
|
||||
if (trimmed.startsWith("../")) {
|
||||
// Outside this repository: `../<paired repository>/<path at its pin>`.
|
||||
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<string>();
|
||||
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;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ class DrillCopyTest(unittest.TestCase):
|
||||
for text in (
|
||||
f"\n`{deleted}`\n", f"\n`{deleted}:12`\n", f"\n`{deleted}#L3`\n",
|
||||
f"\n`corepack pnpm exec vitest run {deleted}`\n",
|
||||
# A `--flag=` prefix and quotes around a command word (verify-documentation-readiness.ts commandPaths).
|
||||
# A `--flag=` prefix and quotes around a command word (documentation-readiness-checks.ts commandPaths).
|
||||
f'\n`vitest run "{deleted}"`\n', f"\n`vitest run --dir={deleted}`\n",
|
||||
f"\n`CI=true node scripts/run-vitest.ts run '{deleted}'`\n",
|
||||
f"\n`scripts/verify.sh exec -- vitest run {deleted}`\n",
|
||||
@@ -323,6 +323,7 @@ class TypeScriptRulesTest(unittest.TestCase):
|
||||
|
||||
DOCS = "scripts/lib/docs-system.ts"
|
||||
READINESS = "scripts/verify-documentation-readiness.ts"
|
||||
CHECKS = "scripts/lib/documentation-readiness-checks.ts"
|
||||
|
||||
def test_the_lists_are_the_same(self) -> None:
|
||||
kinds = re.findall(r'\["([^"]+)", "[^"]+"\]', ts_declaration(self.DOCS, "RECORD_KINDS"))
|
||||
@@ -338,7 +339,7 @@ class TypeScriptRulesTest(unittest.TestCase):
|
||||
("HEAD_SEARCH_LINES", ts_declaration(self.DOCS, "HEAD_SEARCH_LINES"), str(check.HEAD_SEARCH_LINES)),
|
||||
("HEAD_FIELDS", check.HEAD_CANONICAL in ts_strings(self.DOCS, "HEAD_FIELDS"), True),
|
||||
("HEAD_OPTIONAL", ts_strings(self.DOCS, "HEAD_OPTIONAL"), list(check.HEAD_OPTIONAL)),
|
||||
("COMMAND_HEADS", set(ts_strings(self.READINESS, "COMMAND_HEADS")), set(check.COMMAND_HEADS)),
|
||||
("COMMAND_HEADS", set(ts_strings(self.CHECKS, "COMMAND_HEADS")), set(check.COMMAND_HEADS)),
|
||||
("DOCUMENT_INDEX", ts_strings(self.READINESS, "DOCUMENT_INDEX"), [check.DOCUMENT_INDEX]),
|
||||
("copied sets", re.findall(r'selectRepositoryPaths\("([^"]+)"\)', typescript("scripts/lib/removal-fixture.ts")),
|
||||
list(check.COPIED_SETS)),
|
||||
@@ -381,34 +382,35 @@ class TypeScriptRulesTest(unittest.TestCase):
|
||||
".map((name) => join(linked, name));"),
|
||||
(self.READINESS, "for (const document of livingDocuments(process.cwd())) {"),
|
||||
(self.READINESS, "const documentsSystem = checkDocsSystem(process.cwd(), rootDirectory);"),
|
||||
(self.READINESS, f'...[...text.matchAll(/{c.SPAN.pattern}/gu)].flatMap(([, token = ""]) => [ namedPath(token,'
|
||||
" document), ...commandPaths(token, document), ]),"),
|
||||
(self.READINESS, "...fencedCommands(text).flatMap((command) => commandPaths(command, document)),"),
|
||||
(self.READINESS, f'...[...text.matchAll(/{c.DOCUMENT_LINK.pattern}/gu)].map(([, target = ""]) =>'
|
||||
" linkedPath(target, document)),"),
|
||||
(self.READINESS, f'const candidate = token.replace(/{c.ANCHOR.pattern}/u, "")'
|
||||
f'.replace(/{c.LINE_NUMBER.pattern}/u, "");'),
|
||||
(self.READINESS, f'if (!candidate.includes("/") || candidate.startsWith("/") || /{c.NOT_A_PATH.pattern}/u'
|
||||
".test(candidate)) return null;"),
|
||||
(self.READINESS, "if (topLevelEntries.has(first)) return candidate;"),
|
||||
(self.READINESS, "if (pairedPins.has(first)) return `../${candidate}`;"),
|
||||
(self.READINESS, 'return first !== "." && first !== ".." && exists(join(dirname(document), first))'
|
||||
" ? join(dirname(document), candidate) : null;"),
|
||||
(self.READINESS, f"if (/{c.OUTSIDE_LINK.pattern}/iu.test(target)) return null;"),
|
||||
(self.READINESS, f'return normalize(join(dirname(document), target.replace(/{c.ANCHOR.pattern}/u, "")));'),
|
||||
(self.READINESS, f"const VERIFY_ENTRY = /{c.VERIFY_ENTRY.pattern}/u;"),
|
||||
(self.READINESS, f'const words = command.trim().replace(/{c.PROMPT.pattern}/u, "").split(/\\s+/u);'),
|
||||
(self.READINESS, f'while (/{c.ASSIGNMENT.pattern}/u.test(words[head] ?? "")) head += 1;'),
|
||||
(self.READINESS, 'const separator = words.indexOf("--", head + 1);'),
|
||||
(self.READINESS, 'const executed = words[head + 1] === "exec" && separator > head ?'
|
||||
' words.slice(separator + 1).join(" ") : "";'),
|
||||
(self.READINESS, 'return [namedPath(first, document), ...(executed === "" ? [] : commandPaths(executed, document))];'),
|
||||
(self.READINESS, "if (!COMMAND_HEADS.has(first)) return [];"),
|
||||
(self.READINESS, f'.slice(head + 1) .map((word) => namedPath(word.replace(/{c.FLAG.pattern}/u, "")'
|
||||
f'.replace(/{c.QUOTES.pattern}/gu, ""), document));'),
|
||||
(self.READINESS, f"const marker = /{c.FENCE.pattern}/u.exec(line);"),
|
||||
(self.READINESS, 'fence = fence === null ? (marker[1] ?? "") : null;'),
|
||||
(self.READINESS, f"if (fence !== null && /{c.SHELL_FENCE.pattern}/u.test(fence)) commands.push(line);"),
|
||||
(self.CHECKS, f'...[...text.matchAll(/{c.SPAN.pattern}/gu)].flatMap(([, token = ""]) => [ namedPath(token,'
|
||||
" document, facts), ...commandPaths(token, document, facts), ]),"),
|
||||
(self.CHECKS, "...fencedCommands(text).flatMap((command) => commandPaths(command, document, facts)),"),
|
||||
(self.CHECKS, f'...[...text.matchAll(/{c.DOCUMENT_LINK.pattern}/gu)].map(([, target = ""]) =>'
|
||||
" linkedPath(target, document)),"),
|
||||
(self.CHECKS, f'const candidate = token.replace(/{c.ANCHOR.pattern}/u, "")'
|
||||
f'.replace(/{c.LINE_NUMBER.pattern}/u, "");'),
|
||||
(self.CHECKS, f'if (!candidate.includes("/") || candidate.startsWith("/") || /{c.NOT_A_PATH.pattern}/u'
|
||||
".test(candidate)) return null;"),
|
||||
(self.CHECKS, "if (facts.topLevelEntries.has(first)) return candidate;"),
|
||||
(self.CHECKS, "if (facts.pairedRepositories.has(first)) return `../${candidate}`;"),
|
||||
(self.CHECKS, 'return first !== "." && first !== ".." && facts.exists(join(dirname(document), first))'
|
||||
" ? join(dirname(document), candidate) : null;"),
|
||||
(self.CHECKS, f"if (/{c.OUTSIDE_LINK.pattern}/iu.test(target)) return null;"),
|
||||
(self.CHECKS, f'return normalize(join(dirname(document), target.replace(/{c.ANCHOR.pattern}/u, "")));'),
|
||||
(self.CHECKS, f"const VERIFY_ENTRY = /{c.VERIFY_ENTRY.pattern}/u;"),
|
||||
(self.CHECKS, f'const words = command.trim().replace(/{c.PROMPT.pattern}/u, "").split(/\\s+/u);'),
|
||||
(self.CHECKS, f'while (/{c.ASSIGNMENT.pattern}/u.test(words[head] ?? "")) head += 1;'),
|
||||
(self.CHECKS, 'const separator = words.indexOf("--", head + 1);'),
|
||||
(self.CHECKS, 'const executed = words[head + 1] === "exec" && separator > head ?'
|
||||
' words.slice(separator + 1).join(" ") : "";'),
|
||||
(self.CHECKS, 'return [namedPath(first, document, facts), ...(executed === "" ? [] :'
|
||||
' commandPaths(executed, document, facts))];'),
|
||||
(self.CHECKS, "if (!COMMAND_HEADS.has(first)) return [];"),
|
||||
(self.CHECKS, f'.slice(head + 1) .map((word) => namedPath(word.replace(/{c.FLAG.pattern}/u, "")'
|
||||
f'.replace(/{c.QUOTES.pattern}/gu, ""), document, facts));'),
|
||||
(self.CHECKS, f"const marker = /{c.FENCE.pattern}/u.exec(line);"),
|
||||
(self.CHECKS, 'fence = fence === null ? (marker[1] ?? "") : null;'),
|
||||
(self.CHECKS, f"if (fence !== null && /{c.SHELL_FENCE.pattern}/u.test(fence)) commands.push(line);"),
|
||||
):
|
||||
with self.subTest(path=path, fragment=fragment):
|
||||
self.assertIn(" ".join(fragment.split()), " ".join(typescript(path).split()))
|
||||
|
||||
@@ -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/<folder>` — <description>", 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
|
||||
// (`../<name>/…`).
|
||||
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 (`<id>`,
|
||||
// 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 <name>… [-- 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<string>();
|
||||
const unverifiedLinks = new Set<string>();
|
||||
for (const file of named) {
|
||||
if (file === null) continue;
|
||||
const trimmed = file.replace(/\/$/u, "");
|
||||
if (trimmed.startsWith("../")) {
|
||||
// Outside this repository: `../<paired repository>/<path at its pin>`.
|
||||
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<string>();
|
||||
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
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
budgetValues,
|
||||
checkDocsSystem,
|
||||
type DocsDocument,
|
||||
type DocsFacts,
|
||||
type DocsSystemCheck,
|
||||
@@ -12,6 +17,7 @@ import {
|
||||
requiredFolders,
|
||||
runDocsSystemChecks,
|
||||
} from "../../scripts/lib/docs-system.ts";
|
||||
import { childProcessTimeout } from "../helpers/child-process-timeout.ts";
|
||||
|
||||
/**
|
||||
* The checker's own test (docs-system.md 7: a broken input fails, and each
|
||||
@@ -28,6 +34,11 @@ const facts: DocsFacts = {
|
||||
["React", "19.2.8"],
|
||||
["Node.js", "24.14.0"],
|
||||
]),
|
||||
budgetValues: new Map([
|
||||
["bundle.initialJsGzipBytes", 206_848],
|
||||
["lab.lcpMs", 2_500],
|
||||
["lab.namedInteractionMs", 200],
|
||||
]),
|
||||
deletable: ["docs/history", "docs/reviews"],
|
||||
};
|
||||
|
||||
@@ -214,10 +225,56 @@ 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"],
|
||||
["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 suite's test count in the runner's words, after a particle", "1,723개 중 1,619개가 통과했다.", "test count"],
|
||||
["a suite's test count after the runner's word", "통과 1,619개.", "test count"],
|
||||
["a suite's failure count in the runner's English words", "Tests 104 failed | 15 passed (119)", "test count"],
|
||||
["a budget value with its unit attached", "206848B를 넘으면 실패한다.", "budget value"],
|
||||
["a budget value in ms with its unit attached", "LCP가 2500ms를 넘으면 실패한다.", "budget value"],
|
||||
["a budget value after a gate ID, not a change", "FE-GATE-011에서 206,848 B 상한으로 본다.", "budget value"],
|
||||
["a budget value after the number that ends a gate ID, not a change", "FE-GATE-011에서 206,848 B로 본다.", "budget value"],
|
||||
["a budget value after another number and 에서, with no 로 after it", "PR 87에서 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)]);
|
||||
});
|
||||
|
||||
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은 다른 값이다."],
|
||||
["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 });
|
||||
}
|
||||
}, childProcessTimeout(49));
|
||||
|
||||
it("counts a version next to its name once", () => {
|
||||
expect(run("number", living("React 19.2.8을 쓴다."))).toHaveLength(1);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
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<Record<string, string>> = {}) =>
|
||||
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<Record<string, string>>, 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> = {}): 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<string>(),
|
||||
...overrides,
|
||||
});
|
||||
const DOCUMENT = "docs/operations/ci.md";
|
||||
const check = (text: string, overrides?: Partial<ReferenceFacts>) => {
|
||||
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 <release dir>",
|
||||
"```",
|
||||
].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 a path after leading NAME=value assignments and the value of a --flag=value argument", () => {
|
||||
const text = [
|
||||
"`CI=true VERIFY_SNAPSHOT=1 node scripts/no-such-env.ts`",
|
||||
"`node tests/unit/docs.test.ts --out=tests/unit/no-such-flag.test.ts`",
|
||||
].join("\n");
|
||||
expect(check(text).missingPaths).toEqual(["scripts/no-such-env.ts", "tests/unit/no-such-flag.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"],
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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 <release dir>\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);
|
||||
});
|
||||
|
||||
@@ -122,6 +122,21 @@ const MADE_UP_REPOSITORY_LISTS: readonly Readonly<{ file: string; list: string;
|
||||
list: "docs, docs/architecture, docs/architecture/layers.md, src, src/platform",
|
||||
reason: "knownPaths of the in-memory repository the docs-system checker test builds",
|
||||
},
|
||||
{
|
||||
file: "tests/unit/documentation-readiness-checks.test.ts",
|
||||
list: "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",
|
||||
reason: "paths that exist in the in-memory repository the documentation-readiness-checks reference tests build",
|
||||
},
|
||||
{
|
||||
file: "tests/unit/documentation-readiness-checks.test.ts",
|
||||
list: "docs, scripts, src, tests, README.md, artifacts",
|
||||
reason: "root items of the in-memory repository the documentation-readiness-checks reference tests build",
|
||||
},
|
||||
{
|
||||
file: "tests/unit/documentation-readiness-checks.test.ts",
|
||||
list: "docs, src",
|
||||
reason: "root items of the smaller in-memory repository two documentation-readiness-checks reference tests build",
|
||||
},
|
||||
];
|
||||
|
||||
const STRING = String.raw`(?:"[^"\n]*"|'[^'\n]*'|` + "`[^`\\n]*`)";
|
||||
|
||||
Reference in New Issue
Block a user