검사: 볼 것이 없어서 통과한 것을 「문제 없음」이라고 쓰지 않는다

R4 · R13 · R6 · R3. 네 가지가 같은 자리를 본다 — 검사기가 대상을 못 찾았을 때 무엇을
내는가.

세 상태를 가른다 (CLAUDE.md 「검사」 절의 표).

  봤고 괜찮다              exit 0   문제 없음 · error 0
  대상이 성립하지 않는다   exit 2   대상이 성립하지 않는다 — <이유>
  볼 것이 아직 없다        exit 0   기록 0건 — 아직 쓴 기록이 없다

R4 — 없는 프로젝트를 주면 여섯 중 넷이 초록을 냈다. `verify-tech-log-tree.py` 는 그것을
「프로젝트 1 · error 0 · PASS」로 셌다 — 오타 한 번이면 검사를 다 돈 것처럼 보인다.
판정은 `techlog.check_targets()` 하나로 모은다. 여섯 곳에 같은 규칙을 따로 쓰면 다음에
하나만 어긋난다. `check_evidence.mjs` 는 이미 exit 2 라 문구만 맞춘다.

R13 — 프로젝트 이름 쪽만 고치면 `--file` 로 오타를 내는 순간 다시 조용히 0건이 된다.
`techlog.check_files()` 로 같은 자리에 둔다. `preview-figure.py` 는 인자가 아예 없을 때
exit 1 을 냈는데 그것도 「대상이 성립하지 않는다」다.

R6 — 두 자리를 함께 고쳐야 했다.
  (a) `verify_projects()` 가 `docs/*/tech-log-studio` 만 훑어 계약 없는 프로젝트가
      목록에서 사라졌다. 기준을 `final/document.md` 로 바꾼다 — SSOT 가 있으면 대상이다.
  (b) `verify-tech-log-tree.py:194` 가 「분해 계약 없음」을 warn 으로 냈다. CLAUDE.md 는
      「계약 미채택도 error 다 — 경고로 두면 옛 스키마로 남아 있는 한 검사를 피한다」고
      적어 두었는데, 경고로 두었더니 실제로 그렇게 됐다.

R3 — `verify-pipeline.py` 가 `check-figure-text.py` 와 `check_evidence.mjs --repo` 를
프로젝트마다 돌린다(`OUTPUT CHECKS`). 게시 전에 돌리라고 적어 둔 검사인데 전체 훑기가
부르지 않아 결함이 있는 채로 PASS 로 보고됐다. `check-required-content.py` 자리는 주석으로
남겨 둔다 — 그 파일이 들어온 뒤에 더한다.

회귀 `scripts/tests/test_no_target.py` 7건 (92 → 99). 「실재하는 경로는 통과한다」 대조를
함께 넣는다 — 무조건 거절로 성공률을 올리는 것이 R-003 이 든 실패다. 판정을 일부러
되돌려 FAILED 가 나는 것을 확인한 뒤 복구했다.

알려진 부채는 그대로 둔다. `verify-pipeline.py` 는 exit 1 이다 — 미준수 런 1건과
`OUTPUT CHECKS` 5건, 그리고 `ca-tmpl` 의 계약 없음이 이제 `TECH LOG TREES` 에서도 보인다.
같은 사실이고 두 번 세지 않는다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wp9jNbePAmWc5jQwCYhK9v
This commit is contained in:
DongHyeonka
2026-09-10 11:07:24 +09:00
co-authored by Claude Opus 5
parent c2742a66cc
commit e00c1a2b76
10 changed files with 342 additions and 9 deletions
+95 -3
View File
@@ -4,6 +4,7 @@ from __future__ import annotations
import argparse
import importlib.util
import json
import subprocess
import sys
from pathlib import Path
@@ -249,8 +250,12 @@ def verify_projects(shared_root: Path) -> list:
verifier = _load(shared_root, "verify-tech-log-tree.py", "verify_tech_log_tree")
if verifier is None:
return []
projects = sorted(p.parent.name for p in shared_root.glob("docs/*/tech-log-studio")
if not p.parent.name.startswith("_"))
# `docs/*/tech-log-studio` 만 훑으면 **계약을 안 만든 프로젝트가 목록에서 사라진다.**
# CLAUDE.md 는 「계약 미채택도 error」라고 적었는데 그 error 를 셀 자리가 없었다 (R6).
# 프로젝트로 볼 기준은 `final/document.md` 다 — SSOT 가 있으면 이 파이프라인의 대상이다.
projects = sorted({d.name for d in (shared_root / "docs").iterdir()
if d.is_dir() and not d.name.startswith(("_", "."))
and (d / "final" / "document.md").exists()})
return [verifier.verify(name) for name in projects]
@@ -265,6 +270,82 @@ def verify_layouts(shared_root: Path) -> list:
return [verifier.verify(name) for name in projects]
class _OutputReport:
"""`verify-tech-log-tree.py` 의 Report 와 같은 모양. 전체 훑기가 같은 틀로 찍는다."""
def __init__(self, project: str):
self.project = project
self.facts: dict = {}
self.errors: dict = {}
self.warns: dict = {}
def error(self, rule: str, detail: str = "") -> None:
self.errors.setdefault(rule, []).append(detail)
@property
def error_count(self) -> int:
return sum(len(v) for v in self.errors.values())
@property
def warn_count(self) -> int:
return sum(len(v) for v in self.warns.values())
# 전체 훑기가 부르지 않던 산출물 검사. (이름, 명령 만드는 법)
# CLAUDE.md 「검사」 절이 게시 전에 돌리라고 적은 것인데 verify-pipeline.py 가 부르지 않아,
# 결함이 있는 채로 전체가 PASS 로 보고됐다 (V-001 verdict R3).
#
# 셋째로 `check-required-content.py <프로젝트>` 가 들어갈 자리다. B-003 의 신규 파일이라
# 그 작업이 accept 된 뒤에 아래 튜플에 한 줄 더한다 — 없는 스크립트를 부르면 전체가 깨진다.
# 명령이 실재하지 않으면 건너뛰도록 아래 verify_outputs 가 파일 존재를 먼저 본다.
OUTPUT_CHECKS = (
("check-figure-text",
lambda root, proj: [sys.executable, str(root / "scripts" / "check-figure-text.py"), proj]),
("check_evidence --repo",
lambda root, proj: ["node",
str(root / ".agents" / "skills" / "writing-tech-log-records"
/ "scripts" / "check_evidence.mjs"), proj, "--repo"]),
)
def _last_meaningful_line(text: str) -> str:
for line in reversed([ln.strip() for ln in text.splitlines()]):
if line:
return line[:120]
return ""
def verify_outputs(shared_root: Path) -> list:
"""산출물 검사 셋을 프로젝트마다 돌린다.
종료 코드를 그대로 읽는다. **0 이 아니면 error 다** — `ca-tmpl` 처럼 계약 파일이 없어
나는 exit 2 도 포함한다. 「대상 없음」으로 넘기면 계약을 채택하지 않은 프로젝트가
검사를 피한다. `verify-tech-log-tree.py` 는 `tech-log-studio/` 가 없는 프로젝트를
아예 목록에 넣지 않으므로 지금은 그 상태를 아무도 세지 않는다.
"""
projects = sorted(d.name for d in (shared_root / "docs").iterdir()
if d.is_dir() and not d.name.startswith(("_", ".")))
out = []
for proj in projects:
rep = _OutputReport(proj)
for name, build in OUTPUT_CHECKS:
cmd = build(shared_root, proj)
if not Path(cmd[1] if cmd[0] == "node" else cmd[1]).exists():
continue
try:
run = subprocess.run(cmd, cwd=str(shared_root), capture_output=True,
text=True, timeout=300)
except (OSError, subprocess.TimeoutExpired) as exc:
rep.error(f"{name} 을 돌리지 못했다", str(exc)[:120])
continue
rep.facts[name] = f"exit {run.returncode}"
if run.returncode != 0:
rep.error(f"{name} 이 실패했다",
_last_meaningful_line(run.stdout or run.stderr))
out.append(rep)
return out
def verify_runs(shared_root: Path):
"""`runs/<프로젝트>/<runId>/run.json` 이 절차를 지켰는지 본다.
@@ -289,9 +370,11 @@ def main() -> int:
reports = [] if args.skip_projects else verify_projects(args.shared_root)
layouts = [] if args.skip_projects else verify_layouts(args.shared_root)
runs = [] if args.skip_projects else verify_runs(args.shared_root)
outputs = [] if args.skip_projects else verify_outputs(args.shared_root)
project_errors = (sum(r.error_count for r in reports)
+ sum(r.error_count for r in layouts)
+ sum(r.error_count for r in runs))
+ sum(r.error_count for r in runs)
+ sum(r.error_count for r in outputs))
if errors:
print("PIPELINE CONTRACT: FAIL")
@@ -331,6 +414,15 @@ def main() -> int:
for report in reports:
verifier_render(report, args.samples)
if outputs:
output_errors = sum(r.error_count for r in outputs)
print()
print(f"OUTPUT CHECKS: {'FAIL' if output_errors else 'PASS'}"
f" — 프로젝트 {len(outputs)} · error {output_errors} ·"
f" warn {sum(r.warn_count for r in outputs)}")
for report in outputs:
verifier_render(report, args.samples)
return 1 if errors or project_errors else 0