from __future__ import annotations import json import os from pathlib import Path import pytest from live_runner import CLAUDE_BIN, run_live_case LIVE_ENABLED = os.environ.get("TECH_DOC_FLOW_RUN_LIVE") == "1" @pytest.mark.live @pytest.mark.skipif(not LIVE_ENABLED, reason="TECH_DOC_FLOW_RUN_LIVE=1일 때만 실제 LLM을 호출") @pytest.mark.skipif(CLAUDE_BIN is None, reason="claude CLI가 없음") def test_live_skill_produces_verified_readable_revision(tmp_path: Path) -> None: timeout = int(os.environ.get("TECH_DOC_FLOW_LIVE_TIMEOUT", "300")) run_dir, report = run_live_case(tmp_path / "live-case", timeout=timeout) assert report["verdict"] == "pass" final = (run_dir / "final.md").read_text(encoding="utf-8") for protected in ("42ms", "cacheKey", "https://example.test/cache"): assert protected in final ledger = json.loads((run_dir / "05_term_ledger.json").read_text(encoding="utf-8")) assert all(term["plain_definition"].strip() for term in ledger["terms"]) assert all(term["first_use"] in final for term in ledger["terms"])