test(scripts): 하위 CLAUDE.md가 AGENTS.md만 가져오는지 보고 검사기 시험을 둔다
폴더 지역 규칙은 이제 src/**/AGENTS.md이고 옆의 CLAUDE.md는 `@AGENTS.md` 한 줄이다. 누가 CLAUDE.md에 규칙을 다시 쓰거나, AGENTS.md만 만들고 CLAUDE.md를 빠뜨리면 Claude Code가 그 폴더 규칙을 못 읽거나 규칙이 두 벌이 된다. 그리고 check-work-docs.py에는 자기 시험이 하나도 없었다. - check-work-docs.py: src/**/AGENTS.md마다 옆 CLAUDE.md가 있고, 모든 src/**/CLAUDE.md가 정확히 `@AGENTS.md`이며 옆에 AGENTS.md가 있는지 본다 (build 출력 제외). - scripts/tests/test_check_work_docs.py(13건): 최소 매뉴얼 통과, 지도 41줄· CLAUDE.md 11줄 실패, CLAUDE.md 첫 줄이 가져오기가 아니면 실패, 진입 경로가 네 파일(AGENTS.md + CLAUDE.md + README + playbook) 합인지, 짝 셋, 하위 규칙과 .claude/rules·skills·agents의 이력 ID, 로컬 .claude 상태는 안 봄, 하위 규칙의 깨진 링크. - gates.md 「링크 검사」: lychee 범위 밖 지침 문서는 check-docs.py `link`가 보고, 손으로 돌리는 범위를 src/**/AGENTS.md로 바꿨다. docs/README.md의 검사 설명에서 링크 문법 예를 뺐다(링크 검사기가 링크로 읽었다). 위험: 진입 경로 상한 350은 파일별 상한의 합(40+10+80+150=280)보다 커서 지금 구조에서는 닿지 않는다. 옛 상한(120+80+150=350)도 같았다. 상한은 그대로 두고 시험은 상한을 낮춰 계산식을 본다. 검증: unittest(전체), check-work-docs, check-docs, 같은 범위 --links 모두 rc=0(깨진 링크 0). 조건 다섯(짝 검사, 지도 상한, 진입 경로의 CLAUDE.md, 첫 줄 가져오기, .claude 문서 이력)을 하나씩 끈 사본마다 시험이 1~3건 실패했다.
This commit is contained in:
@@ -19,7 +19,8 @@ things break that, and both are mechanical:
|
||||
map limit is 40 lines (owner decision 2026-11-07: vision, map and HARD-STOP only).
|
||||
|
||||
It also checks that every playbook keeps the shared nine-section skeleton, that the
|
||||
"common mistakes" section stays short, and that relative links in the checked files resolve.
|
||||
"common mistakes" section stays short, that every folder rule book src/**/AGENTS.md has a CLAUDE.md
|
||||
beside it that only imports it, and that relative links in the checked files resolve.
|
||||
|
||||
This lives outside Gradle on purpose: the build does not parse documents.
|
||||
|
||||
@@ -214,6 +215,21 @@ def module_guides() -> list[Path]:
|
||||
)
|
||||
|
||||
|
||||
def check_guide_pairs(errors: list[str]) -> None:
|
||||
"""Every folder rule book src/**/AGENTS.md has a CLAUDE.md beside it that only imports it, so Claude
|
||||
Code reads the same book when it opens a file there. A CLAUDE.md that holds rules is a second book."""
|
||||
for guide in module_guides():
|
||||
if not guide.with_name("CLAUDE.md").is_file():
|
||||
errors.append(f"{rel(guide.with_name('CLAUDE.md'))}: missing; it must be the one line '{IMPORT_LINE}'")
|
||||
for entry in sorted(path for path in (REPO_ROOT / "src").rglob("CLAUDE.md")
|
||||
if not SKIPPED_PARTS.intersection(path.relative_to(REPO_ROOT).parts)):
|
||||
lines = [line.strip() for line in entry.read_text(encoding="utf-8").splitlines() if line.strip()]
|
||||
if lines != [IMPORT_LINE]:
|
||||
errors.append(f"{rel(entry)}: must be exactly '{IMPORT_LINE}'; the rules live in AGENTS.md beside it")
|
||||
if not entry.with_name("AGENTS.md").is_file():
|
||||
errors.append(f"{rel(entry)}: imports {rel(entry.with_name('AGENTS.md'))}, which does not exist")
|
||||
|
||||
|
||||
def check_claude_entry(errors: list[str]) -> None:
|
||||
"""The root CLAUDE.md starts with the import, so a Claude Code session reads the map."""
|
||||
lines = CLAUDE_ENTRY.read_text(encoding="utf-8").splitlines()
|
||||
@@ -334,6 +350,7 @@ def main() -> int:
|
||||
if check_exists(errors):
|
||||
check_limits(errors, report)
|
||||
check_claude_entry(errors)
|
||||
check_guide_pairs(errors)
|
||||
check_skeleton(errors)
|
||||
check_history(errors, report)
|
||||
check_links(errors, report)
|
||||
|
||||
Reference in New Issue
Block a user