Merge branch 'harness/C-verification' into harness/A-integration
This commit is contained in:
@@ -9,6 +9,8 @@ from __future__ import annotations
|
||||
import os, re, sys, glob, json, collections
|
||||
|
||||
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",
|
||||
"question": "QUESTION", "decision": "PROJECT_DECISION"}
|
||||
BODY_KINDS = {"case", "concept"}
|
||||
@@ -130,6 +132,10 @@ def audit_project(project: str) -> dict:
|
||||
|
||||
|
||||
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(
|
||||
os.path.basename(os.path.dirname(p))
|
||||
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"]
|
||||
print(f"\n{r['project']} — 기록 {r['records']}건 · 원문 {ev['raw']} · 메타 {ev['meta']} · 렌더 {ev['rendered']}")
|
||||
if not n:
|
||||
print(" 문제 없음")
|
||||
# 볼 것이 아직 없는 것과 봤더니 괜찮은 것을 가른다
|
||||
print(" 기록 0건 — 아직 쓴 기록이 없다" if not r["records"] else " 문제 없음")
|
||||
continue
|
||||
for key, count in r["issues"].most_common():
|
||||
print(f" {count:>5} {key}")
|
||||
|
||||
@@ -25,6 +25,8 @@ import re
|
||||
import sys
|
||||
|
||||
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([^>]*)>")
|
||||
ATTR = re.compile(r'(\w[\w-]*)="([^"]*)"')
|
||||
@@ -145,7 +147,16 @@ def main() -> int:
|
||||
args = ap.parse_args()
|
||||
|
||||
files = list(args.file)
|
||||
names = []
|
||||
if files:
|
||||
bad = techlog.check_files(files)
|
||||
if bad is not None:
|
||||
return bad
|
||||
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(
|
||||
os.path.basename(os.path.dirname(os.path.dirname(p)))
|
||||
for p in glob.glob(os.path.join(ROOT, "docs/*/final/document.md")))
|
||||
@@ -153,7 +164,8 @@ def main() -> int:
|
||||
files += sorted(glob.glob(
|
||||
os.path.join(ROOT, "docs", name, "final/assets/**/*.svg"), recursive=True))
|
||||
if not files:
|
||||
print("볼 그림이 없다", file=sys.stderr)
|
||||
# 대상은 성립하는데 아직 그림이 없다 — 결함이 아니지만 「문제 없음」도 아니다
|
||||
print(f"그림 0장 — {' · '.join(names) or '지정한 파일'} 에 아직 SVG 가 없다")
|
||||
return 0
|
||||
|
||||
bad = 0
|
||||
|
||||
@@ -18,6 +18,8 @@ import re
|
||||
import sys
|
||||
|
||||
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>")
|
||||
|
||||
@@ -72,13 +74,24 @@ def main() -> int:
|
||||
args = ap.parse_args()
|
||||
|
||||
targets = list(args.file)
|
||||
if targets:
|
||||
bad = techlog.check_files(targets)
|
||||
if bad is not None:
|
||||
return bad
|
||||
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(
|
||||
d for d in os.listdir(os.path.join(ROOT, "docs"))
|
||||
if not d.startswith("_")
|
||||
and os.path.isdir(os.path.join(ROOT, "docs", d, "final")))
|
||||
for project in projects:
|
||||
targets.extend(svgs_of(project))
|
||||
if not targets:
|
||||
print(f"그림 0장 — {' · '.join(projects)} 에 final/assets 아래 SVG 가 아직 없다")
|
||||
return 0
|
||||
|
||||
total = 0
|
||||
files = 0
|
||||
|
||||
@@ -22,6 +22,8 @@ import sys
|
||||
import tempfile
|
||||
|
||||
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+)"')
|
||||
|
||||
|
||||
@@ -63,12 +65,23 @@ def main() -> int:
|
||||
args = ap.parse_args()
|
||||
|
||||
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:
|
||||
targets.extend(sorted(glob.glob(
|
||||
os.path.join(ROOT, "docs", project, "final", "assets", "**", "*.svg"),
|
||||
recursive=True)))
|
||||
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-")
|
||||
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"]
|
||||
READINESS = ["READY", "OPEN", "NEEDS_EVIDENCE", "NEEDS_DECISION", "BLOCKED"]
|
||||
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()
|
||||
@@ -0,0 +1,42 @@
|
||||
"""`scripts/terminal-evidence/tests/` 를 문서에 적힌 한 명령이 함께 돌게 잇는다.
|
||||
|
||||
`python3 -m unittest discover -s scripts/tests` 는 그 폴더만 훑는다. 터미널 증거 렌더러의
|
||||
테스트는 `scripts/terminal-evidence/tests/` 에 따로 있어서 그 명령에 안 잡혔고,
|
||||
`verify-pipeline.py` 도 unittest 를 부르지 않는다. 그래서 **초록인데 아무도 안 부르는 회귀**가 됐다.
|
||||
|
||||
`discover -s scripts/terminal-evidence/tests` 를 직접 돌려도 깨진다 — 그 테스트가
|
||||
`render_terminal` 을 같은 폴더 기준으로 부르는데 그 경로가 `sys.path` 에 없다. 여기서
|
||||
경로를 얹고 파일을 직접 불러 `load_tests` 로 끌어온다. 중첩 `discover` 는 쓰지 않는다 —
|
||||
`top_level_dir` 이 바깥을 가리키면 unittest 가 거절한다.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
_HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
_TE = os.path.join(os.path.dirname(_HERE), "terminal-evidence")
|
||||
_TE_TESTS = os.path.join(_TE, "tests")
|
||||
|
||||
|
||||
def load_tests(loader: unittest.TestLoader, tests: unittest.TestSuite,
|
||||
pattern: str | None) -> unittest.TestSuite:
|
||||
if not os.path.isdir(_TE_TESTS):
|
||||
return tests
|
||||
if _TE not in sys.path:
|
||||
sys.path.insert(0, _TE)
|
||||
for name in sorted(os.listdir(_TE_TESTS)):
|
||||
if not (name.startswith("test") and name.endswith(".py")):
|
||||
continue
|
||||
mod_name = "terminal_evidence_" + name[:-3]
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
mod_name, os.path.join(_TE_TESTS, name))
|
||||
if spec is None or spec.loader is None:
|
||||
continue
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[mod_name] = module
|
||||
spec.loader.exec_module(module)
|
||||
tests.addTests(loader.loadTestsFromModule(module))
|
||||
return tests
|
||||
@@ -44,16 +44,29 @@ STAGES = {
|
||||
"gates": ["check_body.mjs", "check_prose.mjs", "check_evidence.mjs"],
|
||||
"skippable": False},
|
||||
"S4": {"skill": "technical-visualizer",
|
||||
"gates": ["lint", "check-figure-text.py", "check-figure-overlap.py"],
|
||||
"gates": ["lint", "check-figure-text.py", "check-figure-overlap.py",
|
||||
"preview-figure.py"],
|
||||
"skippable": True},
|
||||
# S5·S6 은 문장을 고친 뒤라 S3 관문을 다시 돈다 (stage-contracts.md 「관문 요약」)
|
||||
"S5": {"skill": "rewriting-technical-prose-naturally",
|
||||
"gates": ["check_prose.mjs", "style_profile.mjs", "check_body.mjs"],
|
||||
"gates": ["check_prose.mjs", "style_profile.mjs", "check_body.mjs",
|
||||
"check_evidence.mjs"],
|
||||
"skippable": False},
|
||||
"S6": {"skill": "writing-as-the-person-who-did-it",
|
||||
"gates": ["check_voice.mjs", "check_prose.mjs"], "skippable": False},
|
||||
"gates": ["check_voice.mjs", "check_prose.mjs", "check_body.mjs",
|
||||
"check_evidence.mjs"],
|
||||
"skippable": False},
|
||||
"S7": {"skill": "publishing-tech-log-to-studio",
|
||||
"gates": ["저장됨", "verify-tech-log-tree.py"], "skippable": True},
|
||||
"gates": ["저장됨", "build-tech-log-tree.py", "verify-tech-log-tree.py"],
|
||||
"skippable": True},
|
||||
}
|
||||
|
||||
# 측정 관문 — 돌았다는 것은 요구하지만 종료 코드 0 은 요구하지 않는다.
|
||||
# 문서 계약이 「error 0」을 붙인 것은 check_prose 뿐이고 style_profile 은 문체 수치를 보여 주는
|
||||
# 측정이다 (stage-contracts.md:178·:252). 여기에 0 을 요구하면 정직하게 적은 원장이 실패하고,
|
||||
# 0 으로 고쳐 적으면 그건 지어낸 것이 된다.
|
||||
MEASUREMENT_GATES = ("style_profile.mjs",)
|
||||
|
||||
ORDER = ["S1", "S2", "S3", "S4", "S5", "S6", "S7"]
|
||||
|
||||
|
||||
@@ -130,9 +143,14 @@ def _side_proof(rep: Report, st: dict, sid: str, spec: dict, where: str) -> None
|
||||
if not gates:
|
||||
rep.error("곁증명에 관문이 없다", f"{where} — {out}")
|
||||
for g in gates:
|
||||
cmd = str(g.get("cmd") or "")
|
||||
if any(tok in cmd for tok in MEASUREMENT_GATES):
|
||||
if g.get("exit") is None:
|
||||
rep.error("곁증명의 측정 관문에 종료 코드가 없다", f"{where} — {cmd[:70]}")
|
||||
continue
|
||||
if g.get("exit") not in (0, "0"):
|
||||
rep.error("곁증명의 관문이 통과하지 못했다",
|
||||
f"{where} — {str(g.get('cmd'))[:70]} → exit {g.get('exit')}")
|
||||
f"{where} — {cmd[:70]} → exit {g.get('exit')}")
|
||||
rep.facts.setdefault("곁증명", []).append(f"{sid}:{os.path.basename(out)}")
|
||||
|
||||
|
||||
@@ -214,9 +232,16 @@ def verify(path: str) -> Report:
|
||||
if token not in cmds:
|
||||
rep.error("관문이 빠졌다", f"{where} — {token}")
|
||||
for g in gates:
|
||||
cmd = str(g.get("cmd") or "")
|
||||
if any(tok in cmd for tok in MEASUREMENT_GATES):
|
||||
# 측정 관문 — 돌았는지만 본다. exit 칸이 아예 없으면 안 돌린 것이다
|
||||
if g.get("exit") is None:
|
||||
rep.error("측정 관문의 종료 코드가 없다",
|
||||
f"{where} — {cmd[:70]} — 돌렸다는 기록이 없다")
|
||||
continue
|
||||
if g.get("exit") not in (0, "0"):
|
||||
rep.error("관문이 통과하지 못했다",
|
||||
f"{where} — {str(g.get('cmd'))[:70]} → exit {g.get('exit')}")
|
||||
f"{where} — {cmd[:70]} → exit {g.get('exit')}")
|
||||
|
||||
for out in st.get("outputs") or []:
|
||||
if not os.path.exists(os.path.join(ROOT, out)):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from techlog import Report # noqa: E402
|
||||
|
||||
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"}
|
||||
# 분석하는 동안에만 있는 작업 재료. 분석이 끝나면 final/document.md 로 합치고 지운다.
|
||||
@@ -278,6 +280,10 @@ def main() -> int:
|
||||
ap.add_argument("--strict", action="store_true")
|
||||
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(
|
||||
name for name in (
|
||||
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 = techlog.load_index(index_path)
|
||||
if index is None:
|
||||
rep.warn("분해 계약 없음",
|
||||
f"{project}: tech-log-tree.json 이 없다. 디렉터리가 정본 노릇을 하고 있다")
|
||||
# CLAUDE.md — 「계약을 아직 채택하지 않은 프로젝트도 error 다. 칸마다 error 를
|
||||
# 내지는 않고 미채택 자체를 한 번 센다 — 경고로 두면 옛 스키마로 남아 있는 한
|
||||
# 검사를 피한다.」 경고로 두었더니 실제로 그렇게 됐다 (R6)
|
||||
rep.error("분해 계약 없음",
|
||||
f"{project}: tech-log-tree.json 이 없다. 디렉터리가 정본 노릇을 하고 있다")
|
||||
return rep
|
||||
|
||||
# ── 원본 무결성 ────────────────────────────────────────────────
|
||||
@@ -528,6 +531,10 @@ def main() -> int:
|
||||
ap.add_argument("--json", action="store_true")
|
||||
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(
|
||||
name for name in (
|
||||
os.path.basename(os.path.dirname(p))
|
||||
|
||||
Reference in New Issue
Block a user