Chuyển tới nội dung chính

Validate Tool Index

Mô tả công cụ: validate.py

Script: /tools/validate/validate.py

Mục đích: Đảm bảo mọi tài liệu .md trong repo đều hợp lệ theo schema trong /.okf/profile.yaml và không có broken internal links.

Hai pass kiểm tra

Pass 1 — Syntactic Check:

  • Kiểm tra frontmatter có đủ required_fields cho type tương ứng không.
  • Validate enum values (status, tlp, classification).
  • Kiểm tra review_by không vượt quá review cycle limit (90 hoặc 365 ngày từ timestamp).
  • Kiểm tra schema_version compatibility (cho phép 1 minor version drift).

Pass 2 — Semantic Check:

  • Phân loại links: internal (/path/file.md), external (https://), anchor (#heading).
  • Internal links: kiểm tra file tồn tại. Broken link = ERROR (fail CI).
  • Anchor links: kiểm tra heading slug tồn tại trong cùng file. Missing anchor = WARNING (non-blocking).
  • External links: bỏ qua (không validate existence).
  • Kiểm tra ../ relative paths — nghiêm cấm, fail ngay.

Index completeness check:

  • Với mỗi directory có index.md: cảnh báo nếu có .md file trong thư mục nhưng không được reference trong index.md.

Cách chạy

# Validate toàn bộ repo
python tools/validate/validate.py --path .

# Validate một file cụ thể
python tools/validate/validate.py --path services/payment-gateway.md

# Bao gồm cả templates directory
python tools/validate/validate.py --path . --templates

# Verbose mode (hiện chi tiết từng file)
python tools/validate/validate.py --path . --verbose

Exit codes

  • 0 — Pass (không có error)
  • 1 — Fail (có ít nhất 1 error)
X

Graph View