Files
clean-architecture-frontend…/docs/design/2026-08-02-v8-coverage-counter-contract-design.md
DongHyeonka 75fad73a7d docs(records): 기록·설계서·결정 기록 67개에 한국어 머리 블록을 단다
문제: 옮긴 기록은 지금 동작을 설명하는지, 상태가 무엇인지, 지금
정본이 어디인지 알 길이 없다. 설계서·계획서 27개와 docs/architecture
목표 설계 16개에는 상태 칸이 없고, VD는 「상태: Accepted」 같은 영어
값을 쓴다.

고른 방법: docs-system.md 4절 형식으로 맨 위에 머리 블록을 달고 본문은
한 글자도 고치지 않는다. 상태는 기계 변환이다.
- 설계서: Accepted·확정·정본·설계 완료 → 채택, 상태 줄이 없으면
  확인 안 함 (채택 4, 확인 안 함 21)
- 계획서: 체크 상자가 모두 표시됐으면 끝남, 아니면 확인 안 함. SPEC.md는
  같은 폴더 plan.md와 같은 근거(0.2.0으로 끝난 라운드)로 끝남 (끝남 5,
  확인 안 함 14. 이미 블록이 있던 5개는 그대로)
- 결정 기록: Accepted → 채택, 날짜가 붙은 뒤늦은 보완 메모가 본문에
  있으면 채택(보완) (채택 14, 채택(보완) 9). 프론트 VD는 처음부터
  한국어로 썼고 번역하지 않으므로 둘째 줄은 「원문이다」 문구다.
- 작성일: 파일 이름 날짜 → 본문 날짜 줄(VD는 `결정일:`) → git 첫 추가일.

위험: VD-09·11·13은 git으로 보면 결정 뒤 본문이 그 자리에서
고쳐졌지만 본문에 날짜 표시가 없어 기계 규칙대로 채택으로 두었다.
보완으로 올릴지는 사람이 정한다. 「현재 정본」은 지금 있는 살아 있는
문서나 코드 경로만 쓴다.

검증: 블록과 그 뒤 빈 줄 하나를 빼면 72개 모두 `git show HEAD:`와 바이트가
같다. 뒤 커밋의 문서 검사 head 규칙으로 돌려 문제 0건.
2026-11-08 17:25:41 +09:00

4.4 KiB

기록 · 설계서 본문은 쓴 때의 원문이다. 지금 동작은 「현재 정본」을 읽는다.

  • 상태: 확인 안 함
  • 작성일: 2026-08-02
  • 요약: risk-coverage 산출물 schema를 정책과 따로 version 3으로 올리고, 설치된 Vitest·V8이 내는 counter 유무 분류를 고정하는 계약 설계다.
  • 현재 정본: scripts/check-v8-coverage-counter-semantics.ts, scripts/check-risk-coverage.ts

V8 Coverage Counter Contract Design

Goal

Version the serialized risk-coverage artifact independently from its policy and lock the repository's counter-bearing/counterless classifier to the output of the installed Vitest/V8 producer.

Artifact contract

config/testing/risk-coverage.json remains policy schema version 2. scripts/check-risk-coverage.ts changes only its serialized output envelope to schema version 3 because the artifact fields were renamed from executable/non-executable terminology to counterBearingTotal, instrumentedCounterBearingTotal, counterlessTotal, and counterlessModules.

The contract test runs the real CLI against an owned temporary repository. It reuses the current policy, materializes its 19 policy-sensitive source paths as counter-bearing modules, writes an exact consistent coverage summary, and reads the published JSON artifact. It requires output schema version 3, the exact counter-bearing fields, and absence of every legacy executable/non-executable field.

Producer microfixture

Repository fixtures under tests/fixtures/v8-coverage-counter-semantics/ contain only source and a child test template. The child test file uses a .fixture.ts suffix and the main Vitest discovery exclusion is verified behaviorally so it cannot recursively join the repository suite.

At runtime, scripts/check-v8-coverage-counter-semantics.ts creates one owned directory below the operating-system temporary directory. It copies the fixed fixture into that directory and writes the child Vitest config there. The child process uses that directory as its root and writes its JSON summary below that same directory; it never writes repository coverage or artifact paths.

The fixture contains these exact source rows:

  • runtime.ts: a runtime declaration/initializer; at least one standard counter total must be positive.
  • import-type-empty.ts: import type {} only.
  • import-empty.ts: import {} only.
  • import-side-effect.ts: a bare side-effect import only.
  • import-value.ts: a value import only.
  • reexport-named.ts: a named value re-export only.
  • reexport-star.ts: a star value re-export only.
  • type-only.ts: type declarations only.

Every row except runtime.ts must contain exact 0/0/0/100 lines, statements, functions, and branches counters. The checker rejects a missing summary, missing or additional row, malformed counter, counterless nonzero drift, or runtime all-zero drift.

Process and failure handling

The child Vitest process is launched without a shell or network. Exit failure is converted to a bounded diagnostic containing truncated stdout/stderr. File or JSON failures identify the missing or invalid summary without exposing unbounded child output. An outer finally removes only the exact owned temporary root for success and every failure path.

Pure summary validation is exported from a focused library and covered with literal mutation fixtures. Runner tests inject child exit or successful-without-summary behavior and assert cleanup. The real standalone checker executes in test:coverage before the repository coverage run, so FE-GATE-005 and sample removal both consume it through the existing package script contract.

Documentation and evidence

The testing strategy is synchronized to the current 19 high-risk modules and 80 thresholds, documents output schema version 3, and retains policy schema version 2. Final evidence includes the focused unit/contract tests, node/test TypeScript, changed-file lint, standalone producer checker, root risk checker, sample removal, and diff validation.

Self-review

  • No placeholder or deferred choice remains.
  • Policy schema 2 and artifact schema 3 are explicitly separate.
  • All child-owned paths are below one temporary root and cleanup has one owner.
  • Main discovery, subprocess failure, missing summary, exact rows, zero/nonzero drift, and bounded diagnostics have explicit verification paths.