검사: 볼 것이 없어서 통과한 것을 「문제 없음」이라고 쓰지 않는다
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:
co-authored by
Claude Opus 5
parent
c2742a66cc
commit
e00c1a2b76
@@ -22,7 +22,11 @@ const withRepo = flags.includes("--repo");
|
|||||||
const root = execSync("git rev-parse --show-toplevel", { encoding: "utf8" }).trim();
|
const root = execSync("git rev-parse --show-toplevel", { encoding: "utf8" }).trim();
|
||||||
const base = join(root, "docs", project);
|
const base = join(root, "docs", project);
|
||||||
const treePath = join(base, "tech-log-studio", "tech-log-tree.json");
|
const treePath = join(base, "tech-log-studio", "tech-log-tree.json");
|
||||||
if (!existsSync(treePath)) { console.error(`${project}: tech-log-tree.json 이 없다`); process.exit(2); }
|
// 대상이 성립하지 않는다 — CLAUDE.md 「검사」 절의 표. exit 2 로 error 로 센다
|
||||||
|
if (!existsSync(treePath)) {
|
||||||
|
console.error(`대상이 성립하지 않는다 — ${project}: tech-log-tree.json 이 없다`);
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
const tree = JSON.parse(readFileSync(treePath, "utf8"));
|
const tree = JSON.parse(readFileSync(treePath, "utf8"));
|
||||||
const ssotRel = tree.ssot || "final/document.md";
|
const ssotRel = tree.ssot || "final/document.md";
|
||||||
const norm = s => s.replace(/\s+/g, " ").trim();
|
const norm = s => s.replace(/\s+/g, " ").trim();
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ from __future__ import annotations
|
|||||||
import os, re, sys, glob, json, collections
|
import os, re, sys, glob, json, collections
|
||||||
|
|
||||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||||
|
import techlog # noqa: E402
|
||||||
KINDS = {"case": "CASE", "concept": "CONCEPT", "reference": "REFERENCE",
|
KINDS = {"case": "CASE", "concept": "CONCEPT", "reference": "REFERENCE",
|
||||||
"question": "QUESTION", "decision": "PROJECT_DECISION"}
|
"question": "QUESTION", "decision": "PROJECT_DECISION"}
|
||||||
BODY_KINDS = {"case", "concept"}
|
BODY_KINDS = {"case", "concept"}
|
||||||
@@ -130,6 +132,10 @@ def audit_project(project: str) -> dict:
|
|||||||
|
|
||||||
|
|
||||||
def main(argv: list[str]) -> int:
|
def main(argv: list[str]) -> int:
|
||||||
|
if argv[1:]:
|
||||||
|
bad = techlog.check_targets(argv[1:], ROOT, "tech-log-studio")
|
||||||
|
if bad is not None:
|
||||||
|
return bad
|
||||||
projects = argv[1:] or sorted(
|
projects = argv[1:] or sorted(
|
||||||
os.path.basename(os.path.dirname(p))
|
os.path.basename(os.path.dirname(p))
|
||||||
for p in glob.glob(os.path.join(ROOT, "docs/*/tech-log-studio")))
|
for p in glob.glob(os.path.join(ROOT, "docs/*/tech-log-studio")))
|
||||||
@@ -141,7 +147,8 @@ def main(argv: list[str]) -> int:
|
|||||||
ev = r["evidence"]
|
ev = r["evidence"]
|
||||||
print(f"\n{r['project']} — 기록 {r['records']}건 · 원문 {ev['raw']} · 메타 {ev['meta']} · 렌더 {ev['rendered']}")
|
print(f"\n{r['project']} — 기록 {r['records']}건 · 원문 {ev['raw']} · 메타 {ev['meta']} · 렌더 {ev['rendered']}")
|
||||||
if not n:
|
if not n:
|
||||||
print(" 문제 없음")
|
# 볼 것이 아직 없는 것과 봤더니 괜찮은 것을 가른다
|
||||||
|
print(" 기록 0건 — 아직 쓴 기록이 없다" if not r["records"] else " 문제 없음")
|
||||||
continue
|
continue
|
||||||
for key, count in r["issues"].most_common():
|
for key, count in r["issues"].most_common():
|
||||||
print(f" {count:>5} {key}")
|
print(f" {count:>5} {key}")
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||||
|
import techlog # noqa: E402
|
||||||
|
|
||||||
RECT = re.compile(r"<rect\b([^>]*)>")
|
RECT = re.compile(r"<rect\b([^>]*)>")
|
||||||
ATTR = re.compile(r'(\w[\w-]*)="([^"]*)"')
|
ATTR = re.compile(r'(\w[\w-]*)="([^"]*)"')
|
||||||
@@ -145,7 +147,16 @@ def main() -> int:
|
|||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
files = list(args.file)
|
files = list(args.file)
|
||||||
|
names = []
|
||||||
|
if files:
|
||||||
|
bad = techlog.check_files(files)
|
||||||
|
if bad is not None:
|
||||||
|
return bad
|
||||||
if not files:
|
if not files:
|
||||||
|
if args.projects:
|
||||||
|
bad = techlog.check_targets(args.projects, ROOT, "final")
|
||||||
|
if bad is not None:
|
||||||
|
return bad
|
||||||
names = args.projects or sorted(
|
names = args.projects or sorted(
|
||||||
os.path.basename(os.path.dirname(os.path.dirname(p)))
|
os.path.basename(os.path.dirname(os.path.dirname(p)))
|
||||||
for p in glob.glob(os.path.join(ROOT, "docs/*/final/document.md")))
|
for p in glob.glob(os.path.join(ROOT, "docs/*/final/document.md")))
|
||||||
@@ -153,7 +164,8 @@ def main() -> int:
|
|||||||
files += sorted(glob.glob(
|
files += sorted(glob.glob(
|
||||||
os.path.join(ROOT, "docs", name, "final/assets/**/*.svg"), recursive=True))
|
os.path.join(ROOT, "docs", name, "final/assets/**/*.svg"), recursive=True))
|
||||||
if not files:
|
if not files:
|
||||||
print("볼 그림이 없다", file=sys.stderr)
|
# 대상은 성립하는데 아직 그림이 없다 — 결함이 아니지만 「문제 없음」도 아니다
|
||||||
|
print(f"그림 0장 — {' · '.join(names) or '지정한 파일'} 에 아직 SVG 가 없다")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
bad = 0
|
bad = 0
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||||
|
import techlog # noqa: E402
|
||||||
|
|
||||||
TEXT = re.compile(r"<text[^>]*>([^<]*)</text>")
|
TEXT = re.compile(r"<text[^>]*>([^<]*)</text>")
|
||||||
|
|
||||||
@@ -72,13 +74,24 @@ def main() -> int:
|
|||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
targets = list(args.file)
|
targets = list(args.file)
|
||||||
|
if targets:
|
||||||
|
bad = techlog.check_files(targets)
|
||||||
|
if bad is not None:
|
||||||
|
return bad
|
||||||
if not targets:
|
if not targets:
|
||||||
|
if args.projects:
|
||||||
|
bad = techlog.check_targets(args.projects, ROOT, "final")
|
||||||
|
if bad is not None:
|
||||||
|
return bad
|
||||||
projects = args.projects or sorted(
|
projects = args.projects or sorted(
|
||||||
d for d in os.listdir(os.path.join(ROOT, "docs"))
|
d for d in os.listdir(os.path.join(ROOT, "docs"))
|
||||||
if not d.startswith("_")
|
if not d.startswith("_")
|
||||||
and os.path.isdir(os.path.join(ROOT, "docs", d, "final")))
|
and os.path.isdir(os.path.join(ROOT, "docs", d, "final")))
|
||||||
for project in projects:
|
for project in projects:
|
||||||
targets.extend(svgs_of(project))
|
targets.extend(svgs_of(project))
|
||||||
|
if not targets:
|
||||||
|
print(f"그림 0장 — {' · '.join(projects)} 에 final/assets 아래 SVG 가 아직 없다")
|
||||||
|
return 0
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
files = 0
|
files = 0
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||||
|
import techlog # noqa: E402
|
||||||
SIZE = re.compile(r'width="(\d+)"\s+height="(\d+)"')
|
SIZE = re.compile(r'width="(\d+)"\s+height="(\d+)"')
|
||||||
|
|
||||||
|
|
||||||
@@ -63,12 +65,23 @@ def main() -> int:
|
|||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
targets = list(args.file)
|
targets = list(args.file)
|
||||||
|
if targets:
|
||||||
|
bad = techlog.check_files(targets)
|
||||||
|
if bad is not None:
|
||||||
|
return bad
|
||||||
|
if args.projects:
|
||||||
|
bad = techlog.check_targets(args.projects, ROOT, "final")
|
||||||
|
if bad is not None:
|
||||||
|
return bad
|
||||||
for project in args.projects:
|
for project in args.projects:
|
||||||
targets.extend(sorted(glob.glob(
|
targets.extend(sorted(glob.glob(
|
||||||
os.path.join(ROOT, "docs", project, "final", "assets", "**", "*.svg"),
|
os.path.join(ROOT, "docs", project, "final", "assets", "**", "*.svg"),
|
||||||
recursive=True)))
|
recursive=True)))
|
||||||
if not targets:
|
if not targets:
|
||||||
sys.exit("볼 그림을 주지 않았다.")
|
if args.projects:
|
||||||
|
print(f"그림 0장 — {' · '.join(args.projects)} 에 아직 SVG 가 없다")
|
||||||
|
return 0
|
||||||
|
return techlog.missing_target("(인자 없음)", "볼 그림을 주지 않았다")
|
||||||
|
|
||||||
out_dir = args.out or tempfile.mkdtemp(prefix="figure-preview-")
|
out_dir = args.out or tempfile.mkdtemp(prefix="figure-preview-")
|
||||||
os.makedirs(out_dir, exist_ok=True)
|
os.makedirs(out_dir, exist_ok=True)
|
||||||
|
|||||||
@@ -14,6 +14,56 @@ import os
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ── 검사할 것이 없을 때 관문이 무엇을 내야 하는가 ────────────────────────────
|
||||||
|
# CLAUDE.md 「검사」 절의 표. 「볼 것이 없어서 통과」를 「문제 없음」이라고 쓰지 않는다.
|
||||||
|
#
|
||||||
|
# 봤고 괜찮다 exit 0 문제 없음 · error 0
|
||||||
|
# 대상이 성립하지 않는다 exit 2 대상이 성립하지 않는다 — <이유>
|
||||||
|
# 볼 것이 아직 없다 exit 0 기록 0건 — 계약의 글감 N개가 아직 안 쓰였다
|
||||||
|
#
|
||||||
|
# 가운데는 error 로 센다. 아래는 error 가 아니다 — 아직 안 쓴 것은 결함이 아니다.
|
||||||
|
# 다만 초록으로 보이면 안 된다.
|
||||||
|
NO_TARGET_EXIT = 2
|
||||||
|
|
||||||
|
|
||||||
|
def project_root(project: str, root: str) -> str:
|
||||||
|
return os.path.join(root, "docs", project)
|
||||||
|
|
||||||
|
|
||||||
|
def missing_target(project: str, why: str) -> int:
|
||||||
|
"""대상이 성립하지 않는다. 규범 문구를 찍고 2 를 돌려준다."""
|
||||||
|
import sys as _sys
|
||||||
|
print(f"대상이 성립하지 않는다 — {project}: {why}", file=_sys.stderr)
|
||||||
|
return NO_TARGET_EXIT
|
||||||
|
|
||||||
|
|
||||||
|
def check_files(paths) -> int | None:
|
||||||
|
"""`--file` 로 직접 준 경로가 성립하는지 본다. 하나라도 없으면 2, 전부 있으면 None.
|
||||||
|
|
||||||
|
프로젝트 이름으로 부르는 쪽만 고치면 `--file` 로 오타를 내는 순간 다시 조용히
|
||||||
|
0건이 된다. 같은 규칙을 여기 함께 둔다.
|
||||||
|
"""
|
||||||
|
for path in paths:
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
return missing_target(path, "그런 파일이 없다")
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def check_targets(projects, root: str, needs: str = "") -> int | None:
|
||||||
|
"""지정한 프로젝트들이 성립하는지 본다. 하나라도 아니면 2, 전부 성립하면 None.
|
||||||
|
|
||||||
|
`needs` 를 주면 그 하위 경로까지 있어야 성립으로 본다
|
||||||
|
(예: `tech-log-studio` — 계약이 없는 프로젝트를 걸러 낸다).
|
||||||
|
"""
|
||||||
|
for project in projects:
|
||||||
|
base = project_root(project, root)
|
||||||
|
if not os.path.isdir(base):
|
||||||
|
return missing_target(project, "docs 아래 그런 프로젝트가 없다")
|
||||||
|
if needs and not os.path.exists(os.path.join(base, needs)):
|
||||||
|
return missing_target(project, f"{needs} 가 없다")
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
KINDS = ["case", "concept", "reference", "question", "decision"]
|
KINDS = ["case", "concept", "reference", "question", "decision"]
|
||||||
READINESS = ["READY", "OPEN", "NEEDS_EVIDENCE", "NEEDS_DECISION", "BLOCKED"]
|
READINESS = ["READY", "OPEN", "NEEDS_EVIDENCE", "NEEDS_DECISION", "BLOCKED"]
|
||||||
DISPOSITIONS = ["PROMOTE", "MERGE_INTO", "KEEP_IN_SSOT",
|
DISPOSITIONS = ["PROMOTE", "MERGE_INTO", "KEEP_IN_SSOT",
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
"""검사할 것이 없을 때 관문이 무엇을 내는가 (CLAUDE.md 「검사」 절의 표).
|
||||||
|
|
||||||
|
봤고 괜찮다 exit 0 문제 없음 · error 0
|
||||||
|
대상이 성립하지 않는다 exit 2 대상이 성립하지 않는다 — <이유>
|
||||||
|
볼 것이 아직 없다 exit 0 기록 0건 — …
|
||||||
|
|
||||||
|
가운데 줄이 없으면 오타 한 번으로 검사를 다 돈 것처럼 보인다. 실제로 그랬다 —
|
||||||
|
여섯 중 넷이 없는 프로젝트에 초록을 냈고 `verify-tech-log-tree.py` 는 그것을
|
||||||
|
「프로젝트 1 · error 0 · PASS」 로 셌다.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
|
PY_CHECKERS = (
|
||||||
|
"check-figure-text.py",
|
||||||
|
"check-figure-overlap.py",
|
||||||
|
"audit-records.py",
|
||||||
|
"verify-tech-log-tree.py",
|
||||||
|
"verify-project-layout.py",
|
||||||
|
)
|
||||||
|
MJS_CHECKER = os.path.join(".agents", "skills", "writing-tech-log-records",
|
||||||
|
"scripts", "check_evidence.mjs")
|
||||||
|
ABSENT = "no-such-project-r4-regression"
|
||||||
|
|
||||||
|
|
||||||
|
def _run(cmd: list[str]) -> subprocess.CompletedProcess:
|
||||||
|
return subprocess.run(cmd, cwd=ROOT, capture_output=True, text=True, timeout=300)
|
||||||
|
|
||||||
|
|
||||||
|
class NoTargetExitCode(unittest.TestCase):
|
||||||
|
"""대상이 성립하지 않으면 exit 2 와 그 문구를 낸다."""
|
||||||
|
|
||||||
|
def test_python_checkers_reject_absent_project(self) -> None:
|
||||||
|
for name in PY_CHECKERS:
|
||||||
|
with self.subTest(checker=name):
|
||||||
|
run = _run([sys.executable, os.path.join("scripts", name), ABSENT])
|
||||||
|
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
||||||
|
self.assertIn("대상이 성립하지 않는다", run.stdout + run.stderr)
|
||||||
|
|
||||||
|
def test_check_evidence_rejects_absent_project(self) -> None:
|
||||||
|
if not os.path.exists(os.path.join(ROOT, MJS_CHECKER)):
|
||||||
|
self.skipTest("check_evidence.mjs 가 없다")
|
||||||
|
run = _run(["node", MJS_CHECKER, ABSENT])
|
||||||
|
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
||||||
|
self.assertIn("대상이 성립하지 않는다", run.stdout + run.stderr)
|
||||||
|
|
||||||
|
def test_project_without_contract_is_not_a_target(self) -> None:
|
||||||
|
"""계약이 없는 실재 프로젝트도 「대상이 성립하지 않는다」다."""
|
||||||
|
base = os.path.join(ROOT, "docs", "ca-tmpl")
|
||||||
|
if not os.path.isdir(base) or os.path.exists(os.path.join(base, "tech-log-studio")):
|
||||||
|
self.skipTest("계약 없는 프로젝트가 이 저장소에 없다")
|
||||||
|
for name in ("audit-records.py", "verify-tech-log-tree.py"):
|
||||||
|
with self.subTest(checker=name):
|
||||||
|
run = _run([sys.executable, os.path.join("scripts", name), "ca-tmpl"])
|
||||||
|
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
class EmptyTargetIsNotGreen(unittest.TestCase):
|
||||||
|
"""계약은 있고 기록이 0건인 것은 결함이 아니다. 다만 「문제 없음」이라고 쓰지 않는다."""
|
||||||
|
|
||||||
|
def test_zero_records_says_so(self) -> None:
|
||||||
|
base = os.path.join(ROOT, "docs", "keycloak-session-store")
|
||||||
|
if not os.path.isdir(base):
|
||||||
|
self.skipTest("기록 0건 프로젝트가 이 저장소에 없다")
|
||||||
|
run = _run([sys.executable, os.path.join("scripts", "audit-records.py"),
|
||||||
|
"keycloak-session-store"])
|
||||||
|
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
||||||
|
self.assertIn("기록 0건", run.stdout)
|
||||||
|
self.assertNotIn("문제 없음", run.stdout)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class FileTargets(unittest.TestCase):
|
||||||
|
"""`--file` 로 준 경로도 같은 규칙을 지킨다 (R13).
|
||||||
|
|
||||||
|
프로젝트 이름만 고치면 `--file` 로 오타를 내는 순간 다시 조용히 0건이 된다.
|
||||||
|
"""
|
||||||
|
|
||||||
|
FILE_CHECKERS = ("check-figure-text.py", "check-figure-overlap.py", "preview-figure.py")
|
||||||
|
ABSENT_FILE = os.path.join("docs", "no-such-project", "no-such-figure.svg")
|
||||||
|
|
||||||
|
def test_absent_file_is_not_a_target(self) -> None:
|
||||||
|
for name in self.FILE_CHECKERS:
|
||||||
|
with self.subTest(checker=name):
|
||||||
|
run = _run([sys.executable, os.path.join("scripts", name),
|
||||||
|
"--file", self.ABSENT_FILE])
|
||||||
|
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
|
||||||
|
self.assertIn("대상이 성립하지 않는다", run.stdout + run.stderr)
|
||||||
|
|
||||||
|
def test_present_file_still_passes(self) -> None:
|
||||||
|
"""정상 경로를 막으면 안 된다 — 무조건 거절은 결함이다."""
|
||||||
|
svg = os.path.join("docs", "n+1liner", "final", "assets", "diagrams",
|
||||||
|
"eager-lazy-query-sequence", "eager-lazy-query-sequence.svg")
|
||||||
|
if not os.path.exists(os.path.join(ROOT, svg)):
|
||||||
|
self.skipTest("대조에 쓸 그림이 이 저장소에 없다")
|
||||||
|
for name in ("check-figure-text.py", "check-figure-overlap.py"):
|
||||||
|
with self.subTest(checker=name):
|
||||||
|
run = _run([sys.executable, os.path.join("scripts", name), "--file", svg])
|
||||||
|
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
class ContractlessProjectIsCounted(unittest.TestCase):
|
||||||
|
"""계약이 없는 프로젝트가 전체 훑기의 목록에서 사라지면 안 된다 (R6).
|
||||||
|
|
||||||
|
`verify_projects()` 가 `docs/*/tech-log-studio` 만 훑던 동안 `ca-tmpl` 은
|
||||||
|
`TECH LOG TREES` 블록에 아예 안 나왔다. CLAUDE.md 는 「계약 미채택도 error」라고
|
||||||
|
적었는데 그 error 를 셀 자리가 없었다.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_missing_contract_is_an_error(self) -> None:
|
||||||
|
base = os.path.join(ROOT, "docs", "ca-tmpl")
|
||||||
|
if not os.path.isdir(base) or os.path.exists(os.path.join(base, "tech-log-studio")):
|
||||||
|
self.skipTest("계약 없는 프로젝트가 이 저장소에 없다")
|
||||||
|
run = _run([sys.executable, os.path.join("scripts", "verify-pipeline.py")])
|
||||||
|
self.assertIn("분해 계약 없음", run.stdout)
|
||||||
|
block = run.stdout.split("TECH LOG TREES:", 1)
|
||||||
|
self.assertEqual(len(block), 2, "TECH LOG TREES 블록이 없다")
|
||||||
|
head = block[1].splitlines()[0]
|
||||||
|
self.assertNotIn("error 0", head, f"계약 없는 프로젝트가 안 세졌다 — {head}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
import argparse
|
import argparse
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import json
|
import json
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
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")
|
verifier = _load(shared_root, "verify-tech-log-tree.py", "verify_tech_log_tree")
|
||||||
if verifier is None:
|
if verifier is None:
|
||||||
return []
|
return []
|
||||||
projects = sorted(p.parent.name for p in shared_root.glob("docs/*/tech-log-studio")
|
# `docs/*/tech-log-studio` 만 훑으면 **계약을 안 만든 프로젝트가 목록에서 사라진다.**
|
||||||
if not p.parent.name.startswith("_"))
|
# 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]
|
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]
|
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):
|
def verify_runs(shared_root: Path):
|
||||||
"""`runs/<프로젝트>/<runId>/run.json` 이 절차를 지켰는지 본다.
|
"""`runs/<프로젝트>/<runId>/run.json` 이 절차를 지켰는지 본다.
|
||||||
|
|
||||||
@@ -289,9 +370,11 @@ def main() -> int:
|
|||||||
reports = [] if args.skip_projects else verify_projects(args.shared_root)
|
reports = [] if args.skip_projects else verify_projects(args.shared_root)
|
||||||
layouts = [] if args.skip_projects else verify_layouts(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)
|
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)
|
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 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:
|
if errors:
|
||||||
print("PIPELINE CONTRACT: FAIL")
|
print("PIPELINE CONTRACT: FAIL")
|
||||||
@@ -331,6 +414,15 @@ def main() -> int:
|
|||||||
for report in reports:
|
for report in reports:
|
||||||
verifier_render(report, args.samples)
|
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
|
return 1 if errors or project_errors else 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|||||||
from techlog import Report # noqa: E402
|
from techlog import Report # noqa: E402
|
||||||
|
|
||||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||||
|
import techlog # noqa: E402
|
||||||
|
|
||||||
EVIDENCE_DIRS = {"raw", "meta", "rendered", "browser"}
|
EVIDENCE_DIRS = {"raw", "meta", "rendered", "browser"}
|
||||||
# 분석하는 동안에만 있는 작업 재료. 분석이 끝나면 final/document.md 로 합치고 지운다.
|
# 분석하는 동안에만 있는 작업 재료. 분석이 끝나면 final/document.md 로 합치고 지운다.
|
||||||
@@ -278,6 +280,10 @@ def main() -> int:
|
|||||||
ap.add_argument("--strict", action="store_true")
|
ap.add_argument("--strict", action="store_true")
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
|
if args.projects:
|
||||||
|
bad = techlog.check_targets(args.projects, ROOT, "final/document.md")
|
||||||
|
if bad is not None:
|
||||||
|
return bad
|
||||||
projects = args.projects or sorted(
|
projects = args.projects or sorted(
|
||||||
name for name in (
|
name for name in (
|
||||||
os.path.basename(os.path.dirname(os.path.dirname(p)))
|
os.path.basename(os.path.dirname(os.path.dirname(p)))
|
||||||
|
|||||||
@@ -191,8 +191,11 @@ def verify(project: str) -> Report:
|
|||||||
index_path = os.path.join(studio, "tech-log-tree.json")
|
index_path = os.path.join(studio, "tech-log-tree.json")
|
||||||
index = techlog.load_index(index_path)
|
index = techlog.load_index(index_path)
|
||||||
if index is None:
|
if index is None:
|
||||||
rep.warn("분해 계약 없음",
|
# CLAUDE.md — 「계약을 아직 채택하지 않은 프로젝트도 error 다. 칸마다 error 를
|
||||||
f"{project}: tech-log-tree.json 이 없다. 디렉터리가 정본 노릇을 하고 있다")
|
# 내지는 않고 미채택 자체를 한 번 센다 — 경고로 두면 옛 스키마로 남아 있는 한
|
||||||
|
# 검사를 피한다.」 경고로 두었더니 실제로 그렇게 됐다 (R6)
|
||||||
|
rep.error("분해 계약 없음",
|
||||||
|
f"{project}: tech-log-tree.json 이 없다. 디렉터리가 정본 노릇을 하고 있다")
|
||||||
return rep
|
return rep
|
||||||
|
|
||||||
# ── 원본 무결성 ────────────────────────────────────────────────
|
# ── 원본 무결성 ────────────────────────────────────────────────
|
||||||
@@ -528,6 +531,10 @@ def main() -> int:
|
|||||||
ap.add_argument("--json", action="store_true")
|
ap.add_argument("--json", action="store_true")
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
|
if args.projects:
|
||||||
|
bad = techlog.check_targets(args.projects, ROOT, "tech-log-studio")
|
||||||
|
if bad is not None:
|
||||||
|
return bad
|
||||||
projects = args.projects or sorted(
|
projects = args.projects or sorted(
|
||||||
name for name in (
|
name for name in (
|
||||||
os.path.basename(os.path.dirname(p))
|
os.path.basename(os.path.dirname(p))
|
||||||
|
|||||||
Reference in New Issue
Block a user